mirror of
https://github.com/EpicMorg/UniversalValveToolbox.git
synced 2024-12-26 06:35:29 +03:00
Update editor project
This commit is contained in:
parent
a5bbb8f563
commit
b563fa5117
@ -8,6 +8,13 @@ using Newtonsoft.Json;
|
||||
namespace UniversalValveToolbox.Base {
|
||||
public abstract class DtoModel : INotifyPropertyChanged {
|
||||
|
||||
protected bool ForceUpdateField<T>(T value, ref T field, [CallerMemberName]string name = null) {
|
||||
field = value;
|
||||
OnPropertyChanged(name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool UpdateField<T>(T value, ref T field, [CallerMemberName]string name = null) {
|
||||
var updated = !EqualityComparer<T>.Default.Equals(value, field);
|
||||
if (updated) {
|
||||
|
@ -32,6 +32,8 @@ namespace UniversalValveToolbox.Model.Dto {
|
||||
get => args;
|
||||
set => UpdateField(value, ref args);
|
||||
}
|
||||
|
||||
public override string ToString() => name ?? "";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,5 +26,7 @@ namespace UniversalValveToolbox.Model.Dto {
|
||||
get => tools;
|
||||
set => UpdateField(value, ref tools);
|
||||
}
|
||||
|
||||
public override string ToString() => name;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,13 @@ namespace UniversalValveToolbox.Model.Dto {
|
||||
private string name;
|
||||
private string args;
|
||||
|
||||
public ProjectDtoModel() {
|
||||
this.engine = 0;
|
||||
this.path = "";
|
||||
this.name = "";
|
||||
this.args = "";
|
||||
}
|
||||
|
||||
public int Engine {
|
||||
get => engine;
|
||||
set => UpdateField(value, ref engine);
|
||||
@ -27,6 +34,6 @@ namespace UniversalValveToolbox.Model.Dto {
|
||||
set => UpdateField(value, ref args);
|
||||
}
|
||||
|
||||
public override string ToString() => name;
|
||||
public override string ToString() => name ?? "";
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ using UniversalValveToolbox.Utils;
|
||||
namespace UniversalValveToolbox.Model.Provider {
|
||||
class DataProvider {
|
||||
|
||||
private readonly string SettingsPath = Path.Combine(Application.StartupPath, "json", "settings.json");
|
||||
private readonly string EnginesPath = Path.Combine(Application.StartupPath, "json", "engines");
|
||||
private readonly string ProjectsPath = Path.Combine(Application.StartupPath, "json", "projects");
|
||||
private readonly string AddonsPath = Path.Combine(Application.StartupPath, "json", "addons");
|
||||
public static readonly string SettingsPath = Path.Combine(Application.StartupPath, "json", "settings.json");
|
||||
public static readonly string EnginesPath = Path.Combine(Application.StartupPath, "json", "engines");
|
||||
public static readonly string ProjectsPath = Path.Combine(Application.StartupPath, "json", "projects");
|
||||
public static readonly string AddonsPath = Path.Combine(Application.StartupPath, "json", "addons");
|
||||
|
||||
|
||||
public SettingsDtoModel Settings {
|
||||
|
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversalValveToolbox.Base;
|
||||
using UniversalValveToolbox.Model.Dto;
|
||||
|
||||
namespace UniversalValveToolbox.Model.ViewModel {
|
||||
class FormAddonViewModel: DtoModel {
|
||||
private AddonDtoModel selectAddon;
|
||||
|
||||
public AddonDtoModel SelectAddon {
|
||||
get => selectAddon;
|
||||
set => UpdateField(value, ref selectAddon);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -8,11 +8,57 @@ using UniversalValveToolbox.Model.Dto;
|
||||
|
||||
namespace UniversalValveToolbox.Model.ViewModel {
|
||||
class FormProjectViewModel: DtoModel {
|
||||
private ProjectDtoModel selectProject;
|
||||
private ProjectDtoModel[] projects;
|
||||
private int selectProjectIndex = 0;
|
||||
|
||||
public ProjectDtoModel SelectProject {
|
||||
get => selectProject;
|
||||
set => UpdateField(value, ref selectProject);
|
||||
private EngineDtoModel[] engines;
|
||||
private int selectEngineIndex = 0;
|
||||
|
||||
public FormProjectViewModel(ProjectDtoModel[] projects, EngineDtoModel[] engines) {
|
||||
this.projects = projects;
|
||||
this.engines = engines;
|
||||
}
|
||||
|
||||
public ProjectDtoModel[] Projects {
|
||||
get => projects;
|
||||
set {
|
||||
UpdateField(value, ref projects);
|
||||
|
||||
SelectProjectIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int SelectProjectIndex {
|
||||
get => selectProjectIndex;
|
||||
set {
|
||||
ForceUpdateField(value, ref selectProjectIndex);
|
||||
OnPropertyChanged(nameof(SelectProject));
|
||||
|
||||
var index = Math.Max(engines.ToList().FindIndex(engine => engine.Appid == SelectProject.Engine), 0);
|
||||
|
||||
SelectEngineIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectDtoModel SelectProject => projects[selectProjectIndex];
|
||||
|
||||
public EngineDtoModel[] Engines {
|
||||
get => engines;
|
||||
set {
|
||||
UpdateField(value, ref engines);
|
||||
|
||||
SelectEngineIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int SelectEngineIndex {
|
||||
get => selectEngineIndex;
|
||||
set {
|
||||
ForceUpdateField(value, ref selectEngineIndex);
|
||||
OnPropertyChanged(nameof(SelectEngine));
|
||||
}
|
||||
}
|
||||
|
||||
public EngineDtoModel SelectEngine => engines[selectEngineIndex];
|
||||
}
|
||||
}
|
||||
|
62
src/UniversalValveToolbox/UI/FormAddons.Designer.cs
generated
62
src/UniversalValveToolbox/UI/FormAddons.Designer.cs
generated
@ -36,9 +36,6 @@
|
||||
this.buttonNew = new System.Windows.Forms.Button();
|
||||
this.labelAddon = new System.Windows.Forms.Label();
|
||||
this.labelLinkedEngine = new System.Windows.Forms.Label();
|
||||
this.dataGridViewEngines = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnEngineName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnAppID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxPath = new System.Windows.Forms.TextBox();
|
||||
@ -50,7 +47,7 @@
|
||||
this.comboBoxCategory = new System.Windows.Forms.ComboBox();
|
||||
this.labelCategory = new System.Windows.Forms.Label();
|
||||
this.buttonApply = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewEngines)).BeginInit();
|
||||
this.engineListView = new System.Windows.Forms.ListView();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
@ -84,6 +81,7 @@
|
||||
this.comboBox_Addon.Name = "comboBox_Addon";
|
||||
this.comboBox_Addon.Size = new System.Drawing.Size(390, 21);
|
||||
this.comboBox_Addon.TabIndex = 6;
|
||||
this.comboBox_Addon.SelectedIndexChanged += new System.EventHandler(this.comboBox_Addon_SelectedIndexChanged);
|
||||
//
|
||||
// buttonRemove
|
||||
//
|
||||
@ -123,42 +121,6 @@
|
||||
this.labelLinkedEngine.TabIndex = 12;
|
||||
this.labelLinkedEngine.Text = "Linked Engine:";
|
||||
//
|
||||
// dataGridViewEngines
|
||||
//
|
||||
this.dataGridViewEngines.AllowUserToAddRows = false;
|
||||
this.dataGridViewEngines.AllowUserToDeleteRows = false;
|
||||
this.dataGridViewEngines.AllowUserToOrderColumns = true;
|
||||
this.dataGridViewEngines.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dataGridViewEngines.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.dataGridViewEngines.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridViewEngines.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnEngineName,
|
||||
this.ColumnAppID});
|
||||
this.dataGridViewEngines.Location = new System.Drawing.Point(12, 182);
|
||||
this.dataGridViewEngines.Name = "dataGridViewEngines";
|
||||
this.dataGridViewEngines.ReadOnly = true;
|
||||
this.dataGridViewEngines.Size = new System.Drawing.Size(471, 180);
|
||||
this.dataGridViewEngines.TabIndex = 13;
|
||||
//
|
||||
// ColumnEngineName
|
||||
//
|
||||
this.ColumnEngineName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ColumnEngineName.HeaderText = "Engine";
|
||||
this.ColumnEngineName.Name = "ColumnEngineName";
|
||||
this.ColumnEngineName.ReadOnly = true;
|
||||
this.ColumnEngineName.Resizable = System.Windows.Forms.DataGridViewTriState.False;
|
||||
//
|
||||
// ColumnAppID
|
||||
//
|
||||
this.ColumnAppID.FillWeight = 256F;
|
||||
this.ColumnAppID.HeaderText = "AppID";
|
||||
this.ColumnAppID.Name = "ColumnAppID";
|
||||
this.ColumnAppID.ReadOnly = true;
|
||||
this.ColumnAppID.Resizable = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.ColumnAppID.Width = 62;
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
@ -262,11 +224,25 @@
|
||||
this.buttonApply.Text = "Apply";
|
||||
this.buttonApply.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// engineListView
|
||||
//
|
||||
this.engineListView.CheckBoxes = true;
|
||||
this.engineListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.engineListView.HideSelection = false;
|
||||
this.engineListView.Location = new System.Drawing.Point(15, 182);
|
||||
this.engineListView.Name = "engineListView";
|
||||
this.engineListView.Size = new System.Drawing.Size(387, 188);
|
||||
this.engineListView.TabIndex = 28;
|
||||
this.engineListView.UseCompatibleStateImageBehavior = false;
|
||||
this.engineListView.View = System.Windows.Forms.View.List;
|
||||
this.engineListView.SelectedIndexChanged += new System.EventHandler(this.engineListView_SelectedIndexChanged);
|
||||
//
|
||||
// FormAddons
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(495, 417);
|
||||
this.Controls.Add(this.engineListView);
|
||||
this.Controls.Add(this.buttonApply);
|
||||
this.Controls.Add(this.labelCategory);
|
||||
this.Controls.Add(this.comboBoxCategory);
|
||||
@ -278,7 +254,6 @@
|
||||
this.Controls.Add(this.labelPath);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Controls.Add(this.dataGridViewEngines);
|
||||
this.Controls.Add(this.labelLinkedEngine);
|
||||
this.Controls.Add(this.labelAddon);
|
||||
this.Controls.Add(this.buttonRemove);
|
||||
@ -293,7 +268,6 @@
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Edit Addons";
|
||||
this.Load += new System.EventHandler(this.FormAddons_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewEngines)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -308,9 +282,6 @@
|
||||
private System.Windows.Forms.Button buttonNew;
|
||||
private System.Windows.Forms.Label labelAddon;
|
||||
private System.Windows.Forms.Label labelLinkedEngine;
|
||||
private System.Windows.Forms.DataGridView dataGridViewEngines;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn ColumnEngineName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn ColumnAppID;
|
||||
private System.Windows.Forms.Label labelName;
|
||||
private System.Windows.Forms.TextBox textBoxName;
|
||||
private System.Windows.Forms.TextBox textBoxPath;
|
||||
@ -322,5 +293,6 @@
|
||||
private System.Windows.Forms.ComboBox comboBoxCategory;
|
||||
private System.Windows.Forms.Label labelCategory;
|
||||
private System.Windows.Forms.Button buttonApply;
|
||||
private System.Windows.Forms.ListView engineListView;
|
||||
}
|
||||
}
|
@ -1,10 +1,61 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using UniversalValveToolbox.Model.Provider;
|
||||
using UniversalValveToolbox.Model.ViewModel;
|
||||
using UniversalValveToolbox.Model.Dto;
|
||||
using kasthack.binding.wf;
|
||||
using System.Linq;
|
||||
|
||||
namespace UniversalValveToolbox {
|
||||
public partial class FormAddons : Form {
|
||||
private DataProvider dataProvider = new DataProvider();
|
||||
|
||||
private FormAddonViewModel model;
|
||||
|
||||
private AddonDtoModel[] arrayAddon;
|
||||
|
||||
public FormAddons() {
|
||||
InitializeComponent();
|
||||
|
||||
model = new FormAddonViewModel();
|
||||
model.SelectAddon = new AddonDtoModel();
|
||||
|
||||
var addons = dataProvider.Addons;
|
||||
arrayAddon = new AddonDtoModel[addons.Length + 1];
|
||||
arrayAddon[0] = model.SelectAddon;
|
||||
Array.Copy(addons, 0, arrayAddon, 1, addons.Length);
|
||||
|
||||
comboBox_Addon.Items.Clear();
|
||||
comboBox_Addon.Items.AddRange(arrayAddon);
|
||||
comboBox_Addon.SelectedIndex = 0;
|
||||
|
||||
textBoxName.Bind(a => a.Text, model, a => a.SelectAddon.Name);
|
||||
textBoxPath.Bind(a => a.Text, model, a => a.SelectAddon.Bin);
|
||||
textBoxArgs.Bind(a => a.Text, model, a => a.SelectAddon.Args);
|
||||
|
||||
model.PropertyChanged += Model_PropertyChanged;
|
||||
}
|
||||
|
||||
private void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
|
||||
var availableEngines = dataProvider.Engines.Select(engine => {
|
||||
var item = new ListViewItem(engine.Name);
|
||||
item.Checked = model.SelectAddon.Engines.Contains(engine.Appid);
|
||||
return item;
|
||||
}).ToArray();
|
||||
|
||||
|
||||
engineListView.Items.Clear();
|
||||
engineListView.Items.AddRange(availableEngines);
|
||||
|
||||
|
||||
|
||||
//dataGridViewEngines.Rows.add
|
||||
//var index = availableEngines.ToList().FindIndex(engine => engine.Appid == model.SelectProject.Engine);
|
||||
|
||||
//comboBoxEngine.Items.Clear();
|
||||
//comboBoxEngine.Items.AddRange(availableEngines);
|
||||
|
||||
//comboBoxEngine.SelectedIndex = index;
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) {
|
||||
@ -32,5 +83,14 @@ namespace UniversalValveToolbox {
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void comboBox_Addon_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
var selectAddon = arrayAddon.First(addon => addon.Name == ((AddonDtoModel)comboBox_Addon.SelectedItem).Name);
|
||||
model.SelectAddon = selectAddon;
|
||||
}
|
||||
|
||||
private void engineListView_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,12 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ColumnEngineName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnAppID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
@ -36,7 +36,8 @@ namespace UniversalValveToolbox {
|
||||
UpdateAddonsList();
|
||||
|
||||
Text = VersionHelper.AssemblyTitle + VersionHelper.AssemblyVersion;
|
||||
comboBoxGameConfig.SelectedIndex = 0;
|
||||
|
||||
|
||||
|
||||
comboBoxEngine.SelectedIndexChanged += (s, e) => {
|
||||
UpdateProjectList();
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace UniversalValveToolbox {
|
||||
using System;
|
||||
|
||||
namespace UniversalValveToolbox {
|
||||
partial class FormProfiles {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -53,6 +55,7 @@
|
||||
this.comboBox_Mod.Name = "comboBox_Mod";
|
||||
this.comboBox_Mod.Size = new System.Drawing.Size(395, 21);
|
||||
this.comboBox_Mod.TabIndex = 3;
|
||||
this.comboBox_Mod.SelectedIndexChanged += new System.EventHandler(this.comboBox_Mod_SelectedIndexChanged);
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
@ -63,6 +66,7 @@
|
||||
this.buttonOK.TabIndex = 4;
|
||||
this.buttonOK.Text = "OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
@ -84,6 +88,7 @@
|
||||
this.buttonNew.TabIndex = 7;
|
||||
this.buttonNew.Text = "New";
|
||||
this.buttonNew.UseVisualStyleBackColor = true;
|
||||
this.buttonNew.Click += new System.EventHandler(this.buttonNew_Click);
|
||||
//
|
||||
// buttonRemove
|
||||
//
|
||||
@ -94,6 +99,7 @@
|
||||
this.buttonRemove.TabIndex = 8;
|
||||
this.buttonRemove.Text = "Remove";
|
||||
this.buttonRemove.UseVisualStyleBackColor = true;
|
||||
this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
|
||||
//
|
||||
// buttonBrowse
|
||||
//
|
||||
@ -134,6 +140,7 @@
|
||||
this.comboBoxEngine.Name = "comboBoxEngine";
|
||||
this.comboBoxEngine.Size = new System.Drawing.Size(395, 21);
|
||||
this.comboBoxEngine.TabIndex = 15;
|
||||
this.comboBoxEngine.SelectedIndexChanged += new System.EventHandler(this.comboBoxEngine_SelectedIndexChanged);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
@ -190,6 +197,7 @@
|
||||
this.buttonApply.TabIndex = 28;
|
||||
this.buttonApply.Text = "Apply";
|
||||
this.buttonApply.UseVisualStyleBackColor = true;
|
||||
this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click);
|
||||
//
|
||||
// textBoxArgs
|
||||
//
|
||||
@ -243,6 +251,7 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox comboBox_Mod;
|
||||
|
@ -1,23 +1,59 @@
|
||||
using kasthack.binding.wf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using UniversalValveToolbox.Model.Dto;
|
||||
using UniversalValveToolbox.Model.Provider;
|
||||
using UniversalValveToolbox.Model.ViewModel;
|
||||
using UniversalValveToolbox.Utils;
|
||||
|
||||
namespace UniversalValveToolbox {
|
||||
public partial class FormProfiles : Form {
|
||||
private DataProvider dataProvider = new DataProvider();
|
||||
|
||||
private FormProjectViewModel model = new FormProjectViewModel();
|
||||
private FormProjectViewModel model;
|
||||
|
||||
|
||||
public FormProfiles() {
|
||||
InitializeComponent();
|
||||
|
||||
comboBox_Mod.Items.Clear();
|
||||
comboBox_Mod.Items.AddRange(dataProvider.Projects);
|
||||
//textBox1.Text = "1";
|
||||
model = new FormProjectViewModel(dataProvider.Projects, dataProvider.Engines);
|
||||
|
||||
//textBox1.Bind(a => a.Name, model, a => a.SelectProject.Name);
|
||||
UpdateComboBoxProject();
|
||||
UpdateComboBoxEngine();
|
||||
|
||||
textBox1.Bind(a => a.Text, model, a => a.SelectProject.Name);
|
||||
textBoxPath.Bind(a => a.Text, model, a => a.SelectProject.Path);
|
||||
textBoxArgs.Bind(a => a.Text, model, a => a.SelectProject.Args);
|
||||
|
||||
comboBox_Mod.Bind(a => a.SelectedIndex, model, a => a.SelectProjectIndex);
|
||||
comboBoxEngine.Bind(a => a.SelectedIndex, model, a => a.SelectEngineIndex);
|
||||
|
||||
//model.PropertyChanged += Model_PropertyChanged;
|
||||
|
||||
UpdateComboBoxEngine();
|
||||
|
||||
//comboBox_Mod.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
|
||||
|
||||
UpdateComboBoxEngine();
|
||||
}
|
||||
|
||||
private void UpdateComboBoxProject() {
|
||||
comboBox_Mod.Items.Clear();
|
||||
comboBox_Mod.Items.AddRange(model.Projects);
|
||||
|
||||
comboBox_Mod.SelectedIndex = model.SelectProjectIndex;
|
||||
}
|
||||
|
||||
private void UpdateComboBoxEngine() {
|
||||
comboBoxEngine.Items.Clear();
|
||||
comboBoxEngine.Items.AddRange(model.Engines);
|
||||
|
||||
comboBox_Mod.SelectedIndex = model.SelectEngineIndex;
|
||||
}
|
||||
|
||||
private void FormEditProfile_Load(object sender, EventArgs e) {
|
||||
@ -44,5 +80,58 @@ namespace UniversalValveToolbox {
|
||||
textBoxPath.Text = folderpath;
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBoxEngine_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
model.SelectProject.Engine = ((EngineDtoModel)comboBoxEngine.SelectedItem).Appid;
|
||||
}
|
||||
|
||||
private void comboBox_Mod_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
model.SelectProjectIndex = comboBox_Mod.SelectedIndex;
|
||||
}
|
||||
|
||||
private void Remove() {
|
||||
var newProjectList = new List<ProjectDtoModel>(model.Projects);
|
||||
newProjectList.RemoveAt(model.SelectProjectIndex);
|
||||
|
||||
model.Projects = newProjectList.ToArray();
|
||||
|
||||
UpdateComboBoxProject();
|
||||
}
|
||||
|
||||
private void New() {
|
||||
var newProject = new ProjectDtoModel();
|
||||
newProject.Name = "<new project>";
|
||||
|
||||
var newProjectList = new List<ProjectDtoModel>(model.Projects);
|
||||
newProjectList.Insert(0, newProject);
|
||||
|
||||
model.Projects = newProjectList.ToArray();
|
||||
|
||||
UpdateComboBoxProject();
|
||||
}
|
||||
|
||||
private void Save() {
|
||||
var selectProject = model.SelectProject;
|
||||
|
||||
JsonFileUtil.SaveValues(DataProvider.ProjectsPath, "json", model.Projects.ToList());
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e) {
|
||||
Save();
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonApply_Click(object sender, EventArgs e) {
|
||||
Save();
|
||||
}
|
||||
|
||||
private void buttonNew_Click(object sender, EventArgs e) {
|
||||
New();
|
||||
}
|
||||
|
||||
private void buttonRemove_Click(object sender, EventArgs e) {
|
||||
Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@
|
||||
<Reference Include="WindowsFormsIntegration" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Model\ViewModel\FormAddonViewModel.cs" />
|
||||
<Compile Include="Model\ViewModel\FormProjectViewModel.cs" />
|
||||
<Compile Include="Model\ViewModel\SteamDataViewModel.cs" />
|
||||
<Compile Include="Properties\translations\LangDict.Designer.cs">
|
||||
|
@ -12,6 +12,30 @@ namespace UniversalValveToolbox.Utils {
|
||||
|
||||
public static T[] ReadValues<T>(string directoryPath) => Directory.GetFiles(directoryPath, "*").Select(path => ReadValue<T>(path)).ToArray();
|
||||
|
||||
public static List<T> ReadListValues<T>(string directoryPath) => new List<T>(ReadValues<T>(directoryPath));
|
||||
|
||||
public static void WriteValue<T>(string path, T value) => File.WriteAllText(path, JsonConvert.SerializeObject(value, Formatting.Indented));
|
||||
|
||||
public static void SaveValues<T>(string folderPath, string fileExtension, List<T> values) {
|
||||
DirectoryInfo di = new DirectoryInfo(folderPath);
|
||||
|
||||
foreach (FileInfo file in di.GetFiles()) {
|
||||
file.Delete();
|
||||
}
|
||||
foreach (DirectoryInfo dir in di.GetDirectories()) {
|
||||
dir.Delete(true);
|
||||
}
|
||||
|
||||
foreach (var item in values) {
|
||||
StringBuilder fileName = new StringBuilder(item.ToString().ToLower());
|
||||
foreach (char c in System.IO.Path.GetInvalidFileNameChars()) {
|
||||
fileName = fileName.Replace(c, '_');
|
||||
}
|
||||
|
||||
var path = Path.Combine(folderPath, $"{fileName}.{fileExtension}");
|
||||
|
||||
File.WriteAllText(path, JsonConvert.SerializeObject(item, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,5 +2,5 @@
|
||||
"engine": 243730, //linked avalible engine by id
|
||||
"path": "C:\\Test", //path for export to users's env
|
||||
"name": "Test Project", //name for launcher
|
||||
"args": "" //run args
|
||||
"args": "-test" //run args
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user