From 09768ae88bf4ceeddcc2a61a174f02c69c936302 Mon Sep 17 00:00:00 2001 From: Admin Date: Mon, 7 Dec 2020 14:56:10 -0600 Subject: [PATCH] Added a new form to allow the user to manage naming patterns. --- .vs/DataOrganizer/v16/.suo | Bin 145920 -> 139776 bytes DataOrganizer/DB.cs | 52 ++++ DataOrganizer/DataOrganizer.csproj | 9 + DataOrganizer/FileViewer.Designer.cs | 1 + DataOrganizer/FileViewer.cs | 2 + DataOrganizer/MainForm.Designer.cs | 12 +- DataOrganizer/MainForm.cs | 6 + .../NamingConventionManager.Designer.cs | 261 ++++++++++++++++++ DataOrganizer/NamingConventionManager.cs | 133 +++++++++ DataOrganizer/NamingConventionManager.resx | 120 ++++++++ 10 files changed, 595 insertions(+), 1 deletion(-) create mode 100644 DataOrganizer/NamingConventionManager.Designer.cs create mode 100644 DataOrganizer/NamingConventionManager.cs create mode 100644 DataOrganizer/NamingConventionManager.resx diff --git a/.vs/DataOrganizer/v16/.suo b/.vs/DataOrganizer/v16/.suo index 99fcc70521a748f68935d9a609a10a9c3359745d..bc8617d5568df79348593d1d0b26d5110e08d9b0 100644 GIT binary patch delta 4581 zcmZqp!qISqV}cE%_(WTA)=UNl2Cd18oZ=e`{xEVTH243wb>{1DB+z!1a0z!1y8z!1m4z#z!Lz>vVez#zcDz>tcjIgNpVApz5fPJYOt&jNDgWD!mkPEZI1fITE8R`OnCxFu7FjKcoEQQu%sD+09?&>p3tz%V@Fr zt9U)CCm9tdf7PvLl$l(rS3kK#PiC@!ehQ=1bLWV^FOi=Z9DC*h3>KQiw z3T9*4KfJ^|{zF8pb4dbF1W@V5#BQz)1tzF67yCORGR-TU2 z>;+qGr+*t~K2_ar%j03A?R3i0FRuQ!LK%1d z=B#uvMjoTE-~f<$uFk;$n|+c>7&k@yK-fO{K(fQ+dr5ZF?VK3bGBGesR%8;M?%>Sm zGM&Yl(PnysGo!DP|}wdVn#R!HOYMc?{_c$smU?lrf|-z@5dAJK0f5n9+K&V!8D6<8F*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rt09=uQT1=oe5+rDI844Im z7#N_*59BgXtHYc@kHHw+k}7A&WXKa?NM)!1w{AcRKn5@{gusJV5Eis945OR5maF4Go&zp0uvO+xgeJ@WHJ;plrUs6Br|9;C@|BjN@pkon_A3} z2@Y^828fT`oqRk&Y21aui2;&!Kv4h^1qFHGL}^e7$^hbvGcZgxoTLlq^Dr<>-grVB z&KCvqg(pwx6@!Zjfy9m|qwo!t5PWHnnTt)eVRnLAE&<>Kp3YFjkjRjW<|b(dhUxh# zjN+P(pft*m%8<*D#E`>K$>7P5$B@R5kEWc5fnmBK6BELXictNNK8v8ZQvoW@9}Esm zQ1In3q%#yxp4clX3v-+;0|NtQ#4^5-oxCVo&Qgy7-A#@RB@87DMGTqXBv8VT3QqB$ zJPb0?#ns0X6s%d38(*)To~6d9Fm$s0LE-10*zA?g?0R)$|5!#o@30oXF8t|Bgf=J_f#hDyS;Au0Ru+9 z=?USCT+=@oF=|cUAOul$24w1Vu2M#*iU3nak;xX%Ri;;%G9H`$p^Q<2F=M)+A>;1p z0qKkalaJg}nx10Lcnhqn%93&4|50|`y9vSU02_DYo{) z$xt2NVzizhvYuc}n%wxhck-ndNuW}m zZF@!-;|%8M3sM?92F=L?%DFU^Kblg3k6hKBh(N(-fEt#1k3(8HyOv!7XG^eG6^$ zPYzrtI(g1T6@lH726k~Od-I-UoczCg@?QJN4f6~(A6VqTIN9i8%%qDVlM5~cY(F5v zY2r`Ak%IB{U|q=j*lMainForm.cs + + Form + + + NamingConventionManager.cs + Form @@ -106,6 +112,9 @@ MainForm.cs + + NamingConventionManager.cs + ProfileManager.cs diff --git a/DataOrganizer/FileViewer.Designer.cs b/DataOrganizer/FileViewer.Designer.cs index 4183c38..1f853ce 100644 --- a/DataOrganizer/FileViewer.Designer.cs +++ b/DataOrganizer/FileViewer.Designer.cs @@ -327,6 +327,7 @@ // // MoveModifiedFilesButton // + this.MoveModifiedFilesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.MoveModifiedFilesButton.Enabled = false; this.MoveModifiedFilesButton.Location = new System.Drawing.Point(10, 216); this.MoveModifiedFilesButton.Name = "MoveModifiedFilesButton"; diff --git a/DataOrganizer/FileViewer.cs b/DataOrganizer/FileViewer.cs index 9ec7f00..d285047 100644 --- a/DataOrganizer/FileViewer.cs +++ b/DataOrganizer/FileViewer.cs @@ -61,6 +61,8 @@ namespace DataOrganizer UpdateStatusStrip($"Moving {file.Name} to default location '{profile.DefaultNewContentFolder}'."); if(!File.Exists(newFilePath)) File.Copy(file.FullPath, newFilePath); } + + UpdateStatusStrip($"Finished copying file(s) Copied {files.Count} file(s)."); } private void CommitScanResultsButton_Click(object sender, EventArgs e) diff --git a/DataOrganizer/MainForm.Designer.cs b/DataOrganizer/MainForm.Designer.cs index f6833c8..46d971a 100644 --- a/DataOrganizer/MainForm.Designer.cs +++ b/DataOrganizer/MainForm.Designer.cs @@ -35,6 +35,7 @@ this.MainLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteDBToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.manageNamingPatternsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MainMenu.SuspendLayout(); this.SuspendLayout(); // @@ -55,7 +56,8 @@ // this.FileMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.ManageProfilesFileMainMenu, - this.FileManagerFileMainMenu}); + this.FileManagerFileMainMenu, + this.manageNamingPatternsToolStripMenuItem}); this.FileMainMenu.Name = "FileMainMenu"; this.FileMainMenu.Size = new System.Drawing.Size(54, 29); this.FileMainMenu.Text = "&File"; @@ -103,6 +105,13 @@ this.deleteDBToolStripMenuItem.Text = "&Delete DB"; this.deleteDBToolStripMenuItem.Click += new System.EventHandler(this.deleteDBToolStripMenuItem_Click); // + // manageNamingPatternsToolStripMenuItem + // + this.manageNamingPatternsToolStripMenuItem.Name = "manageNamingPatternsToolStripMenuItem"; + this.manageNamingPatternsToolStripMenuItem.Size = new System.Drawing.Size(314, 34); + this.manageNamingPatternsToolStripMenuItem.Text = "Manage &Naming Patterns"; + this.manageNamingPatternsToolStripMenuItem.Click += new System.EventHandler(this.manageNamingPatternsToolStripMenuItem_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); @@ -130,6 +139,7 @@ private System.Windows.Forms.ToolStripMenuItem FileManagerFileMainMenu; private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deleteDBToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem manageNamingPatternsToolStripMenuItem; } } diff --git a/DataOrganizer/MainForm.cs b/DataOrganizer/MainForm.cs index 13e08a1..3cd25a1 100644 --- a/DataOrganizer/MainForm.cs +++ b/DataOrganizer/MainForm.cs @@ -34,5 +34,11 @@ namespace DataOrganizer var db = new DB(); db.DeleteDatabase(); } + + private void manageNamingPatternsToolStripMenuItem_Click(object sender, EventArgs e) + { + var form = new NamingConventionManager(); + form.ShowDialog(); + } } } diff --git a/DataOrganizer/NamingConventionManager.Designer.cs b/DataOrganizer/NamingConventionManager.Designer.cs new file mode 100644 index 0000000..585a965 --- /dev/null +++ b/DataOrganizer/NamingConventionManager.Designer.cs @@ -0,0 +1,261 @@ +namespace DataOrganizer +{ + partial class NamingConventionManager + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.MainLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.MainPanel = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.NamingConventionPatternsComboBox = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.RegexTextBox = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.NameTextBox = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.ExampleTextBox = new System.Windows.Forms.TextBox(); + this.AddUpdateButton = new System.Windows.Forms.Button(); + this.PatternIdLabel = new System.Windows.Forms.Label(); + this.DeleteButton = new System.Windows.Forms.Button(); + this.RegexResultsTextBox = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.RegexTestTextBox = new System.Windows.Forms.TextBox(); + this.TestRegexButton = new System.Windows.Forms.Button(); + this.MainLayoutPanel.SuspendLayout(); + this.MainPanel.SuspendLayout(); + this.SuspendLayout(); + // + // MainLayoutPanel + // + this.MainLayoutPanel.ColumnCount = 1; + this.MainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.MainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.MainLayoutPanel.Controls.Add(this.MainPanel, 0, 0); + this.MainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.MainLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.MainLayoutPanel.Name = "MainLayoutPanel"; + this.MainLayoutPanel.RowCount = 1; + this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.MainLayoutPanel.Size = new System.Drawing.Size(800, 450); + this.MainLayoutPanel.TabIndex = 0; + // + // MainPanel + // + this.MainPanel.Controls.Add(this.TestRegexButton); + this.MainPanel.Controls.Add(this.RegexTestTextBox); + this.MainPanel.Controls.Add(this.label5); + this.MainPanel.Controls.Add(this.RegexResultsTextBox); + this.MainPanel.Controls.Add(this.DeleteButton); + this.MainPanel.Controls.Add(this.PatternIdLabel); + this.MainPanel.Controls.Add(this.AddUpdateButton); + this.MainPanel.Controls.Add(this.ExampleTextBox); + this.MainPanel.Controls.Add(this.label4); + this.MainPanel.Controls.Add(this.NameTextBox); + this.MainPanel.Controls.Add(this.label3); + this.MainPanel.Controls.Add(this.RegexTextBox); + this.MainPanel.Controls.Add(this.label2); + this.MainPanel.Controls.Add(this.NamingConventionPatternsComboBox); + this.MainPanel.Controls.Add(this.label1); + this.MainPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.MainPanel.Location = new System.Drawing.Point(3, 3); + this.MainPanel.Name = "MainPanel"; + this.MainPanel.Size = new System.Drawing.Size(794, 444); + this.MainPanel.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(15, 6); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(114, 20); + this.label1.TabIndex = 0; + this.label1.Text = "Select Pattern:"; + // + // NamingConventionPatternsComboBox + // + this.NamingConventionPatternsComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.NamingConventionPatternsComboBox.FormattingEnabled = true; + this.NamingConventionPatternsComboBox.Location = new System.Drawing.Point(13, 36); + this.NamingConventionPatternsComboBox.Name = "NamingConventionPatternsComboBox"; + this.NamingConventionPatternsComboBox.Size = new System.Drawing.Size(182, 28); + this.NamingConventionPatternsComboBox.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(13, 170); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(59, 20); + this.label2.TabIndex = 2; + this.label2.Text = "Regex:"; + // + // RegexTextBox + // + this.RegexTextBox.Location = new System.Drawing.Point(13, 200); + this.RegexTextBox.Multiline = true; + this.RegexTextBox.Name = "RegexTextBox"; + this.RegexTextBox.Size = new System.Drawing.Size(776, 96); + this.RegexTextBox.TabIndex = 3; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(13, 104); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(111, 20); + this.label3.TabIndex = 4; + this.label3.Text = "Pattern Name:"; + // + // NameTextBox + // + this.NameTextBox.Location = new System.Drawing.Point(13, 134); + this.NameTextBox.Name = "NameTextBox"; + this.NameTextBox.Size = new System.Drawing.Size(182, 26); + this.NameTextBox.TabIndex = 5; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(13, 306); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(361, 20); + this.label4.TabIndex = 6; + this.label4.Text = "Example Text (I.E. What the Pattern Matches On):"; + // + // ExampleTextBox + // + this.ExampleTextBox.Location = new System.Drawing.Point(13, 336); + this.ExampleTextBox.Name = "ExampleTextBox"; + this.ExampleTextBox.Size = new System.Drawing.Size(357, 26); + this.ExampleTextBox.TabIndex = 7; + // + // AddUpdateButton + // + this.AddUpdateButton.Enabled = false; + this.AddUpdateButton.Location = new System.Drawing.Point(612, 388); + this.AddUpdateButton.Name = "AddUpdateButton"; + this.AddUpdateButton.Size = new System.Drawing.Size(173, 47); + this.AddUpdateButton.TabIndex = 8; + this.AddUpdateButton.Text = "Insert New Pattern"; + this.AddUpdateButton.UseVisualStyleBackColor = true; + // + // PatternIdLabel + // + this.PatternIdLabel.AutoSize = true; + this.PatternIdLabel.Location = new System.Drawing.Point(13, 74); + this.PatternIdLabel.Name = "PatternIdLabel"; + this.PatternIdLabel.Size = new System.Drawing.Size(116, 20); + this.PatternIdLabel.TabIndex = 9; + this.PatternIdLabel.Text = "Pattern ID: N/A"; + // + // DeleteButton + // + this.DeleteButton.Enabled = false; + this.DeleteButton.Location = new System.Drawing.Point(13, 388); + this.DeleteButton.Name = "DeleteButton"; + this.DeleteButton.Size = new System.Drawing.Size(107, 47); + this.DeleteButton.TabIndex = 10; + this.DeleteButton.Text = "Delete"; + this.DeleteButton.UseVisualStyleBackColor = true; + this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click); + // + // RegexResultsTextBox + // + this.RegexResultsTextBox.Location = new System.Drawing.Point(220, 9); + this.RegexResultsTextBox.Multiline = true; + this.RegexResultsTextBox.Name = "RegexResultsTextBox"; + this.RegexResultsTextBox.ReadOnly = true; + this.RegexResultsTextBox.Size = new System.Drawing.Size(565, 181); + this.RegexResultsTextBox.TabIndex = 11; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(405, 306); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(94, 20); + this.label5.TabIndex = 12; + this.label5.Text = "Regex Test:"; + // + // RegexTestTextBox + // + this.RegexTestTextBox.Location = new System.Drawing.Point(505, 303); + this.RegexTestTextBox.Name = "RegexTestTextBox"; + this.RegexTestTextBox.Size = new System.Drawing.Size(280, 26); + this.RegexTestTextBox.TabIndex = 13; + // + // TestRegexButton + // + this.TestRegexButton.Location = new System.Drawing.Point(681, 335); + this.TestRegexButton.Name = "TestRegexButton"; + this.TestRegexButton.Size = new System.Drawing.Size(104, 37); + this.TestRegexButton.TabIndex = 14; + this.TestRegexButton.Text = "Test"; + this.TestRegexButton.UseVisualStyleBackColor = true; + this.TestRegexButton.Click += new System.EventHandler(this.TestRegexButton_Click); + // + // NamingConventionManager + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.MainLayoutPanel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "NamingConventionManager"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Manage Naming Convention Patterns"; + this.MainLayoutPanel.ResumeLayout(false); + this.MainPanel.ResumeLayout(false); + this.MainPanel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel MainLayoutPanel; + private System.Windows.Forms.Panel MainPanel; + private System.Windows.Forms.ComboBox NamingConventionPatternsComboBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox RegexTextBox; + private System.Windows.Forms.TextBox NameTextBox; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox ExampleTextBox; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button AddUpdateButton; + private System.Windows.Forms.Label PatternIdLabel; + private System.Windows.Forms.Button DeleteButton; + private System.Windows.Forms.TextBox RegexResultsTextBox; + private System.Windows.Forms.Button TestRegexButton; + private System.Windows.Forms.TextBox RegexTestTextBox; + private System.Windows.Forms.Label label5; + } +} \ No newline at end of file diff --git a/DataOrganizer/NamingConventionManager.cs b/DataOrganizer/NamingConventionManager.cs new file mode 100644 index 0000000..1a0fce7 --- /dev/null +++ b/DataOrganizer/NamingConventionManager.cs @@ -0,0 +1,133 @@ +using System; +using System.Windows.Forms; +using System.Text.RegularExpressions; + +namespace DataOrganizer +{ + public partial class NamingConventionManager : Form + { + private int ActivePatternId { get; set; } + + public NamingConventionManager() + { + InitializeComponent(); + + var db = new DB(); + NamingConventionPatternsComboBox.Items.Add("Add New Pattern"); + NamingConventionPatternsComboBox.SelectedIndex = 0; + + foreach(var pattern in db.GetNamingConventions()) + { + NamingConventionPatternsComboBox.Items.Add(pattern.Name); + } + + NamingConventionPatternsComboBox.SelectedIndexChanged += NamingConventionPatternsComboBox_SelectedIndexChanged; + NameTextBox.TextChanged += TextChanged; + RegexTextBox.TextChanged += TextChanged; + ExampleTextBox.TextChanged += TextChanged; + RegexTestTextBox.TextChanged += RegexTestTextBox_TextChanged; + ActivePatternId = 0; + } + + private void RegexTestTextBox_TextChanged(object sender, EventArgs e) + { + if (RegexTestTextBox.Text.Length > 0 && RegexTextBox.Text.Length > 0) TestRegexButton.Enabled = true; + else TestRegexButton.Enabled = false; + } + + private new void TextChanged(object sender, EventArgs e) + { + if (RegexTestTextBox.Text.Length > 0 && RegexTextBox.Text.Length > 0) TestRegexButton.Enabled = true; + else TestRegexButton.Enabled = false; + + if (NameTextBox.Text.Length > 0 && RegexTextBox.Text.Length > 0 && ExampleTextBox.Text.Length > 0) + { + AddUpdateButton.Enabled = true; + } + else + { + AddUpdateButton.Enabled = false; + } + } + + private void NamingConventionPatternsComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (NamingConventionPatternsComboBox.SelectedIndex == 0) + { + ClearForm(); + return; + } + else AddUpdateButton.Text = $"Update Convention"; + + var db = new DB(); + var convention = db.GetNamingConventionByName(NamingConventionPatternsComboBox.Text); + + NameTextBox.Text = convention.Name; + RegexTextBox.Text = convention.Regex; + ExampleTextBox.Text = convention.ExampleText; + ActivePatternId = convention.Id; + + PatternIdLabel.Text = $"Pattern ID: {ActivePatternId}"; + DeleteButton.Enabled = true; + } + + private void ClearForm() + { + NameTextBox.Text = string.Empty; + RegexTextBox.Text = string.Empty; + ExampleTextBox.Text = string.Empty; + ActivePatternId = 0; + AddUpdateButton.Enabled = false; + AddUpdateButton.Text = "Insert Pattern"; + PatternIdLabel.Text = "Pattern ID: N/A"; + DeleteButton.Enabled = false; + } + + private void DeleteButton_Click(object sender, EventArgs e) + { + var result = MessageBox.Show($"Are you sure you want to delete the '{NamingConventionPatternsComboBox.Text}'? This will reset all folder groups and files that use this pattern to 'None'.", + $"Delete '{NamingConventionPatternsComboBox.Text}'", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); + + if(result == DialogResult.Yes) + { + var db = new DB(); + db.DeleteNamingConvention(ActivePatternId); + + NamingConventionPatternsComboBox.SelectedIndex = 0; + } + } + + private void TestRegexButton_Click(object sender, EventArgs e) + { + try + { + var regex = new Regex(RegexTextBox.Text); + var testString = RegexTestTextBox.Text; + + var match = regex.Match(testString); + + if (!match.Success) + { + RegexResultsTextBox.Text = $"Input: {testString}{Environment.NewLine}No matches found."; + return; + } + + RegexResultsTextBox.Text = string.Empty; + + foreach (Group m in match.Groups) + { + if(m.Name == "0") + { + RegexResultsTextBox.Text += $"Input: {m.Value}{Environment.NewLine}"; + continue; + } + RegexResultsTextBox.Text += $"{m.Name}: {m.Value}{Environment.NewLine}"; + } + } + catch(Exception ex) + { + RegexResultsTextBox.Text = $"Error:{Environment.NewLine}{ex.Message}"; + } + } + } +} diff --git a/DataOrganizer/NamingConventionManager.resx b/DataOrganizer/NamingConventionManager.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DataOrganizer/NamingConventionManager.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file