Skip to content

Commit c609433

Browse files
author
Sébastien Geiser
committed
Export VS Solution in progress
1 parent 9ffab71 commit c609433

12 files changed

+217
-20
lines changed

RegexDialog/RegExToolDialog.xaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<BitmapImage x:Key="ShowSpaces" UriSource="Resources/space.png"/>
4040
<BitmapImage x:Key="ShowReturns" UriSource="Resources/return.png"/>
4141
<BitmapImage x:Key="Play" UriSource="Resources/control_play_blue.png"/>
42+
<BitmapImage x:Key="VS" UriSource="Resources/visual_studio_purple.png"/>
4243

4344
<Style TargetType="Image">
4445
<Style.Triggers>
@@ -72,6 +73,14 @@
7273
</MenuItem.Icon>
7374
</MenuItem>
7475
<Separator/>
76+
<MenuItem Header="Export To Visual Studio _Solution..." Click="ExportToVisualStudio_Click">
77+
<MenuItem.Icon>
78+
<Image Source="{StaticResource VS}" />
79+
</MenuItem.Icon>
80+
</MenuItem>
81+
<MenuItem Header="Export C# Code in a new tab" >
82+
</MenuItem>
83+
<Separator />
7584
<MenuItem Header="_Exit" Click="Exit_MenuItem_Click" >
7685
<MenuItem.Icon>
7786
<Image Source="{StaticResource ExitPicture}" />
@@ -692,7 +701,7 @@
692701
<ToggleButton x:Name="ToggleShowSpacesInCSharpTextSourceButton"
693702
IsChecked="{Binding ShowSpaceCharsCSharpTextSourceEditorOption}">
694703
<StackPanel Orientation="Horizontal">
695-
<Image Source="{StaticResource ShowSpaces}" Width="16" Height="16" ToolTip="Show/Hide Spaces and tabulations" />
704+
<Image Source="{StaticResource ShowSpaces}" Width="16" Height="16" ToolTip="Show/Hide spaces and tabulations" />
696705
</StackPanel>
697706
</ToggleButton>
698707
<ToggleButton x:Name="ToggleShowReturnsInCSharpTextSourceButton"
@@ -704,7 +713,7 @@
704713
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
705714
<Button x:Name="TestCSharpTextSourceButton"
706715
Click="TestCSharpTextSourceButton_Click">
707-
<Image Source="{StaticResource Play}" Width="16" Height="16" ToolTip="Test and show result" />
716+
<Image Source="{StaticResource Play}" Width="16" Height="16" ToolTip="Test and Show Result" />
708717
</Button>
709718
<CheckBox Content="In a new tab"
710719
VerticalAlignment="Center"

RegexDialog/RegExToolDialog.xaml.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,5 +2025,56 @@ private void TestCSharpTextSourceButton_Click(object sender, RoutedEventArgs e)
20252025
MessageBox.Show($"{exception}");
20262026
}
20272027
}
2028+
2029+
private void ExportToVisualStudio_Click(object sender, RoutedEventArgs e)
2030+
{
2031+
VistaFolderBrowserDialog folderBrowserDialog = new VistaFolderBrowserDialog()
2032+
{
2033+
ShowNewFolderButton = true,
2034+
};
2035+
2036+
Ookii.Dialogs.WinForms.InputDialog inputDialog = new Ookii.Dialogs.WinForms.InputDialog()
2037+
{
2038+
Content = "give a name for your project/solution :",
2039+
Input = "MySolution"
2040+
};
2041+
2042+
if (folderBrowserDialog.ShowDialog(this) == true && inputDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
2043+
{
2044+
string projectName = inputDialog.Input.Replace(" ", string.Empty);
2045+
2046+
if(string.IsNullOrWhiteSpace(projectName))
2047+
{
2048+
MessageBox.Show("The project name can not be empty or only whitespaces", "Exportation Aborted", MessageBoxButton.OK, MessageBoxImage.Information);
2049+
return;
2050+
}
2051+
2052+
string solutionDirectory = Path.Combine(folderBrowserDialog.SelectedPath, projectName);
2053+
string solutionFile = Path.Combine(solutionDirectory, $"{projectName}.sln");
2054+
string projectDirectory = Path.Combine(solutionDirectory, projectName);
2055+
string projectFile = Path.Combine(projectDirectory, $"{projectName}.csproj");
2056+
string entryFile = Path.Combine(projectDirectory, "Program.cs");
2057+
string projectGuid = Guid.NewGuid().ToString();
2058+
2059+
Directory.CreateDirectory(projectDirectory);
2060+
2061+
// Write solution file
2062+
File.WriteAllText(solutionFile,
2063+
Res.VSSolution
2064+
.Replace("$guid1$", projectGuid)
2065+
.Replace("$guid2$", Guid.NewGuid().ToString())
2066+
.Replace("$guid2$", Guid.NewGuid().ToString())
2067+
.Replace("$projectname$", projectName));
2068+
2069+
// Write project file
2070+
File.WriteAllText(projectFile,
2071+
Res.VSProject);
2072+
2073+
// Write Entry file
2074+
File.WriteAllText(entryFile,
2075+
Res.VSProgram
2076+
.Replace("projectname", projectName));
2077+
}
2078+
}
20282079
}
20292080
}

RegexDialog/RegexDialog.csproj

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@
9595
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
9696
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
9797
</Reference>
98+
<Reference Include="Ookii.Dialogs.WinForms, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
99+
<HintPath>..\packages\Ookii.Dialogs.WinForms.1.0.0\lib\net45\Ookii.Dialogs.WinForms.dll</HintPath>
100+
</Reference>
98101
<Reference Include="Ookii.Dialogs.Wpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0c15020868fd6249, processorArchitecture=MSIL">
99102
<HintPath>..\packages\Ookii.Dialogs.1.0\lib\net35\Ookii.Dialogs.Wpf.dll</HintPath>
100103
</Reference>
@@ -118,6 +121,7 @@
118121
<HintPath>..\packages\System.Console.4.3.1\lib\net46\System.Console.dll</HintPath>
119122
</Reference>
120123
<Reference Include="System.Core" />
124+
<Reference Include="System.Design" />
121125
<Reference Include="System.Diagnostics.FileVersionInfo, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
122126
<HintPath>..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll</HintPath>
123127
<Private>True</Private>
@@ -259,6 +263,12 @@
259263
<Compile Include="Model\RegexFileResult.cs" />
260264
<Compile Include="RegexPatternIndenter.cs" />
261265
<Resource Include="Resources\CSharpTextSourceContainer.cs" />
266+
<Compile Include="Res.Designer.cs">
267+
<AutoGen>True</AutoGen>
268+
<DesignTime>True</DesignTime>
269+
<DependentUpon>Res.resx</DependentUpon>
270+
</Compile>
271+
<None Include="Resources\VSProgram.cs" />
262272
<Compile Include="Utils\Config.cs" />
263273
<Compile Include="Properties\AssemblyInfo.cs" />
264274
<Compile Include="Model\RegexCaptureResult.cs" />
@@ -279,11 +289,6 @@
279289
<Compile Include="RegExToolDialog.xaml.cs">
280290
<DependentUpon>RegExToolDialog.xaml</DependentUpon>
281291
</Compile>
282-
<Compile Include="Res.Designer.cs">
283-
<AutoGen>True</AutoGen>
284-
<DesignTime>True</DesignTime>
285-
<DependentUpon>Res.resx</DependentUpon>
286-
</Compile>
287292
<Compile Include="Converters\ShowOnOneLineConverter.cs" />
288293
<Compile Include="Utils\RegexTextSource.cs" />
289294
<Compile Include="Utils\Extensions.cs" />
@@ -394,6 +399,18 @@
394399
<ItemGroup>
395400
<Resource Include="Resources\control_play_blue.png" />
396401
</ItemGroup>
402+
<ItemGroup>
403+
<Resource Include="Resources\visual_studio_black.png" />
404+
</ItemGroup>
405+
<ItemGroup>
406+
<Resource Include="Resources\visual_studio_purple.png" />
407+
</ItemGroup>
408+
<ItemGroup>
409+
<Resource Include="Resources\VSSolution.sln" />
410+
</ItemGroup>
411+
<ItemGroup>
412+
<Resource Include="Resources\VSProject.csproj" />
413+
</ItemGroup>
397414
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
398415
<PropertyGroup>
399416
<PostBuildEvent>

RegexDialog/Res.Designer.cs

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

RegexDialog/Res.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,13 @@
136136
<data name="Replace_syntax_color" type="System.Resources.ResXFileRef, System.Windows.Forms">
137137
<value>resources\replace_syntax_color.xshd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;iso-8859-1</value>
138138
</data>
139+
<data name="VSProgram" type="System.Resources.ResXFileRef, System.Windows.Forms">
140+
<value>resources\vsprogram.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
141+
</data>
142+
<data name="VSProject" type="System.Resources.ResXFileRef, System.Windows.Forms">
143+
<value>resources\vsproject.csproj;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
144+
</data>
145+
<data name="VSSolution" type="System.Resources.ResXFileRef, System.Windows.Forms">
146+
<value>resources\vssolution.sln;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
147+
</data>
139148
</root>

RegexDialog/Resources/CSharpReplaceContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using RegexDialog;
1010
//usings
1111

12-
public class Script
12+
public class CSharpReplaceContainer
1313
{
1414
//global
1515

RegexDialog/Resources/VSProgram.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//usings
2+
3+
namespace projectname
4+
{
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
//code
10+
}
11+
}
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>

RegexDialog/Resources/VSSolution.sln

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
Project("{$guid2$}") = "$projectname$", "$projectname$\$projectname$.csproj", "{$guid1$}"
3+
EndProject
4+
Global
5+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6+
Debug|Any CPU = Debug|Any CPU
7+
Release|Any CPU = Release|Any CPU
8+
EndGlobalSection
9+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
10+
{$guid1$}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
11+
{$guid1$}.Debug|Any CPU.Build.0 = Debug|Any CPU
12+
{$guid1$}.Release|Any CPU.ActiveCfg = Release|Any CPU
13+
{$guid1$}.Release|Any CPU.Build.0 = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(SolutionProperties) = preSolution
16+
HideSolutionNode = FALSE
17+
EndGlobalSection
18+
GlobalSection(ExtensibilityGlobals) = postSolution
19+
SolutionGuid = {$guid3$}
20+
EndGlobalSection
21+
EndGlobal
329 Bytes
Loading
319 Bytes
Loading

RegexDialog/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<package id="Microsoft.SDK.Expression.Blend" version="1.0.0" targetFramework="net452" />
1515
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net46" />
1616
<package id="Ookii.Dialogs" version="1.0" targetFramework="net452" />
17+
<package id="Ookii.Dialogs.WinForms" version="1.0.0" targetFramework="net46" />
1718
<package id="PropertyChanged.Fody" version="3.0.1" targetFramework="net46" />
1819
<package id="System.AppContext" version="4.3.0" targetFramework="net452" />
1920
<package id="System.Collections" version="4.3.0" targetFramework="net452" />

0 commit comments

Comments
 (0)