From e7fe4aa60a00c6d25b842d8b1116fdeb80cd084f Mon Sep 17 00:00:00 2001 From: iSmokeDrow Date: Sun, 22 Sep 2019 10:22:26 -0500 Subject: [PATCH] Implementation of Localization and new Logs.Manager/GUI.LogsViewer --- GUI/BitFlag.cs | 10 +- GUI/DataRebuild.cs | 8 +- GUI/Input.cs | 11 +- GUI/ListInput.Designer.cs | 34 +- GUI/ListInput.cs | 12 +- GUI/ListSelect.cs | 9 +- GUI/LogViewer.Designer.cs | 80 ++-- GUI/LogViewer.cs | 79 +++- GUI/Main.Designer.cs | 31 +- GUI/Main.cs | 46 +- GUI/Main.resx | 290 +----------- GUI/MessageListBox.Designer.cs | 16 +- GUI/MessageListBox.cs | 11 +- Grimoire.csproj | 23 +- Grimoire.opt | 13 +- Grimoire.sln | 6 +- Localization/Enums/SenderType.cs | 14 + Localization/Structures/ControlConfig.cs | 30 ++ Localization/Structures/FontConfig.cs | 15 + Localization/Structures/Locale.cs | 27 ++ Localization/Structures/Text.cs | 16 + Localization/en-US.xml | 235 ++++++++++ Logs/Enums.cs | 21 +- Logs/Manager.cs | 58 +-- Properties/AssemblyInfo.cs | 4 +- Tabs/Styles/Data.cs | 26 +- Tabs/Styles/Data.resx | 3 + Tabs/Styles/Hasher.cs | 23 +- Tabs/Styles/RDB.Designer.cs | 16 +- Tabs/Styles/RDB.cs | 21 +- Utilities/XmlManager.cs | 549 +++++++++++++++++++++++ packages.config | 4 + strings.Designer.cs | 531 ---------------------- strings.resx | 328 -------------- 34 files changed, 1212 insertions(+), 1388 deletions(-) create mode 100644 Localization/Enums/SenderType.cs create mode 100644 Localization/Structures/ControlConfig.cs create mode 100644 Localization/Structures/FontConfig.cs create mode 100644 Localization/Structures/Locale.cs create mode 100644 Localization/Structures/Text.cs create mode 100644 Localization/en-US.xml create mode 100644 Utilities/XmlManager.cs create mode 100644 packages.config delete mode 100644 strings.Designer.cs delete mode 100644 strings.resx diff --git a/GUI/BitFlag.cs b/GUI/BitFlag.cs index ec6da2a..45aaa6f 100644 --- a/GUI/BitFlag.cs +++ b/GUI/BitFlag.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Grimoire.Utilities; namespace Grimoire.GUI { @@ -21,6 +22,7 @@ public BitFlag() InitializeComponent(); lManager = Logs.Manager.Instance; + localize(); } public BitFlag(int vector) @@ -29,6 +31,7 @@ public BitFlag(int vector) lManager = Logs.Manager.Instance; defaultFlag = vector; + localize(); } #endregion @@ -58,7 +61,8 @@ public int Flag } set { flag = value; } } - + + XmlManager xMan = XmlManager.Instance; #endregion @@ -226,9 +230,9 @@ private void clear_on_list_change_CheckedChanged(object sender, EventArgs e) Utilities.OPT.Update("flag.clear_on_list_change", Convert.ToInt32(clear_on_change_chkBx.Checked).ToString()); } - void load_strings() + void localize() { - clear_on_change_chkBx.Text = strings.clear_on_change; + xMan.Localize(this, Localization.Enums.SenderType.GUI); } } } diff --git a/GUI/DataRebuild.cs b/GUI/DataRebuild.cs index 91a2d88..f131d58 100644 --- a/GUI/DataRebuild.cs +++ b/GUI/DataRebuild.cs @@ -11,6 +11,7 @@ using System.Windows.Forms.DataVisualization.Charting; using System.Windows.Forms; using DataCore; +using Grimoire.Utilities; namespace Grimoire.GUI { @@ -19,6 +20,7 @@ public partial class DataRebuild : Form Tabs.Manager tManager = Tabs.Manager.Instance; Logs.Manager lManager = Logs.Manager.Instance; DataCore.Core core = null; + XmlManager xMan = XmlManager.Instance; public DataRebuild() { @@ -27,7 +29,7 @@ public DataRebuild() hook_core_events(); dataChart.Series.Add(new Series() { Name = "All Data", ChartType = SeriesChartType.Pie }); dataList.Items[0].Selected = true; - load_strings(); + localize(); } private void hook_core_events() @@ -183,9 +185,9 @@ private void cleanup(int dataId) } - public void load_strings() + public void localize() { - rebuildBtn.Text = strings.rebuildBtn; + xMan.Localize(this, Localization.Enums.SenderType.GUI); } } } diff --git a/GUI/Input.cs b/GUI/Input.cs index 4da2339..b68725e 100644 --- a/GUI/Input.cs +++ b/GUI/Input.cs @@ -1,17 +1,20 @@ using System; using System.Windows.Forms; +using Grimoire.Utilities; namespace Grimoire.GUI { public partial class InputBox : Form { + XmlManager xMan = XmlManager.Instance; + public InputBox(string description, string defaultText) { InitializeComponent(); Text = description; input.Text = defaultText; DialogResult = DialogResult.Cancel; - load_strings(); + localize(); } public InputBox(string description, bool resizable) @@ -21,7 +24,7 @@ public InputBox(string description, bool resizable) this.FormBorderStyle = (resizable) ? FormBorderStyle.SizableToolWindow : FormBorderStyle.FixedToolWindow; input.Multiline = resizable; DialogResult = DialogResult.Cancel; - load_strings(); + localize(); } public string Value { get { return (input.Text.Length > 0) ? input.Text : null; } set { input.Text = value; } } @@ -37,9 +40,9 @@ private void InputBox_Shown(object sender, EventArgs e) input.Focus(); } - private void load_strings() + private void localize() { - okBtn.Text = strings.okBtn; + xMan.Localize(this, Localization.Enums.SenderType.GUI); } } } diff --git a/GUI/ListInput.Designer.cs b/GUI/ListInput.Designer.cs index a22ad94..7db1770 100644 --- a/GUI/ListInput.Designer.cs +++ b/GUI/ListInput.Designer.cs @@ -31,7 +31,7 @@ private void InitializeComponent() this.list = new System.Windows.Forms.ListBox(); this.descLbl = new System.Windows.Forms.Label(); this.input = new System.Windows.Forms.TextBox(); - this.ok_btn = new System.Windows.Forms.Button(); + this.okBtn = new System.Windows.Forms.Button(); this.inputLbl = new System.Windows.Forms.Label(); this.SuspendLayout(); // @@ -42,7 +42,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.list.FormattingEnabled = true; this.list.Location = new System.Drawing.Point(9, 23); - this.list.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.list.Margin = new System.Windows.Forms.Padding(2); this.list.Name = "list"; this.list.Size = new System.Drawing.Size(186, 212); this.list.TabIndex = 0; @@ -62,22 +62,22 @@ private void InitializeComponent() this.input.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.input.Location = new System.Drawing.Point(9, 254); - this.input.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.input.Margin = new System.Windows.Forms.Padding(2); this.input.Name = "input"; this.input.Size = new System.Drawing.Size(134, 20); this.input.TabIndex = 2; // - // ok_btn + // okBtn // - this.ok_btn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.ok_btn.Location = new System.Drawing.Point(146, 249); - this.ok_btn.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); - this.ok_btn.Name = "ok_btn"; - this.ok_btn.Size = new System.Drawing.Size(45, 23); - this.ok_btn.TabIndex = 3; - this.ok_btn.Text = "OK"; - this.ok_btn.UseVisualStyleBackColor = true; - this.ok_btn.Click += new System.EventHandler(this.ok_btn_Click); + this.okBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okBtn.Location = new System.Drawing.Point(146, 252); + this.okBtn.Margin = new System.Windows.Forms.Padding(2); + this.okBtn.Name = "okBtn"; + this.okBtn.Size = new System.Drawing.Size(45, 23); + this.okBtn.TabIndex = 3; + this.okBtn.Text = "OK"; + this.okBtn.UseVisualStyleBackColor = true; + this.okBtn.Click += new System.EventHandler(this.ok_btn_Click); // // inputLbl // @@ -92,17 +92,17 @@ private void InitializeComponent() // // ListInput // - this.AcceptButton = this.ok_btn; + this.AcceptButton = this.okBtn; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(203, 282); this.Controls.Add(this.inputLbl); - this.Controls.Add(this.ok_btn); + this.Controls.Add(this.okBtn); this.Controls.Add(this.input); this.Controls.Add(this.descLbl); this.Controls.Add(this.list); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; - this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "ListInput"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; @@ -117,7 +117,7 @@ private void InitializeComponent() private System.Windows.Forms.ListBox list; private System.Windows.Forms.Label descLbl; private System.Windows.Forms.TextBox input; - private System.Windows.Forms.Button ok_btn; + private System.Windows.Forms.Button okBtn; private System.Windows.Forms.Label inputLbl; } } \ No newline at end of file diff --git a/GUI/ListInput.cs b/GUI/ListInput.cs index 4012674..0f29d1b 100644 --- a/GUI/ListInput.cs +++ b/GUI/ListInput.cs @@ -8,17 +8,20 @@ using System.Threading.Tasks; using System.Windows.Forms; using Daedalus.Structures; +using Grimoire.Utilities; namespace Grimoire.GUI { public partial class ListInput : Form { + XmlManager xMan = XmlManager.Instance; + Cell[] cells = null; public ListInput() { InitializeComponent(); - load_strings(); + localize(); } public ListInput(string description, Cell[] cells) @@ -30,7 +33,7 @@ public ListInput(string description, Cell[] cells) populateList(); - load_strings(); + localize(); } public ListInput(string description, string[] selections) @@ -71,10 +74,9 @@ private void ok_btn_Click(object sender, EventArgs e) Hide(); } - private void load_strings() + private void localize() { - descLbl.Text = strings.descLbl; - inputLbl.Text = strings.inputLbl; + xMan.Localize(this, Localization.Enums.SenderType.GUI); } private void ListInput_Shown(object sender, EventArgs e) diff --git a/GUI/ListSelect.cs b/GUI/ListSelect.cs index e9d99a8..db2e4e7 100644 --- a/GUI/ListSelect.cs +++ b/GUI/ListSelect.cs @@ -2,17 +2,20 @@ using System.Collections.Generic; using DataCore.Structures; using System.Windows.Forms; +using Grimoire.Utilities; namespace Grimoire.GUI { public partial class ListSelect : Form { + XmlManager xMan = XmlManager.Instance; + public ListSelect(string title, List selections) { this.Text = title; InitializeComponent(); populateList(selections); - load_strings(); + localize(); } public string SelectedText @@ -40,9 +43,9 @@ private void list_DoubleClick(object sender, EventArgs e) Close(); } - private void load_strings() + private void localize() { - okBtn.Text = strings.okBtn; + xMan.Localize(this, Localization.Enums.SenderType.GUI); } } } diff --git a/GUI/LogViewer.Designer.cs b/GUI/LogViewer.Designer.cs index ca9a6b7..51cf93f 100644 --- a/GUI/LogViewer.Designer.cs +++ b/GUI/LogViewer.Designer.cs @@ -28,67 +28,67 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.logList = new System.Windows.Forms.ListView(); - this.time = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.sender = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.type = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.msg = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.logView = new BrightIdeasSoftware.DataListView(); + this.displayType_lst = new System.Windows.Forms.ComboBox(); + this.displayType = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.logView)).BeginInit(); this.SuspendLayout(); // - // logList + // logView // - this.logList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.sender, - this.type, - this.time, - this.msg}); - this.logList.Dock = System.Windows.Forms.DockStyle.Fill; - this.logList.Location = new System.Drawing.Point(0, 0); - this.logList.Name = "logList"; - this.logList.Size = new System.Drawing.Size(800, 421); - this.logList.TabIndex = 2; - this.logList.UseCompatibleStateImageBehavior = false; - this.logList.View = System.Windows.Forms.View.Details; + this.logView.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.logView.CellEditUseWholeCell = false; + this.logView.Cursor = System.Windows.Forms.Cursors.Default; + this.logView.DataSource = null; + this.logView.Location = new System.Drawing.Point(0, 34); + this.logView.Name = "logView"; + this.logView.Size = new System.Drawing.Size(800, 387); + this.logView.TabIndex = 0; + this.logView.UseCompatibleStateImageBehavior = false; + this.logView.View = System.Windows.Forms.View.Details; // - // time + // displayType_lst // - this.time.Text = "Time"; - this.time.Width = 100; + this.displayType_lst.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.displayType_lst.FormattingEnabled = true; + this.displayType_lst.Location = new System.Drawing.Point(62, 7); + this.displayType_lst.Name = "displayType_lst"; + this.displayType_lst.Size = new System.Drawing.Size(121, 21); + this.displayType_lst.TabIndex = 1; + this.displayType_lst.SelectedIndexChanged += new System.EventHandler(this.displayType_lst_SelectedIndexChanged); // - // sender + // displayType // - this.sender.Text = "Sender"; - this.sender.Width = 80; - // - // type - // - this.type.Text = "Type"; - this.type.Width = 80; - // - // msg - // - this.msg.Text = "Message"; - this.msg.Width = 510; + this.displayType.AutoSize = true; + this.displayType.Location = new System.Drawing.Point(12, 10); + this.displayType.Name = "displayType"; + this.displayType.Size = new System.Drawing.Size(44, 13); + this.displayType.TabIndex = 2; + this.displayType.Text = "Display:"; // // LogViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 421); - this.Controls.Add(this.logList); + this.Controls.Add(this.displayType); + this.Controls.Add(this.displayType_lst); + this.Controls.Add(this.logView); this.Name = "LogViewer"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Log Viewer"; + ((System.ComponentModel.ISupportInitialize)(this.logView)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.ListView logList; - private System.Windows.Forms.ColumnHeader sender; - private System.Windows.Forms.ColumnHeader type; - private System.Windows.Forms.ColumnHeader time; - private System.Windows.Forms.ColumnHeader msg; + private BrightIdeasSoftware.DataListView logView; + private System.Windows.Forms.ComboBox displayType_lst; + private System.Windows.Forms.Label displayType; } } \ No newline at end of file diff --git a/GUI/LogViewer.cs b/GUI/LogViewer.cs index 5e4b439..ffe1f66 100644 --- a/GUI/LogViewer.cs +++ b/GUI/LogViewer.cs @@ -7,35 +7,94 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Linq; using Grimoire.Logs; using Grimoire.Structures; +using Grimoire.Utilities; +using System.Threading; +using System.Collections.ObjectModel; +using BrightIdeasSoftware; namespace Grimoire.GUI { public partial class LogViewer : Form { - Manager lManager = Manager.Instance; + int interval = 0; + + Logs.Manager lManager; + + List filteredEntries = new List(); - public LogViewer() + public bool ViewDisposed + { + get + { + return logView.IsDisposed; + } + } + + public LogViewer(Logs.Manager lManager) { InitializeComponent(); - parseLogs(); + this.lManager = lManager; + + interval = OPT.GetInt("log.display.refresh"); + + configureViewer(); + + generate_type_list(); } - private void parseLogs() + private void generate_type_list() { + displayType_lst.DataSource = Enum.GetValues(typeof(DisplayLevel)); + displayType_lst.SelectedIndex = 0; + } + public void Refresh() + { + logView.SetObjects(lManager.Entries); + } + + private void configureViewer() + { + logView.RowHeight = 50; + logView.Columns.AddRange(new OLVColumn[] + { + new OLVColumn("Sender", "Sender") { Width = 100 }, + new OLVColumn("Level", "Level") { Width = 100 }, + new OLVColumn("DateTime", "DateTime") { Width = 100 }, + new OLVColumn("Message", "Message") { FillsFreeSpace = true, WordWrap=true } + }); + } - int len = lManager.Entries.Count; - for (int i = 0; i < len; i++) + private void displayType_lst_SelectedIndexChanged(object sender, EventArgs e) + { + if (displayType_lst.SelectedIndex != -1) { - Log log = lManager.Entries[i]; + DisplayLevel type = (DisplayLevel)displayType_lst.SelectedIndex; - logList.Items.Add(new ListViewItem() + switch (type) { - Name = string.Format("{0}_{1}", i.ToString("D2"), log.Level) - }); + case DisplayLevel.ALL: + logView.SetObjects(lManager.Entries); + break; + + case DisplayLevel.DEBUG: + logView.SetObjects(lManager.Entries.Where(l => l.Level == Level.DEBUG)); + break; + + case DisplayLevel.NOTICE: + logView.SetObjects(lManager.Entries.Where(l => l.Level == Level.NOTICE)); + break; + + case DisplayLevel.ERRORS: + logView.SetObjects(lManager.Entries.Where(l => l.Level == Level.ERROR || + l.Level == Level.HASHER_ERROR || + l.Level == Level.SQL_ERROR)); + break; + } } } } diff --git a/GUI/Main.Designer.cs b/GUI/Main.Designer.cs index e080208..04f5065 100644 --- a/GUI/Main.Designer.cs +++ b/GUI/Main.Designer.cs @@ -38,12 +38,12 @@ private void InitializeComponent() this.new_list = new System.Windows.Forms.ComboBox(); this.settingsBtn = new System.Windows.Forms.Button(); this.aboutLbl = new System.Windows.Forms.Label(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.ms = new System.Windows.Forms.MenuStrip(); this.ts_utilities = new System.Windows.Forms.ToolStripMenuItem(); this.ts_bitflag_editor = new System.Windows.Forms.ToolStripMenuItem(); this.ts_log_viewer = new System.Windows.Forms.ToolStripMenuItem(); this.tabs_cMenu.SuspendLayout(); - this.menuStrip1.SuspendLayout(); + this.ms.SuspendLayout(); this.SuspendLayout(); // // tabs @@ -132,16 +132,16 @@ private void InitializeComponent() this.aboutLbl.Text = "About"; this.aboutLbl.Click += new System.EventHandler(this.aboutLbl_Click); // - // menuStrip1 + // ms // - this.menuStrip1.Dock = System.Windows.Forms.DockStyle.None; - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ms.Dock = System.Windows.Forms.DockStyle.None; + this.ms.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.ts_utilities}); - this.menuStrip1.Location = new System.Drawing.Point(141, 5); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(66, 24); - this.menuStrip1.TabIndex = 6; - this.menuStrip1.Text = "menuStrip1"; + this.ms.Location = new System.Drawing.Point(141, 5); + this.ms.Name = "ms"; + this.ms.Size = new System.Drawing.Size(186, 24); + this.ms.TabIndex = 6; + this.ms.Text = "menuStrip1"; // // ts_utilities // @@ -161,7 +161,6 @@ private void InitializeComponent() // // ts_log_viewer // - this.ts_log_viewer.Enabled = false; this.ts_log_viewer.Name = "ts_log_viewer"; this.ts_log_viewer.Size = new System.Drawing.Size(180, 22); this.ts_log_viewer.Text = "Log Viewer"; @@ -173,7 +172,7 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(808, 521); - this.Controls.Add(this.menuStrip1); + this.Controls.Add(this.ms); this.Controls.Add(this.aboutLbl); this.Controls.Add(this.settingsBtn); this.Controls.Add(this.new_list); @@ -181,7 +180,7 @@ private void InitializeComponent() this.Controls.Add(this.tabs); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.KeyPreview = true; - this.MainMenuStrip = this.menuStrip1; + this.MainMenuStrip = this.ms; this.Margin = new System.Windows.Forms.Padding(2); this.MinimumSize = new System.Drawing.Size(794, 558); this.Name = "Main"; @@ -192,8 +191,8 @@ private void InitializeComponent() this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Main_DragEnter); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Main_KeyDown); this.tabs_cMenu.ResumeLayout(false); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); + this.ms.ResumeLayout(false); + this.ms.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -208,7 +207,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem tabs_cMenu_close; private System.Windows.Forms.Button settingsBtn; private System.Windows.Forms.Label aboutLbl; - private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.MenuStrip ms; private System.Windows.Forms.ToolStripMenuItem ts_utilities; private System.Windows.Forms.ToolStripMenuItem ts_bitflag_editor; private System.Windows.Forms.ToolStripMenuItem ts_log_viewer; diff --git a/GUI/Main.cs b/GUI/Main.cs index 1448110..7b2ebd5 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -6,6 +6,7 @@ using System.Resources; using System.Globalization; using System.Threading; +using Grimoire.Utilities; namespace Grimoire.GUI { @@ -13,6 +14,7 @@ public partial class Main : Form { readonly Tabs.Manager tManager; readonly Logs.Manager lManager; + readonly XmlManager xMan; public static Main Instance; public Main() @@ -20,25 +22,17 @@ public Main() InitializeComponent(); Instance = this; tManager = Tabs.Manager.Instance; - lManager = Logs.Manager.Instance; + lManager = Logs.Manager.Instance; Utilities.OPT.Load(); + xMan = XmlManager.Instance; check_first_start(); generate_new_list(); - load_strings(); + localize(); } - private void load_strings() + private void localize() { - // TODO: Move me I don't belong here - string lang = Utilities.OPT.GetString("lang"); - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(string.Format("{0}-{1}", lang, lang.ToUpperInvariant())); - - newLbl.Text = strings.newLbl; - ts_utilities.Text = strings.ts_utilities; - ts_bitflag_editor.Text = strings.ts_bitflag_editor; - ts_log_viewer.Text = strings.ts_log_viewer; - settingsBtn.Text = strings.settingsBtn; - aboutLbl.Text = strings.aboutLbl; + xMan.Localize(this, Localization.Enums.SenderType.GUI); } private void check_first_start() @@ -147,6 +141,8 @@ private void Main_Shown(object sender, EventArgs e) private void Main_FormClosing(object sender, FormClosingEventArgs e) { lManager.Enter(Logs.Sender.MAIN, Logs.Level.DEBUG, "Closing down..."); + + lManager.Save(); Utilities.OPT.Save(); } @@ -215,6 +211,27 @@ private void Main_KeyDown(object sender, KeyEventArgs e) if (tManager.Style == Style.DATA) tManager.DataTab.TS_File_Rebuild_Click(this, EventArgs.Empty); } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.L) + { + xMan.RefreshLocale(); + + xMan.Localize(this, Localization.Enums.SenderType.GUI); + + switch (tManager.Style) + { + case Style.DATA: + tManager.DataTab.Localize(); + break; + + case Style.RDB: + tManager.RDBTab.Localize(); + break; + + case Style.HASHER: + tManager.HashTab.Localize(); + break; + } + } } private void aboutLbl_Click(object sender, EventArgs e) @@ -238,8 +255,7 @@ private void ts_bitflag_editor_Click(object sender, EventArgs e) private void ts_log_viewer_Click(object sender, EventArgs e) { - using (LogViewer viewer = new LogViewer()) - viewer.ShowDialog(this); + lManager.ShowViewer(); } } } \ No newline at end of file diff --git a/GUI/Main.resx b/GUI/Main.resx index d7d058b..e76ca96 100644 --- a/GUI/Main.resx +++ b/GUI/Main.resx @@ -117,198 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 134, 17 + - - 794, 558 - - - 5 - - - newLbl - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 103, 22 - - - - 6 - - - - Top, Bottom, Left, Right - - - About - - - 9, 10 - - - 144, 22 - - - tabs_cMenu_close - - - $this - - - $this - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Flat - - - 2, 2, 2, 2 - - - 1 - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabs_cMenu_clear - - - Log Viewer - - - $this - - - 104, 48 - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 788, 472 - - - 35, 13 - - - 92, 21 - - - New: - - - 6, 13 - - - 103, 22 - - - 2, 2, 2, 2 - - - 144, 22 - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - 2, 2, 2, 2 - - - 3 - - - System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 1 - - - RDB - - - False - - - 4 - - - menuStrip1 - - - 2 - - - tabs_cMenu - - - 5 - - - settingsBtn - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 32, 13 - - - ts_bitflag_editor - - - 762, 505 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Top, Right - - - System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Utilities - - - 2, 2, 2, 2 - - - BitFlag Editor - - - $this - - - Close - - - Microsoft Sans Serif, 7.8pt, style=Underline - - - tabs - - - 58, 20 - - - Clear - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 9, 32 - AAABAAQAEBAAAAEAIABoBAAARgAAACAgAAABACAAqBAAAK4EAAAwMAAAAQAgAKglAABWFQAAAAAAAAEA @@ -2621,97 +2436,4 @@ r/7wr9xe9d9i/N+4oMJgd0uTSwAAAABJRU5ErkJggg== - - 2 - - - Bottom, Right - - - True - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 2, 0, 2, 0 - - - $this - - - Grimoire - - - 740, 5 - - - None - - - menuStrip1 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 66, 24 - - - ts_utilities - - - 4 - - - 3 - - - new_list - - - $this - - - 141, 5 - - - Settings - - - HASHER - - - 43, 7 - - - 56, 23 - - - 2, 0, 2, 0 - - - 808, 521 - - - Main - - - aboutLbl - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 6 - - - ts_log_viewer - - - 134, 17 - - - 17, 17 - \ No newline at end of file diff --git a/GUI/MessageListBox.Designer.cs b/GUI/MessageListBox.Designer.cs index 84754be..3d7a724 100644 --- a/GUI/MessageListBox.Designer.cs +++ b/GUI/MessageListBox.Designer.cs @@ -44,7 +44,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.list.FormattingEnabled = true; this.list.Location = new System.Drawing.Point(9, 88); - this.list.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.list.Margin = new System.Windows.Forms.Padding(2); this.list.Name = "list"; this.list.SelectionMode = System.Windows.Forms.SelectionMode.None; this.list.Size = new System.Drawing.Size(368, 199); @@ -54,7 +54,7 @@ private void InitializeComponent() // this.yesBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.yesBtn.Location = new System.Drawing.Point(286, 299); - this.yesBtn.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.yesBtn.Margin = new System.Windows.Forms.Padding(2); this.yesBtn.Name = "yesBtn"; this.yesBtn.Size = new System.Drawing.Size(43, 25); this.yesBtn.TabIndex = 1; @@ -67,7 +67,7 @@ private void InitializeComponent() this.noBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.noBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.noBtn.Location = new System.Drawing.Point(333, 299); - this.noBtn.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.noBtn.Margin = new System.Windows.Forms.Padding(2); this.noBtn.Name = "noBtn"; this.noBtn.Size = new System.Drawing.Size(43, 25); this.noBtn.TabIndex = 2; @@ -78,10 +78,10 @@ private void InitializeComponent() // msg_grpBx // this.msg_grpBx.Controls.Add(this.msg); - this.msg_grpBx.Location = new System.Drawing.Point(9, 2); - this.msg_grpBx.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.msg_grpBx.Location = new System.Drawing.Point(9, 3); + this.msg_grpBx.Margin = new System.Windows.Forms.Padding(2); this.msg_grpBx.Name = "msg_grpBx"; - this.msg_grpBx.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.msg_grpBx.Padding = new System.Windows.Forms.Padding(2); this.msg_grpBx.Size = new System.Drawing.Size(367, 81); this.msg_grpBx.TabIndex = 3; this.msg_grpBx.TabStop = false; @@ -91,7 +91,7 @@ private void InitializeComponent() // this.msg.BorderStyle = System.Windows.Forms.BorderStyle.None; this.msg.Location = new System.Drawing.Point(4, 17); - this.msg.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.msg.Margin = new System.Windows.Forms.Padding(2); this.msg.Multiline = true; this.msg.Name = "msg"; this.msg.ReadOnly = true; @@ -112,7 +112,7 @@ private void InitializeComponent() this.Controls.Add(this.list); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "MessageListBox"; this.msg_grpBx.ResumeLayout(false); this.msg_grpBx.PerformLayout(); diff --git a/GUI/MessageListBox.cs b/GUI/MessageListBox.cs index 0c11515..a749dce 100644 --- a/GUI/MessageListBox.cs +++ b/GUI/MessageListBox.cs @@ -8,18 +8,21 @@ using System.Threading.Tasks; using System.IO; using System.Windows.Forms; +using Grimoire.Utilities; namespace Grimoire.GUI { public partial class MessageListBox : Form { + XmlManager xMan = XmlManager.Instance; + public MessageListBox(string title, string msg, string[] filePaths) { InitializeComponent(); Text = title; this.msg.Text = msg; populateList(filePaths); - load_strings(); + localize(); } private void populateList(string[] filePaths) @@ -42,11 +45,9 @@ private void no_btn_Click(object sender, EventArgs e) this.Hide(); } - private void load_strings() + private void localize() { - msg_grpBx.Text = strings.msg_grpBx; - yesBtn.Text = strings.yesBtn; - noBtn.Text = strings.noBtn; + xMan.Localize(this, Localization.Enums.SenderType.GUI); } } } diff --git a/Grimoire.csproj b/Grimoire.csproj index b928e6d..c838869 100644 --- a/Grimoire.csproj +++ b/Grimoire.csproj @@ -70,6 +70,9 @@ ..\3rd Party\MoonSharp.Interpreter.dll + + packages\ObjectListView.Official.2.9.1\lib\net20\ObjectListView.dll + @@ -145,11 +148,11 @@ StructureEditor.cs - - True - True - strings.resx - + + + + + @@ -214,6 +217,7 @@ + BitFlag.cs @@ -263,10 +267,6 @@ Resources.resx True - - PublicResXFileCodeGenerator - strings.Designer.cs - Data.cs @@ -282,6 +282,7 @@ RDB.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -310,6 +311,10 @@ + + Always + Designer + diff --git a/Grimoire.opt b/Grimoire.opt index fe4f874..d4c7c13 100644 --- a/Grimoire.opt +++ b/Grimoire.opt @@ -1,5 +1,5 @@ tab.styles:RDB,DATA,HASHER -tab.default_style:RDB +tab.default_style:HASHER db.ip:(local) db.port:1433 db.world.name:Arcadia @@ -23,8 +23,13 @@ data.clear_on_create:0 hash.auto_clear:0 hash.auto_convert:0 hash.type:0 -log.level:3 +log.enabled:1 +log.write.type:ALL +log.display.type:ALL +log.display.refresh:1500 +log.exit.save:1 flag.directory:C:\Users\dying\Documents\GitHub\Grimoire\bin\Debug\Flags -flag.default._list:buff_flags_91 +flag.default_list:buff_flags_91 flag.clear_on_list_change:0 -lang:en \ No newline at end of file +locale:fr-FR +locale.directory:C:\Users\dying\Documents\GitHub\Grimoire\bin\Debug\Localization \ No newline at end of file diff --git a/Grimoire.sln b/Grimoire.sln index 79a80bc..29a6df9 100644 --- a/Grimoire.sln +++ b/Grimoire.sln @@ -12,9 +12,6 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Daedalus", "..\Daedalus\Daedalus.csproj", "{8591EF8A-CD35-494D-9CBA-0EFE0DF646FE}" EndProject Global - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -49,4 +46,7 @@ Global GlobalSection(Performance) = preSolution HasPerformanceSessions = true EndGlobalSection + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection EndGlobal diff --git a/Localization/Enums/SenderType.cs b/Localization/Enums/SenderType.cs new file mode 100644 index 0000000..6080a0f --- /dev/null +++ b/Localization/Enums/SenderType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Grimoire.Localization.Enums +{ + public enum SenderType + { + GUI = 0, + Tab = 1 + } +} diff --git a/Localization/Structures/ControlConfig.cs b/Localization/Structures/ControlConfig.cs new file mode 100644 index 0000000..b8effa9 --- /dev/null +++ b/Localization/Structures/ControlConfig.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Drawing; + +namespace Grimoire.Localization.Structures +{ + public class ControlConfig + { + public string Name; + public string Comment; + public FontConfig Font; + public Point Location; + public Size Size; + public TextConfig Text; + + public bool Populated + { + get + { + return Name.Length > 0 && + Font != null && + Location != null && + Size != null; + } + } + } +} diff --git a/Localization/Structures/FontConfig.cs b/Localization/Structures/FontConfig.cs new file mode 100644 index 0000000..3c913fc --- /dev/null +++ b/Localization/Structures/FontConfig.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Grimoire.Localization.Structures +{ + public class FontConfig + { + public string Name = "Microsoft Sans Serif"; + public double Size = 8.25; + public System.Drawing.FontStyle Style = System.Drawing.FontStyle.Regular; + } +} diff --git a/Localization/Structures/Locale.cs b/Localization/Structures/Locale.cs new file mode 100644 index 0000000..57aae8d --- /dev/null +++ b/Localization/Structures/Locale.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Grimoire.Localization.Structures +{ + public struct Locale + { + public string Name; + public string DisplayName; + public int Encoding; + public List Controls; + + public bool Populated + { + get + { + return Name.Length > 0 && + DisplayName.Length > 0 && + Encoding > 0 && + Controls.Count > 0; + } + } + } +} diff --git a/Localization/Structures/Text.cs b/Localization/Structures/Text.cs new file mode 100644 index 0000000..9ae4dec --- /dev/null +++ b/Localization/Structures/Text.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Drawing; + +namespace Grimoire.Localization.Structures +{ + public struct TextConfig + { + public ContentAlignment Alignment; + public System.Windows.Forms.RightToLeft RightToLeft; + public string Text; + } +} diff --git a/Localization/en-US.xml b/Localization/en-US.xml new file mode 100644 index 0000000..2dfaf03 --- /dev/null +++ b/Localization/en-US.xml @@ -0,0 +1,235 @@ + + + English (US) + 1252 + + + 8.25 + + No + + + + + + + Clear on List Change + + + + Rebuild + + + + OK + + + + Please select a field + + + Input: + + + OK + + + + OK + + + + New: + + + 43, 7 + 92, 21 + + + Utilities + + + BitFlag Editor + + + Log Viewer + + + Settings + + + About + + + 8.25 + + + + + Message + + + Yes + + + No + + + + + Load + + + New + + + Rebuild + + + Extensions + + + Search + + + Statistics + + + Data ID: + + + Offset: + + + Size: + + + Encrypted: + + + Extension: + + + Upload Path: + + + + Instant + + + Input: + + + Output: + + + Flip + + + Name Options + + + None + + + Append (ascii) + + + Remove (ascii) + + + Grid Options + + + Auto Clear + + + Auto Convert + + + Multi-File + + + + Load + + + File + + + SQL + + + Save + + + File + + + RDB + + + CSV + + + SQL + + + Encrypted + + + Encoding: + + + Structure: + + + Structure: + + + Encryped: + + + (ASCII) + + + \ No newline at end of file diff --git a/Logs/Enums.cs b/Logs/Enums.cs index dde84d9..5f8e012 100644 --- a/Logs/Enums.cs +++ b/Logs/Enums.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Grimoire.Logs +namespace Grimoire.Logs { public enum Level { @@ -18,10 +12,10 @@ public enum Level public enum DisplayLevel { - NOTICE = 0, - ERRORS = 1, + ALL = 0, + NOTICE = 1, DEBUG = 2, - ALL = 3 + ERRORS = 3 } public enum Sender // TODO: Update me a-doi @@ -29,12 +23,11 @@ public enum Sender // TODO: Update me a-doi RDB = 0, HASHER = 1, DATA = 2, - GM = 3, - DROPS = 4, - FLAG = 5, + DROPS = 3, + FLAG = 4, DATABASE = 91, OPT = 92, MANAGER = 93, - MAIN = 94 + MAIN = 94, } } diff --git a/Logs/Manager.cs b/Logs/Manager.cs index 4b6b221..0e891ef 100644 --- a/Logs/Manager.cs +++ b/Logs/Manager.cs @@ -1,17 +1,25 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; +using Grimoire.Structures; +using Grimoire.Utilities; namespace Grimoire.Logs { public class Manager { - public List Entries = new List(); + int idx = 0; + + public ObservableCollection Entries = new ObservableCollection(); public string LogsDirectory; public readonly string LogPath; + + GUI.LogViewer viewer; + static Manager instance; public static Manager Instance { @@ -32,9 +40,17 @@ public Manager() if (!Directory.Exists(LogsDirectory)) Directory.CreateDirectory(LogsDirectory); + Entries.CollectionChanged += Entries_CollectionChanged; + Enter(Sender.MANAGER, Level.NOTICE, "Log Manager initialized."); } + private void Entries_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + if (viewer != null && !viewer.ViewDisposed) + viewer.Refresh(); + } + public void Enter(Sender sender, Level level, string message, params object[] args) { Entries.Add(new Structures.Log() @@ -46,7 +62,6 @@ public void Enter(Sender sender, Level level, string message, params object[] ar StackTrace = null }); - writeLast(); } public void Enter(Sender sender, Level level, Exception ex) @@ -60,7 +75,6 @@ public void Enter(Sender sender, Level level, Exception ex) StackTrace = ex.StackTrace }); - writeLast(); } public void Enter(Sender sender, Level level, Exception ex, string message, params object[] args) @@ -74,25 +88,20 @@ public void Enter(Sender sender, Level level, Exception ex, string message, para StackTrace = ex.StackTrace }); - writeLast(); } - void read() + + #region Public Methods + + public void ShowViewer() { - if (System.IO.File.Exists(LogPath)) - { - using (StreamReader sr = new StreamReader(LogPath, Encoding.Default)) - { - string line; - while ((line = sr.ReadLine()) != null) - { - string[] lineVals = line.Split(']'); - } - } - } + if (viewer == null) + viewer = new GUI.LogViewer(instance); + + viewer.Show(GUI.Main.Instance); } - public void writeAll() + public void Save() { using (FileStream fs = new FileStream(LogPath, FileMode.Append, FileAccess.Write, FileShare.None)) { @@ -110,21 +119,12 @@ public void writeAll() } } - public void writeLast() - { - using (FileStream fs = new FileStream(LogPath, FileMode.Append, FileAccess.Write, FileShare.None)) - { - Structures.Log log = Entries[Entries.Count - 1]; + #endregion - string text = string.Format("[{0} | {1} | {2}]: {3}\n", log.Sender.ToString(), log.Level.ToString(), log.DateTime.ToString("hh:mm:ss"), log.Message); + #region Private Methods - if (log.StackTrace != null) - text += string.Format("\n\t- Stack trace:\n\t{0}\n", log.StackTrace); - byte[] buffer = Encoding.Default.GetBytes(text); - fs.Write(buffer, 0, buffer.Length); - } - } + #endregion } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index dd4f96a..a64732c 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.6.31")] -[assembly: AssemblyFileVersion("0.4.6.31")] +[assembly: AssemblyVersion("0.4.7.0")] +[assembly: AssemblyFileVersion("0.4.7.0")] diff --git a/Tabs/Styles/Data.cs b/Tabs/Styles/Data.cs index 90734db..e3cb124 100644 --- a/Tabs/Styles/Data.cs +++ b/Tabs/Styles/Data.cs @@ -95,6 +95,8 @@ private bool tab_disabled } } + XmlManager xMan = XmlManager.Instance; + #endregion #region Constructors @@ -106,7 +108,7 @@ public Data() lManager = Logs.Manager.Instance; tManager = Tabs.Manager.Instance; gridUtils = new Utilities.Grid(); - load_strings(); + localize(); } public Data(string key) @@ -117,7 +119,7 @@ public Data(string key) lManager = Logs.Manager.Instance; tManager = Tabs.Manager.Instance; gridUtils = new Utilities.Grid(); - load_strings(); + localize(); } #endregion @@ -469,6 +471,8 @@ public void Clear() public void Insert(string[] filePaths) { insert_files(filePaths); } + public void Localize() { localize(); } + #endregion #region Methods (private) @@ -621,21 +625,9 @@ private async void insert_files(string[] filePaths) } } - private void load_strings() - { - ts_file_load.Text = strings.ts_file_load; - ts_file_new.Text = strings.ts_file_new; - ts_file_rebuild.Text = strings.ts_file_rebuild; - grid_grpBx.Text = strings.grid_grpBx; - ext_grpBx.Text = strings.ext_grpBx; - search_grpBx.Text = strings.search_grpBx; - stats_grpBx.Text = strings.stats_grpBx; - dataId_lbl.Text = strings.dataId_lbl; - offsetLbl.Text = strings.offsetLbl; - sizeLbl.Text = strings.sizeLbl; - encLbl.Text = strings.encLbl; - extLbl.Text = strings.extLbl; - upPathLbl.Text = strings.upPathLbl; + private void localize() + { + xMan.Localize(this, Localization.Enums.SenderType.Tab); } #endregion diff --git a/Tabs/Styles/Data.resx b/Tabs/Styles/Data.resx index d8115d3..731d8e7 100644 --- a/Tabs/Styles/Data.resx +++ b/Tabs/Styles/Data.resx @@ -172,6 +172,9 @@ True + + True + 122, 17 diff --git a/Tabs/Styles/Hasher.cs b/Tabs/Styles/Hasher.cs index c20e6ad..4ed71d8 100644 --- a/Tabs/Styles/Hasher.cs +++ b/Tabs/Styles/Hasher.cs @@ -2,6 +2,7 @@ using System.IO; using System.Windows.Forms; using DataCore.Functions; +using Grimoire.Utilities; namespace Grimoire.Tabs.Styles { @@ -9,6 +10,7 @@ public partial class Hasher : UserControl { #region Properties Logs.Manager lManager; + XmlManager xMan = XmlManager.Instance; #endregion #region Constructors @@ -18,7 +20,7 @@ public Hasher() lManager = Logs.Manager.Instance; lManager.Enter(Logs.Sender.HASHER, Logs.Level.NOTICE, "Hasher Utility Started."); set_checks(); - load_strings(); + localize(); } #endregion @@ -114,6 +116,8 @@ public void Add_Dropped_Files(string[] paths) convertAllEntries(); } + public void Localize() { localize(); } + #endregion #region Methods (private) @@ -197,20 +201,9 @@ private void add_file_to_grid(string path) fileGrid.Rows.Add(originalName, convertedName, Path.GetDirectoryName(path), "Pending"); } - private void load_strings() - { - inst_grpBx.Text = strings.inst_grpBx; - inst_inputLbl.Text = strings.inst_inputLbl; - inst_outLbl.Text = strings.inst_outLbl; - inst_flipBtn.Text = strings.inst_flipBtn; - optName_grpBx.Text = strings.optName_grpBx; - optNone_rBtn.Text = strings.optNone_rBtn; - optAppend_ascii_rBtn.Text = strings.optAppend_ascii_rBtn; - optRemove_ascii_rBtn.Text = strings.optRemove_ascii_rBtn; - optGrid_grpBx.Text = strings.optGrid_grpBx; - autoClear_chk.Text = strings.autoClear_chk; - autoConvert_chk.Text = strings.autoConvert_chk; - multi_grpBx.Text = strings.multi_grpBx; + private void localize() + { + xMan.Localize(this, Localization.Enums.SenderType.Tab); } #endregion diff --git a/Tabs/Styles/RDB.Designer.cs b/Tabs/Styles/RDB.Designer.cs index 39524c2..a1760da 100644 --- a/Tabs/Styles/RDB.Designer.cs +++ b/Tabs/Styles/RDB.Designer.cs @@ -37,7 +37,7 @@ private void InitializeComponent() this.ts_load_sql = new System.Windows.Forms.ToolStripMenuItem(); this.ts_save = new System.Windows.Forms.ToolStripDropDownButton(); this.ts_save_file = new System.Windows.Forms.ToolStripMenuItem(); - this.ts_file_save_rdb = new System.Windows.Forms.ToolStripMenuItem(); + this.ts_save_file_rdb = new System.Windows.Forms.ToolStripMenuItem(); this.ts_save_file_csv = new System.Windows.Forms.ToolStripMenuItem(); this.ts_save_file_sql = new System.Windows.Forms.ToolStripMenuItem(); this.ts_save_sql = new System.Windows.Forms.ToolStripMenuItem(); @@ -147,19 +147,19 @@ private void InitializeComponent() // this.ts_save_file.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.ts_save_file.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.ts_file_save_rdb, + this.ts_save_file_rdb, this.ts_save_file_csv, this.ts_save_file_sql}); this.ts_save_file.Name = "ts_save_file"; this.ts_save_file.Size = new System.Drawing.Size(180, 22); this.ts_save_file.Text = "File"; // - // ts_file_save_rdb + // ts_save_file_rdb // - this.ts_file_save_rdb.Name = "ts_file_save_rdb"; - this.ts_file_save_rdb.Size = new System.Drawing.Size(180, 22); - this.ts_file_save_rdb.Text = "RDB"; - this.ts_file_save_rdb.Click += new System.EventHandler(this.TS_Save_File_Click); + this.ts_save_file_rdb.Name = "ts_save_file_rdb"; + this.ts_save_file_rdb.Size = new System.Drawing.Size(180, 22); + this.ts_save_file_rdb.Text = "RDB"; + this.ts_save_file_rdb.Click += new System.EventHandler(this.TS_Save_File_Click); // // ts_save_file_csv // @@ -318,7 +318,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripButton ts_save_enc; private System.Windows.Forms.ToolStripButton ts_save_w_ascii; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripMenuItem ts_file_save_rdb; + private System.Windows.Forms.ToolStripMenuItem ts_save_file_rdb; private System.Windows.Forms.ToolStripMenuItem ts_save_file_csv; private System.Windows.Forms.ToolStripMenuItem ts_save_file_sql; private System.Windows.Forms.ContextMenuStrip grid_cs; diff --git a/Tabs/Styles/RDB.cs b/Tabs/Styles/RDB.cs index 8110c48..e4edc6d 100644 --- a/Tabs/Styles/RDB.cs +++ b/Tabs/Styles/RDB.cs @@ -29,6 +29,7 @@ public partial class rdbTab : UserControl readonly string key = null; readonly Tabs.Utilities.Grid gridUtil; readonly Stopwatch actionSW = new Stopwatch(); + XmlManager xMan = XmlManager.Instance; bool structLoaded { get { return (ts_struct_list.SelectedIndex != -1); } } readonly string buildDir = string.Format(@"{0}\Output\", Directory.GetCurrentDirectory()); @@ -72,7 +73,7 @@ public rdbTab(string key) ts_save_enc.Checked = OPT.GetBool("rdb.save.hashed"); ts_save_w_ascii.Checked = OPT.GetBool("rdb.use.ascii"); structsDir = OPT.GetString("rdb.structure.directory") ?? string.Format(@"{0}\Structures\", Directory.GetCurrentDirectory()); - load_strings(); + localize(); } #endregion @@ -383,21 +384,9 @@ private void grid_cs_open_flag_editor_Click(object sender, EventArgs e) grid.SelectedCells[0].Value = bitflag; } - private void load_strings() + private void localize() { - ts_load.Text = strings.ts_load; - ts_load_file.Text = strings.ts_load_file; - ts_load_sql.Text = strings.ts_load_sql; - ts_save.Text = strings.ts_save; - ts_save_file.Text = strings.ts_save_file; - ts_file_save_rdb.Text = strings.ts_file_save_rdb; - ts_save_file_csv.Text = strings.ts_save_file_csv; - ts_save_file_sql.Text = strings.ts_save_file_sql; - ts_save_sql.Text = strings.ts_save_sql; - ts_encLbl.Text = strings.ts_encLbl; - ts_structLb.Text = strings.ts_structLb; - ts_save_enc.Text = strings.ts_save_enc; - ts_save_w_ascii.Text = strings.ts_save_w_ascii; + xMan.Localize(this, Localization.Enums.SenderType.Tab); } #endregion @@ -617,6 +606,8 @@ public void Sort(Cell cell, SortOrder order) initializeGrid(); } + public void Localize() { localize(); } + #endregion #region Methods (private) diff --git a/Utilities/XmlManager.cs b/Utilities/XmlManager.cs new file mode 100644 index 0000000..36f80c8 --- /dev/null +++ b/Utilities/XmlManager.cs @@ -0,0 +1,549 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.Linq; +using System.Globalization; +using Grimoire.Localization.Structures; +using Grimoire.Localization.Enums; + +namespace Grimoire.Utilities +{ + public class XmlManager + { + Logs.Manager lManager = Logs.Manager.Instance; + + List locales = new List(); + Locale locale + { + get { return locales.Find(l => l.Name == key); } + } + string key = OPT.GetString("locale"); + string localeDir = OPT.GetString("locale.directory") ?? string.Format(@"{0}\Localization", Directory.GetCurrentDirectory()); + + static XmlManager instance; + public static XmlManager Instance + { + get + { + if (instance == null) + instance = new XmlManager(); + + return instance; + } + set { instance = value; } + } + + public XmlManager() + { + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.NOTICE, "Localization Manager Started."); + + compileLocales(); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, string.Format("{0} locales loaded from:\n\t- {1}", locales.Count, localeDir)); + } + + void compileLocales() + { + if (string.IsNullOrEmpty(key)) + { + string msg = "compileLocales() key is null!"; + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.ERROR, msg); + System.Windows.Forms.MessageBox.Show(msg, "XML Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + } + + if (!Directory.Exists(localeDir)) + { + string msg = "compileLocales() localeDir is null!"; + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.ERROR, msg); + System.Windows.Forms.MessageBox.Show(msg, "XML Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + } + + string[] filePaths = Directory.GetFiles(localeDir); + for (int i = 0; i < filePaths.Length; i++) + { + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, "{0} locales found in:\n\t- {1}", filePaths.Length, localeDir); + + parseXML(filePaths[i]); + } + } + + public void RefreshLocale() + { + string localePath = string.Format(@"{0}\{1}.xml", localeDir, key); + + if (File.Exists(localePath)) + { + locales.Remove(locale); + parseXML(localePath); + } + } + + public void Localize(object sender, SenderType type) + { + if (locales.FindIndex(l => l.Name == key) == -1) + { + key = "en-US"; + string msg = string.Format("Requested Locale: {0} does not exist!\n\t Defaulting to en-US", key); + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.NOTICE, msg); + System.Windows.Forms.MessageBox.Show(msg, "XML Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand); + } + + switch (type) + { + case SenderType.GUI: + { + System.Windows.Forms.Form f = (System.Windows.Forms.Form)sender; + + if (f != null) + { + localizeControls(f.Controls); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, string.Format("{0} control configurations loaded for gui: {1}", f.Controls.Count, f.Name)); + } + } + break; + + case SenderType.Tab: + { + System.Windows.Forms.UserControl u = (System.Windows.Forms.UserControl)sender; + + if (u != null) + { + localizeControls(u.Controls); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, string.Format("{0} control configurations loaded for tab: {1}", u.Controls.Count, u.Name)); + } + } + break; + } + } + + void parseXML(string filePath) + { + XDocument xDoc = XDocument.Load(filePath); + + List element = xDoc.Elements("locale").ToList(); + if (element != null) + { + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, " found for locale:{0}", key); + + Locale locale = new Locale(); + + if (!element[0].HasAttributes) + { + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.ERROR, " element does not have expected attributes!"); + return; + } + + locale.Name = element[0].FirstAttribute.Value; + + List childNodes = element[0].Elements().ToList(); + locale.DisplayName = childNodes[0].Value; + locale.Encoding = Convert.ToInt32(childNodes[1].Value); + + FontConfig globalFont = new FontConfig(); + System.Windows.Forms.RightToLeft rightToLeft = System.Windows.Forms.RightToLeft.No; + + if (childNodes.Count == 4) // Global font is likely defined + { + if (childNodes[2].Name == "font") + { + List fontElements = childNodes[2].Elements().ToList(); + + globalFont.Style = (System.Drawing.FontStyle)Enum.Parse(typeof(System.Drawing.FontStyle), fontElements[0].Value); + globalFont.Size = Convert.ToDouble(fontElements[1].Value, CultureInfo.InvariantCulture); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, "Global is defined.\nFamily:{0}\nStyle:{1}\nSize:{2}", globalFont.Name, + globalFont.Style.ToString(), + globalFont.Size); + } + } + else if (childNodes.Count == 5) // Global right to left is likely defined + { + if (childNodes[3].Name == "rightToLeft") + { + rightToLeft = (System.Windows.Forms.RightToLeft)Enum.Parse(typeof(System.Windows.Forms.RightToLeft), childNodes[3].Value); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, "Global defined."); + } + } + + // Get the nodes in the elemenent + childNodes = childNodes[childNodes.Count - 1].Elements().ToList(); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, "{0} nodes found.", childNodes.Count); + + List controls = new List(); + for (int c = 0; c < childNodes.Count; c++) + { + ControlConfig control = new ControlConfig(); + + if (childNodes[c].HasAttributes) + { + List attributes = childNodes[c].Attributes().ToList(); + if (attributes.Count >= 1) + control.Name = attributes[0].Value; + + if (attributes.Count >= 2) + control.Comment = attributes[1].Value; + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, " {0} has expected attributes.", control.Name); + } + else + { + string msg = string.Format(" at index: {0} does not have attributes! Ignoring!", c); + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.WARNING, msg); + System.Windows.Forms.MessageBox.Show(msg, "XML Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); + } + + FontConfig controlFont = null; + + List fontElements = childNodes[c].Elements("font").ToList(); + if (fontElements.Count > 0) + { + controlFont = new FontConfig(); + controlFont.Name = fontElements[0].FirstAttribute.Value; + + fontElements = fontElements[0].Elements().ToList(); + controlFont.Style = (System.Drawing.FontStyle)Enum.Parse(typeof(System.Drawing.FontStyle), fontElements[0].Value); + controlFont.Size = Convert.ToDouble(fontElements[1].Value, CultureInfo.InvariantCulture); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, " detected.\nFamily:{0}\nStyle:{2}\nSize:{1}", controlFont.Name, + controlFont.Style.ToString(), + controlFont.Size); + } + else + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, "No detected for control: {0}", control.Name); + + control.Font = (controlFont != null) ? controlFont : globalFont; + + List locationElements = childNodes[c].Elements("location").ToList(); + if (locationElements.Count == 1) + { + string[] location = childNodes[c].Elements("location").ToList()[0].Value.Split(','); + control.Location = new System.Drawing.Point(int.Parse(location[0]), int.Parse(location[1])); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, " detected.\nx:{0}\ny:{1}", control.Location.X, + control.Location.Y); + } + else + control.Location = new System.Drawing.Point(0, 0); + + List sizeElements = childNodes[c].Elements("size").ToList(); + if (sizeElements.Count == 1) + { + string[] size = childNodes[c].Elements("size").ToList()[0].Value.Split(','); + control.Size = new System.Drawing.Size(int.Parse(size[0]), int.Parse(size[1])); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, " detected. \nheight:{0}\nwidth:{1}", control.Size.Height, + control.Size.Width); + } + else + control.Size = new System.Drawing.Size(0, 0); + + TextConfig text = new TextConfig(); + text.Alignment = System.Drawing.ContentAlignment.MiddleLeft; + + List textElements = childNodes[c].Elements("text").ToList(); + + if (textElements.Count > 0) + { + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, " element detected!"); + + if (textElements[0].HasAttributes) + { + List attributes = textElements[0].Attributes().ToList(); + + XAttribute attribute = attributes.Find(a => a.Name == "align"); + if (attribute != null) + text.Alignment = (System.Drawing.ContentAlignment)Enum.Parse(typeof(System.Drawing.ContentAlignment), attribute.Value); + + attribute = attributes.Find(a => a.Name == "rightToLeft"); + if (attribute != null) + text.RightToLeft = (System.Windows.Forms.RightToLeft)Enum.Parse(typeof(System.Windows.Forms.RightToLeft), attribute.Value); + } + + text.Text = textElements[0].Value; + } + else + text.Text = string.Empty; + + control.Text = text; + + if (control.Populated) + controls.Add(control); + } + + locale.Controls = controls; + + if (locale.Populated) + locales.Add(locale); + + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, string.Format("{0} controls configurations loaded from locale: {1} from\n\t- {2}", locale.Controls.Count, locale.Name, filePath)); + } + } + + void localizeControls(System.Windows.Forms.Control.ControlCollection controls) + { + foreach (System.Windows.Forms.Control control in controls) + { + ControlConfig config = null; + + if (control.GetType() == typeof(System.Windows.Forms.MenuStrip)) + { + System.Windows.Forms.MenuStrip ms = (System.Windows.Forms.MenuStrip)control; + + foreach (System.Windows.Forms.ToolStripMenuItem tsmi in ms.Items) + { + config = locale.Controls.Find(c => c.Name == tsmi.Name); + + if (config != null) + { + tsmi.Text = config.Text.Text; + tsmi.TextAlign = config.Text.Alignment; + tsmi.RightToLeft = config.Text.RightToLeft; + + if (!control.Size.IsEmpty) + tsmi.Size = config.Size; + } + + foreach (System.Windows.Forms.ToolStripMenuItem subTSMI in tsmi.DropDownItems) + { + config = locale.Controls.Find(c => c.Name == subTSMI.Name); + + if (config != null) + { + subTSMI.Text = config.Text.Text; + subTSMI.TextAlign = config.Text.Alignment; + subTSMI.RightToLeft = config.Text.RightToLeft; + + if (!control.Size.IsEmpty) + subTSMI.Size = config.Size; + } + } + + } + + } + else if (control.GetType() == typeof(System.Windows.Forms.GroupBox)) + { + System.Windows.Forms.GroupBox grpBx = (System.Windows.Forms.GroupBox)control; + + config = locale.Controls.Find(c => c.Name == grpBx.Name); + if (config != null) + grpBx.Text = config.Text.Text; + + for (int i = 0; i < grpBx.Controls.Count; i++) + { + System.Windows.Forms.Control ctrl = grpBx.Controls[i]; + + if (ctrl.GetType() == typeof(System.Windows.Forms.Button)) + { + System.Windows.Forms.Button btn = (System.Windows.Forms.Button)ctrl; + + config = locale.Controls.Find(c => c.Name == btn.Name); + + if (config != null) + { + btn.TextAlign = config.Text.Alignment; + } + } + else if (ctrl.GetType() == typeof(System.Windows.Forms.RadioButton)) + { + System.Windows.Forms.RadioButton rBtn = (System.Windows.Forms.RadioButton)ctrl; + + config = locale.Controls.Find(c => c.Name == rBtn.Name); + + if (config != null) + { + rBtn.TextAlign = config.Text.Alignment; + rBtn.Font = new System.Drawing.Font(config.Font.Name, (float)config.Font.Size, config.Font.Style); + rBtn.RightToLeft = config.Text.RightToLeft; + } + } + else if (ctrl.GetType() == typeof(System.Windows.Forms.Label)) + { + System.Windows.Forms.Label lbl = (System.Windows.Forms.Label)ctrl; + + config = locale.Controls.Find(c => c.Name == lbl.Name); + + if (config != null) + { + lbl.TextAlign = config.Text.Alignment; + lbl.Font = new System.Drawing.Font(config.Font.Name, (float)config.Font.Size, config.Font.Style); + lbl.RightToLeft = config.Text.RightToLeft; + } + } + else if (ctrl.GetType() == typeof(System.Windows.Forms.CheckBox)) + { + System.Windows.Forms.CheckBox chkBx = (System.Windows.Forms.CheckBox)ctrl; + + config = locale.Controls.Find(c => c.Name == chkBx.Name); + + if (config != null) + { + chkBx.TextAlign = config.Text.Alignment; + chkBx.Font = new System.Drawing.Font(config.Font.Name, (float)config.Font.Size, config.Font.Style); + chkBx.RightToLeft = config.Text.RightToLeft; + } + } + else if (ctrl.GetType() == typeof(System.Windows.Forms.TextBox)) + { + /*Textbox shouldn't be touched*/ + } + + if (config != null) + + ctrl.Font = config.Font; + + if (!config.Location.IsEmpty) + ctrl.Location = config.Location; + + if (!config.Size.IsEmpty) + ctrl.Size = config.Size; + + ctrl.Text = config.Text.Text; + } + + config = null; + } + } + else if (control.GetType() == typeof(System.Windows.Forms.ToolStrip)) + { + foreach (object tso in ((System.Windows.Forms.ToolStrip)control).Items) + { + if (tso.GetType() == typeof(System.Windows.Forms.ToolStripDropDownButton)) + { + System.Windows.Forms.ToolStripDropDownButton tsb = (System.Windows.Forms.ToolStripDropDownButton)tso; + + config = locale.Controls.Find(c => c.Name == tsb.Name); + + if (config != null) + { + tsb.Text = config.Text.Text; + tsb.TextAlign = config.Text.Alignment; + tsb.Font = new System.Drawing.Font(config.Font.Name, (float)config.Font.Size, config.Font.Style); + tsb.RightToLeft = config.Text.RightToLeft; + } + } + else if (tso.GetType() == typeof(System.Windows.Forms.ToolStripButton)) + { + System.Windows.Forms.ToolStripButton tsb = (System.Windows.Forms.ToolStripButton)tso; + + config = locale.Controls.Find(c => c.Name == tsb.Name); + + if (config != null) + { + tsb.Text = config.Text.Text; + tsb.TextAlign = config.Text.Alignment; + tsb.Font = new System.Drawing.Font(config.Font.Name, (float)config.Font.Size, config.Font.Style); + tsb.RightToLeft = config.Text.RightToLeft; + } + } + else if (tso.GetType() == typeof(System.Windows.Forms.ToolStripMenuItem)) + { + System.Windows.Forms.ToolStripMenuItem tsi = (System.Windows.Forms.ToolStripMenuItem)tso; + + config = locale.Controls.Find(c => c.Name == tsi.Name); + + if (config != null) + { + tsi.Text = config.Text.Text; + tsi.TextAlign = config.Text.Alignment; + tsi.Font = new System.Drawing.Font(config.Font.Name, (float)config.Font.Size, config.Font.Style); + tsi.RightToLeft = config.Text.RightToLeft; + } + } + else if (tso.GetType() == typeof(System.Windows.Forms.ToolStripLabel)) + { + System.Windows.Forms.ToolStripLabel tsl = (System.Windows.Forms.ToolStripLabel)tso; + + config = locale.Controls.Find(c => c.Name == tsl.Name); + + if (config != null) + { + tsl.Text = config.Text.Text; + tsl.TextAlign = config.Text.Alignment; + tsl.Font = new System.Drawing.Font(config.Font.Name, (float)config.Font.Size, config.Font.Style); + tsl.RightToLeft = config.Text.RightToLeft; + } + } + + if (config != null) + { + if (!config.Location.IsEmpty) + control.Location = config.Location; + + if (!config.Size.IsEmpty) + control.Size = config.Size; + + control.Text = config.Text.Text; + } + + config = null; + } + } + else + { + config = locale.Controls.Find(c => c.Name == control.Name); + + if (config != null) + { + System.Drawing.Font font = new System.Drawing.Font(config.Font.Name, (float)config.Font.Size, config.Font.Style); + + control.Font = font; + + Type t = control.GetType(); + if (t == typeof(System.Windows.Forms.CheckBox)) + { + System.Windows.Forms.CheckBox chkBx = (System.Windows.Forms.CheckBox)control; + chkBx.TextAlign = config.Text.Alignment; + } + else if (t == typeof(System.Windows.Forms.Label)) + { + System.Windows.Forms.Label lbl = (System.Windows.Forms.Label)control; + lbl.TextAlign = config.Text.Alignment; + } + else if (t == typeof(System.Windows.Forms.Button)) + { + System.Windows.Forms.Button lbl = (System.Windows.Forms.Button)control; + lbl.TextAlign = config.Text.Alignment; + } + else if (t == typeof(System.Windows.Forms.ToolStripMenuItem)) + { + System.Windows.Forms.ToolStrip tsm = (System.Windows.Forms.ToolStrip)control; + System.Windows.Forms.ToolStripItem tsi = tsm.Items[config.Name]; + + tsi.TextAlign = config.Text.Alignment; + } + else if (t == typeof(System.Windows.Forms.ToolStripDropDownButton)) + { + System.Windows.Forms.ToolStrip tsm = (System.Windows.Forms.ToolStrip)control; + System.Windows.Forms.ToolStripItem tsi = tsm.Items[config.Name]; + + tsi.TextAlign = config.Text.Alignment; + } + else + { + /*Alignment doesn't exist bruh*/ + } + + if (!config.Location.IsEmpty) + control.Location = config.Location; + + if (!config.Size.IsEmpty) + control.Size = config.Size; + + control.Text = config.Text.Text; + } + else + lManager.Enter(Logs.Sender.MANAGER, Logs.Level.DEBUG, "Control: {0} is not configured! It will default.", control.Name); + } + } + } + } +} diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..2d16adb --- /dev/null +++ b/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/strings.Designer.cs b/strings.Designer.cs deleted file mode 100644 index 55d883c..0000000 --- a/strings.Designer.cs +++ /dev/null @@ -1,531 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Grimoire { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Grimoire.strings", typeof(strings).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to About. - /// - public static string aboutLbl { - get { - return ResourceManager.GetString("aboutLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Auto Clear. - /// - public static string autoClear_chk { - get { - return ResourceManager.GetString("autoClear_chk", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Auto Convert. - /// - public static string autoConvert_chk { - get { - return ResourceManager.GetString("autoConvert_chk", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Clear on List Change. - /// - public static string clear_on_change { - get { - return ResourceManager.GetString("clear_on_change", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Data ID:. - /// - public static string dataId_lbl { - get { - return ResourceManager.GetString("dataId_lbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Please select a field. - /// - public static string descLbl { - get { - return ResourceManager.GetString("descLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Encrypted:. - /// - public static string encLbl { - get { - return ResourceManager.GetString("encLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Extensions. - /// - public static string ext_grpBx { - get { - return ResourceManager.GetString("ext_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Extension:. - /// - public static string extLbl { - get { - return ResourceManager.GetString("extLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Index. - /// - public static string grid_grpBx { - get { - return ResourceManager.GetString("grid_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Input:. - /// - public static string inputLbl { - get { - return ResourceManager.GetString("inputLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Flip. - /// - public static string inst_flipBtn { - get { - return ResourceManager.GetString("inst_flipBtn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Instant. - /// - public static string inst_grpBx { - get { - return ResourceManager.GetString("inst_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Input:. - /// - public static string inst_inputLbl { - get { - return ResourceManager.GetString("inst_inputLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Output:. - /// - public static string inst_outLbl { - get { - return ResourceManager.GetString("inst_outLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Message. - /// - public static string msg_grpBx { - get { - return ResourceManager.GetString("msg_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Multi-File. - /// - public static string multi_grpBx { - get { - return ResourceManager.GetString("multi_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New. - /// - public static string newLbl { - get { - return ResourceManager.GetString("newLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No. - /// - public static string noBtn { - get { - return ResourceManager.GetString("noBtn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Offset:. - /// - public static string offsetLbl { - get { - return ResourceManager.GetString("offsetLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to OK. - /// - public static string okBtn { - get { - return ResourceManager.GetString("okBtn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Append (ascii). - /// - public static string optAppend_ascii_rBtn { - get { - return ResourceManager.GetString("optAppend_ascii_rBtn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Grid Options. - /// - public static string optGrid_grpBx { - get { - return ResourceManager.GetString("optGrid_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Name Options:. - /// - public static string optName_grpBx { - get { - return ResourceManager.GetString("optName_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to None. - /// - public static string optNone_rBtn { - get { - return ResourceManager.GetString("optNone_rBtn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove (ascii). - /// - public static string optRemove_ascii_rBtn { - get { - return ResourceManager.GetString("optRemove_ascii_rBtn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Rebuild. - /// - public static string rebuildBtn { - get { - return ResourceManager.GetString("rebuildBtn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Search. - /// - public static string search_grpBx { - get { - return ResourceManager.GetString("search_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings. - /// - public static string settingsBtn { - get { - return ResourceManager.GetString("settingsBtn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Size:. - /// - public static string sizeLbl { - get { - return ResourceManager.GetString("sizeLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Statistics. - /// - public static string stats_grpBx { - get { - return ResourceManager.GetString("stats_grpBx", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to BitFlag Editor. - /// - public static string ts_bitflag_editor { - get { - return ResourceManager.GetString("ts_bitflag_editor", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Encoding:. - /// - public static string ts_encLbl { - get { - return ResourceManager.GetString("ts_encLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Load. - /// - public static string ts_file_load { - get { - return ResourceManager.GetString("ts_file_load", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New. - /// - public static string ts_file_new { - get { - return ResourceManager.GetString("ts_file_new", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Rebuild. - /// - public static string ts_file_rebuild { - get { - return ResourceManager.GetString("ts_file_rebuild", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to RDB. - /// - public static string ts_file_save_rdb { - get { - return ResourceManager.GetString("ts_file_save_rdb", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Load. - /// - public static string ts_load { - get { - return ResourceManager.GetString("ts_load", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File. - /// - public static string ts_load_file { - get { - return ResourceManager.GetString("ts_load_file", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SQL. - /// - public static string ts_load_sql { - get { - return ResourceManager.GetString("ts_load_sql", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Log Viewer. - /// - public static string ts_log_viewer { - get { - return ResourceManager.GetString("ts_log_viewer", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Save. - /// - public static string ts_save { - get { - return ResourceManager.GetString("ts_save", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Encrypted. - /// - public static string ts_save_enc { - get { - return ResourceManager.GetString("ts_save_enc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File. - /// - public static string ts_save_file { - get { - return ResourceManager.GetString("ts_save_file", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to CSV. - /// - public static string ts_save_file_csv { - get { - return ResourceManager.GetString("ts_save_file_csv", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SQL. - /// - public static string ts_save_file_sql { - get { - return ResourceManager.GetString("ts_save_file_sql", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SQL. - /// - public static string ts_save_sql { - get { - return ResourceManager.GetString("ts_save_sql", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to (ASCII). - /// - public static string ts_save_w_ascii { - get { - return ResourceManager.GetString("ts_save_w_ascii", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Structure:. - /// - public static string ts_structLb { - get { - return ResourceManager.GetString("ts_structLb", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Utilities. - /// - public static string ts_utilities { - get { - return ResourceManager.GetString("ts_utilities", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Upload Path:. - /// - public static string upPathLbl { - get { - return ResourceManager.GetString("upPathLbl", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Yes. - /// - public static string yesBtn { - get { - return ResourceManager.GetString("yesBtn", resourceCulture); - } - } - } -} diff --git a/strings.resx b/strings.resx deleted file mode 100644 index dd312d1..0000000 --- a/strings.resx +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - About - GUI.Main.aboutLbl.Text - - - Auto Clear - Tabs.Styles.Hasher.autoClear_chk.Text - - - Auto Convert - Tabs.Styles.Hasher.autoConvert_chk.Text - - - Clear on List Change - GUI.BitFlag.clear_on_change_chkBx.Text - - - Data ID: - Tabs.Styles.Data.dataId_lbl.Text - - - Please select a field - GUI.ListInput.descLbl.Text - - - Encrypted: - Tabs.Styles.Data.encLbl.Text - - - Extension: - Tabs.Styles.Data.extLbl.Text - - - Extensions - Tabs.Styles.Data.ext_grpBx.Text - - - Index - Tabs.Styles.Data.grid_grpBx.Text - - - Input: - GUI.ListInput.inputLbl.Text - - - Flip - Tabs.Styles.Hasher.inst_flipBtn.Text - - - Instant - Tabs.Styles.Hasher.inst_grpBx.Text - - - Input: - Tabs.Styles.Hasher.inst_inputLbl.Text - - - Output: - Tabs.Styles.Hasher.inst_outLbl.Text - - - Message - GUI.MessageListBox.msg_grpBx.Text - - - Multi-File - Tabs.Styles.Hasher.multi_grpBx.Text - - - New - GUI.Main.newLbl.Text - - - No - GUI.MessageListBox.noBtn.Text - - - Offset: - Tabs.Styles.Data.offsetLbl.Text - - - OK - GUI.Input.okBtn.Text, GUI.ListSelect.okBtn - - - Append (ascii) - Tabs.Styles.Hasher.optAppend_ascii_rBtn.Text - - - Grid Options - Tabs.Styles.Hasher.optGrid_grpBx.Text - - - Name Options: - Tabs.Styles.Hasher.optName_grpBx.Text - - - None - Tabs.Styles.Hasher.optNone_rBtn.Text - - - Remove (ascii) - Tabs.Styles.Hasher.optRemove_ascii_rBtn.Text - - - Rebuild - GUI.DataRebuild.rebuildBtn.Text - - - Search - Tabs.Styles.Data.search_grpBx.Text - - - Settings - GUI.Main.settingsBtn.Text - - - Size: - Tabs.Styles.Data.sizeLbl.Text - - - Statistics - Tabs.Styles.Data.stats_grpBx.Text - - - BitFlag Editor - GUI.Main.ts_bitflag_editor.Text - - - Encoding: - Tabs.Styles.RDB.ts_encLbl.Text - - - Load - Tabs.Styles.Data.ts_file_load.Text - - - New - Tabs.Styles.Data.ts_file_new.Text - - - Rebuild - Tabs.Styles.Data.ts_file_rebuild.Text - - - RDB - Tabs.Styles.RDB.ts_file_save_rdb.Text - - - Load - Tabs.Styles.RDB.ts_load.Text - - - File - Tabs.Styles.RDB.ts_load_file.Text - - - SQL - Tabs.Styles.RDB.ts_load_sql.Text - - - Log Viewer - GUI.Main.ts_log_viewer.Text - - - Save - Tabs.Styles.RDB.ts_save.Text - - - Encrypted - Tabs.Styles.RDB.ts_save_enc.Text - - - File - Tabs.Styles.RDB.ts_save_file.Text - - - CSV - Tabs.Styles.RDB.ts_save_file_csv.Text - - - SQL - Tabs.Styles.RDB.ts_save_file_sql.Text - - - SQL - Tabs.Styles.RDB.ts_save_sql.Text - - - (ASCII) - Tabs.Styles.RDB.ts_save_w_ascii.Text - - - Structure: - Tabs.Styles.RDB.ts_structLb.Text; - - - Utilities - GUI.Main.ts_utilities.Text - - - Upload Path: - Tabs.Styles.Data.upPathLbl.Text - - - Yes - GUI.MessageListBox.yesBtn.Text - - \ No newline at end of file