diff --git a/PCK-Studio/Forms/Editor/COLEditor.Designer.cs b/PCK-Studio/Forms/Editor/COLEditor.Designer.cs index 8f38b52c..567a1b98 100644 --- a/PCK-Studio/Forms/Editor/COLEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/COLEditor.Designer.cs @@ -60,6 +60,8 @@ namespace PckStudio.Forms.Editor this.tabControl = new MetroFramework.Controls.MetroTabControl(); this.underwaterTab = new System.Windows.Forms.TabPage(); this.fogTab = new System.Windows.Forms.TabPage(); + this.metroTextBox1 = new MetroFramework.Controls.MetroTextBox(); + this.metroLabel2 = new MetroFramework.Controls.MetroLabel(); this.metroPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.blueUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.greenUpDown)).BeginInit(); @@ -77,6 +79,8 @@ namespace PckStudio.Forms.Editor // // metroPanel1 // + this.metroPanel1.Controls.Add(this.metroTextBox1); + this.metroPanel1.Controls.Add(this.metroLabel2); this.metroPanel1.Controls.Add(this.setColorBtn); this.metroPanel1.Controls.Add(this.blueUpDown); this.metroPanel1.Controls.Add(this.greenUpDown); @@ -189,16 +193,16 @@ namespace PckStudio.Forms.Editor // // // - this.colorTextbox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image"))); + this.colorTextbox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image1"))); this.colorTextbox.CustomButton.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("resource.ImeMode"))); - this.colorTextbox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location"))); + this.colorTextbox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location1"))); this.colorTextbox.CustomButton.Name = ""; - this.colorTextbox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size"))); + this.colorTextbox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size1"))); this.colorTextbox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; - this.colorTextbox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex"))); + this.colorTextbox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex1"))); this.colorTextbox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; this.colorTextbox.CustomButton.UseSelectable = true; - this.colorTextbox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible"))); + this.colorTextbox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible1"))); this.colorTextbox.Lines = new string[0]; resources.ApplyResources(this.colorTextbox, "colorTextbox"); this.colorTextbox.MaxLength = 32767; @@ -336,6 +340,42 @@ namespace PckStudio.Forms.Editor resources.ApplyResources(this.fogTab, "fogTab"); this.fogTab.Name = "fogTab"; // + // metroTextBox1 + // + // + // + // + this.metroTextBox1.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image"))); + this.metroTextBox1.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location"))); + this.metroTextBox1.CustomButton.Name = ""; + this.metroTextBox1.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size"))); + this.metroTextBox1.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.metroTextBox1.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex"))); + this.metroTextBox1.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.metroTextBox1.CustomButton.UseSelectable = true; + this.metroTextBox1.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible"))); + this.metroTextBox1.Lines = new string[0]; + resources.ApplyResources(this.metroTextBox1, "metroTextBox1"); + this.metroTextBox1.MaxLength = 32767; + this.metroTextBox1.Name = "metroTextBox1"; + this.metroTextBox1.PasswordChar = '\0'; + this.metroTextBox1.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.metroTextBox1.SelectedText = ""; + this.metroTextBox1.SelectionLength = 0; + this.metroTextBox1.SelectionStart = 0; + this.metroTextBox1.ShortcutsEnabled = true; + this.metroTextBox1.Theme = MetroFramework.MetroThemeStyle.Dark; + this.metroTextBox1.UseSelectable = true; + this.metroTextBox1.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.metroTextBox1.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + this.metroTextBox1.TextChanged += new System.EventHandler(this.metroTextBox1_TextChanged); + // + // metroLabel2 + // + resources.ApplyResources(this.metroLabel2, "metroLabel2"); + this.metroLabel2.Name = "metroLabel2"; + this.metroLabel2.Theme = MetroFramework.MetroThemeStyle.Dark; + // // COLEditor // resources.ApplyResources(this, "$this"); @@ -395,5 +435,7 @@ namespace PckStudio.Forms.Editor private MetroFramework.Controls.MetroLabel metroLabel1; private MetroFramework.Controls.MetroContextMenu ColorContextMenu; private ToolStripMenuItem restoreOriginalColorToolStripMenuItem; + private MetroFramework.Controls.MetroTextBox metroTextBox1; + private MetroFramework.Controls.MetroLabel metroLabel2; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Editor/COLEditor.cs b/PCK-Studio/Forms/Editor/COLEditor.cs index dd6f6892..098f645b 100644 --- a/PCK-Studio/Forms/Editor/COLEditor.cs +++ b/PCK-Studio/Forms/Editor/COLEditor.cs @@ -21,6 +21,11 @@ namespace PckStudio.Forms.Editor private readonly PCKFile.FileData _file; + List colorCache = new List(); + List waterCache = new List(); + List underwaterCache = new List(); + List fogCache = new List(); + public COLEditor(PCKFile.FileData file) { InitializeComponent(); @@ -42,6 +47,7 @@ namespace PckStudio.Forms.Editor TreeNode tn = new TreeNode(obj.name); tn.Tag = entry != null ? entry : obj; colorTreeView.Nodes.Add(tn); + colorCache.Add(tn); } foreach (var obj in colourfile.waterEntries) { @@ -49,12 +55,15 @@ namespace PckStudio.Forms.Editor TreeNode tn = new TreeNode(obj.name); tn.Tag = entry != null ? entry : obj; waterTreeView.Nodes.Add(tn); + waterCache.Add(tn); TreeNode tnB = new TreeNode(obj.name); tnB.Tag = entry != null ? entry : obj; underwaterTreeView.Nodes.Add(tnB); + underwaterCache.Add(tnB); TreeNode tnC = new TreeNode(obj.name); tnC.Tag = entry != null ? entry : obj; fogTreeView.Nodes.Add(tnC); + fogCache.Add(tnC); } } @@ -366,5 +375,76 @@ namespace PckStudio.Forms.Editor pictureBox1.BackColor = Color.FromArgb(0xff << 24 | (int)colorInfoC.color_c); } } + + private void metroTextBox1_TextChanged(object sender, EventArgs e) + { + // Some code in this function is modified code from this StackOverflow answer - MattNL + //https://stackoverflow.com/questions/8260322/filter-a-treeview-with-a-textbox-in-a-c-sharp-winforms-app + + //blocks repainting tree until all objects loaded + colorTreeView.BeginUpdate(); + colorTreeView.Nodes.Clear(); + waterTreeView.BeginUpdate(); + waterTreeView.Nodes.Clear(); + underwaterTreeView.BeginUpdate(); + underwaterTreeView.Nodes.Clear(); + fogTreeView.BeginUpdate(); + fogTreeView.Nodes.Clear(); + if (!string.IsNullOrEmpty(metroTextBox1.Text)) + { + foreach (TreeNode _node in colorCache) + { + if (_node.Text.ToLower().Contains(metroTextBox1.Text.ToLower())) + { + colorTreeView.Nodes.Add((TreeNode)_node.Clone()); + } + } + foreach (TreeNode _node in waterCache) + { + if (_node.Text.ToLower().Contains(metroTextBox1.Text.ToLower())) + { + waterTreeView.Nodes.Add((TreeNode)_node.Clone()); + } + } + foreach (TreeNode _node in underwaterCache) + { + if (_node.Text.ToLower().Contains(metroTextBox1.Text.ToLower())) + { + underwaterTreeView.Nodes.Add((TreeNode)_node.Clone()); + } + } + foreach (TreeNode _node in fogCache) + { + if (_node.Text.ToLower().Contains(metroTextBox1.Text.ToLower())) + { + fogTreeView.Nodes.Add((TreeNode)_node.Clone()); + } + } + } + else + { + foreach (TreeNode _node in colorCache) + { + colorTreeView.Nodes.Add((TreeNode)_node.Clone()); + } + foreach (TreeNode _node in waterCache) + { + waterTreeView.Nodes.Add((TreeNode)_node.Clone()); + } + foreach (TreeNode _node in underwaterCache) + { + underwaterTreeView.Nodes.Add((TreeNode)_node.Clone()); + } + foreach (TreeNode _node in fogCache) + { + fogTreeView.Nodes.Add((TreeNode)_node.Clone()); + } + } + //enables redrawing tree after all objects have been added + colorTreeView.EndUpdate(); + waterTreeView.EndUpdate(); + underwaterTreeView.EndUpdate(); + fogTreeView.EndUpdate(); + } } } diff --git a/PCK-Studio/Forms/Editor/COLEditor.resx b/PCK-Studio/Forms/Editor/COLEditor.resx index 41b1eb83..3ca373b8 100644 --- a/PCK-Studio/Forms/Editor/COLEditor.resx +++ b/PCK-Studio/Forms/Editor/COLEditor.resx @@ -117,14 +117,78 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + 113, 1 + + + 21, 21 + + + + 1 + + + False + + + 101, 27 + + + 135, 23 + + + 24 + + + metroTextBox1 + + + MetroFramework.Controls.MetroTextBox, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a + + + metroPanel1 + + + 2 + + + True + + + 62, 27 + + + 46, 19 + + + 23 + + + Filter: + + + metroLabel2 + + + MetroFramework.Controls.MetroLabel, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a + + + metroPanel1 + + + 3 + 400, 290 125, 23 - 22 @@ -141,7 +205,7 @@ metroPanel1 - 2 + 4 400, 397 @@ -162,7 +226,7 @@ metroPanel1 - 3 + 5 400, 371 @@ -183,7 +247,7 @@ metroPanel1 - 4 + 6 400, 345 @@ -204,7 +268,7 @@ metroPanel1 - 5 + 7 400, 319 @@ -228,7 +292,7 @@ metroPanel1 - 6 + 8 True @@ -258,7 +322,7 @@ metroPanel1 - 7 + 9 True @@ -285,7 +349,7 @@ metroPanel1 - 8 + 10 True @@ -312,7 +376,7 @@ metroPanel1 - 9 + 11 True @@ -339,25 +403,24 @@ metroPanel1 - 10 + 12 - - + NoControl - + 103, 1 - + 21, 21 - + 1 - + False @@ -379,7 +442,7 @@ metroPanel1 - 11 + 13 True @@ -406,7 +469,7 @@ metroPanel1 - 12 + 14 378, 92 @@ -427,7 +490,7 @@ metroPanel1 - 13 + 15 Fill @@ -459,6 +522,28 @@ False + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4yMfEgaZUAAADfSURBVDhPYxg8 + QLt++3yTGbf/Fm599P/Nh49wfPXxq/+rTt37f+Dak/8gOSBgAGEMANIMxGBFyAasPf/0v8GE8//z1t8C + y4HU4DIALIluwLpLL+HiMANAGKoNAWASCavv/n/57gPcgOvP3oENOXj7NViOoAFGU6791+k4ghWD5Aga + QCyGakMAkODcU89R/I8Ng9TgNADk14dPn/8/c+kqVgySgwUqVBsCwAx49urN/zsPHmPFIDmaGvAXJInN + 38gYasBfqDYE0K7dOn/Wvut/sfkdGYPUgJI9VNuAAwYGAGn6yvdevWgPAAAAAElFTkSuQmCC + + + + 98, 22 + + + Save + + + 37, 20 + + + File + 20, 60 @@ -483,67 +568,15 @@ 1 - - 37, 20 - - - File - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4yMfEgaZUAAADfSURBVDhPYxg8 - QLt++3yTGbf/Fm599P/Nh49wfPXxq/+rTt37f+Dak/8gOSBgAGEMANIMxGBFyAasPf/0v8GE8//z1t8C - y4HU4DIALIluwLpLL+HiMANAGKoNAWASCavv/n/57gPcgOvP3oENOXj7NViOoAFGU6791+k4ghWD5Aga - QCyGakMAkODcU89R/I8Ng9TgNADk14dPn/8/c+kqVgySgwUqVBsCwAx49urN/zsPHmPFIDmaGvAXJInN - 38gYasBfqDYE0K7dOn/Wvut/sfkdGYPUgJI9VNuAAwYGAGn6yvdevWgPAAAAAElFTkSuQmCC - - - - 98, 22 - - - Save - - - waterTreeView - - - System.Windows.Forms.TreeView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - waterTab - - - 0 - - - 4, 38 - - - 320, 458 - - - 1 - - - Water - - - waterTab - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl - - - 1 - 125, 17 + + 186, 22 + + + Restore original color + 187, 26 @@ -563,7 +596,7 @@ No - 320, 458 + 320, 381 0 @@ -580,11 +613,29 @@ 0 - - 186, 22 + + 4, 38 - - Restore original color + + 320, 381 + + + 1 + + + Water + + + waterTab + + + System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabControl + + + 1 0, 0 @@ -628,6 +679,18 @@ 0 + + Fill + + + 0, 0 + + + 320, 381 + + + 0 + colorTreeView @@ -644,7 +707,7 @@ 4, 38 - 320, 458 + 320, 381 0 @@ -664,83 +727,14 @@ 0 - - Fill - - - 0, 0 - - - 320, 458 - - - 0 - - - colorTreeView - - - System.Windows.Forms.TreeView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - colorsTab - - - 0 - Top, Bottom, Left - - underwaterTab - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl - - - 2 - - - fogTab - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tabControl - - - 3 - - - 20, 83 - - - 328, 500 - - - 22 - - - tabControl - - - MetroFramework.Controls.MetroTabControl, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a - - - $this - - - 2 - 4, 38 - 320, 458 + 320, 381 2 @@ -764,7 +758,7 @@ 4, 38 - 320, 458 + 320, 381 3 @@ -784,6 +778,27 @@ 3 + + 23, 114 + + + 328, 423 + + + 22 + + + tabControl + + + MetroFramework.Controls.MetroTabControl, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a + + + $this + + + 2 + True