Added a new form to allow the user to manage naming patterns.
This commit is contained in:
@@ -328,6 +328,32 @@ namespace DataOrganizer
|
||||
return conventions;
|
||||
}
|
||||
|
||||
public Namingconvention GetNamingConventionByName(string name)
|
||||
{
|
||||
var query = @"SELECT name, example_text, pattern_id, regex FROM main.naming_pattern WHERE name = @Name";
|
||||
|
||||
using (var connection = new SqliteConnection(ConnectionString))
|
||||
{
|
||||
using (var command = new SqliteCommand(query, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("Name", name);
|
||||
connection.Open();
|
||||
|
||||
var reader = command.ExecuteReader();
|
||||
|
||||
reader.Read();
|
||||
|
||||
return new Namingconvention
|
||||
{
|
||||
Regex = reader["regex"].ToString(),
|
||||
Name = reader["name"].ToString(),
|
||||
ExampleText = reader["example_text"].ToString(),
|
||||
Id = Convert.ToInt32(reader["pattern_id"])
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetNamingPatternById(int id)
|
||||
{
|
||||
if (id == 0) return string.Empty;
|
||||
@@ -350,6 +376,32 @@ namespace DataOrganizer
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteNamingConvention(int id)
|
||||
{
|
||||
var query = @"UPDATE main.file SET pattern_override_id = 0 WHERE pattern_override_id = @ID";//@"DELETE FROM main.naming_pattern WHERE pattern_id = @Id";
|
||||
|
||||
using (var connection = new SqliteConnection(ConnectionString))
|
||||
{
|
||||
connection.Open();
|
||||
using (var transaction = connection.BeginTransaction())
|
||||
{
|
||||
using (var command = new SqliteCommand(query, connection, transaction))
|
||||
{
|
||||
command.Parameters.AddWithValue("ID", id);
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
query = @"UPDATE main.folder_root SET pattern_id = 0 WHERE pattern_id = @ID";
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
query = @"DELETE FROM main.naming_pattern WHERE pattern_id = @ID";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetRootPathById(int id)
|
||||
{
|
||||
var query = @"SELECT path FROM folder_root WHERE root_id = @ID";
|
||||
|
||||
@@ -91,6 +91,12 @@
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GlobalSettings.cs" />
|
||||
<Compile Include="NamingConventionManager.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NamingConventionManager.Designer.cs">
|
||||
<DependentUpon>NamingConventionManager.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProfileManager.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -106,6 +112,9 @@
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="NamingConventionManager.resx">
|
||||
<DependentUpon>NamingConventionManager.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ProfileManager.resx">
|
||||
<DependentUpon>ProfileManager.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
Generated
+1
@@ -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";
|
||||
|
||||
@@ -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)
|
||||
|
||||
Generated
+11
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
namespace DataOrganizer
|
||||
{
|
||||
partial class NamingConventionManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user