mirror of
https://github.com/EpicMorg/UniversalValveToolbox.git
synced 2025-02-05 18:20:29 +03:00
commit
This commit is contained in:
parent
fbec876475
commit
429c8da82f
@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29521.150
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalValveToolbox", "UniversalValveToolbox\UniversalValveToolbox.csproj", "{DE66895F-7317-45D3-B5CA-292253CE086A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalValveToolbox", "UniversalValveToolbox\UniversalValveToolbox.csproj", "{DE66895F-7317-45D3-B5CA-292253CE086A}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wpfExample", "wpfExample\wpfExample.csproj", "{8532F273-FDBB-462A-9276-85641A9B059B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{DE66895F-7317-45D3-B5CA-292253CE086A}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<configuration>
|
|
||||||
<startup>
|
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
|
||||||
</startup>
|
|
||||||
</configuration>
|
|
@ -1,6 +1,9 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using UniversalValveToolbox.Util;
|
||||||
|
using UniversalValveToolbox.Util.Dto;
|
||||||
|
|
||||||
namespace UniversalValveToolbox {
|
namespace UniversalValveToolbox {
|
||||||
public partial class FormMain : Form {
|
public partial class FormMain : Form {
|
||||||
@ -77,16 +80,14 @@ namespace UniversalValveToolbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void button_Launch_Click(object sender, EventArgs e) {
|
private void button_Launch_Click(object sender, EventArgs e) {
|
||||||
var frmSettings = new FormSettings();
|
this.OpenSettings();
|
||||||
frmSettings.ShowDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listView_MouseDoubleClick(object sender, MouseEventArgs e) {
|
private void listView_MouseDoubleClick(object sender, MouseEventArgs e) {
|
||||||
var selectItemText = listView.SelectedItems[0].Text;
|
var selectItemText = listView.SelectedItems[0].Text;
|
||||||
|
|
||||||
if (selectItemText == Properties.translations.MenuItems.itmOpenSettings) {
|
if (selectItemText == Properties.translations.MenuItems.itmOpenSettings) {
|
||||||
var frmSettings = new FormSettings();
|
this.OpenSettings();
|
||||||
frmSettings.ShowDialog();
|
|
||||||
}
|
}
|
||||||
else if (selectItemText == Properties.translations.MenuItems.itmEditConfigurations) {
|
else if (selectItemText == Properties.translations.MenuItems.itmEditConfigurations) {
|
||||||
var frmProfiles = new FormProfiles();
|
var frmProfiles = new FormProfiles();
|
||||||
@ -104,5 +105,19 @@ namespace UniversalValveToolbox {
|
|||||||
Process.Start("https://github.com/EpicMorg/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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
this.comboBoxLang = new System.Windows.Forms.ComboBox();
|
this.comboBoxLang = new System.Windows.Forms.ComboBox();
|
||||||
this.comboBoxTheme = new System.Windows.Forms.ComboBox();
|
this.comboBoxTheme = new System.Windows.Forms.ComboBox();
|
||||||
this.label6 = new System.Windows.Forms.Label();
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
this.elementHost1 = new System.Windows.Forms.Integration.ElementHost();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelDivider
|
// labelDivider
|
||||||
@ -38,7 +39,7 @@
|
|||||||
this.labelDivider.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
this.labelDivider.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.labelDivider.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
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.Name = "labelDivider";
|
||||||
this.labelDivider.Size = new System.Drawing.Size(385, 2);
|
this.labelDivider.Size = new System.Drawing.Size(385, 2);
|
||||||
this.labelDivider.TabIndex = 26;
|
this.labelDivider.TabIndex = 26;
|
||||||
@ -46,7 +47,7 @@
|
|||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
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.Name = "buttonCancel";
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonCancel.TabIndex = 25;
|
this.buttonCancel.TabIndex = 25;
|
||||||
@ -57,7 +58,8 @@
|
|||||||
// buttonOK
|
// buttonOK
|
||||||
//
|
//
|
||||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
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.Name = "buttonOK";
|
||||||
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonOK.TabIndex = 24;
|
this.buttonOK.TabIndex = 24;
|
||||||
@ -108,11 +110,21 @@
|
|||||||
this.label6.TabIndex = 31;
|
this.label6.TabIndex = 31;
|
||||||
this.label6.Text = "Theme:";
|
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
|
// FormSettings
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
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.comboBoxTheme);
|
||||||
this.Controls.Add(this.label6);
|
this.Controls.Add(this.label6);
|
||||||
this.Controls.Add(this.comboBoxLang);
|
this.Controls.Add(this.comboBoxLang);
|
||||||
@ -142,5 +154,6 @@
|
|||||||
private System.Windows.Forms.ComboBox comboBoxLang;
|
private System.Windows.Forms.ComboBox comboBoxLang;
|
||||||
private System.Windows.Forms.ComboBox comboBoxTheme;
|
private System.Windows.Forms.ComboBox comboBoxTheme;
|
||||||
private System.Windows.Forms.Label label6;
|
private System.Windows.Forms.Label label6;
|
||||||
|
private System.Windows.Forms.Integration.ElementHost elementHost1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,24 @@
|
|||||||
using System;
|
using kasthack.binding.wf;
|
||||||
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using UniversalValveToolbox.Util.Dto;
|
||||||
|
|
||||||
namespace UniversalValveToolbox {
|
namespace UniversalValveToolbox {
|
||||||
public partial class FormSettings : Form {
|
public partial class FormSettings : Form {
|
||||||
public FormSettings() {
|
public FormSettings(SettingsViewModel settings) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
comboBoxLang.SelectedIndex = 0;
|
comboBoxLang.SelectedIndex = 0;
|
||||||
comboBoxTheme.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) {
|
private void buttonCancel_Click(object sender, EventArgs e) {
|
||||||
|
@ -36,14 +36,11 @@
|
|||||||
<ApplicationIcon>valve.ico</ApplicationIcon>
|
<ApplicationIcon>valve.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="EpicMorg.SteamPathsLib, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="PresentationCore" />
|
||||||
<HintPath>..\packages\EpicMorg.SteamPathsLib.1.1.0\lib\net48\EpicMorg.SteamPathsLib.dll</HintPath>
|
<Reference Include="PresentationFramework" />
|
||||||
</Reference>
|
|
||||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xaml" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
@ -53,6 +50,14 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<PackageReference Include="EpicMorg.SteamPathsLib" Version="1.1.0" />
|
||||||
|
<PackageReference Include="kasthack.binding.wf">
|
||||||
|
<Version>1.2.26</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
<Reference Include="UIAutomationProvider" />
|
||||||
|
<Reference Include="WindowsBase" />
|
||||||
|
<Reference Include="WindowsFormsIntegration" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Form\FormAbout.cs">
|
<Compile Include="Form\FormAbout.cs">
|
||||||
@ -112,6 +117,7 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>MessageBoxes.resx</DependentUpon>
|
<DependentUpon>MessageBoxes.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Util\JsonReader.cs" />
|
||||||
<Compile Include="Util\VersionHelper.cs" />
|
<Compile Include="Util\VersionHelper.cs" />
|
||||||
<EmbeddedResource Include="Form\FormAbout.resx">
|
<EmbeddedResource Include="Form\FormAbout.resx">
|
||||||
<DependentUpon>FormAbout.cs</DependentUpon>
|
<DependentUpon>FormAbout.cs</DependentUpon>
|
||||||
@ -183,7 +189,6 @@
|
|||||||
<None Include="json\settings.json">
|
<None Include="json\settings.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="packages.config" />
|
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
@ -194,9 +199,6 @@
|
|||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="App.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources\cancel_16.png" />
|
<None Include="Resources\cancel_16.png" />
|
||||||
<None Include="Resources\checked_16.png" />
|
<None Include="Resources\checked_16.png" />
|
||||||
|
221
src/UniversalValveToolbox/Util/JsonReader.cs
Normal file
221
src/UniversalValveToolbox/Util/JsonReader.cs
Normal file
@ -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<Settings>(SettingsPath);
|
||||||
|
public void SaveSettings(Settings settingsDto) => this.WriteModel(SettingsPath, settingsDto);
|
||||||
|
|
||||||
|
|
||||||
|
private T ReadModel<T>(string path) => JsonConvert.DeserializeObject<T>(File.ReadAllText(path));
|
||||||
|
private void WriteModel<T>(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<string, VProject> { }
|
||||||
|
|
||||||
|
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>(T value, ref T field, [CallerMemberName]string name = null) {
|
||||||
|
var updated = !EqualityComparer<T>.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
"vproject": {
|
"vproject": {
|
||||||
"engine": 243730, //linked avalible engine by id
|
"engine": 243730, //linked avalible engine by id
|
||||||
"path": "C:\\Test", //path for export to users's env
|
"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
|
"args": "" //run args
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"default-project": "projects//test project.json",
|
"DefaultProject": null,
|
||||||
"avalible-enginies": [ 243730 ],
|
"AvalibleEnginies": null,
|
||||||
"language": null,
|
"Language": "Россиян",
|
||||||
"theme": null
|
"Theme": null
|
||||||
}
|
}
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="EpicMorg.SteamPathsLib" version="1.1.0" targetFramework="net48" />
|
|
||||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net48" />
|
|
||||||
</packages>
|
|
9
src/wpfExample/App.xaml
Normal file
9
src/wpfExample/App.xaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="wpfExample.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:wpfExample"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
15
src/wpfExample/App.xaml.cs
Normal file
15
src/wpfExample/App.xaml.cs
Normal file
@ -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 {
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application {
|
||||||
|
}
|
||||||
|
}
|
10
src/wpfExample/AssemblyInfo.cs
Normal file
10
src/wpfExample/AssemblyInfo.cs
Normal file
@ -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)
|
||||||
|
)]
|
22
src/wpfExample/MainWindow.xaml
Normal file
22
src/wpfExample/MainWindow.xaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<Window x:Class="wpfExample.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:wpfExample"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow" Height="450" Width="800">
|
||||||
|
<Grid>
|
||||||
|
<TextBox HorizontalAlignment="Left" Margin="73,123,0,0" Text="TextBox" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" RenderTransformOrigin="0.5,0.5">
|
||||||
|
<TextBox.RenderTransform>
|
||||||
|
<TransformGroup>
|
||||||
|
<ScaleTransform/>
|
||||||
|
<SkewTransform/>
|
||||||
|
<RotateTransform Angle="719.385"/>
|
||||||
|
<TranslateTransform/>
|
||||||
|
</TransformGroup>
|
||||||
|
</TextBox.RenderTransform>
|
||||||
|
</TextBox>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
25
src/wpfExample/MainWindow.xaml.cs
Normal file
25
src/wpfExample/MainWindow.xaml.cs
Normal file
@ -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 {
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window {
|
||||||
|
public MainWindow() {
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
src/wpfExample/wpfExample.csproj
Normal file
9
src/wpfExample/wpfExample.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user