Skip to content

Commit 49cc955

Browse files
migrated TypeConsole to Winforms library
1 parent 5153af0 commit 49cc955

25 files changed

+331
-623
lines changed

FlipnoteDesktop.sln

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlipnoteDesktop", "Flipnote
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{668EC33D-F7E1-4F5C-8614-EFB8FE82553F}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "G_TypeConsole", "G_TypeConsole\G_TypeConsole.csproj", "{6C6B6EBE-0CE4-4EBE-9FF6-12631A5BC0BF}"
11-
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{B8F65948-DD38-4559-BAC1-BFC68FE86D64}"
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "G_TypeConsole", "G_TypeConsole\G_TypeConsole.csproj", "{D0010493-9A51-44C7-A56C-8F685C7E1448}"
1311
EndProject
1412
Global
1513
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,21 +19,16 @@ Global
2119
{9E15DC82-CCDE-447D-91F9-988E917147EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
2220
{9E15DC82-CCDE-447D-91F9-988E917147EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
2321
{9E15DC82-CCDE-447D-91F9-988E917147EA}.Release|Any CPU.Build.0 = Release|Any CPU
24-
{6C6B6EBE-0CE4-4EBE-9FF6-12631A5BC0BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25-
{6C6B6EBE-0CE4-4EBE-9FF6-12631A5BC0BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
26-
{6C6B6EBE-0CE4-4EBE-9FF6-12631A5BC0BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
27-
{6C6B6EBE-0CE4-4EBE-9FF6-12631A5BC0BF}.Release|Any CPU.Build.0 = Release|Any CPU
28-
{B8F65948-DD38-4559-BAC1-BFC68FE86D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29-
{B8F65948-DD38-4559-BAC1-BFC68FE86D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
30-
{B8F65948-DD38-4559-BAC1-BFC68FE86D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
31-
{B8F65948-DD38-4559-BAC1-BFC68FE86D64}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{D0010493-9A51-44C7-A56C-8F685C7E1448}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{D0010493-9A51-44C7-A56C-8F685C7E1448}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{D0010493-9A51-44C7-A56C-8F685C7E1448}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{D0010493-9A51-44C7-A56C-8F685C7E1448}.Release|Any CPU.Build.0 = Release|Any CPU
3226
EndGlobalSection
3327
GlobalSection(SolutionProperties) = preSolution
3428
HideSolutionNode = FALSE
3529
EndGlobalSection
3630
GlobalSection(NestedProjects) = preSolution
37-
{6C6B6EBE-0CE4-4EBE-9FF6-12631A5BC0BF} = {668EC33D-F7E1-4F5C-8614-EFB8FE82553F}
38-
{B8F65948-DD38-4559-BAC1-BFC68FE86D64} = {668EC33D-F7E1-4F5C-8614-EFB8FE82553F}
31+
{D0010493-9A51-44C7-A56C-8F685C7E1448} = {668EC33D-F7E1-4F5C-8614-EFB8FE82553F}
3932
EndGlobalSection
4033
GlobalSection(ExtensibilityGlobals) = postSolution
4134
SolutionGuid = {3D063199-4222-4D97-9059-BCE39666CE39}

G_TypeConsole/G_TypeConsole.csproj

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{6C6B6EBE-0CE4-4EBE-9FF6-12631A5BC0BF}</ProjectGuid>
8-
<OutputType>library</OutputType>
7+
<ProjectGuid>{D0010493-9A51-44C7-A56C-8F685C7E1448}</ProjectGuid>
8+
<OutputType>Library</OutputType>
99
<RootNamespace>G_TypeConsole</RootNamespace>
1010
<AssemblyName>G_TypeConsole</AssemblyName>
1111
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
13-
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14-
<WarningLevel>4</WarningLevel>
1513
<Deterministic>true</Deterministic>
1614
</PropertyGroup>
1715
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -26,55 +24,38 @@
2624
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2725
<DebugType>pdbonly</DebugType>
2826
<Optimize>true</Optimize>
29-
<OutputPath>bin\Release\</OutputPath>
27+
<OutputPath>..\FlipnoteDesktop\bin\Release\Plugins</OutputPath>
3028
<DefineConstants>TRACE</DefineConstants>
3129
<ErrorReport>prompt</ErrorReport>
3230
<WarningLevel>4</WarningLevel>
3331
</PropertyGroup>
3432
<ItemGroup>
3533
<Reference Include="System" />
36-
<Reference Include="System.Data" />
37-
<Reference Include="System.Xml" />
38-
<Reference Include="Microsoft.CSharp" />
3934
<Reference Include="System.Core" />
4035
<Reference Include="System.Xml.Linq" />
4136
<Reference Include="System.Data.DataSetExtensions" />
37+
<Reference Include="Microsoft.CSharp" />
38+
<Reference Include="System.Data" />
39+
<Reference Include="System.Drawing" />
4240
<Reference Include="System.Net.Http" />
43-
<Reference Include="System.Xaml">
44-
<RequiredTargetFramework>4.0</RequiredTargetFramework>
45-
</Reference>
46-
<Reference Include="WindowsBase" />
47-
<Reference Include="PresentationCore" />
48-
<Reference Include="PresentationFramework" />
41+
<Reference Include="System.Windows.Forms" />
42+
<Reference Include="System.Xml" />
4943
</ItemGroup>
5044
<ItemGroup>
51-
<Compile Include="FDHeader.Metadata.cs" />
52-
<Compile Include="GenSettingsWindow.xaml.cs">
53-
<DependentUpon>GenSettingsWindow.xaml</DependentUpon>
45+
<Compile Include="GenSettingsWindow.cs">
46+
<SubType>Form</SubType>
5447
</Compile>
55-
<Compile Include="Properties\AssemblyInfo.cs">
56-
<SubType>Code</SubType>
48+
<Compile Include="GenSettingsWindow.Designer.cs">
49+
<DependentUpon>GenSettingsWindow.cs</DependentUpon>
5750
</Compile>
58-
<Compile Include="Properties\Resources.Designer.cs">
59-
<AutoGen>True</AutoGen>
60-
<DesignTime>True</DesignTime>
61-
<DependentUpon>Resources.resx</DependentUpon>
51+
<Compile Include="UserControl1.cs">
52+
<SubType>UserControl</SubType>
6253
</Compile>
63-
<Compile Include="Properties\Settings.Designer.cs">
64-
<AutoGen>True</AutoGen>
65-
<DependentUpon>Settings.settings</DependentUpon>
66-
<DesignTimeSharedInput>True</DesignTimeSharedInput>
54+
<Compile Include="UserControl1.Designer.cs">
55+
<DependentUpon>UserControl1.cs</DependentUpon>
6756
</Compile>
68-
<Compile Include="TcsEditor.cs" />
69-
<Compile Include="TypeConsoleGenerator.cs" />
70-
<EmbeddedResource Include="Properties\Resources.resx">
71-
<Generator>ResXFileCodeGenerator</Generator>
72-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
73-
</EmbeddedResource>
74-
<None Include="Properties\Settings.settings">
75-
<Generator>SettingsSingleFileGenerator</Generator>
76-
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
77-
</None>
57+
<Compile Include="Properties\AssemblyInfo.cs" />
58+
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
7859
</ItemGroup>
7960
<ItemGroup>
8061
<ProjectReference Include="..\FlipnoteDesktop\FlipnoteDesktop.csproj">
@@ -84,10 +65,12 @@
8465
</ProjectReference>
8566
</ItemGroup>
8667
<ItemGroup>
87-
<Page Include="GenSettingsWindow.xaml">
88-
<SubType>Designer</SubType>
89-
<Generator>MSBuild:Compile</Generator>
90-
</Page>
68+
<EmbeddedResource Include="GenSettingsWindow.resx">
69+
<DependentUpon>GenSettingsWindow.cs</DependentUpon>
70+
</EmbeddedResource>
71+
<EmbeddedResource Include="UserControl1.resx">
72+
<DependentUpon>UserControl1.cs</DependentUpon>
73+
</EmbeddedResource>
9174
</ItemGroup>
9275
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
9376
</Project>

G_TypeConsole/GenSettingsWindow.Designer.cs

Lines changed: 129 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

G_TypeConsole/GenSettingsWindow.cs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Text.RegularExpressions;
9+
using System.Threading.Tasks;
10+
using System.Windows.Forms;
11+
12+
namespace G_TypeConsole
13+
{
14+
public partial class GenSettingsWindow : Form
15+
{
16+
public GenSettingsWindow()
17+
{
18+
InitializeComponent();
19+
Editor.AppendText("cls\nwrite \"Hello world!\"\ndelay 1000\n");
20+
}
21+
22+
// https://codingvision.net/c-simple-syntax-highlighting
23+
private void Editor_TextChanged(object sender, EventArgs e)
24+
{
25+
MatchCollection keywordMatches = Regex.Matches(Editor.Text, @"\b(cls|delay|fontsize|type|write|writeln)\b");
26+
MatchCollection commentMatches = Regex.Matches(Editor.Text, @"(^#.*$)");
27+
MatchCollection stringMatches = Regex.Matches(Editor.Text, "\".*?\"");
28+
MatchCollection numberMatches = Regex.Matches(Editor.Text, "(?<![A-Za-z0-9.])[0-9]+(?![A-Za-z0-9.])");
29+
30+
int originalIndex = Editor.SelectionStart;
31+
int originalLength = Editor.SelectionLength;
32+
Color originalColor = Color.Black;
33+
34+
PreviewButton.Focus();
35+
36+
Editor.SelectionStart = 0;
37+
Editor.SelectionLength = Editor.Text.Length;
38+
Editor.SelectionColor = originalColor;
39+
40+
foreach (Match m in keywordMatches)
41+
{
42+
Editor.SelectionStart = m.Index;
43+
Editor.SelectionLength = m.Length;
44+
Editor.SelectionColor = Color.Blue;
45+
}
46+
47+
foreach (Match m in commentMatches)
48+
{
49+
Editor.SelectionStart = m.Index;
50+
Editor.SelectionLength = m.Length;
51+
Editor.SelectionColor = Color.Green;
52+
}
53+
54+
foreach (Match m in numberMatches)
55+
{
56+
Editor.SelectionStart = m.Index;
57+
Editor.SelectionLength = m.Length;
58+
Editor.SelectionColor = Color.DarkMagenta;
59+
}
60+
61+
foreach (Match m in stringMatches)
62+
{
63+
Editor.SelectionStart = m.Index;
64+
Editor.SelectionLength = m.Length;
65+
Editor.SelectionColor = Color.Brown;
66+
}
67+
68+
Editor.SelectionStart = originalIndex;
69+
Editor.SelectionLength = originalLength;
70+
Editor.SelectionColor = originalColor;
71+
72+
Editor.Focus();
73+
}
74+
75+
// https://stackoverflow.com/questions/4683663/how-to-remove-annoying-beep-with-richtextbox
76+
private void Editor_KeyDown(object sender, KeyEventArgs e)
77+
{
78+
if (Editor.GetLineFromCharIndex(Editor.SelectionStart) == 0 && e.KeyData == Keys.Up ||
79+
Editor.GetLineFromCharIndex(Editor.SelectionStart) == Editor.GetLineFromCharIndex(Editor.TextLength) && e.KeyData == Keys.Down ||
80+
Editor.SelectionStart == Editor.TextLength && e.KeyData == Keys.Right ||
81+
Editor.SelectionStart == 0 && e.KeyData == Keys.Left)
82+
e.Handled = true;
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)