diff --git a/.gitignore b/.gitignore index ec28807..49e0efc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# Roslyn Path +roslyn/ + # Build results [Dd]ebug/ [Dd]ebugPublic/ diff --git a/LineSorter/Commands/UserSort/FormCreateFunc.Designer.cs b/LineSorter/Commands/UserSort/FormCreateFunc.Designer.cs index 7d2a514..556cb29 100644 --- a/LineSorter/Commands/UserSort/FormCreateFunc.Designer.cs +++ b/LineSorter/Commands/UserSort/FormCreateFunc.Designer.cs @@ -135,7 +135,7 @@ private void InitializeComponent() this.buttCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.buttCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttCancel.Location = new System.Drawing.Point(379, 211); + this.buttCancel.Location = new System.Drawing.Point(379, 476); this.buttCancel.Name = "buttCancel"; this.buttCancel.Size = new System.Drawing.Size(121, 23); this.buttCancel.TabIndex = 7; @@ -147,7 +147,7 @@ private void InitializeComponent() // this.buttCompile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttCompile.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttCompile.Location = new System.Drawing.Point(252, 211); + this.buttCompile.Location = new System.Drawing.Point(252, 476); this.buttCompile.Name = "buttCompile"; this.buttCompile.Size = new System.Drawing.Size(121, 23); this.buttCompile.TabIndex = 6; @@ -161,7 +161,7 @@ private void InitializeComponent() this.panelBack.Cursor = System.Windows.Forms.Cursors.IBeam; this.panelBack.Location = new System.Drawing.Point(15, 172); this.panelBack.Name = "panelBack"; - this.panelBack.Size = new System.Drawing.Size(485, 17); + this.panelBack.Size = new System.Drawing.Size(485, 282); this.panelBack.TabIndex = 11; this.panelBack.Click += new System.EventHandler(this.PanelBack_Click); // @@ -228,7 +228,7 @@ private void InitializeComponent() this.textAfter.Freezed = false; this.textAfter.Interval = 1000; this.textAfter.KeywordColor = System.Drawing.Color.SteelBlue; - this.textAfter.Location = new System.Drawing.Point(15, 189); + this.textAfter.Location = new System.Drawing.Point(15, 454); this.textAfter.Name = "textAfter"; this.textAfter.NumericColor = System.Drawing.Color.SpringGreen; this.textAfter.ReadOnly = true; @@ -266,26 +266,28 @@ private void InitializeComponent() this.textMain.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.textMain.AutoHeight = true; + this.textMain.AutoHeight = false; this.textMain.BackColor = System.Drawing.Color.White; this.textMain.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textMain.ClassColor = System.Drawing.Color.LightSeaGreen; this.textMain.CommentColor = System.Drawing.Color.YellowGreen; - this.textMain.Font = new System.Drawing.Font("Segoe UI", 9F); + this.textMain.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.textMain.Freezed = false; this.textMain.Interval = 1000; this.textMain.KeywordColor = System.Drawing.Color.SteelBlue; this.textMain.Location = new System.Drawing.Point(35, 172); - this.textMain.MaximumSize = new System.Drawing.Size(465, 200); + this.textMain.MaximumSize = new System.Drawing.Size(465, 300); this.textMain.MinimumSize = new System.Drawing.Size(465, 17); this.textMain.Name = "textMain"; this.textMain.NumericColor = System.Drawing.Color.MediumSeaGreen; - this.textMain.Size = new System.Drawing.Size(465, 17); + this.textMain.Size = new System.Drawing.Size(465, 282); this.textMain.StringColor = System.Drawing.Color.Firebrick; this.textMain.TabIndex = 5; this.textMain.TabSize = 4; - this.textMain.Text = ""; + this.textMain.Text = "// Your code here :)"; this.textMain.TextChanged += new System.EventHandler(this.TextMain_TextChanged); + this.textMain.Enter += new System.EventHandler(this.TextMain_Enter); + this.textMain.Leave += new System.EventHandler(this.TextMain_Leave); // // FormCreateFunc // @@ -293,7 +295,7 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttCancel; - this.ClientSize = new System.Drawing.Size(512, 246); + this.ClientSize = new System.Drawing.Size(512, 511); this.Controls.Add(this.labelEmpty); this.Controls.Add(this.comboLines); this.Controls.Add(this.textName); diff --git a/LineSorter/Commands/UserSort/FormCreateFunc.cs b/LineSorter/Commands/UserSort/FormCreateFunc.cs index ec918b6..5faee57 100644 --- a/LineSorter/Commands/UserSort/FormCreateFunc.cs +++ b/LineSorter/Commands/UserSort/FormCreateFunc.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Windows.Forms; using System.CodeDom.Compiler; +using Microsoft.CodeDom.Providers.DotNetCompilerPlatform; namespace LineSorter.Commands.UserSort { @@ -30,6 +31,7 @@ public partial class FormCreateFunc : Form private string[] DefaultAssemblies { get; } = new string[] { "System", "System.Xml", + "System.Web", // Ha-ha, funny joke, Roslyn... (vbc.exe doesn't work without this reference) "System.Core", "System.Data", "System.Net.Http", @@ -40,6 +42,30 @@ public partial class FormCreateFunc : Form }; public new IUserSort DialogResult { get; private set; } private static ResourceManager Manager { get; } = ResourceManager.Instance; + + private abstract class CompilerSettings : ICompilerSettings + { + public string CompilerFullPath { get; } + public int CompilerServerTimeToLive { get; } + + protected CompilerSettings(string CompilerName) + { + CompilerFullPath = Path.Combine(Path.GetDirectoryName(VSPackage.DllLocation), $"roslyn\\{CompilerName}.exe"); + CompilerServerTimeToLive = 0; + } + } + private class CSCompilerSettings : CompilerSettings + { + public static ICompilerSettings Instance { get; } = new CSCompilerSettings(); + + private CSCompilerSettings() : base("csc") { } + } + private class VBCompilerSettings : CompilerSettings + { + public static ICompilerSettings Instance { get; } = new VBCompilerSettings(); + + private VBCompilerSettings() : base("vbc") { } + } #endregion #region Init @@ -213,7 +239,7 @@ End Class CompilerParameters options = new CompilerParameters { GenerateExecutable = false, GenerateInMemory = false, OutputAssembly = $"{SavePath}{guid}.dll" }; foreach (string a in DefaultAssemblies.Select(x => x.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || x.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) ? x : $"{x}.dll")) options.ReferencedAssemblies.Add(a); - CompilerResults results = (isCSharp ? new Microsoft.CSharp.CSharpCodeProvider() : (CodeDomProvider)new Microsoft.VisualBasic.VBCodeProvider()).CompileAssemblyFromSource(options, resultCode); + CompilerResults results = (isCSharp ? new CSharpCodeProvider(CSCompilerSettings.Instance) : (CodeDomProvider)new VBCodeProvider(VBCompilerSettings.Instance)).CompileAssemblyFromSource(options, resultCode); if (results.Errors.HasErrors) ShowError(string.Join(Environment.NewLine + Environment.NewLine, results.Errors.Cast().Where(x => !x.IsWarning).Select(x => x.ErrorText))); else @@ -298,6 +324,9 @@ private void TextMain_TextChanged(object sender, EventArgs e) } private void FormCreateFunc_Load(object sender, EventArgs e) => ControlBox = ShowIcon = MinimizeBox = MaximizeBox = false; + + private void TextMain_Enter(object sender, EventArgs e) => AcceptButton = null; + private void TextMain_Leave(object sender, EventArgs e) => AcceptButton = buttCompile; #endregion } } diff --git a/LineSorter/Commands/UserSort/LangBox.cs b/LineSorter/Commands/UserSort/LangBox.cs index b3bd799..43a6d03 100644 --- a/LineSorter/Commands/UserSort/LangBox.cs +++ b/LineSorter/Commands/UserSort/LangBox.cs @@ -61,12 +61,12 @@ public Token(Regex Regex, Color Color, bool NeedWhitespace) public LangBox() { Tokens = new Token[] { - new Token(new Regex("namespace|unchecked|continue|delegate|checked|decimal|default|public|static|using|finally|foreach|double|object|params|return|sizeof|string|switch|typeof|unsafe|ushort|break|catch|const|false|fixed|float|sbyte|short|throw|ulong|while|bool|byte|case|char|else|goto|lock|long|null|true|uint|void|Void|for|int|new|out|ref|try|as|do|if|in|is|ByVal|ByRef|As|Of|Optional|ParamArray|If|Else|And|Or|Xor|False|True|And|AndAlso|Is|IsNot|Like|Mod|OrElse|Then|Sub|End|Function|Public|Return|CType"), KeywordColor, true), + new Token(new Regex("namespace|unchecked|continue|delegate|checked|decimal|default|public|static|using|finally|foreach|double|object|params|return|sizeof|string|switch|typeof|unsafe|ushort|break|catch|const|false|fixed|float|sbyte|short|throw|ulong|while|bool|byte|case|char|else|goto|lock|long|null|true|uint|void|Void|for|int|new|out|ref|try|as|do|if|in|is|ByVal|ByRef|As|Of|Optional|ParamArray|If|Else|And|Or|Xor|False|True|And|AndAlso|Is|IsNot|Like|Mod|OrElse|Then|Sub|End|Function|Public|Return|CType|var"), KeywordColor, true), new Token(new Regex("IEnumerable|Random|Boolean|Regex|Match|MatchCollection|Int16|Int32|Int64|Integer|String|Char|Decimal|Double|Float|Delegate|Action|Row"), ClassColor, true), new Token(new Regex("([-]+)?[0-9]+"), NumericColor, true), new Token(new Regex("\".*\""), StringColor, false), new Token(new Regex("@\".*\"", RegexOptions.Singleline), StringColor, false), - new Token(new Regex("/*.*/", RegexOptions.Singleline), CommentColor, false), + new Token(new Regex(@"/\*.*\*/", RegexOptions.Singleline), CommentColor, false), new Token(new Regex("//.*"), CommentColor, false), new Token(new Regex("''.*"), CommentColor, false) }; diff --git a/LineSorter/Images/Donate Button.png b/LineSorter/Images/Donate Button.png new file mode 100644 index 0000000..f6cc751 Binary files /dev/null and b/LineSorter/Images/Donate Button.png differ diff --git a/LineSorter/Images/VSPackageIcon.ico b/LineSorter/Images/VSPackageIcon.ico index 047a3cb..fff25f1 100644 Binary files a/LineSorter/Images/VSPackageIcon.ico and b/LineSorter/Images/VSPackageIcon.ico differ diff --git a/LineSorter/LineSorter.csproj b/LineSorter/LineSorter.csproj index 8a14d0b..5366e76 100644 --- a/LineSorter/LineSorter.csproj +++ b/LineSorter/LineSorter.csproj @@ -1,5 +1,6 @@  + 15.0 @@ -110,6 +111,46 @@ + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + Designer @@ -131,6 +172,9 @@ False .\LineSorter.Export.dll + + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + False @@ -285,6 +329,162 @@ true Always + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + + + Always + true + TextTemplatingFileGenerator @@ -319,6 +519,7 @@ + diff --git a/LineSorter/Options/OptionControl.Designer.cs b/LineSorter/Options/OptionControl.Designer.cs index bcdcfbe..bf00bfe 100644 --- a/LineSorter/Options/OptionControl.Designer.cs +++ b/LineSorter/Options/OptionControl.Designer.cs @@ -43,9 +43,11 @@ private void InitializeComponent() this.buttUse = new System.Windows.Forms.ToolStripMenuItem(); this.buttDelete = new System.Windows.Forms.ToolStripMenuItem(); this.groupLines = new System.Windows.Forms.GroupBox(); - this.checkRemove = new System.Windows.Forms.RadioButton(); - this.checkAsLine = new System.Windows.Forms.RadioButton(); this.checkAsMask = new System.Windows.Forms.RadioButton(); + this.checkAsLine = new System.Windows.Forms.RadioButton(); + this.checkRemove = new System.Windows.Forms.RadioButton(); + this.buttDonate = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); this.groupAutoLoad.SuspendLayout(); this.groupUserSort.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gridSorts)).BeginInit(); @@ -60,7 +62,7 @@ private void InitializeComponent() this.groupAutoLoad.Controls.Add(this.checkLoadOnCreate); this.groupAutoLoad.Controls.Add(this.checkLoadOnInit); this.groupAutoLoad.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.groupAutoLoad.Location = new System.Drawing.Point(3, 104); + this.groupAutoLoad.Location = new System.Drawing.Point(3, 136); this.groupAutoLoad.Name = "groupAutoLoad"; this.groupAutoLoad.Size = new System.Drawing.Size(332, 79); this.groupAutoLoad.TabIndex = 5; @@ -94,7 +96,7 @@ private void InitializeComponent() this.groupUserSort.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupUserSort.Controls.Add(this.gridSorts); - this.groupUserSort.Location = new System.Drawing.Point(3, 189); + this.groupUserSort.Location = new System.Drawing.Point(3, 221); this.groupUserSort.Name = "groupUserSort"; this.groupUserSort.Size = new System.Drawing.Size(332, 64); this.groupUserSort.TabIndex = 6; @@ -199,24 +201,24 @@ private void InitializeComponent() this.groupLines.Controls.Add(this.checkAsLine); this.groupLines.Controls.Add(this.checkRemove); this.groupLines.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.groupLines.Location = new System.Drawing.Point(3, 0); + this.groupLines.Location = new System.Drawing.Point(3, 32); this.groupLines.Name = "groupLines"; this.groupLines.Size = new System.Drawing.Size(332, 98); this.groupLines.TabIndex = 6; this.groupLines.TabStop = false; this.groupLines.Text = "Обработка пустых строк"; // - // checkRemove + // checkAsMask // - this.checkRemove.AutoSize = true; - this.checkRemove.Location = new System.Drawing.Point(7, 23); - this.checkRemove.Name = "checkRemove"; - this.checkRemove.Size = new System.Drawing.Size(151, 19); - this.checkRemove.TabIndex = 0; - this.checkRemove.TabStop = true; - this.checkRemove.Text = "Удалять пустые строки"; - this.checkRemove.UseVisualStyleBackColor = true; - this.checkRemove.CheckedChanged += new System.EventHandler(this.StateChanged); + this.checkAsMask.AutoSize = true; + this.checkAsMask.Location = new System.Drawing.Point(7, 73); + this.checkAsMask.Name = "checkAsMask"; + this.checkAsMask.Size = new System.Drawing.Size(283, 19); + this.checkAsMask.TabIndex = 2; + this.checkAsMask.TabStop = true; + this.checkAsMask.Text = "Использовать как маску (неподвижный якорь)"; + this.checkAsMask.UseVisualStyleBackColor = true; + this.checkAsMask.CheckedChanged += new System.EventHandler(this.StateChanged); // // checkAsLine // @@ -230,22 +232,50 @@ private void InitializeComponent() this.checkAsLine.UseVisualStyleBackColor = true; this.checkAsLine.CheckedChanged += new System.EventHandler(this.StateChanged); // - // checkAsMask + // checkRemove // - this.checkAsMask.AutoSize = true; - this.checkAsMask.Location = new System.Drawing.Point(7, 73); - this.checkAsMask.Name = "checkAsMask"; - this.checkAsMask.Size = new System.Drawing.Size(283, 19); - this.checkAsMask.TabIndex = 2; - this.checkAsMask.TabStop = true; - this.checkAsMask.Text = "Использовать как маску (неподвижный якорь)"; - this.checkAsMask.UseVisualStyleBackColor = true; - this.checkAsMask.CheckedChanged += new System.EventHandler(this.StateChanged); + this.checkRemove.AutoSize = true; + this.checkRemove.Location = new System.Drawing.Point(7, 23); + this.checkRemove.Name = "checkRemove"; + this.checkRemove.Size = new System.Drawing.Size(151, 19); + this.checkRemove.TabIndex = 0; + this.checkRemove.TabStop = true; + this.checkRemove.Text = "Удалять пустые строки"; + this.checkRemove.UseVisualStyleBackColor = true; + this.checkRemove.CheckedChanged += new System.EventHandler(this.StateChanged); + // + // buttDonate + // + this.buttDonate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttDonate.BackColor = System.Drawing.SystemColors.Highlight; + this.buttDonate.Cursor = System.Windows.Forms.Cursors.Hand; + this.buttDonate.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.buttDonate.ForeColor = System.Drawing.SystemColors.HighlightText; + this.buttDonate.Location = new System.Drawing.Point(252, 3); + this.buttDonate.Name = "buttDonate"; + this.buttDonate.Size = new System.Drawing.Size(83, 23); + this.buttDonate.TabIndex = 7; + this.buttDonate.Text = "Donate"; + this.buttDonate.UseVisualStyleBackColor = false; + this.buttDonate.Click += new System.EventHandler(this.ButtDonate_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI", 8.25F); + this.label1.Location = new System.Drawing.Point(7, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(169, 13); + this.label1.TabIndex = 8; + this.label1.Text = "Help LineSorter become better!)"; // // OptionControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScroll = true; + this.Controls.Add(this.label1); + this.Controls.Add(this.buttDonate); this.Controls.Add(this.groupLines); this.Controls.Add(this.groupUserSort); this.Controls.Add(this.groupAutoLoad); @@ -260,6 +290,7 @@ private void InitializeComponent() this.groupLines.ResumeLayout(false); this.groupLines.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -279,5 +310,7 @@ private void InitializeComponent() private System.Windows.Forms.RadioButton checkAsMask; private System.Windows.Forms.RadioButton checkAsLine; private System.Windows.Forms.RadioButton checkRemove; + private System.Windows.Forms.Button buttDonate; + private System.Windows.Forms.Label label1; } } diff --git a/LineSorter/Options/OptionControl.cs b/LineSorter/Options/OptionControl.cs index 74acf48..114ba9e 100644 --- a/LineSorter/Options/OptionControl.cs +++ b/LineSorter/Options/OptionControl.cs @@ -3,6 +3,7 @@ using System.Drawing; using LineSorter.Export; using LineSorter.Helpers; +using System.Diagnostics; using System.Globalization; using System.Windows.Forms; using System.Collections.Generic; @@ -61,6 +62,8 @@ static OptionControl() public OptionControl() { InitializeComponent(); + Dock = DockStyle.Fill; + Selected = new List(VSPackage.Loader.Settings.Loaded); checkLoadOnInit.Checked = VSPackage.Loader.Settings.LoadOnInit; checkLoadOnCreate.Checked = VSPackage.Loader.Settings.LoadOnCreate; @@ -188,7 +191,8 @@ private void ButtDelete_Click(object sender, System.EventArgs e) File.Delete(file); RefreshData(); } - #endregion + private void ButtDonate_Click(object sender, System.EventArgs e) => Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4L6Q6P7UAW7WS&source=url"); + #endregion } } diff --git a/LineSorter/app.config b/LineSorter/app.config index 2de4eb0..bd5ab62 100644 --- a/LineSorter/app.config +++ b/LineSorter/app.config @@ -8,4 +8,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/LineSorter/packages.config b/LineSorter/packages.config index d10210e..12f2a64 100644 --- a/LineSorter/packages.config +++ b/LineSorter/packages.config @@ -1,5 +1,6 @@  + diff --git a/LineSorter/source.extension.vsixmanifest b/LineSorter/source.extension.vsixmanifest index 4ec171c..6ef2609 100644 --- a/LineSorter/source.extension.vsixmanifest +++ b/LineSorter/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + LineSorter An extension that allows you to sort rows by different criteria Images\VSPackageIcon.ico