diff --git a/ZeroLocalizationToolGUI/Forms/BetterTreeView.cs b/ZeroLocalizationToolGUI/Forms/BetterTreeView.cs
new file mode 100644
index 0000000..f7c999b
--- /dev/null
+++ b/ZeroLocalizationToolGUI/Forms/BetterTreeView.cs
@@ -0,0 +1,12 @@
+namespace System.Windows.Forms
+{
+ public class BetterTreeView : TreeView
+ {
+ protected override void WndProc(ref Message m)
+ {
+ // Suppress WM_LBUTTONDBLCLK
+ if (m.Msg == 0x203) { m.Result = IntPtr.Zero; }
+ else base.WndProc(ref m);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ZeroLocalizationToolGUI/MainForm.Designer.cs b/ZeroLocalizationToolGUI/MainForm.Designer.cs
index 807359e..39d09c2 100644
--- a/ZeroLocalizationToolGUI/MainForm.Designer.cs
+++ b/ZeroLocalizationToolGUI/MainForm.Designer.cs
@@ -29,13 +29,116 @@ protected override void Dispose(bool disposing)
///
private void InitializeComponent()
{
- this.components = new System.ComponentModel.Container();
+ this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+ this.toolStripMenuItem_File = new System.Windows.Forms.ToolStripMenuItem();
+ this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.lbl_NodePath = new System.Windows.Forms.Label();
+ this.rtb_KeyValue = new System.Windows.Forms.RichTextBox();
+ this.treeView_Database = new System.Windows.Forms.BetterTreeView();
+ this.menuStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // menuStrip1
+ //
+ this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
+ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripMenuItem_File});
+ this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip1.Name = "menuStrip1";
+ this.menuStrip1.Padding = new System.Windows.Forms.Padding(4, 1, 0, 1);
+ this.menuStrip1.Size = new System.Drawing.Size(777, 24);
+ this.menuStrip1.TabIndex = 1;
+ this.menuStrip1.Text = "menuStrip1";
+ //
+ // toolStripMenuItem_File
+ //
+ this.toolStripMenuItem_File.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.openToolStripMenuItem,
+ this.saveToolStripMenuItem,
+ this.exitToolStripMenuItem});
+ this.toolStripMenuItem_File.Name = "toolStripMenuItem_File";
+ this.toolStripMenuItem_File.Size = new System.Drawing.Size(37, 22);
+ this.toolStripMenuItem_File.Text = "File";
+ //
+ // openToolStripMenuItem
+ //
+ this.openToolStripMenuItem.Name = "openToolStripMenuItem";
+ this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
+ this.openToolStripMenuItem.Text = "Open";
+ this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
+ //
+ // saveToolStripMenuItem
+ //
+ this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
+ this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
+ this.saveToolStripMenuItem.Text = "Save";
+ //
+ // exitToolStripMenuItem
+ //
+ this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
+ this.exitToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
+ this.exitToolStripMenuItem.Text = "Exit";
+ //
+ // lbl_NodePath
+ //
+ this.lbl_NodePath.AutoSize = true;
+ this.lbl_NodePath.Location = new System.Drawing.Point(237, 28);
+ this.lbl_NodePath.Name = "lbl_NodePath";
+ this.lbl_NodePath.Size = new System.Drawing.Size(35, 13);
+ this.lbl_NodePath.TabIndex = 3;
+ this.lbl_NodePath.Text = "label1";
+ //
+ // rtb_KeyValue
+ //
+ this.rtb_KeyValue.Enabled = false;
+ this.rtb_KeyValue.Location = new System.Drawing.Point(237, 45);
+ this.rtb_KeyValue.Name = "rtb_KeyValue";
+ this.rtb_KeyValue.Size = new System.Drawing.Size(528, 210);
+ this.rtb_KeyValue.TabIndex = 4;
+ this.rtb_KeyValue.Text = "";
+ //
+ // treeView_Database
+ //
+ this.treeView_Database.Location = new System.Drawing.Point(9, 24);
+ this.treeView_Database.Margin = new System.Windows.Forms.Padding(2);
+ this.treeView_Database.Name = "treeView_Database";
+ this.treeView_Database.PathSeparator = ".";
+ this.treeView_Database.Size = new System.Drawing.Size(222, 499);
+ this.treeView_Database.TabIndex = 2;
+ this.treeView_Database.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView_Database_NodeMouseClick);
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
+ this.ClientSize = new System.Drawing.Size(777, 530);
+ this.Controls.Add(this.rtb_KeyValue);
+ this.Controls.Add(this.lbl_NodePath);
+ this.Controls.Add(this.treeView_Database);
+ this.Controls.Add(this.menuStrip1);
+ this.MainMenuStrip = this.menuStrip1;
+ this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.Name = "MainForm";
+ this.Text = "Zero Localization Tool";
+ this.Load += new System.EventHandler(this.MainForm_Load);
+ this.menuStrip1.ResumeLayout(false);
+ this.menuStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
}
#endregion
+ private System.Windows.Forms.MenuStrip menuStrip1;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_File;
+ private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
+ private System.Windows.Forms.BetterTreeView treeView_Database;
+ private System.Windows.Forms.Label lbl_NodePath;
+ private System.Windows.Forms.RichTextBox rtb_KeyValue;
}
}
diff --git a/ZeroLocalizationToolGUI/MainForm.cs b/ZeroLocalizationToolGUI/MainForm.cs
index 3c60178..d4ddc66 100644
--- a/ZeroLocalizationToolGUI/MainForm.cs
+++ b/ZeroLocalizationToolGUI/MainForm.cs
@@ -2,19 +2,130 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
+using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using Microsoft.WindowsAPICodePack.Dialogs;
+using ZeroLocalizationToolShared.Modules;
namespace ZeroLocalizationToolGUI
{
public partial class MainForm : Form
{
+ public CommonOpenFileDialog openDlg_AddProjectPrompt = new CommonOpenFileDialog();
+ public DataBase db = new DataBase();
+
public MainForm()
{
InitializeComponent();
}
+
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ openDlg_AddProjectPrompt.Title = "Open Localization File";
+ //openDlg_AddProjectPrompt.IsFolderPicker = true;
+
+ if (openDlg_AddProjectPrompt.ShowDialog() == CommonFileDialogResult.Ok)
+ {
+ LoadDatabase(openDlg_AddProjectPrompt.FileName);
+ }
+ }
+
+ private void openToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void treeView_Database_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
+ {
+ string keyPath = e.Node.FullPath;
+ Key key = db.GetKey(keyPath);
+
+ if (key != null)
+ {
+ rtb_KeyValue.Enabled = true;
+ lbl_NodePath.Text = keyPath;
+ rtb_KeyValue.Text = key.GetValue();
+ }
+ else
+ {
+ rtb_KeyValue.Text = string.Empty;
+ rtb_KeyValue.Enabled = false;
+ }
+ }
+
+ void LoadDatabase(string fileName)
+ {
+ db = LocalizationParser.ParseDataBase(fileName);
+
+ foreach (Scope rootScope in db.Scopes)
+ {
+ AddDatabaseNodesForScope(rootScope);
+ }
+ }
+
+ void AddDatabaseNodesForScope(Scope scope)
+ {
+ AddDatabaseNodesForScope(scope, null);
+ }
+
+ void AddDatabaseNodesForScope(Scope scope, TreeNode node)
+ {
+ // Add the scope
+ TreeNode scopeNode;
+ if (node != null)
+ scopeNode = node.Nodes.Add(scope.Name);
+ else
+ scopeNode = treeView_Database.Nodes.Add(scope.Name);
+
+ // Add any subscopes
+ if (scope.Scopes.Count > 0)
+ {
+ foreach (Scope subScope in scope.Scopes)
+ {
+ AddDatabaseNodesForScope(subScope, scopeNode);
+ }
+ }
+
+ // Add any keys
+ foreach (Key key in scope.Keys)
+ {
+ TreeNode keyNode = scopeNode.Nodes.Add(key.Name);
+ }
+ }
+
+ ///
+ /// Populates a TreeView based on a list of file paths.
+ ///
+ /// Adapted from https://stackoverflow.com/a/19332770/3639133
+ ///
+ /// TreeView control to populate.
+ /// List of paths.
+ /// Character to split the path.
+ private void PopulateTreeView(TreeView treeView, List paths, char pathSeparator)
+ {
+ TreeNode lastNode = null;
+ string subPathAgg;
+ foreach (string path in paths)
+ {
+ subPathAgg = string.Empty;
+ foreach (string subPath in path.Split(pathSeparator))
+ {
+ subPathAgg += subPath + pathSeparator;
+ TreeNode[] nodes = treeView.Nodes.Find(subPathAgg, true);
+ if (nodes.Length == 0)
+ if (lastNode == null)
+ lastNode = treeView.Nodes.Add(subPathAgg, subPath);
+ else
+ lastNode = lastNode.Nodes.Add(subPathAgg, subPath);
+ else
+ lastNode = nodes[0];
+ }
+ lastNode = null; // This is the place code was changed
+ }
+ }
}
}
diff --git a/ZeroLocalizationToolGUI/MainForm.resx b/ZeroLocalizationToolGUI/MainForm.resx
new file mode 100644
index 0000000..d5494e3
--- /dev/null
+++ b/ZeroLocalizationToolGUI/MainForm.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/ZeroLocalizationToolGUI/Modules/TreeviewExt.cs b/ZeroLocalizationToolGUI/Modules/TreeviewExt.cs
new file mode 100644
index 0000000..51aff51
--- /dev/null
+++ b/ZeroLocalizationToolGUI/Modules/TreeviewExt.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace ZeroLocalizationToolGUI.Modules
+{
+ internal static class TreeViewExt
+ {
+ // Adapted from https://stackoverflow.com/a/26543212/3639133
+ internal static IEnumerable Descendants(this TreeNodeCollection c)
+ {
+ foreach (var node in c.OfType())
+ {
+ yield return node;
+
+ foreach (var child in node.Nodes.Descendants())
+ {
+ yield return child;
+ }
+ }
+ }
+
+ internal static TreeNode GetNodeByValue(this TreeNodeCollection c, string value)
+ {
+ foreach (var node in c.OfType())
+ {
+ if (node.Text == value)
+ {
+ return node;
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/ZeroLocalizationToolGUI/ZeroLocalizationToolGUI.csproj b/ZeroLocalizationToolGUI/ZeroLocalizationToolGUI.csproj
index 2e9694c..bbc4f59 100644
--- a/ZeroLocalizationToolGUI/ZeroLocalizationToolGUI.csproj
+++ b/ZeroLocalizationToolGUI/ZeroLocalizationToolGUI.csproj
@@ -33,6 +33,12 @@
4
+
+ ..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll
+
+
+ ..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll
+
@@ -46,14 +52,21 @@
+
+ Component
+
Form
MainForm.cs
+
+
+ MainForm.cs
+
ResXFileCodeGenerator
Resources.Designer.cs
@@ -63,6 +76,7 @@
True
Resources.resx
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/ZeroLocalizationToolGUI/packages.config b/ZeroLocalizationToolGUI/packages.config
new file mode 100644
index 0000000..ab5060a
--- /dev/null
+++ b/ZeroLocalizationToolGUI/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ZeroLocalizationToolShared/Modules/LocalizationParser.cs b/ZeroLocalizationToolShared/Modules/LocalizationParser.cs
index ee623d5..f0fc24f 100644
--- a/ZeroLocalizationToolShared/Modules/LocalizationParser.cs
+++ b/ZeroLocalizationToolShared/Modules/LocalizationParser.cs
@@ -516,7 +516,8 @@ void GetScope(Scope scope)
if (!foundKey)
{
- throw new LocalizedKeyNotFoundException(string.Format("Localized key not found in localization file."), keyPath);
+ //throw new LocalizedKeyNotFoundException(string.Format("Localized key not found in localization file."), keyPath);
+ Trace.WriteLine("Localized key not found in localization file.");
}
return keyToFind;