diff --git a/src/UniversalValveToolbox.sln b/src/UniversalValveToolbox.sln
index 1003379..d70618d 100644
--- a/src/UniversalValveToolbox.sln
+++ b/src/UniversalValveToolbox.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29521.150
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalValveToolbox", "UniversalValveToolbox\UniversalValveToolbox.csproj", "{DE66895F-7317-45D3-B5CA-292253CE086A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wpfExample", "wpfExample\wpfExample.csproj", "{8532F273-FDBB-462A-9276-85641A9B059B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{DE66895F-7317-45D3-B5CA-292253CE086A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE66895F-7317-45D3-B5CA-292253CE086A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE66895F-7317-45D3-B5CA-292253CE086A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8532F273-FDBB-462A-9276-85641A9B059B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8532F273-FDBB-462A-9276-85641A9B059B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8532F273-FDBB-462A-9276-85641A9B059B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8532F273-FDBB-462A-9276-85641A9B059B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/UniversalValveToolbox/App.config b/src/UniversalValveToolbox/App.config
deleted file mode 100644
index 193aecc..0000000
--- a/src/UniversalValveToolbox/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/UniversalValveToolbox/Form/FormMain.cs b/src/UniversalValveToolbox/Form/FormMain.cs
index 637cdc2..3630e9c 100644
--- a/src/UniversalValveToolbox/Form/FormMain.cs
+++ b/src/UniversalValveToolbox/Form/FormMain.cs
@@ -1,6 +1,9 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Diagnostics;
using System.Windows.Forms;
+using UniversalValveToolbox.Util;
+using UniversalValveToolbox.Util.Dto;
namespace UniversalValveToolbox {
public partial class FormMain : Form {
@@ -77,16 +80,14 @@ namespace UniversalValveToolbox {
}
private void button_Launch_Click(object sender, EventArgs e) {
- var frmSettings = new FormSettings();
- frmSettings.ShowDialog();
+ this.OpenSettings();
}
private void listView_MouseDoubleClick(object sender, MouseEventArgs e) {
var selectItemText = listView.SelectedItems[0].Text;
if (selectItemText == Properties.translations.MenuItems.itmOpenSettings) {
- var frmSettings = new FormSettings();
- frmSettings.ShowDialog();
+ this.OpenSettings();
}
else if (selectItemText == Properties.translations.MenuItems.itmEditConfigurations) {
var frmProfiles = new FormProfiles();
@@ -104,5 +105,19 @@ namespace UniversalValveToolbox {
Process.Start("https://github.com/EpicMorg/UniversalValveToolbox");
}
}
+
+ private void OpenSettings() {
+ var dataManager = new DataManager();
+ var settingsDto = dataManager.ReadSettings();
+ var languageProvider = new LanguageProvider();
+
+ var settingsModel = new SettingsViewModel(settingsDto, languageProvider);
+
+ var frmSettings = new FormSettings(settingsModel);
+
+ if (frmSettings.ShowDialog() == DialogResult.OK) {
+ dataManager.SaveSettings(settingsDto);
+ }
+ }
}
}
diff --git a/src/UniversalValveToolbox/Form/FormSettings.Designer.cs b/src/UniversalValveToolbox/Form/FormSettings.Designer.cs
index 777a797..a6cdade 100644
--- a/src/UniversalValveToolbox/Form/FormSettings.Designer.cs
+++ b/src/UniversalValveToolbox/Form/FormSettings.Designer.cs
@@ -31,6 +31,7 @@
this.comboBoxLang = new System.Windows.Forms.ComboBox();
this.comboBoxTheme = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
+ this.elementHost1 = new System.Windows.Forms.Integration.ElementHost();
this.SuspendLayout();
//
// labelDivider
@@ -38,7 +39,7 @@
this.labelDivider.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.labelDivider.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
- this.labelDivider.Location = new System.Drawing.Point(-21, 101);
+ this.labelDivider.Location = new System.Drawing.Point(-21, 272);
this.labelDivider.Name = "labelDivider";
this.labelDivider.Size = new System.Drawing.Size(385, 2);
this.labelDivider.TabIndex = 26;
@@ -46,7 +47,7 @@
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonCancel.Location = new System.Drawing.Point(224, 113);
+ this.buttonCancel.Location = new System.Drawing.Point(224, 284);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 25;
@@ -57,7 +58,8 @@
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonOK.Location = new System.Drawing.Point(143, 113);
+ this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.buttonOK.Location = new System.Drawing.Point(143, 284);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 24;
@@ -108,11 +110,21 @@
this.label6.TabIndex = 31;
this.label6.Text = "Theme:";
//
+ // elementHost1
+ //
+ this.elementHost1.Location = new System.Drawing.Point(12, 93);
+ this.elementHost1.Name = "elementHost1";
+ this.elementHost1.Size = new System.Drawing.Size(287, 176);
+ this.elementHost1.TabIndex = 33;
+ this.elementHost1.Text = "elementHost1";
+ this.elementHost1.Child = null;
+ //
// FormSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(311, 148);
+ this.ClientSize = new System.Drawing.Size(311, 319);
+ this.Controls.Add(this.elementHost1);
this.Controls.Add(this.comboBoxTheme);
this.Controls.Add(this.label6);
this.Controls.Add(this.comboBoxLang);
@@ -142,5 +154,6 @@
private System.Windows.Forms.ComboBox comboBoxLang;
private System.Windows.Forms.ComboBox comboBoxTheme;
private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Integration.ElementHost elementHost1;
}
}
\ No newline at end of file
diff --git a/src/UniversalValveToolbox/Form/FormSettings.cs b/src/UniversalValveToolbox/Form/FormSettings.cs
index 568675b..20b0655 100644
--- a/src/UniversalValveToolbox/Form/FormSettings.cs
+++ b/src/UniversalValveToolbox/Form/FormSettings.cs
@@ -1,12 +1,24 @@
-using System;
+using kasthack.binding.wf;
+using System;
using System.Windows.Forms;
+using UniversalValveToolbox.Util.Dto;
namespace UniversalValveToolbox {
public partial class FormSettings : Form {
- public FormSettings() {
+ public FormSettings(SettingsViewModel settings) {
InitializeComponent();
+
comboBoxLang.SelectedIndex = 0;
comboBoxTheme.SelectedIndex = 0;
+
+ comboBoxLang.Bind(a => a.DataSource, settings, a => a.Languages);
+ comboBoxLang.Bind(a => a.SelectedIndex, settings, a => a.SelectedLanguageIndex);
+
+ //this.Bind(a => a.Text, settings, a => a.Language);
+
+ //^
+ //this.DataBindings.Add(new Binding(nameof(this.Text), settings, nameof(settings.Language), false, DataSourceUpdateMode.OnPropertyChanged));
+
}
private void buttonCancel_Click(object sender, EventArgs e) {
diff --git a/src/UniversalValveToolbox/UniversalValveToolbox.csproj b/src/UniversalValveToolbox/UniversalValveToolbox.csproj
index 9071ca1..f3d4695 100644
--- a/src/UniversalValveToolbox/UniversalValveToolbox.csproj
+++ b/src/UniversalValveToolbox/UniversalValveToolbox.csproj
@@ -36,14 +36,11 @@
valve.ico
-
- ..\packages\EpicMorg.SteamPathsLib.1.1.0\lib\net48\EpicMorg.SteamPathsLib.dll
-
-
- ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
-
+
+
+
@@ -53,6 +50,14 @@
+
+
+ 1.2.26
+
+
+
+
+
@@ -112,6 +117,7 @@
True
MessageBoxes.resx
+
FormAbout.cs
@@ -183,7 +189,6 @@
Always
-
SettingsSingleFileGenerator
Settings.Designer.cs
@@ -194,9 +199,6 @@
True
-
-
-
diff --git a/src/UniversalValveToolbox/Util/JsonReader.cs b/src/UniversalValveToolbox/Util/JsonReader.cs
new file mode 100644
index 0000000..e053eda
--- /dev/null
+++ b/src/UniversalValveToolbox/Util/JsonReader.cs
@@ -0,0 +1,221 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using UniversalValveToolbox.Util.Dto;
+
+namespace UniversalValveToolbox.Util {
+ class DataManager {
+ private const string SettingsPath = "settings.json";
+
+ public Settings ReadSettings() => this.ReadModel(SettingsPath);
+ public void SaveSettings(Settings settingsDto) => this.WriteModel(SettingsPath, settingsDto);
+
+
+ private T ReadModel(string path) => JsonConvert.DeserializeObject(File.ReadAllText(path));
+ private void WriteModel(string path, T value) => File.WriteAllText(path, JsonConvert.SerializeObject(value, Formatting.Indented));
+ }
+}
+
+namespace UniversalValveToolbox.Util.Dto {
+ public class Addon : BaseModel {
+ private int[] engine;
+
+ private string args;
+
+ private string bin;
+
+ private string name;
+
+ public int[] Engine {
+ get => this.engine;
+ set => this.UpdateField(value, ref this.engine);
+ }
+
+ public string Name {
+ get => this.name;
+ set => this.UpdateField(value, ref this.name);
+ }
+
+ private string category;
+
+ public string Category {
+ get => this.category;
+ set => this.UpdateField(value, ref this.category);
+ }
+
+ public string Bin {
+ get => this.bin;
+ set => this.UpdateField(value, ref this.bin);
+ }
+
+ public string Args {
+ get => this.args;
+ set => this.UpdateField(value, ref this.args);
+ }
+ }
+
+ public class Engine : BaseModel {
+ private int appid;
+
+ public int Appid {
+ get => this.appid;
+ set => this.UpdateField(value, ref this.appid);
+ }
+
+ private string name;
+
+ public string Name {
+ get => this.name;
+ set => this.UpdateField(value, ref this.name);
+ }
+
+ private string bin;
+
+ public string Bin {
+ get => this.bin;
+ set => this.UpdateField(value, ref this.bin);
+ }
+
+ private Tool[] tools;
+
+ public Tool[] Tools {
+ get => this.tools;
+ set => this.UpdateField(value, ref this.tools);
+ }
+ }
+
+ public class Tool : BaseModel {
+ private string args;
+
+ public string Args {
+ get => this.args;
+ set => this.UpdateField(value, ref this.args);
+ }
+
+ private string bin;
+
+ public string Bin {
+ get => this.bin;
+ set => this.UpdateField(value, ref this.bin);
+ }
+
+ private string name;
+
+ public string Name {
+ get => this.name;
+ set => this.UpdateField(value, ref this.name);
+ }
+ }
+
+ public class VProject : BaseModel {
+ private int engine;
+
+ public int Engine {
+ get => this.engine;
+ set => this.UpdateField(value, ref this.engine);
+ }
+
+ private string path;
+
+ public string Path {
+ get => this.path;
+ set => this.UpdateField(value, ref this.path);
+ }
+
+ private string name;
+
+ public string Name {
+ get => this.name;
+ set => this.UpdateField(value, ref this.name);
+ }
+
+ private string args;
+
+ public string Args {
+ get => this.args;
+ set => this.UpdateField(value, ref this.args);
+ }
+ }
+
+ public class Project : Dictionary { }
+
+ public class SettingsViewModel : BaseModel {
+ private readonly Settings settings;
+ private readonly LanguageProvider languageProvider;
+
+ private int selectedLanguage;
+
+ public int SelectedLanguageIndex {
+ get => this.selectedLanguage;
+ set {
+ if (this.UpdateField(value, ref selectedLanguage)) {
+ this.settings.Language = this.SelectedLanguage;
+ }
+ }
+ }
+
+ public string[] Languages => this.languageProvider.Languages;
+ private string SelectedLanguage => this.Languages[this.SelectedLanguageIndex];
+
+ public SettingsViewModel(Settings settings, LanguageProvider languageProvider) {
+ this.settings = settings;
+ this.languageProvider = languageProvider;
+
+ this.SelectedLanguageIndex = Math.Max(0, Array.IndexOf(this.Languages, settings.Language));
+ }
+ }
+
+ public class LanguageProvider {
+ public string[] Languages { get; } = { "English", "Россиян" };
+ }
+
+ public class Settings : BaseModel {
+ private string defaultProject;
+ private int[] avalibleEnginies;
+ private string language;
+ private string theme;
+
+ public string DefaultProject {
+ get => this.defaultProject;
+ set => this.UpdateField(value, ref this.defaultProject);
+ }
+
+ public int[] AvalibleEnginies {
+ get => this.avalibleEnginies;
+ set => this.UpdateField(value, ref this.avalibleEnginies);
+ }
+
+ public string Language {
+ get => this.language;
+ set => this.UpdateField(value, ref this.language);
+ }
+
+ public string Theme {
+ get => this.theme;
+ set => this.UpdateField(value, ref this.theme);
+ }
+ }
+
+ public abstract class BaseModel : INotifyPropertyChanged {
+
+ protected bool UpdateField(T value, ref T field, [CallerMemberName]string name = null) {
+ var updated = !EqualityComparer.Default.Equals(value, field);
+ if (updated) {
+ field = value;
+ OnPropertyChanged(name);
+ }
+ return updated;
+ }
+
+ protected void OnPropertyChanged([CallerMemberName]string name = null) => this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ }
+
+}
diff --git a/src/UniversalValveToolbox/json/projects/test project.json b/src/UniversalValveToolbox/json/projects/test project.json
index 831652b..f3662d8 100644
--- a/src/UniversalValveToolbox/json/projects/test project.json
+++ b/src/UniversalValveToolbox/json/projects/test project.json
@@ -2,7 +2,7 @@
"vproject": {
"engine": 243730, //linked avalible engine by id
"path": "C:\\Test", //path for export to users's env
- "name": "Test Project" //name for launcher
+ "name": "Test Project", //name for launcher
"args": "" //run args
}
}
diff --git a/src/UniversalValveToolbox/json/settings.json b/src/UniversalValveToolbox/json/settings.json
index af7b4de..9e91e31 100644
--- a/src/UniversalValveToolbox/json/settings.json
+++ b/src/UniversalValveToolbox/json/settings.json
@@ -1,6 +1,6 @@
{
- "default-project": "projects//test project.json",
- "avalible-enginies": [ 243730 ],
- "language": null,
- "theme": null
-}
+ "DefaultProject": null,
+ "AvalibleEnginies": null,
+ "Language": "Россиян",
+ "Theme": null
+}
\ No newline at end of file
diff --git a/src/UniversalValveToolbox/packages.config b/src/UniversalValveToolbox/packages.config
deleted file mode 100644
index e6872e8..0000000
--- a/src/UniversalValveToolbox/packages.config
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/wpfExample/App.xaml b/src/wpfExample/App.xaml
new file mode 100644
index 0000000..fa43eef
--- /dev/null
+++ b/src/wpfExample/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/src/wpfExample/App.xaml.cs b/src/wpfExample/App.xaml.cs
new file mode 100644
index 0000000..2eaa5c7
--- /dev/null
+++ b/src/wpfExample/App.xaml.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace wpfExample {
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application {
+ }
+}
diff --git a/src/wpfExample/AssemblyInfo.cs b/src/wpfExample/AssemblyInfo.cs
new file mode 100644
index 0000000..8b5504e
--- /dev/null
+++ b/src/wpfExample/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/src/wpfExample/MainWindow.xaml b/src/wpfExample/MainWindow.xaml
new file mode 100644
index 0000000..53222f5
--- /dev/null
+++ b/src/wpfExample/MainWindow.xaml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/wpfExample/MainWindow.xaml.cs b/src/wpfExample/MainWindow.xaml.cs
new file mode 100644
index 0000000..6b66aea
--- /dev/null
+++ b/src/wpfExample/MainWindow.xaml.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace wpfExample {
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window {
+ public MainWindow() {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/wpfExample/wpfExample.csproj b/src/wpfExample/wpfExample.csproj
new file mode 100644
index 0000000..6c68d0e
--- /dev/null
+++ b/src/wpfExample/wpfExample.csproj
@@ -0,0 +1,9 @@
+
+
+
+ WinExe
+ netcoreapp3.1
+ true
+
+
+
\ No newline at end of file