Skip to content

Commit

Permalink
config file auto load
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Aug 24, 2016
1 parent 3543bc2 commit 336244d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Shadowsocks-Plus/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
if (System.IO.File.Exists(@".\config.txt"))
{
string[] lines = System.IO.File.ReadLines(".\\config.txt").ToArray();
//MessageBox.Show("test");
//MessageBox.Show(lines[0]);
textBox.Text = lines[0];
textBox1.Text = lines[1];
passwordBox.Password = lines[2];
textBox2.Text = lines[3];
}
}

private void button_Click(object sender, RoutedEventArgs e)
Expand All @@ -44,12 +54,16 @@ private void button1_Click(object sender, RoutedEventArgs e)
return;
//Application.Current.Shutdown();
}

string server = textBox.Text;
//int sport = Int32.Parse(textBox1.Text);
string sport = textBox1.Text;
string password = passwordBox.Password;
//int lport = Int32.Parse(textBox2.Text);
string lport = textBox2.Text;
// write into file
string[] config = { server, sport, password, lport };
System.IO.File.WriteAllLines(@".\config.txt", config);
if(String.IsNullOrWhiteSpace(server) || String.IsNullOrWhiteSpace(password) || String.IsNullOrWhiteSpace(sport) || String.IsNullOrWhiteSpace(lport))
{
MessageBox.Show("Fill in all the forms before proceeding!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Expand Down
5 changes: 5 additions & 0 deletions Shadowsocks-Plus/Shadowsocks-Plus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
Expand Down Expand Up @@ -129,6 +133,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
4 changes: 4 additions & 0 deletions Shadowsocks-Plus/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
</packages>

0 comments on commit 336244d

Please sign in to comment.