diff --git a/nppRandomStringGenerator/Forms/ConfigAndGenerate.cs b/nppRandomStringGenerator/Forms/ConfigAndGenerate.cs index 1a0d6dd..e93c9fd 100644 --- a/nppRandomStringGenerator/Forms/ConfigAndGenerate.cs +++ b/nppRandomStringGenerator/Forms/ConfigAndGenerate.cs @@ -51,7 +51,7 @@ public void LoadSettings() { foreach (nppRandomStringGenerator.Storage.Models.ConfigItem configitem in settings.settings.ConfigItems) { - if (configitem == null) { continue; } + if (configitem == null || configitem.Name.StartsWith("Quick")) { continue; } Control ctrl = this.Controls.Find(configitem.Name, true).FirstOrDefault(); @@ -93,6 +93,8 @@ private void SaveSettings() { foreach (nppRandomStringGenerator.Storage.Models.ConfigItem configitem in settings.settings.ConfigItems) { + if (configitem.Name.StartsWith("Quick")) { continue; } + Control ctrl = this.Controls.Find(configitem.Name, true).FirstOrDefault(); if (ctrl != null && ctrl.Name.StartsWith("NumericUpDown")) @@ -132,14 +134,6 @@ private void SaveSettings() private async void ButtonGenerate_Click(Object sender, EventArgs e) { - //if (this.RadioButtonInline.Checked && NumericUpDownQuantity.Value > 5000) - //{ - // if (MessageBox.Show($"It will take allot of time to process {this.NumericUpDownQuantity.Value} lines and Notepad++ will be frozen until it is done.\nFor example it will take 20 seconds to process 5000 lines on a AMD Ryzen 9 5900. Are you sure you want to start this process?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No) - // { - // return; - // } - //} - this.Cursor = Cursors.WaitCursor; this.AvailableChars = ""; diff --git a/nppRandomStringGenerator/Forms/InsertGuid.Designer.cs b/nppRandomStringGenerator/Forms/InsertGuid.Designer.cs new file mode 100644 index 0000000..66f3dc6 --- /dev/null +++ b/nppRandomStringGenerator/Forms/InsertGuid.Designer.cs @@ -0,0 +1,211 @@ +namespace nppRandomStringGenerator.Forms +{ + partial class InsertGuid + { + /// + /// 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.panel1 = new System.Windows.Forms.Panel(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.radioX = new System.Windows.Forms.RadioButton(); + this.radioP = new System.Windows.Forms.RadioButton(); + this.radioB = new System.Windows.Forms.RadioButton(); + this.radioD = new System.Windows.Forms.RadioButton(); + this.radioN = new System.Windows.Forms.RadioButton(); + this.panel2 = new System.Windows.Forms.Panel(); + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.radioUE = new System.Windows.Forms.RadioButton(); + this.panel1.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.groupBox1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(426, 173); + this.panel1.TabIndex = 0; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.radioUE); + this.groupBox1.Controls.Add(this.radioX); + this.groupBox1.Controls.Add(this.radioP); + this.groupBox1.Controls.Add(this.radioB); + this.groupBox1.Controls.Add(this.radioD); + this.groupBox1.Controls.Add(this.radioN); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(402, 159); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Format"; + // + // radioX + // + this.radioX.AutoSize = true; + this.radioX.Location = new System.Drawing.Point(6, 113); + this.radioX.Name = "radioX"; + this.radioX.Size = new System.Drawing.Size(392, 17); + this.radioX.TabIndex = 4; + this.radioX.TabStop = true; + this.radioX.Text = "X: {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}"; + this.radioX.UseVisualStyleBackColor = true; + // + // radioP + // + this.radioP.AutoSize = true; + this.radioP.Location = new System.Drawing.Point(6, 90); + this.radioP.Name = "radioP"; + this.radioP.Size = new System.Drawing.Size(251, 17); + this.radioP.TabIndex = 3; + this.radioP.TabStop = true; + this.radioP.Text = "P: (00000000-0000-0000-0000-000000000000)"; + this.radioP.UseVisualStyleBackColor = true; + // + // radioB + // + this.radioB.AutoSize = true; + this.radioB.Location = new System.Drawing.Point(6, 67); + this.radioB.Name = "radioB"; + this.radioB.Size = new System.Drawing.Size(251, 17); + this.radioB.TabIndex = 2; + this.radioB.TabStop = true; + this.radioB.Text = "B: {00000000-0000-0000-0000-000000000000}"; + this.radioB.UseVisualStyleBackColor = true; + // + // radioD + // + this.radioD.AutoSize = true; + this.radioD.Location = new System.Drawing.Point(6, 44); + this.radioD.Name = "radioD"; + this.radioD.Size = new System.Drawing.Size(247, 17); + this.radioD.TabIndex = 1; + this.radioD.TabStop = true; + this.radioD.Text = "D: 00000000-0000-0000-0000-000000000000"; + this.radioD.UseVisualStyleBackColor = true; + // + // radioN + // + this.radioN.AutoSize = true; + this.radioN.Location = new System.Drawing.Point(6, 21); + this.radioN.Name = "radioN"; + this.radioN.Size = new System.Drawing.Size(231, 17); + this.radioN.TabIndex = 0; + this.radioN.TabStop = true; + this.radioN.Text = "N: 00000000000000000000000000000000"; + this.radioN.UseVisualStyleBackColor = true; + // + // panel2 + // + this.panel2.Controls.Add(this.btnOK); + this.panel2.Controls.Add(this.btnCancel); + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(0, 173); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(426, 29); + this.panel2.TabIndex = 0; + // + // btnOK + // + this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnOK.Location = new System.Drawing.Point(348, 3); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 1; + this.btnOK.Text = "OK"; + this.btnOK.UseVisualStyleBackColor = true; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(267, 3); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 0; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // radioUE + // + this.radioUE.AutoSize = true; + this.radioUE.Location = new System.Drawing.Point(6, 136); + this.radioUE.Name = "radioUE"; + this.radioUE.Size = new System.Drawing.Size(262, 17); + this.radioUE.TabIndex = 5; + this.radioUE.TabStop = true; + this.radioUE.Text = "UE: (ID=00000000000000000000000000000000)"; + this.radioUE.UseVisualStyleBackColor = true; + // + // InsertGuid + // + this.AcceptButton = this.btnOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(426, 202); + this.Controls.Add(this.panel1); + this.Controls.Add(this.panel2); + this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximumSize = new System.Drawing.Size(442, 241); + this.MinimumSize = new System.Drawing.Size(442, 241); + this.Name = "InsertGuid"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Insert Guid"; + this.panel1.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.panel2.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Button btnOK; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.RadioButton radioX; + private System.Windows.Forms.RadioButton radioP; + private System.Windows.Forms.RadioButton radioB; + private System.Windows.Forms.RadioButton radioD; + private System.Windows.Forms.RadioButton radioN; + private System.Windows.Forms.RadioButton radioUE; + } +} \ No newline at end of file diff --git a/nppRandomStringGenerator/Forms/InsertGuid.cs b/nppRandomStringGenerator/Forms/InsertGuid.cs new file mode 100644 index 0000000..db572cf --- /dev/null +++ b/nppRandomStringGenerator/Forms/InsertGuid.cs @@ -0,0 +1,80 @@ +using Kbg.NppPluginNET.PluginInfrastructure; +using nppRandomStringGenerator.Storage; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace nppRandomStringGenerator.Forms +{ + public partial class InsertGuid : Form + { + public Settings settings { get; set; } + private IScintillaGateway Editor; + private INotepadPPGateway Notepad; + + public InsertGuid() + { + InitializeComponent(); + this.Editor = new ScintillaGateway(PluginBase.GetCurrentScintilla()); + this.Notepad = new NotepadPPGateway(); + } + + public void LoadSettings() + { + foreach (nppRandomStringGenerator.Storage.Models.ConfigItem configitem in settings.settings.ConfigItems) + { + if (configitem == null || !configitem.Name.StartsWith("Quick")) { continue; } + + Control ctrl = this.Controls.Find(configitem.Value, true).FirstOrDefault(); + + if (ctrl != null) + { + RadioButton radio = ctrl as RadioButton; + radio.Checked = true; + } + } + } + + private void SaveSettings() + { + foreach (nppRandomStringGenerator.Storage.Models.ConfigItem configitem in settings.settings.ConfigItems) + { + if (configitem == null || !configitem.Name.StartsWith("Quick")) { continue; } + + foreach (Control ctrl in this.groupBox1.Controls) + { + if (ctrl is RadioButton radio && radio.Checked) + { + configitem.Value = radio.Name; + break; + } + } + } + + settings.Save(); + } + + private void btnOK_Click(object sender, EventArgs e) + { + if (radioB.Checked) { this.Editor.InsertText(this.Editor.GetCurrentPos(), Guid.NewGuid().ToString("B")); } + if (radioD.Checked) { this.Editor.InsertText(this.Editor.GetCurrentPos(), Guid.NewGuid().ToString("D")); } + if (radioN.Checked) { this.Editor.InsertText(this.Editor.GetCurrentPos(), Guid.NewGuid().ToString("N")); } + if (radioX.Checked) { this.Editor.InsertText(this.Editor.GetCurrentPos(), Guid.NewGuid().ToString("X")); } + if (radioUE.Checked) { this.Editor.InsertText(this.Editor.GetCurrentPos(), "(ID=" + Guid.NewGuid().ToString("N") + ")"); } + + this.SaveSettings(); + this.Close(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/nppRandomStringGenerator/Forms/InsertGuid.resx b/nppRandomStringGenerator/Forms/InsertGuid.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/nppRandomStringGenerator/Forms/InsertGuid.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 diff --git a/nppRandomStringGenerator/Main.cs b/nppRandomStringGenerator/Main.cs index b92acf6..be132fb 100644 --- a/nppRandomStringGenerator/Main.cs +++ b/nppRandomStringGenerator/Main.cs @@ -1,8 +1,10 @@ -using System.Drawing; +using System; +using System.Drawing; using System.IO; using System.Windows.Forms; using Kbg.NppPluginNET.PluginInfrastructure; using NppPluginNET.Utils; +using nppRandomStringGenerator.Forms; using nppRandomStringGenerator.Storage; namespace Kbg.NppPluginNET @@ -14,6 +16,7 @@ class Main static ConfigAndGenerate ConfigAndGenerate = null; static About About = null; static Settings MySettings = null; + static InsertGuid mInsertGuid = null; public static bool isShuttingDown = false; @@ -32,8 +35,25 @@ public static void OnNotification(ScNotification notification) internal static void CommandMenuInit() { - PluginBase.SetCommand(0, "Config && Generate", myDockableDialog ); - PluginBase.SetCommand(1, "&About", AboutnppRandomStringGenerator); + PluginBase.SetCommand(0, "Config && Generate", myDockableDialog); + PluginBase.SetCommand(1, "Insert GUID at cursor", myDockableGuidDialog); + PluginBase.SetCommand(2, "&About", AboutnppRandomStringGenerator); + } + + private static void myDockableGuidDialog() + { + MySettings = new Settings(); + MySettings.Load(); + + mInsertGuid = new InsertGuid + { + settings = MySettings + }; + mInsertGuid.LoadSettings(); + mInsertGuid.ShowDialog(); + + mInsertGuid = null; + } internal static void SetToolBarIcons() diff --git a/nppRandomStringGenerator/Properties/AssemblyInfo.cs b/nppRandomStringGenerator/Properties/AssemblyInfo.cs index 388ea71..a69e248 100644 --- a/nppRandomStringGenerator/Properties/AssemblyInfo.cs +++ b/nppRandomStringGenerator/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("1.9.6")] -[assembly: AssemblyFileVersion("1.9.6")] +[assembly: AssemblyVersion("1.9.7")] +[assembly: AssemblyFileVersion("1.9.7")] diff --git a/nppRandomStringGenerator/Storage/Settings.cs b/nppRandomStringGenerator/Storage/Settings.cs index 96d1f89..0ae1038 100644 --- a/nppRandomStringGenerator/Storage/Settings.cs +++ b/nppRandomStringGenerator/Storage/Settings.cs @@ -5,7 +5,6 @@ using System.Windows.Forms; using nppRandomStringGenerator.Storage.Models; using System.Collections.Generic; -using System.Security.Cryptography; namespace nppRandomStringGenerator.Storage { @@ -46,7 +45,7 @@ public void Load(bool reset = false) settings = DeserializeIni(FilePath); - if (settings.Appversion != "1.9.6") + if (settings.Appversion != "1.9.7") { SettingsModel defaults = DeserializeIniFromString(Resources.nppRandomStringGeneratorSettings); @@ -58,7 +57,7 @@ public void Load(bool reset = false) } } settings.Appname = "nppRandomStringGenerator"; - settings.Appversion = "1.9.6"; + settings.Appversion = "1.9.7"; } //else //{ diff --git a/nppRandomStringGenerator/Storage/nppRandomStringGeneratorSettings.ini b/nppRandomStringGenerator/Storage/nppRandomStringGeneratorSettings.ini index d8f2b04..ba83db8 100644 --- a/nppRandomStringGenerator/Storage/nppRandomStringGeneratorSettings.ini +++ b/nppRandomStringGenerator/Storage/nppRandomStringGeneratorSettings.ini @@ -26,4 +26,5 @@ CheckboxMTA=True NumericUpDownGUIDQuantity=8 ComboBoxGUIDFormat=D TabControl1=0 -CheckboxDarkMode=True \ No newline at end of file +CheckboxDarkMode=True +QuickGuidFormat=radioD diff --git a/nppRandomStringGenerator/nppRandomStringGenerator.csproj b/nppRandomStringGenerator/nppRandomStringGenerator.csproj index d7b3ed3..ecefd4e 100644 --- a/nppRandomStringGenerator/nppRandomStringGenerator.csproj +++ b/nppRandomStringGenerator/nppRandomStringGenerator.csproj @@ -88,6 +88,12 @@ About.cs + + Form + + + InsertGuid.cs + @@ -136,6 +142,9 @@ ConfigAndGenerate.cs + + InsertGuid.cs + ResXFileCodeGenerator Resources.Designer.cs