mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
Finish name changer UI
This commit is contained in:
parent
22abdea752
commit
1f87bfe6c5
2 changed files with 90 additions and 1 deletions
|
@ -105,6 +105,7 @@ namespace ShiftOS.WinForms.Applications {
|
|||
this.btnclose.TabIndex = 0;
|
||||
this.btnclose.Text = "Close";
|
||||
this.btnclose.UseVisualStyleBackColor = true;
|
||||
this.btnclose.Click += new System.EventHandler(this.btnclose_Click);
|
||||
//
|
||||
// btnloaddefault
|
||||
//
|
||||
|
@ -116,6 +117,7 @@ namespace ShiftOS.WinForms.Applications {
|
|||
this.btnloaddefault.TabIndex = 1;
|
||||
this.btnloaddefault.Text = "Load default";
|
||||
this.btnloaddefault.UseVisualStyleBackColor = true;
|
||||
this.btnloaddefault.Click += new System.EventHandler(this.btnloaddefault_Click);
|
||||
//
|
||||
// btnimport
|
||||
//
|
||||
|
@ -127,6 +129,7 @@ namespace ShiftOS.WinForms.Applications {
|
|||
this.btnimport.TabIndex = 2;
|
||||
this.btnimport.Text = "Import";
|
||||
this.btnimport.UseVisualStyleBackColor = true;
|
||||
this.btnimport.Click += new System.EventHandler(this.btnimport_Click);
|
||||
//
|
||||
// btnexport
|
||||
//
|
||||
|
@ -138,6 +141,7 @@ namespace ShiftOS.WinForms.Applications {
|
|||
this.btnexport.TabIndex = 3;
|
||||
this.btnexport.Text = "Export";
|
||||
this.btnexport.UseVisualStyleBackColor = true;
|
||||
this.btnexport.Click += new System.EventHandler(this.btnexport_Click);
|
||||
//
|
||||
// btnapply
|
||||
//
|
||||
|
@ -149,6 +153,7 @@ namespace ShiftOS.WinForms.Applications {
|
|||
this.btnapply.TabIndex = 4;
|
||||
this.btnapply.Text = "Apply";
|
||||
this.btnapply.UseVisualStyleBackColor = true;
|
||||
this.btnapply.Click += new System.EventHandler(this.btnapply_Click);
|
||||
//
|
||||
// NameChanger
|
||||
//
|
||||
|
|
|
@ -31,7 +31,10 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
using ShiftOS.Engine;
|
||||
using ShiftOS.Objects.ShiftFS;
|
||||
using ShiftOS.WinForms.Tools;
|
||||
|
||||
namespace ShiftOS.WinForms.Applications {
|
||||
|
||||
|
@ -46,8 +49,49 @@ namespace ShiftOS.WinForms.Applications {
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
private Dictionary<string, string> names = new Dictionary<string, string>();
|
||||
|
||||
public void OnLoad()
|
||||
{
|
||||
names = JsonConvert.DeserializeObject<Dictionary<string, string>>(JsonConvert.SerializeObject(NameChangerBackend.GetCurrent()));
|
||||
SetupUI();
|
||||
}
|
||||
|
||||
public void SetupUI()
|
||||
{
|
||||
flnames.Controls.Clear();
|
||||
foreach(var name in names)
|
||||
{
|
||||
var pnl = new Panel();
|
||||
var lbl = new Label();
|
||||
var txt = new TextBox();
|
||||
pnl.Controls.Add(lbl);
|
||||
lbl.Show();
|
||||
pnl.Controls.Add(txt);
|
||||
txt.Show();
|
||||
|
||||
ControlManager.SetupControls(pnl);
|
||||
|
||||
pnl.Width = flnames.Width - 10;
|
||||
pnl.Height = 50;
|
||||
lbl.Left = 10;
|
||||
lbl.Width = (pnl.Width / 4) - 10;
|
||||
lbl.Text = name.Key;
|
||||
lbl.Top = (pnl.Height - lbl.Height) / 2;
|
||||
lbl.TextAlign = ContentAlignment.MiddleLeft;
|
||||
|
||||
txt.Text = name.Value;
|
||||
|
||||
txt.TextChanged += (o, a) =>
|
||||
{
|
||||
names[name.Key] = txt.Text;
|
||||
};
|
||||
txt.Width = pnl.Width - (pnl.Width / 4) - 20;
|
||||
txt.Left = lbl.Width + 20;
|
||||
txt.Top = (pnl.Height - txt.Height) / 2;
|
||||
flnames.Controls.Add(pnl);
|
||||
pnl.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSkinLoad()
|
||||
|
@ -67,7 +111,40 @@ namespace ShiftOS.WinForms.Applications {
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void btnclose_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnloaddefault_Click(object sender, EventArgs e)
|
||||
{
|
||||
names = NameChangerBackend.GetDefault();
|
||||
SetupUI();
|
||||
}
|
||||
|
||||
private void btnimport_Click(object sender, EventArgs e)
|
||||
{
|
||||
FileSkimmerBackend.GetFile(new[] { ".nme" }, FileOpenerStyle.Open, new Action<string>((path) =>
|
||||
{
|
||||
names = JsonConvert.DeserializeObject<Dictionary<string, string>>(Utils.ReadAllText(path));
|
||||
}));
|
||||
}
|
||||
|
||||
private void btnexport_Click(object sender, EventArgs e)
|
||||
{
|
||||
FileSkimmerBackend.GetFile(new[] { ".nme" }, FileOpenerStyle.Save, new Action<string>((path) =>
|
||||
{
|
||||
Utils.WriteAllText(path, JsonConvert.SerializeObject(names));
|
||||
}));
|
||||
}
|
||||
|
||||
private void btnapply_Click(object sender, EventArgs e)
|
||||
{
|
||||
SkinEngine.LoadedSkin.AppNames = names;
|
||||
Utils.WriteAllText(Paths.GetPath("skin.json"), SkinEngine.LoadedSkin.ToString());
|
||||
SkinEngine.LoadSkin();
|
||||
}
|
||||
}
|
||||
|
||||
public static class NameChangerBackend
|
||||
|
@ -92,6 +169,13 @@ namespace ShiftOS.WinForms.Applications {
|
|||
|
||||
if (SkinEngine.LoadedSkin.AppNames == null)
|
||||
SkinEngine.LoadedSkin.AppNames = GetDefault();
|
||||
|
||||
foreach(var def in GetDefault())
|
||||
{
|
||||
if (!SkinEngine.LoadedSkin.AppNames.ContainsKey(def.Key))
|
||||
SkinEngine.LoadedSkin.AppNames.Add(def.Key, def.Value);
|
||||
}
|
||||
|
||||
return SkinEngine.LoadedSkin.AppNames;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue