Skip to content

Commit e6fb778

Browse files
committed
new example application File Change
1 parent d488404 commit e6fb778

86 files changed

Lines changed: 699 additions & 78 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FC", "FC\FC.csproj", "{5EC97B58-BFB5-4FE9-85D7-6B37AC0307A2}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{5EC97B58-BFB5-4FE9-85D7-6B37AC0307A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{5EC97B58-BFB5-4FE9-85D7-6B37AC0307A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{5EC97B58-BFB5-4FE9-85D7-6B37AC0307A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{5EC97B58-BFB5-4FE9-85D7-6B37AC0307A2}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
28 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>
38.5 KB
Binary file not shown.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{5EC97B58-BFB5-4FE9-85D7-6B37AC0307A2}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>FC</RootNamespace>
11+
<AssemblyName>FC</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="ConsoleDraw, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
36+
<SpecificVersion>False</SpecificVersion>
37+
<HintPath>.\ConsoleDraw.dll</HintPath>
38+
</Reference>
39+
<Reference Include="System" />
40+
<Reference Include="System.Core" />
41+
<Reference Include="System.Xml.Linq" />
42+
<Reference Include="System.Data.DataSetExtensions" />
43+
<Reference Include="Microsoft.CSharp" />
44+
<Reference Include="System.Data" />
45+
<Reference Include="System.Xml" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="MainWindow.cs" />
49+
<Compile Include="Program.cs" />
50+
<Compile Include="Properties\AssemblyInfo.cs" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<None Include="App.config" />
54+
</ItemGroup>
55+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
56+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
57+
Other similar extension points exist, see Microsoft.Common.targets.
58+
<Target Name="BeforeBuild">
59+
</Target>
60+
<Target Name="AfterBuild">
61+
</Target>
62+
-->
63+
</Project>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using ConsoleDraw.Inputs;
2+
using ConsoleDraw.Windows.Base;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace FC
11+
{
12+
public class MainWindow : PopupWindow
13+
{
14+
public bool changePath = false;
15+
public String Path = Directory.GetCurrentDirectory();
16+
17+
public MainWindow()
18+
: base("Change Folder", 1, (Console.WindowWidth / 2) - ((Console.WindowWidth - 4) / 2), Console.WindowWidth - 4, Console.WindowHeight - 2, null)
19+
{
20+
var folderSelect = new FileSelect(3, 3, Console.WindowWidth - 6, Height - 6, Directory.GetCurrentDirectory(), "folderSelect", this, true);
21+
folderSelect.SelectFile = delegate() { Path = folderSelect.CurrentPath; changePath = true; ExitWindow(); };
22+
23+
var selectBtn = new Button(PostionX + Height - 2, 3, "Select", "selectBtn", this);
24+
selectBtn.Action = delegate() { Path = folderSelect.CurrentPath; changePath = true; ExitWindow(); };
25+
26+
var cancelBtn = new Button(PostionX + Height - 2, 12, "Cancel", "cancelBtn", this);
27+
cancelBtn.Action = delegate() { changePath = false; ExitWindow(); };
28+
29+
Inputs.Add(folderSelect);
30+
Inputs.Add(selectBtn);
31+
Inputs.Add(cancelBtn);
32+
33+
CurrentlySelected = selectBtn;
34+
35+
Draw();
36+
MainLoop();
37+
}
38+
39+
}
40+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using ConsoleDraw;
7+
using System.Diagnostics;
8+
using System.IO;
9+
using System.Runtime.InteropServices;
10+
11+
namespace FC
12+
{
13+
class Program
14+
{
15+
[DllImport("user32")]
16+
[return: MarshalAs(UnmanagedType.Bool)]
17+
public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr i);
18+
19+
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
20+
static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
21+
22+
[DllImport("user32.dll", SetLastError = true)]
23+
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
24+
IntPtr hWnd = FindWindow(null, "Untitled - Notepad");
25+
26+
[DllImport("user32.dll", SetLastError = true)]
27+
static extern bool PostMessage(IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] uint Msg, IntPtr wParam, IntPtr lParam);
28+
29+
30+
[DllImport("user32.dll", SetLastError = true)]
31+
static extern bool PostMessage(IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] uint Msg, int wParam, int lParam);
32+
33+
const int WM_KEYDOWN = 0x0100;
34+
const int WM_KEYUP = 0x0101;
35+
const int WM_CHAR = 0x0102;
36+
37+
public static IntPtr cmdHwnd = IntPtr.Zero;
38+
39+
40+
static void Main(string[] args)
41+
{
42+
foreach (IntPtr child in GetChildWindows(Process.GetCurrentProcess().MainWindowHandle))
43+
{
44+
StringBuilder sb = new StringBuilder(100);
45+
GetClassName(child, sb, sb.Capacity);
46+
47+
if (sb.ToString() == "ConsoleWindowClass")
48+
{
49+
cmdHwnd = child;
50+
}
51+
}
52+
53+
54+
55+
56+
57+
58+
WindowManager.SetupWindow();
59+
var mainWindow = new MainWindow();
60+
WindowManager.EndWindow();
61+
62+
if (mainWindow.changePath) //User did not cancel
63+
{
64+
var command = "chdir " + mainWindow.Path;
65+
uint wparam = 0 << 29 | 0;
66+
for (var i = 0; i < command.Length; i++)
67+
{
68+
PostMessage(cmdHwnd, WM_CHAR, (int)command[i], 0);
69+
PostMessage(cmdHwnd, WM_KEYDOWN, (IntPtr)ConsoleKey.Applications, (IntPtr)wparam); //Hacky buy fix
70+
}
71+
PostMessage(cmdHwnd, WM_KEYDOWN, (IntPtr)ConsoleKey.Enter, (IntPtr)wparam);
72+
}
73+
74+
}
75+
76+
public static List<IntPtr> GetChildWindows(IntPtr parent)
77+
{
78+
List<IntPtr> result = new List<IntPtr>();
79+
GCHandle listHandle = GCHandle.Alloc(result);
80+
try
81+
{
82+
EnumWindowProc childProc = new EnumWindowProc(EnumWindow);
83+
EnumChildWindows(parent, childProc, GCHandle.ToIntPtr(listHandle));
84+
}
85+
finally
86+
{
87+
if (listHandle.IsAllocated)
88+
listHandle.Free();
89+
}
90+
return result;
91+
}
92+
93+
private static bool EnumWindow(IntPtr handle, IntPtr pointer)
94+
{
95+
GCHandle gch = GCHandle.FromIntPtr(pointer);
96+
List<IntPtr> list = gch.Target as List<IntPtr>;
97+
if (list == null)
98+
{
99+
throw new InvalidCastException("GCHandle Target could not be cast as List<IntPtr>");
100+
}
101+
list.Add(handle);
102+
// You can modify this to check to see if you want to cancel the operation, then return a null here
103+
return true;
104+
}
105+
106+
public delegate bool EnumWindowProc(IntPtr hWnd, IntPtr parameter);
107+
108+
}
109+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("FC")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("FC")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("df1bb628-1358-4bf6-ab7b-0c8f7b215204")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file not shown.
8.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)