From 2e8711342209aac3fceec323a781d05f50460f5c Mon Sep 17 00:00:00 2001 From: CreepyCrafter24 <33260128+CreepyCrafter24@users.noreply.github.com> Date: Tue, 7 Apr 2020 18:54:22 +0200 Subject: [PATCH] Fix HTML Menu --- cashew/MainForm.Designer.cs | 225 +++--- cashew/MainForm.cs | 563 ++++++++------- cashew/MessageBox/MetroContextMenu.cs | 134 ++++ cashew/MessageBox/MetroMessageBox.cs | 282 ++++---- cashew/MessageBox/MetroMessageBoxControl.cs | 651 +++++++++--------- .../MessageBox/MetroMessageBoxProperties.cs | 19 +- cashew/Resources.Designer.cs | 35 +- cashew/Splash.Designer.cs | 9 +- 8 files changed, 1027 insertions(+), 891 deletions(-) create mode 100644 cashew/MessageBox/MetroContextMenu.cs diff --git a/cashew/MainForm.Designer.cs b/cashew/MainForm.Designer.cs index a05b953..5a7cdc3 100644 --- a/cashew/MainForm.Designer.cs +++ b/cashew/MainForm.Designer.cs @@ -1,11 +1,16 @@ -namespace cashew +using System.ComponentModel; +using System.Windows.Forms; +using ICSharpCode.TextEditor; +using MetroFramework.Controls; + +namespace cashew { partial class MainForm { /// /// Required designer variable. /// - private System.ComponentModel.IContainer components = null; + private IContainer components = null; /// /// Clean up any resources being used. @@ -64,7 +69,7 @@ this.nmtext = new MetroFramework.Controls.MetroLabel(); this.csSaveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.csOpenFileDialog = new System.Windows.Forms.OpenFileDialog(); - //this.htmlOptionsMenu = new MetroFramework.Controls.MetroContextMenu(this.components); + this.htmlOptionsMenu = new MetroFramework.Controls.MetroContextMenu(this.components); this.hTMLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.hTMLStructureSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.linkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -144,7 +149,7 @@ this.htmlSep.SuspendLayout(); this.pythontab.SuspendLayout(); this.infotab.SuspendLayout(); - //this.htmlOptionsMenu.SuspendLayout(); + this.htmlOptionsMenu.SuspendLayout(); this.SuspendLayout(); // // languageTabControl @@ -610,14 +615,14 @@ // // htmlOptionsMenu // - /*this.htmlOptionsMenu.DropShadowEnabled = false; + this.htmlOptionsMenu.DropShadowEnabled = false; this.htmlOptionsMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.hTMLToolStripMenuItem, this.javaScriptToolStripMenuItem, this.cSSToolStripMenuItem, this.pHPToolStripMenuItem }); this.htmlOptionsMenu.Name = "metroContextMenu1"; - this.htmlOptionsMenu.Size = new System.Drawing.Size(127, 92);*/ + this.htmlOptionsMenu.Size = new System.Drawing.Size(127, 92); // // hTMLToolStripMenuItem // @@ -1192,115 +1197,115 @@ this.htmlSep.ResumeLayout(false); this.pythontab.ResumeLayout(false); this.infotab.ResumeLayout(false); - //this.htmlOptionsMenu.ResumeLayout(false); + this.htmlOptionsMenu.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion - private MetroFramework.Controls.MetroTabControl languageTabControl; - private MetroFramework.Controls.MetroTabPage cstab; - private MetroFramework.Controls.MetroTabPage infotab; - private MetroFramework.Controls.MetroToggle nightmodeToggle; - private MetroFramework.Controls.MetroLabel nmtext; - private System.Windows.Forms.SaveFileDialog csSaveFileDialog; - private System.Windows.Forms.OpenFileDialog csOpenFileDialog; - private MetroFramework.Controls.MetroTabPage htmltab; - private MetroFramework.Controls.MetroLabel infoPanel; - private System.Windows.Forms.SplitContainer htmlSep; - private System.Windows.Forms.WebBrowser htmldisplay; - private MetroFramework.Controls.MetroLabel htmltitle; - //private MetroFramework.Controls.MetroContextMenu htmlOptionsMenu; - private System.Windows.Forms.ToolStripMenuItem hTMLToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem hTMLStructureSetupToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem linkToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem imageToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tableToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem listsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem javaScriptToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cSSToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem pHPToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem headingsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem heading1h1ToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem heading2h2ToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem heading3h3ToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem heading4h4ToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem heading5h5ToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem heading6h6ToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boldbToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem underlineuToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem italiciToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem deleteddelToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem subscriptedSubToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem superscriptedsupToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tableFormatSetupToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tableHeadingthToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem newRowtrToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem newHorizontalItemtdToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem orderedListSetupolToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem unorderedListSetupulToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem listItemliToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem javaStructureSetupToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem functionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem alertBoxToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem timeoutToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem randomNumberToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cSSStructureSetupToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cSSCustomizeTagToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cSSCustomTagPropertiesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem backgroundToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem backgroundAttachmentToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem backgroundColorToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem backgroundImageToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem backgroundPositionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem backgroundRepeatToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem2; - private System.Windows.Forms.ToolStripMenuItem fontToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sizeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem weightToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem directionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem lineHeightToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem letterSpacingToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem alignToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem decorationToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem indentToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem shadowToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem transformToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem wordspacingToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem pHPStructureSetupToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem3; - private MetroFramework.Controls.MetroTile htmlOptionsTile; - private MetroFramework.Controls.MetroTile htmlRefreshTile; - private System.Windows.Forms.SaveFileDialog htmlSaveFileDialog; - private System.Windows.Forms.OpenFileDialog htmlOpenFileDialog; - private MetroFramework.Controls.MetroTile htmlLoad; - private MetroFramework.Controls.MetroTile htmlSave; - private MetroFramework.Controls.MetroProgressSpinner htmlLoadIndicator; - private MetroFramework.Controls.MetroToggle htmlUpdateToggle; - private MetroFramework.Controls.MetroLabel htmlLiveLabel; - private MetroFramework.Controls.MetroPanel livehider; - private MetroFramework.Controls.MetroPanel nightmodehide; - private System.Windows.Forms.ToolStripMenuItem centercenterToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem paragraphpToolStripMenuItem; - private MetroFramework.Controls.MetroTabPage pythontab; - private MetroFramework.Controls.MetroTile pythonSave; - private MetroFramework.Controls.MetroTile pythonRun; - private MetroFramework.Controls.MetroTile pythonOpen; - private System.Windows.Forms.OpenFileDialog pythonOpenFileDialog; - private System.Windows.Forms.SaveFileDialog pythonSaveFileDialog; - private MetroFramework.Controls.MetroTile cseditrun; - private MetroFramework.Controls.MetroTile cseditsave; - private MetroFramework.Controls.MetroTile cseditref; - private MetroFramework.Controls.MetroTile cseditopen; - private MetroFramework.Controls.MetroPanel csediterrorpanel; - private MetroFramework.Controls.MetroLabel csediterrors; - private ICSharpCode.TextEditor.TextEditorControl cseditCode; - private ICSharpCode.TextEditor.TextEditorControl htmlText; - private ICSharpCode.TextEditor.TextEditorControl pythonCode; - private System.Windows.Forms.Timer buttonFix; + private MetroTabControl languageTabControl; + private MetroTabPage cstab; + private MetroTabPage infotab; + private MetroToggle nightmodeToggle; + private MetroLabel nmtext; + private SaveFileDialog csSaveFileDialog; + private OpenFileDialog csOpenFileDialog; + private MetroTabPage htmltab; + private MetroLabel infoPanel; + private SplitContainer htmlSep; + private WebBrowser htmldisplay; + private MetroLabel htmltitle; + private MetroFramework.Controls.MetroContextMenu htmlOptionsMenu; + private ToolStripMenuItem hTMLToolStripMenuItem; + private ToolStripMenuItem hTMLStructureSetupToolStripMenuItem; + private ToolStripMenuItem linkToolStripMenuItem; + private ToolStripMenuItem imageToolStripMenuItem; + private ToolStripMenuItem textToolStripMenuItem; + private ToolStripMenuItem tableToolStripMenuItem; + private ToolStripMenuItem listsToolStripMenuItem; + private ToolStripMenuItem javaScriptToolStripMenuItem; + private ToolStripMenuItem cSSToolStripMenuItem; + private ToolStripMenuItem pHPToolStripMenuItem; + private ToolStripMenuItem headingsToolStripMenuItem; + private ToolStripMenuItem heading1h1ToolStripMenuItem; + private ToolStripMenuItem heading2h2ToolStripMenuItem; + private ToolStripMenuItem heading3h3ToolStripMenuItem; + private ToolStripMenuItem heading4h4ToolStripMenuItem; + private ToolStripMenuItem heading5h5ToolStripMenuItem; + private ToolStripMenuItem heading6h6ToolStripMenuItem; + private ToolStripMenuItem boldbToolStripMenuItem; + private ToolStripMenuItem underlineuToolStripMenuItem; + private ToolStripMenuItem italiciToolStripMenuItem; + private ToolStripMenuItem deleteddelToolStripMenuItem; + private ToolStripMenuItem subscriptedSubToolStripMenuItem; + private ToolStripMenuItem superscriptedsupToolStripMenuItem; + private ToolStripMenuItem tableFormatSetupToolStripMenuItem; + private ToolStripMenuItem tableHeadingthToolStripMenuItem; + private ToolStripMenuItem newRowtrToolStripMenuItem; + private ToolStripMenuItem newHorizontalItemtdToolStripMenuItem; + private ToolStripMenuItem orderedListSetupolToolStripMenuItem; + private ToolStripMenuItem unorderedListSetupulToolStripMenuItem; + private ToolStripMenuItem listItemliToolStripMenuItem; + private ToolStripMenuItem javaStructureSetupToolStripMenuItem; + private ToolStripMenuItem functionToolStripMenuItem; + private ToolStripMenuItem textToolStripMenuItem1; + private ToolStripMenuItem alertBoxToolStripMenuItem; + private ToolStripMenuItem timeoutToolStripMenuItem; + private ToolStripMenuItem randomNumberToolStripMenuItem; + private ToolStripMenuItem cSSStructureSetupToolStripMenuItem; + private ToolStripMenuItem cSSCustomizeTagToolStripMenuItem; + private ToolStripMenuItem cSSCustomTagPropertiesToolStripMenuItem; + private ToolStripMenuItem backgroundToolStripMenuItem; + private ToolStripMenuItem backgroundAttachmentToolStripMenuItem; + private ToolStripMenuItem backgroundColorToolStripMenuItem; + private ToolStripMenuItem backgroundImageToolStripMenuItem; + private ToolStripMenuItem backgroundPositionToolStripMenuItem; + private ToolStripMenuItem backgroundRepeatToolStripMenuItem; + private ToolStripMenuItem textToolStripMenuItem2; + private ToolStripMenuItem fontToolStripMenuItem; + private ToolStripMenuItem sizeToolStripMenuItem; + private ToolStripMenuItem weightToolStripMenuItem; + private ToolStripMenuItem colorToolStripMenuItem; + private ToolStripMenuItem directionToolStripMenuItem; + private ToolStripMenuItem lineHeightToolStripMenuItem; + private ToolStripMenuItem letterSpacingToolStripMenuItem; + private ToolStripMenuItem alignToolStripMenuItem; + private ToolStripMenuItem decorationToolStripMenuItem; + private ToolStripMenuItem indentToolStripMenuItem; + private ToolStripMenuItem shadowToolStripMenuItem; + private ToolStripMenuItem transformToolStripMenuItem; + private ToolStripMenuItem wordspacingToolStripMenuItem; + private ToolStripMenuItem pHPStructureSetupToolStripMenuItem; + private ToolStripMenuItem textToolStripMenuItem3; + private MetroTile htmlOptionsTile; + private MetroTile htmlRefreshTile; + private SaveFileDialog htmlSaveFileDialog; + private OpenFileDialog htmlOpenFileDialog; + private MetroTile htmlLoad; + private MetroTile htmlSave; + private MetroProgressSpinner htmlLoadIndicator; + private MetroToggle htmlUpdateToggle; + private MetroLabel htmlLiveLabel; + private MetroPanel livehider; + private MetroPanel nightmodehide; + private ToolStripMenuItem centercenterToolStripMenuItem; + private ToolStripMenuItem paragraphpToolStripMenuItem; + private MetroTabPage pythontab; + private MetroTile pythonSave; + private MetroTile pythonRun; + private MetroTile pythonOpen; + private OpenFileDialog pythonOpenFileDialog; + private SaveFileDialog pythonSaveFileDialog; + private MetroTile cseditrun; + private MetroTile cseditsave; + private MetroTile cseditref; + private MetroTile cseditopen; + private MetroPanel csediterrorpanel; + private MetroLabel csediterrors; + private TextEditorControl cseditCode; + private TextEditorControl htmlText; + private TextEditorControl pythonCode; + private Timer buttonFix; } } diff --git a/cashew/MainForm.cs b/cashew/MainForm.cs index 1bafdf0..13ef1da 100644 --- a/cashew/MainForm.cs +++ b/cashew/MainForm.cs @@ -1,15 +1,4 @@ -using CC_Functions.Misc; -using ICSharpCode.Decompiler; -using ICSharpCode.Decompiler.CSharp; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; -using IronPython.Hosting; -using MetroFramework; -using MetroFramework.Forms; -using MetroFramework.Interfaces; -using Microsoft.CSharp; -using Microsoft.Scripting.Hosting; -using System; +using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Drawing; @@ -21,7 +10,16 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Threading; using System.Windows.Forms; using System.Xml.Linq; -using ThreadState = System.Threading.ThreadState; +using CC_Functions.Misc; +using ICSharpCode.Decompiler; +using ICSharpCode.Decompiler.CSharp; +using ICSharpCode.TextEditor.Document; +using IronPython.Hosting; +using MetroFramework; +using MetroFramework.Forms; +using MetroFramework.Interfaces; +using Microsoft.CSharp; +using Microsoft.Scripting.Hosting; using MetroMessageBox = cashew.MessageBox.MetroMessageBox; #pragma warning disable IDE1006 @@ -30,13 +28,27 @@ namespace cashew { public partial class MainForm : MetroForm { + private void MainForm_FormClosed(object sender, FormClosedEventArgs e) + { + if (Directory.Exists(Path.Combine(Path.GetTempPath(), "Cashew"))) + Directory.Delete(Path.Combine(Path.GetTempPath(), "Cashew"), true); + } + #region General - private readonly ThreadState[] _runningStates = { ThreadState.Background, ThreadState.Running, ThreadState.StopRequested, ThreadState.WaitSleepJoin }; + + private readonly ThreadState[] _runningStates = + {ThreadState.Background, ThreadState.Running, ThreadState.StopRequested, ThreadState.WaitSleepJoin}; + private readonly IMetroControl[] _metroControls; private readonly Control[] _normalControls; private readonly ToolStripMenuItem[] _menuItems; private string[] _cseditcodel = new string[0]; - private string[] _cseditrefl = { "Microsoft.CSharp.dll", "System.dll", "System.Core.dll", "System.Data.dll", "System.Data.DataSetExtensions.dll", "System.Net.Http.dll", "System.Xml.dll", "System.Xml.Linq.dll" }; + + private string[] _cseditrefl = + { + "Microsoft.CSharp.dll", "System.dll", "System.Core.dll", "System.Data.dll", + "System.Data.DataSetExtensions.dll", "System.Net.Http.dll", "System.Xml.dll", "System.Xml.Linq.dll" + }; public MainForm() { @@ -44,20 +56,49 @@ namespace cashew { splash.Show(); InitializeComponent(); - _metroControls = new IMetroControl[] { nmtext, languageTabControl, cstab, infotab, nightmodeToggle, cseditopen, cseditrun, cseditsave, csediterrorpanel, csediterrors, cseditref, infoPanel, htmltab, htmltitle, htmlOptionsTile, /*htmlOptionsMenu, */htmlRefreshTile, htmlLoad, htmlSave, htmlLoadIndicator, htmlUpdateToggle, htmlLiveLabel, livehider, nightmodehide, pythontab, - pythonSave, pythonRun, pythonOpen}; - _normalControls = new Control[] { htmlSep, htmldisplay, cseditCode, pythonCode, htmlText }; - _menuItems = new[] { hTMLToolStripMenuItem, javaScriptToolStripMenuItem, cSSToolStripMenuItem, pHPToolStripMenuItem, hTMLStructureSetupToolStripMenuItem, javaStructureSetupToolStripMenuItem, cSSStructureSetupToolStripMenuItem, pHPStructureSetupToolStripMenuItem, linkToolStripMenuItem, imageToolStripMenuItem, textToolStripMenuItem, tableToolStripMenuItem, - listsToolStripMenuItem, functionToolStripMenuItem, textToolStripMenuItem1, alertBoxToolStripMenuItem, timeoutToolStripMenuItem, randomNumberToolStripMenuItem, cSSCustomizeTagToolStripMenuItem, cSSCustomTagPropertiesToolStripMenuItem, textToolStripMenuItem3, headingsToolStripMenuItem, boldbToolStripMenuItem, underlineuToolStripMenuItem, italiciToolStripMenuItem, - deleteddelToolStripMenuItem, subscriptedSubToolStripMenuItem, superscriptedsupToolStripMenuItem, tableFormatSetupToolStripMenuItem, tableHeadingthToolStripMenuItem, newHorizontalItemtdToolStripMenuItem, newRowtrToolStripMenuItem, orderedListSetupolToolStripMenuItem, unorderedListSetupulToolStripMenuItem, listItemliToolStripMenuItem, heading1h1ToolStripMenuItem, - heading2h2ToolStripMenuItem, heading3h3ToolStripMenuItem, heading4h4ToolStripMenuItem, heading5h5ToolStripMenuItem, heading6h6ToolStripMenuItem, textToolStripMenuItem2, backgroundToolStripMenuItem, backgroundRepeatToolStripMenuItem, backgroundPositionToolStripMenuItem, backgroundImageToolStripMenuItem, backgroundColorToolStripMenuItem, backgroundAttachmentToolStripMenuItem, - fontToolStripMenuItem, sizeToolStripMenuItem, weightToolStripMenuItem, colorToolStripMenuItem, directionToolStripMenuItem, lineHeightToolStripMenuItem, alignToolStripMenuItem, letterSpacingToolStripMenuItem, decorationToolStripMenuItem, indentToolStripMenuItem, shadowToolStripMenuItem, transformToolStripMenuItem, wordspacingToolStripMenuItem, centercenterToolStripMenuItem, - paragraphpToolStripMenuItem}; + _metroControls = new IMetroControl[] + { + nmtext, languageTabControl, cstab, infotab, nightmodeToggle, cseditopen, cseditrun, cseditsave, + csediterrorpanel, csediterrors, cseditref, infoPanel, htmltab, htmltitle, + htmlOptionsTile, /*htmlOptionsMenu, */htmlRefreshTile, htmlLoad, htmlSave, htmlLoadIndicator, + htmlUpdateToggle, htmlLiveLabel, livehider, nightmodehide, pythontab, + pythonSave, pythonRun, pythonOpen + }; + _normalControls = new Control[] {htmlSep, htmldisplay, cseditCode, pythonCode, htmlText}; + _menuItems = new[] + { + hTMLToolStripMenuItem, javaScriptToolStripMenuItem, cSSToolStripMenuItem, pHPToolStripMenuItem, + hTMLStructureSetupToolStripMenuItem, javaStructureSetupToolStripMenuItem, + cSSStructureSetupToolStripMenuItem, pHPStructureSetupToolStripMenuItem, linkToolStripMenuItem, + imageToolStripMenuItem, textToolStripMenuItem, tableToolStripMenuItem, + listsToolStripMenuItem, functionToolStripMenuItem, textToolStripMenuItem1, + alertBoxToolStripMenuItem, timeoutToolStripMenuItem, randomNumberToolStripMenuItem, + cSSCustomizeTagToolStripMenuItem, cSSCustomTagPropertiesToolStripMenuItem, textToolStripMenuItem3, + headingsToolStripMenuItem, boldbToolStripMenuItem, underlineuToolStripMenuItem, + italiciToolStripMenuItem, + deleteddelToolStripMenuItem, subscriptedSubToolStripMenuItem, superscriptedsupToolStripMenuItem, + tableFormatSetupToolStripMenuItem, tableHeadingthToolStripMenuItem, + newHorizontalItemtdToolStripMenuItem, newRowtrToolStripMenuItem, + orderedListSetupolToolStripMenuItem, unorderedListSetupulToolStripMenuItem, + listItemliToolStripMenuItem, heading1h1ToolStripMenuItem, + heading2h2ToolStripMenuItem, heading3h3ToolStripMenuItem, heading4h4ToolStripMenuItem, + heading5h5ToolStripMenuItem, heading6h6ToolStripMenuItem, textToolStripMenuItem2, + backgroundToolStripMenuItem, backgroundRepeatToolStripMenuItem, backgroundPositionToolStripMenuItem, + backgroundImageToolStripMenuItem, backgroundColorToolStripMenuItem, + backgroundAttachmentToolStripMenuItem, + fontToolStripMenuItem, sizeToolStripMenuItem, weightToolStripMenuItem, colorToolStripMenuItem, + directionToolStripMenuItem, lineHeightToolStripMenuItem, alignToolStripMenuItem, + letterSpacingToolStripMenuItem, decorationToolStripMenuItem, indentToolStripMenuItem, + shadowToolStripMenuItem, transformToolStripMenuItem, wordspacingToolStripMenuItem, + centercenterToolStripMenuItem, + paragraphpToolStripMenuItem + }; htmldisplay.DocumentText = htmlText.Text; metroToggle1_CheckedChanged(this, new EventArgs()); languageTabControl.SelectedTab = infotab; splash.Hide(); } + cseditCode.SetHighlighting("C#"); pythonCode.SetHighlighting("Python"); htmlText.SetHighlighting("HTML"); @@ -66,9 +107,11 @@ namespace cashew using (MemoryStream ms = new MemoryStream(Resources.IronPythonBCL)) using (ZipArchive ar = new ZipArchive(ms)) ar.ExtractToDirectory(Path.Combine(Path.GetTempPath(), "Cashew\\Python")); - - infoPanel.Text = infoPanel.Text.Replace("[PACKAGELIST]", string.Join("\r\n", XDocument.Parse(Resources.packages).Element("Project").Elements("ItemGroup").SelectMany(s => s.Elements("PackageReference")) - .Select(s => $"- {s.Attribute("Include").Value} {s.Attribute("Version").Value}").OrderBy(s => s))); + + infoPanel.Text = infoPanel.Text.Replace("[PACKAGELIST]", string.Join("\r\n", + XDocument.Parse(Resources.packages).Element("Project").Elements("ItemGroup") + .SelectMany(s => s.Elements("PackageReference")) + .Select(s => $"- {s.Attribute("Include").Value} {s.Attribute("Version").Value}").OrderBy(s => s))); } private void MAIN_Load(object sender, EventArgs e) => BringToFront(); @@ -85,11 +128,13 @@ namespace cashew Theme = MetroThemeStyle.Light; Style = MetroColorStyle.Blue; } + foreach (IMetroControl c in _metroControls) { c.Style = Style; c.Theme = Theme; } + foreach (Control c in _normalControls) { if (Theme == MetroThemeStyle.Dark) @@ -103,6 +148,7 @@ namespace cashew c.ForeColor = Color.White; } } + foreach (ToolStripMenuItem t in _menuItems) { if (Theme == MetroThemeStyle.Dark) @@ -116,13 +162,16 @@ namespace cashew t.ForeColor = Color.FromArgb(45, 137, 239); } } + Refresh(); } private void buttonFix_Tick(object sender, EventArgs e) { - pythonRun.Text = pythonScript != null && _runningStates.Contains(pythonScript.ThreadState) ? "Stop" : "Run"; - cseditrun.Text = csScript != null && _runningStates.Contains(csScript.ThreadState) ? "Stop" : "Run"; + pythonRun.Text = _pythonScript != null && _runningStates.Contains(_pythonScript.ThreadState) + ? "Stop" + : "Run"; + cseditrun.Text = _csScript != null && _runningStates.Contains(_csScript.ThreadState) ? "Stop" : "Run"; htmlOptionsTile.Enabled = htmlText.ActiveTextAreaControl.TextArea.SelectionManager.HasSomethingSelected; } @@ -130,180 +179,161 @@ namespace cashew #region CS - Thread csScript; - private void metroLabel2_Click(object sender, EventArgs e) - { - MetroMessageBox.Show(this, csediterrors.Text, "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error); - - } + private Thread _csScript; - private void metroPanel1_Click(object sender, EventArgs e) => MetroMessageBox.Show(this, csediterrors.Text, "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error); + private void metroLabel2_Click(object sender, EventArgs e) => MetroMessageBox.Show(this, csediterrors.Text, + "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error); + + private void metroPanel1_Click(object sender, EventArgs e) => MetroMessageBox.Show(this, csediterrors.Text, + "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error); private void cseditsave_Click(object sender, EventArgs e) { - if (csSaveFileDialog.ShowDialog() == DialogResult.OK) + if (csSaveFileDialog.ShowDialog() != DialogResult.OK) return; + try { - try + if (csSaveFileDialog.FilterIndex == 1) { - if (csSaveFileDialog.FilterIndex == 1) - { - if (cseditref.Text == "Code") - { - _cseditrefl = cseditCode.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); - } - else - { - _cseditcodel = cseditCode.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); - } - Stream s = File.OpenWrite(csSaveFileDialog.FileName); - new BinaryFormatter().Serialize(s, new string[][] { _cseditcodel, _cseditrefl }); - s.Dispose(); - } + if (cseditref.Text == "Code") + _cseditrefl = cseditCode.Text.Split(new[] {"\r\n"}, StringSplitOptions.None); else - { - compileCS(false, csSaveFileDialog.FilterIndex == 2, csSaveFileDialog.FileName); - //File.Copy(compileCS(false, csSaveFileDialog.FilterIndex == 2).PathToAssembly, csSaveFileDialog.FileName, true); - } + _cseditcodel = cseditCode.Text.Split(new[] {"\r\n"}, StringSplitOptions.None); + Stream s = File.OpenWrite(csSaveFileDialog.FileName); + new BinaryFormatter().Serialize(s, new[] {_cseditcodel, _cseditrefl}); + s.Dispose(); } - catch (Exception e1) + else { - MetroMessageBox.Show(this, e1.Message, "Failed to Save", MessageBoxButtons.OK, MessageBoxIcon.Error); + CompileCs(false, csSaveFileDialog.FilterIndex == 2, csSaveFileDialog.FileName); + //File.Copy(compileCS(false, csSaveFileDialog.FilterIndex == 2).PathToAssembly, csSaveFileDialog.FileName, true); } } + catch (Exception e1) + { + MetroMessageBox.Show(this, e1.Message, "Failed to Save", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } private void cseditrun_Click(object sender, EventArgs e) { - if ((csScript != null) && _runningStates.Contains(csScript.ThreadState)) - { - csScript.Abort(); - } + if (_csScript != null && _runningStates.Contains(_csScript.ThreadState)) + _csScript.Abort(); else - { try { - CompilerResults results = compileCS(); + CompilerResults results = CompileCs(); cseditrun.Text = "Stop"; - csScript = new Thread(() => + _csScript = new Thread(() => + { + try + { + _ = results.CompiledAssembly.EntryPoint.Invoke(null, null); + } + catch { try { - _ = results.CompiledAssembly.EntryPoint.Invoke(null, null); + _ = results.CompiledAssembly.EntryPoint.Invoke(null, new object[] {new string[0]}); } - catch + catch (Exception e1) { - try - { - _ = results.CompiledAssembly.EntryPoint.Invoke(null, new object[] { new string[0] }); - } - catch (Exception e1) - { - if (!e1.tryCast(out ThreadAbortException ex)) - Invoke((MethodInvoker)delegate () - { - MetroMessageBox.Show(this, e1.Message, "Execution Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); - }); - } + if (!e1.tryCast(out ThreadAbortException ex)) + Invoke((MethodInvoker) delegate + { + MetroMessageBox.Show(this, e1.Message, "Execution Failed", + MessageBoxButtons.OK, MessageBoxIcon.Error); + }); } - }); - csScript.Start(); + } + }); + _csScript.Start(); csediterrors.Text = "Ready"; } catch (Exception e1) { csediterrors.Text = e1.Message; } - } } - private CompilerResults compileCS(bool memory = true, bool library = false, string OF = "") + private CompilerResults CompileCs(bool memory = true, bool library = false, string of = "") { csediterrors.Text = ""; if (cseditref.Text == "Code") - { - _cseditrefl = cseditCode.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); - } + _cseditrefl = cseditCode.Text.Split(new[] {"\r\n"}, StringSplitOptions.None); else - { - _cseditcodel = cseditCode.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); - } + _cseditcodel = cseditCode.Text.Split(new[] {"\r\n"}, StringSplitOptions.None); + CompilerParameters parameters = new CompilerParameters { GenerateInMemory = memory, GenerateExecutable = !library }; - parameters.OutputAssembly = memory ? parameters.OutputAssembly : OF; + parameters.OutputAssembly = memory ? parameters.OutputAssembly : of; parameters.ReferencedAssemblies.AddRange(_cseditrefl); CompilerResults results; using (CSharpCodeProvider provider = new CSharpCodeProvider()) { results = provider.CompileAssemblyFromSource(parameters, string.Join("\r\n", _cseditcodel)); - if (results.Errors.HasErrors) - { - IEnumerable err = results.Errors.OfType(); - /*err.ToList().ForEach(s => + if (!results.Errors.HasErrors) return results; + IEnumerable err = results.Errors.OfType(); + /*err.ToList().ForEach(s => { TextMarker marker = new TextMarker(0, 5, TextMarkerType.WaveLine, Color.Red); cseditCode.Document.MarkerStrategy.AddMarker(marker); }); cseditCode.Update();*/ - throw new InvalidOperationException(string.Join("\r\n\r\n", - err.Select(s => "Error in line " + s.Line.ToString() + ": " + s.ErrorNumber + " - " + s.ErrorText).ToArray())); - } + throw new InvalidOperationException(string.Join("\r\n\r\n", + err.Select(s => "Error in line " + s.Line + ": " + s.ErrorNumber + " - " + s.ErrorText).ToArray())); } + return results; } private void cseditopen_Click(object sender, EventArgs e) { - if (csOpenFileDialog.ShowDialog() == DialogResult.OK) + if (csOpenFileDialog.ShowDialog() != DialogResult.OK) return; + try { - try + if (csOpenFileDialog.FilterIndex == 1) { - if (csOpenFileDialog.FilterIndex == 1) - { - Stream s = File.OpenRead(csOpenFileDialog.FileName); - string[][] tmp = (string[][])new BinaryFormatter().Deserialize(s); - s.Dispose(); - _cseditcodel = tmp[0]; - _cseditrefl = tmp[1]; - if (cseditref.Text == "References") - cseditCode.Text = string.Join("\r\n", _cseditcodel); - else - cseditCode.Text = string.Join("\r\n", _cseditrefl); - } - else - { - CSharpDecompiler decompiler = new CSharpDecompiler(csOpenFileDialog.FileName, new DecompilerSettings()); - _cseditcodel = decompiler.DecompileWholeModuleAsString().Split(new string[] { "\r\n" }, StringSplitOptions.None); - _cseditrefl = Assembly.LoadFrom(csOpenFileDialog.FileName).GetReferencedAssemblies().Where(s => !new string[] { "mscorlib" }.Contains(s.Name)) - .Select(s => string.IsNullOrWhiteSpace(s.CodeBase) ? (s.Name + ".dll") : s.CodeBase).ToArray(); - if (cseditref.Text == "References") - cseditCode.Text = string.Join("\r\n", _cseditcodel); - else - cseditCode.Text = string.Join("\r\n", _cseditrefl); - } + Stream s = File.OpenRead(csOpenFileDialog.FileName); + string[][] tmp = (string[][]) new BinaryFormatter().Deserialize(s); + s.Dispose(); + _cseditcodel = tmp[0]; + _cseditrefl = tmp[1]; + cseditCode.Text = string.Join("\r\n", cseditref.Text == "References" ? _cseditcodel : _cseditrefl); } - catch (Exception e1) + else { - Console.WriteLine(e1.ToString()); - MetroMessageBox.Show(this, e1.ToString(), "Failed to Load", MessageBoxButtons.OK, MessageBoxIcon.Error); + CSharpDecompiler decompiler = + new CSharpDecompiler(csOpenFileDialog.FileName, new DecompilerSettings()); + _cseditcodel = decompiler.DecompileWholeModuleAsString() + .Split(new[] {"\r\n"}, StringSplitOptions.None); + _cseditrefl = Assembly.LoadFrom(csOpenFileDialog.FileName).GetReferencedAssemblies() + .Where(s => !new[] {"mscorlib"}.Contains(s.Name)) + .Select(s => string.IsNullOrWhiteSpace(s.CodeBase) ? s.Name + ".dll" : s.CodeBase).ToArray(); + cseditCode.Text = string.Join("\r\n", cseditref.Text == "References" ? _cseditcodel : _cseditrefl); } } + catch (Exception e1) + { + Console.WriteLine(e1.ToString()); + MetroMessageBox.Show(this, e1.ToString(), "Failed to Load", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } private void cseditref_Click(object sender, EventArgs e) { if (cseditref.Text == "References") { - _cseditcodel = cseditCode.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); + _cseditcodel = cseditCode.Text.Split(new[] {"\r\n"}, StringSplitOptions.None); cseditCode.Text = string.Join("\r\n", _cseditrefl); cseditCode.Refresh(); cseditref.Text = "Code"; } else { - _cseditrefl = cseditCode.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None); + _cseditrefl = cseditCode.Text.Split(new[] {"\r\n"}, StringSplitOptions.None); cseditCode.Text = string.Join("\r\n", _cseditcodel); cseditCode.Refresh(); cseditref.Text = "References"; @@ -314,10 +344,10 @@ namespace cashew #region HTML - private Point sels = Point.Empty; - private Point sele = Point.Empty; - private bool htmlHasSelection = false; - private bool UpdateHTML = true; + private Point _sels = Point.Empty; + private Point _sele = Point.Empty; + private bool _htmlHasSelection; + private bool _updateHtml = true; private void htmldisplay_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { @@ -325,17 +355,16 @@ namespace cashew htmltitle.Text = htmldisplay.DocumentTitle; } - private void metroToggle2_CheckedChanged(object sender, EventArgs e) => UpdateHTML = htmlUpdateToggle.Checked; + private void metroToggle2_CheckedChanged(object sender, EventArgs e) => _updateHtml = htmlUpdateToggle.Checked; - private void htmldisplay_Navigating(object sender, WebBrowserNavigatingEventArgs e) => htmlLoadIndicator.Visible = true; + private void htmldisplay_Navigating(object sender, WebBrowserNavigatingEventArgs e) => + htmlLoadIndicator.Visible = true; private void HtmlText_TextChanged_1(object sender, EventArgs e) { - if (UpdateHTML) - { - htmldisplay.DocumentText = htmlText.Text; - htmltitle.Text = htmldisplay.DocumentTitle; - } + if (!_updateHtml) return; + htmldisplay.DocumentText = htmlText.Text; + htmltitle.Text = htmldisplay.DocumentTitle; } private void htmlRefreshTile_Click(object sender, EventArgs e) @@ -344,254 +373,264 @@ namespace cashew htmltitle.Text = htmldisplay.DocumentTitle; } - private void htmlOptionsTile_Click(object sender, EventArgs e) - { - //htmlOptionsMenu.Show(htmlOptionsTile.Location); - } + private void htmlOptionsTile_Click(object sender, EventArgs e) => + htmlOptionsMenu.Show(htmlOptionsTile.Location); private void htmlOptionsTile_MouseEnter(object sender, EventArgs e) { - htmlHasSelection = htmlText.ActiveTextAreaControl.TextArea.SelectionManager.HasSomethingSelected; - if (htmlHasSelection) - { - ISelection sel = htmlText.ActiveTextAreaControl.SelectionManager.SelectionCollection[0]; - sels.Y = sel.StartPosition.Line; - sels.X = sel.StartPosition.Column; - sele.Y = sel.EndPosition.Line; - sele.X = sel.EndPosition.Column; - } + _htmlHasSelection = htmlText.ActiveTextAreaControl.TextArea.SelectionManager.HasSomethingSelected; + if (!_htmlHasSelection) return; + ISelection sel = htmlText.ActiveTextAreaControl.SelectionManager.SelectionCollection[0]; + _sels.Y = sel.StartPosition.Line; + _sels.X = sel.StartPosition.Column; + _sele.Y = sel.EndPosition.Line; + _sele.X = sel.EndPosition.Column; } - private void addToHTMLBox(string inFront, string atEnd) + private void AddToHtmlBox(string inFront, string atEnd) { - if (htmlHasSelection) - { - List temp = htmlText.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList(); - temp[sele.Y] = temp[sele.Y].Insert(sele.X, atEnd); - temp[sels.Y] = temp[sels.Y].Insert(sels.X, inFront); - htmlText.Text = string.Join("\r\n", temp.ToArray()); - } + if (!_htmlHasSelection) return; + List temp = htmlText.Text.Split(new[] {"\r\n"}, StringSplitOptions.None).ToList(); + temp[_sele.Y] = temp[_sele.Y].Insert(_sele.X, atEnd); + temp[_sels.Y] = temp[_sels.Y].Insert(_sels.X, inFront); + htmlText.Text = string.Join("\r\n", temp.ToArray()); } private void htmlSave_Click(object sender, EventArgs e) { - if (htmlSaveFileDialog.ShowDialog() == DialogResult.OK) + if (htmlSaveFileDialog.ShowDialog() != DialogResult.OK) return; + try { - try - { - File.WriteAllText(htmlSaveFileDialog.FileName, htmlText.Text); - } - catch (Exception e1) - { - MetroMessageBox.Show(this, e1.Message, "Saving Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + File.WriteAllText(htmlSaveFileDialog.FileName, htmlText.Text); + } + catch (Exception e1) + { + MetroMessageBox.Show(this, e1.Message, "Saving Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void htmlLoad_Click(object sender, EventArgs e) { - if (htmlOpenFileDialog.ShowDialog() == DialogResult.OK) + if (htmlOpenFileDialog.ShowDialog() != DialogResult.OK) return; + try { - try - { - htmlText.Text = File.ReadAllText(htmlOpenFileDialog.FileName); - } - catch (Exception e1) - { - MetroMessageBox.Show(this, e1.Message, "Loading Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + htmlText.Text = File.ReadAllText(htmlOpenFileDialog.FileName); + } + catch (Exception e1) + { + MetroMessageBox.Show(this, e1.Message, "Loading Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } #region Menu-HTML - private void hTMLStructureSetupToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("\r\n\r\nTitle\r\n\r\n\r\n", "\r\n\r\n"); + private void hTMLStructureSetupToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("\r\n\r\nTitle\r\n\r\n\r\n", "\r\n\r\n"); - private void linkToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void linkToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("", ""); - private void imageToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("Alternative Text + AddToHtmlBox("Alternative Text addToHTMLBox("
", "
"); + private void centercenterToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("
", "
"); - private void heading1h1ToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("

", "

"); + private void heading1h1ToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("

", "

"); - private void heading2h2ToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("

", "

"); + private void heading2h2ToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("

", "

"); - private void heading3h3ToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("

", "

"); + private void heading3h3ToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("

", "

"); - private void heading4h4ToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("

", "

"); + private void heading4h4ToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("

", "

"); - private void heading5h5ToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("
", "
"); + private void heading5h5ToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("
", "
"); - private void heading6h6ToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("
", "
"); + private void heading6h6ToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("
", "
"); - private void paragraphpToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("

", "

"); + private void paragraphpToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("

", "

"); - private void boldbToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void boldbToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("", ""); - private void underlineuToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void underlineuToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("", ""); - private void italiciToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void italiciToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("", ""); - private void deleteddelToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void deleteddelToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("", ""); - private void subscriptedSubToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void subscriptedSubToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("", ""); - private void superscriptedsupToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void superscriptedsupToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("", ""); - private void tableFormatSetupToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("\r\n", "\r\n
"); + private void tableFormatSetupToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("\r\n", "\r\n
"); - private void tableHeadingthToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void tableHeadingthToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("", ""); - private void newRowtrToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void newRowtrToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("", ""); - private void newHorizontalItemtdToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", ""); + private void newHorizontalItemtdToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("", ""); - private void orderedListSetupolToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("
    \r\n", "\r\n
"); + private void orderedListSetupolToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("
    \r\n", "\r\n
"); - private void unorderedListSetupulToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("
    \r\n", "
\r\n"); + private void unorderedListSetupulToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("
    \r\n", "
\r\n"); - private void listItemliToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("
  • ", "
  • "); + private void listItemliToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("
  • ", "
  • "); #endregion Menu-HTML #region Menu-Java - private void javaStructureSetupToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox(""); + private void javaStructureSetupToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox(""); - private void functionToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("function ", "()\r\n{\r\n\r\n}"); + private void functionToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("function ", "()\r\n{\r\n\r\n}"); - private void textToolStripMenuItem1_Click(object sender, EventArgs e) => addToHTMLBox("document.write('", "')"); + private void textToolStripMenuItem1_Click(object sender, EventArgs e) => AddToHtmlBox("document.write('", "')"); - private void alertBoxToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("alert('", "')"); + private void alertBoxToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("alert('", "')"); - private void timeoutToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("setTimeout('", "',TIME HERE)"); + private void timeoutToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("setTimeout('", "',TIME HERE)"); - private void randomNumberToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("Math.floor(Math.random()*MAXIMUM HERE)+MINIMUM HERE", ""); + private void randomNumberToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("Math.floor(Math.random()*MAXIMUM HERE)+MINIMUM HERE", ""); #endregion Menu-Java #region Menu-CSS - private void cSSStructureSetupToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox(""); + private void cSSStructureSetupToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox(""); - private void cSSCustomizeTagToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("", "\r\n{\r\n\r\n}"); + private void cSSCustomizeTagToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("", "\r\n{\r\n\r\n}"); - private void backgroundAttachmentToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("background-attachment:", ";"); + private void backgroundAttachmentToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("background-attachment:", ";"); - private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("background-color:", ";"); + private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("background-color:", ";"); - private void backgroundImageToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("background-image:url('", "');"); + private void backgroundImageToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("background-image:url('", "');"); - private void backgroundPositionToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("background-position:", ";"); + private void backgroundPositionToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("background-position:", ";"); - private void backgroundRepeatToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("background-repeat:", ";"); + private void backgroundRepeatToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("background-repeat:", ";"); - private void fontToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("font-family:'", "';"); + private void fontToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("font-family:'", "';"); - private void sizeToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("font-size:", ";"); + private void sizeToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("font-size:", ";"); - private void weightToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("font-weight:", ";"); + private void weightToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("font-weight:", ";"); - private void colorToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("color:", ";"); + private void colorToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("color:", ";"); - private void directionToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("direction:", ";"); + private void directionToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("direction:", ";"); - private void lineHeightToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("line-height:", ";"); + private void lineHeightToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("line-height:", ";"); - private void letterSpacingToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("letter-spacing:", ";"); + private void letterSpacingToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("letter-spacing:", ";"); - private void alignToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("text-align:", ";"); + private void alignToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("text-align:", ";"); - private void decorationToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("text-decoration:", ";"); + private void decorationToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("text-decoration:", ";"); - private void indentToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("text-indent:", ";"); + private void indentToolStripMenuItem_Click(object sender, EventArgs e) => AddToHtmlBox("text-indent:", ";"); - private void shadowToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("text-shadow: COLOR_HERE X_IN_PX Y_IN_PX RADIUS_IN_PX;", ""); + private void shadowToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("text-shadow: COLOR_HERE X_IN_PX Y_IN_PX RADIUS_IN_PX;", ""); - private void transformToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("text-transform:", ";"); + private void transformToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("text-transform:", ";"); - private void wordspacingToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox("word-spacing:", ";"); + private void wordspacingToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox("word-spacing:", ";"); #endregion Menu-CSS #region Menu-PHP - private void pHPStructureSetupToolStripMenuItem_Click(object sender, EventArgs e) => addToHTMLBox(""); + private void pHPStructureSetupToolStripMenuItem_Click(object sender, EventArgs e) => + AddToHtmlBox(""); - private void textToolStripMenuItem3_Click(object sender, EventArgs e) => addToHTMLBox("echo '", "';"); + private void textToolStripMenuItem3_Click(object sender, EventArgs e) => AddToHtmlBox("echo '", "';"); #endregion Menu-PHP #endregion HTML #region Python - Thread pythonScript; + + private Thread _pythonScript; + private void pythonOpen_Click(object sender, EventArgs e) { - if (pythonOpenFileDialog.ShowDialog() == DialogResult.OK) + if (pythonOpenFileDialog.ShowDialog() != DialogResult.OK) return; + try { - try - { - pythonCode.Text = File.ReadAllText(pythonOpenFileDialog.FileName); - } - catch (Exception e1) - { - MetroMessageBox.Show(this, e1.Message, "Loading Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + pythonCode.Text = File.ReadAllText(pythonOpenFileDialog.FileName); + } + catch (Exception e1) + { + MetroMessageBox.Show(this, e1.Message, "Loading Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void pythonSave_Click(object sender, EventArgs e) { - if (pythonSaveFileDialog.ShowDialog() == DialogResult.OK) + if (pythonSaveFileDialog.ShowDialog() != DialogResult.OK) return; + try { - try - { - File.WriteAllText(pythonSaveFileDialog.FileName, pythonCode.Text); - } - catch (Exception e1) - { - MetroMessageBox.Show(this, e1.Message, "Saving Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + File.WriteAllText(pythonSaveFileDialog.FileName, pythonCode.Text); + } + catch (Exception e1) + { + MetroMessageBox.Show(this, e1.Message, "Saving Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void pythonRun_Click(object sender, EventArgs e) { - if ((pythonScript != null) && _runningStates.Contains(pythonScript.ThreadState)) + if (_pythonScript != null && _runningStates.Contains(_pythonScript.ThreadState)) { - pythonScript.Abort(); + _pythonScript.Abort(); } else { - pythonScript = new Thread(() => + _pythonScript = new Thread(() => { ScriptEngine engine = Python.CreateEngine(); - engine.SetSearchPaths(new string[] { Path.Combine(Path.GetTempPath(), "Cashew\\Python") }); + engine.SetSearchPaths(new[] {Path.Combine(Path.GetTempPath(), "Cashew\\Python")}); try { engine.Execute(pythonCode.Text); } catch (Exception e1) { - if (!e1.tryCast(out ThreadAbortException ex)) - Invoke((MethodInvoker)delegate () + if (!e1.tryCast(out ThreadAbortException _)) + Invoke((MethodInvoker) delegate { - MetroMessageBox.Show(this, e1.Message, "Execution Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + MetroMessageBox.Show(this, e1.Message, "Execution Failed", MessageBoxButtons.OK, + MessageBoxIcon.Error); }); } }); - pythonScript.Start(); + _pythonScript.Start(); } } #endregion Python - - private void MainForm_FormClosed(object sender, FormClosedEventArgs e) - { - if (Directory.Exists(Path.Combine(Path.GetTempPath(), "Cashew"))) - Directory.Delete(Path.Combine(Path.GetTempPath(), "Cashew"), true); - } } } \ No newline at end of file diff --git a/cashew/MessageBox/MetroContextMenu.cs b/cashew/MessageBox/MetroContextMenu.cs new file mode 100644 index 0000000..3d24828 --- /dev/null +++ b/cashew/MessageBox/MetroContextMenu.cs @@ -0,0 +1,134 @@ +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using MetroFramework.Components; +using MetroFramework.Drawing; +using MetroFramework.Interfaces; + +namespace MetroFramework.Controls +{ + public class MetroContextMenu : ContextMenuStrip, IMetroControl + { + private MetroColorStyle metroStyle; + private MetroStyleManager metroStyleManager; + private MetroThemeStyle metroTheme; + + public MetroContextMenu(IContainer Container) + { + Container?.Add(this); + } + + [DefaultValue(false)] + [Category("Metro Appearance")] + public bool UseCustomBackColor { get; set; } + + [DefaultValue(false)] + [Category("Metro Appearance")] + public bool UseCustomForeColor { get; set; } + + [DefaultValue(false)] + [Category("Metro Appearance")] + public bool UseStyleColors { get; set; } + + [Category("Metro Behaviour")] + [Browsable(false)] + [DefaultValue(false)] + public bool UseSelectable + { + get => GetStyle(ControlStyles.Selectable); + set => SetStyle(ControlStyles.Selectable, value); + } + + [Category("Metro Appearance")] + [DefaultValue(MetroColorStyle.Blue)] + public MetroColorStyle Style + { + get + { + if (DesignMode || metroStyle != MetroColorStyle.Blue) + return metroStyle; + if (StyleManager != null && metroStyle == MetroColorStyle.Blue) + return StyleManager.Style; + return StyleManager == null && metroStyle == MetroColorStyle.Blue ? MetroColorStyle.Blue : metroStyle; + } + set => metroStyle = value; + } + + [Category("Metro Appearance")] + [DefaultValue(MetroThemeStyle.Light)] + public MetroThemeStyle Theme + { + get + { + if (DesignMode || metroTheme != MetroThemeStyle.Light) + return metroTheme; + if (StyleManager != null && metroTheme == MetroThemeStyle.Light) + return StyleManager.Theme; + return StyleManager == null && metroTheme == MetroThemeStyle.Light ? MetroThemeStyle.Light : metroTheme; + } + set => metroTheme = value; + } + + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [Browsable(false)] + public MetroStyleManager StyleManager + { + get => metroStyleManager; + set + { + metroStyleManager = value; + settheme(); + } + } + + private void settheme() + { + BackColor = MetroPaint.BackColor.Form(Theme); + ForeColor = MetroPaint.ForeColor.Button.Normal(Theme); + Renderer = new MetroCTXRenderer(Theme, Style); + } + + private class MetroCTXRenderer : ToolStripProfessionalRenderer + { + private readonly MetroThemeStyle _theme; + + public MetroCTXRenderer(MetroThemeStyle Theme, MetroColorStyle Style) + : base(new contextcolors(Theme, Style)) => + _theme = Theme; + + protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) + { + e.TextColor = MetroPaint.ForeColor.Button.Normal(_theme); + base.OnRenderItemText(e); + } + } + + private class contextcolors : ProfessionalColorTable + { + private readonly MetroColorStyle _style = MetroColorStyle.Blue; + private readonly MetroThemeStyle _theme = MetroThemeStyle.Light; + + public contextcolors(MetroThemeStyle Theme, MetroColorStyle Style) + { + _theme = Theme; + _style = Style; + } + + public override Color MenuItemSelected => MetroPaint.GetStyleColor(_style); + + public override Color MenuBorder => MetroPaint.BackColor.Form(_theme); + + public override Color ToolStripBorder => MetroPaint.GetStyleColor(_style); + + public override Color MenuItemBorder => MetroPaint.GetStyleColor(_style); + + public override Color ToolStripDropDownBackground => MetroPaint.BackColor.Form(_theme); + + public override Color ImageMarginGradientBegin => MetroPaint.BackColor.Form(_theme); + + public override Color ImageMarginGradientMiddle => MetroPaint.BackColor.Form(_theme); + + public override Color ImageMarginGradientEnd => MetroPaint.BackColor.Form(_theme); + } + } +} \ No newline at end of file diff --git a/cashew/MessageBox/MetroMessageBox.cs b/cashew/MessageBox/MetroMessageBox.cs index 43c845c..f9c105b 100644 --- a/cashew/MessageBox/MetroMessageBox.cs +++ b/cashew/MessageBox/MetroMessageBox.cs @@ -6,167 +6,151 @@ using System.Windows.Forms; namespace cashew.MessageBox { - public static class MetroMessageBox - { - public static DialogResult Show(IWin32Window owner, string message) + public static class MetroMessageBox { - return MetroMessageBox.Show(owner, message, "Notification", 211); - } + public static DialogResult Show(IWin32Window owner, string message) => + Show(owner, message, "Notification", 211); - public static DialogResult Show(IWin32Window owner, string message, int height) - { - return MetroMessageBox.Show(owner, message, "Notification", height); - } + public static DialogResult Show(IWin32Window owner, string message, int height) => + Show(owner, message, "Notification", height); - public static DialogResult Show(IWin32Window owner, string message, string title) - { - return MetroMessageBox.Show(owner, message, title, MessageBoxButtons.OK, 211); - } + public static DialogResult Show(IWin32Window owner, string message, string title) => + Show(owner, message, title, MessageBoxButtons.OK, 211); - public static DialogResult Show( - IWin32Window owner, - string message, - string title, - int height) - { - return MetroMessageBox.Show(owner, message, title, MessageBoxButtons.OK, height); - } + public static DialogResult Show( + IWin32Window owner, + string message, + string title, + int height) => + Show(owner, message, title, MessageBoxButtons.OK, height); - public static DialogResult Show( - IWin32Window owner, - string message, - string title, - MessageBoxButtons buttons) - { - return MetroMessageBox.Show(owner, message, title, buttons, MessageBoxIcon.None, 211); - } + public static DialogResult Show( + IWin32Window owner, + string message, + string title, + MessageBoxButtons buttons) => + Show(owner, message, title, buttons, MessageBoxIcon.None, 211); - public static DialogResult Show( - IWin32Window owner, - string message, - string title, - MessageBoxButtons buttons, - int height) - { - return MetroMessageBox.Show(owner, message, title, buttons, MessageBoxIcon.None, height); - } + public static DialogResult Show( + IWin32Window owner, + string message, + string title, + MessageBoxButtons buttons, + int height) => + Show(owner, message, title, buttons, MessageBoxIcon.None, height); - public static DialogResult Show( - IWin32Window owner, - string message, - string title, - MessageBoxButtons buttons, - MessageBoxIcon icon) - { - return MetroMessageBox.Show(owner, message, title, buttons, icon, MessageBoxDefaultButton.Button1, 211); - } + public static DialogResult Show( + IWin32Window owner, + string message, + string title, + MessageBoxButtons buttons, + MessageBoxIcon icon) => + Show(owner, message, title, buttons, icon, MessageBoxDefaultButton.Button1, 211); - public static DialogResult Show( - IWin32Window owner, - string message, - string title, - MessageBoxButtons buttons, - MessageBoxIcon icon, - int height) - { - return MetroMessageBox.Show(owner, message, title, buttons, icon, MessageBoxDefaultButton.Button1, height); - } + public static DialogResult Show( + IWin32Window owner, + string message, + string title, + MessageBoxButtons buttons, + MessageBoxIcon icon, + int height) => + Show(owner, message, title, buttons, icon, MessageBoxDefaultButton.Button1, height); - public static DialogResult Show( - IWin32Window owner, - string message, - string title, - MessageBoxButtons buttons, - MessageBoxIcon icon, - MessageBoxDefaultButton defaultbutton) - { - return MetroMessageBox.Show(owner, message, title, buttons, icon, defaultbutton, 211); - } + public static DialogResult Show( + IWin32Window owner, + string message, + string title, + MessageBoxButtons buttons, + MessageBoxIcon icon, + MessageBoxDefaultButton defaultbutton) => + Show(owner, message, title, buttons, icon, defaultbutton, 211); - public static DialogResult Show( - IWin32Window owner, - string message, - string title, - MessageBoxButtons buttons, - MessageBoxIcon icon, - MessageBoxDefaultButton defaultbutton, - int height) - { - DialogResult dialogResult = DialogResult.None; - if (owner != null) - { - Form form = !(owner is Form) ? ((ContainerControl) owner).ParentForm : (Form) owner; - switch (icon) + public static DialogResult Show( + IWin32Window owner, + string message, + string title, + MessageBoxButtons buttons, + MessageBoxIcon icon, + MessageBoxDefaultButton defaultbutton, + int height) { - case MessageBoxIcon.Hand: - SystemSounds.Hand.Play(); - break; - case MessageBoxIcon.Question: - SystemSounds.Beep.Play(); - break; - case MessageBoxIcon.Exclamation: - SystemSounds.Exclamation.Play(); - break; - default: - SystemSounds.Asterisk.Play(); - break; - } - MetroMessageBoxControl messageBoxControl = new MetroMessageBoxControl(); - messageBoxControl.BackColor = form.BackColor; - messageBoxControl.Properties.Buttons = buttons; - messageBoxControl.Properties.DefaultButton = defaultbutton; - messageBoxControl.Properties.Icon = icon; - messageBoxControl.Properties.Message = message; - messageBoxControl.Properties.Title = title; - messageBoxControl.Padding = new Padding(0, 0, 0, 0); - messageBoxControl.ControlBox = false; - messageBoxControl.ShowInTaskbar = false; - messageBoxControl.TopMost = true; - messageBoxControl.Size = new Size(form.Size.Width, height); - messageBoxControl.Location = new Point(form.Location.X, form.Location.Y + (form.Height - messageBoxControl.Height) / 2); - messageBoxControl.ArrangeApperance(); - Convert.ToInt32(Math.Floor((double) messageBoxControl.Size.Height * 0.28)); - int num = (int) messageBoxControl.ShowDialog(); - messageBoxControl.BringToFront(); - messageBoxControl.SetDefaultButton(); - Action action = new Action(MetroMessageBox.ModalState); - IAsyncResult asyncResult = action.BeginInvoke(messageBoxControl, (AsyncCallback) null, (object) action); - bool flag = false; - try - { - while (!asyncResult.IsCompleted) - { - Thread.Sleep(1); - Application.DoEvents(); - } - } - catch - { - flag = true; - if (!asyncResult.IsCompleted) - { - try + DialogResult dialogResult = DialogResult.None; + if (owner != null) { - } - catch - { - } - } - } - if (!flag) - { - dialogResult = messageBoxControl.Result; - messageBoxControl.Dispose(); - } - } - return dialogResult; - } + Form form = !(owner is Form) ? ((ContainerControl) owner).ParentForm : (Form) owner; + switch (icon) + { + case MessageBoxIcon.Hand: + SystemSounds.Hand.Play(); + break; + case MessageBoxIcon.Question: + SystemSounds.Beep.Play(); + break; + case MessageBoxIcon.Exclamation: + SystemSounds.Exclamation.Play(); + break; + default: + SystemSounds.Asterisk.Play(); + break; + } - private static void ModalState(MetroMessageBoxControl control) - { - do - ; - while (control.Visible); + MetroMessageBoxControl messageBoxControl = new MetroMessageBoxControl(); + messageBoxControl.BackColor = form.BackColor; + messageBoxControl.Properties.Buttons = buttons; + messageBoxControl.Properties.DefaultButton = defaultbutton; + messageBoxControl.Properties.Icon = icon; + messageBoxControl.Properties.Message = message; + messageBoxControl.Properties.Title = title; + messageBoxControl.Padding = new Padding(0, 0, 0, 0); + messageBoxControl.ControlBox = false; + messageBoxControl.ShowInTaskbar = false; + messageBoxControl.TopMost = true; + messageBoxControl.Size = new Size(form.Size.Width, height); + messageBoxControl.Location = new Point(form.Location.X, + form.Location.Y + (form.Height - messageBoxControl.Height) / 2); + messageBoxControl.ArrangeApperance(); + Convert.ToInt32(Math.Floor(messageBoxControl.Size.Height * 0.28)); + int num = (int) messageBoxControl.ShowDialog(); + messageBoxControl.BringToFront(); + messageBoxControl.SetDefaultButton(); + Action action = ModalState; + IAsyncResult asyncResult = action.BeginInvoke(messageBoxControl, null, action); + bool flag = false; + try + { + while (!asyncResult.IsCompleted) + { + Thread.Sleep(1); + Application.DoEvents(); + } + } + catch + { + flag = true; + if (!asyncResult.IsCompleted) + try + { + } + catch + { + } + } + + if (!flag) + { + dialogResult = messageBoxControl.Result; + messageBoxControl.Dispose(); + } + } + + return dialogResult; + } + + private static void ModalState(MetroMessageBoxControl control) + { + do + ; + while (control.Visible); + } } - } } \ No newline at end of file diff --git a/cashew/MessageBox/MetroMessageBoxControl.cs b/cashew/MessageBox/MetroMessageBoxControl.cs index b761b7a..faadcaa 100644 --- a/cashew/MessageBox/MetroMessageBoxControl.cs +++ b/cashew/MessageBox/MetroMessageBoxControl.cs @@ -1,361 +1,340 @@ -// Decompiled with JetBrains decompiler -// Type: MetroFramework.MetroMessageBoxControl -// Assembly: MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a -// MVID: 57814A66-940D-4455-B30A-E2997453B959 -// Assembly location: C:\Users\Systemadmin\Downloads\MetroFramework.dll - -using System; +using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Windows.Forms; -using MetroFramework; using MetroFramework.Controls; namespace cashew.MessageBox { - public class MetroMessageBoxControl : Form - { - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private Color _defaultColor = Color.FromArgb(57, 179, 215); - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private Color _errorColor = Color.FromArgb(210, 50, 45); - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private Color _warningColor = Color.FromArgb(237, 156, 40); - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private Color _success = Color.FromArgb(71, 164, 71); - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private Color _question = Color.FromArgb(71, 164, 71); - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private MetroMessageBoxProperties _properties; - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private DialogResult _result; - private IContainer components; - private Panel panelbody; - private Label titleLabel; - private Label messageLabel; - private MetroButton metroButton1; - private MetroButton metroButton2; - private MetroButton metroButton3; - private TableLayoutPanel tlpBody; - private Panel pnlBottom; - - public MetroMessageBoxControl() + public class MetroMessageBoxControl : Form { - this.InitializeComponent(); - this._properties = new MetroMessageBoxProperties(this); - this.StylizeButton(this.metroButton1); - this.StylizeButton(this.metroButton2); - this.StylizeButton(this.metroButton3); - this.metroButton1.Click += new EventHandler(this.button_Click); - this.metroButton2.Click += new EventHandler(this.button_Click); - this.metroButton3.Click += new EventHandler(this.button_Click); - } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly Color _defaultColor = Color.FromArgb(57, 179, 215); - public Panel Body - { - get - { - return this.panelbody; - } - } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly Color _errorColor = Color.FromArgb(210, 50, 45); - public MetroMessageBoxProperties Properties - { - get - { - return this._properties; - } - } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly Color _question = Color.FromArgb(71, 164, 71); - public DialogResult Result - { - get - { - return this._result; - } - } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly Color _warningColor = Color.FromArgb(237, 156, 40); - public void ArrangeApperance() - { - this.titleLabel.Text = this._properties.Title; - this.messageLabel.Text = this._properties.Message; - switch (this._properties.Icon) - { - case MessageBoxIcon.Hand: - this.panelbody.BackColor = this._errorColor; - break; - case MessageBoxIcon.Exclamation: - this.panelbody.BackColor = this._warningColor; - break; - } - switch (this._properties.Buttons) - { - case MessageBoxButtons.OK: - this.EnableButton(this.metroButton1); - this.metroButton1.Text = ("Ok"); - this.metroButton1.Location = this.metroButton3.Location; - this.metroButton1.Tag = (object) DialogResult.OK; - this.EnableButton(this.metroButton2, false); - this.EnableButton(this.metroButton3, false); - break; - case MessageBoxButtons.OKCancel: - this.EnableButton(this.metroButton1); - this.metroButton1.Text = ("Ok"); - this.metroButton1.Location = this.metroButton2.Location; - this.metroButton1.Tag = (object) DialogResult.OK; - this.EnableButton(this.metroButton2); - this.metroButton2.Text = ("Cancel"); - this.metroButton2.Location = this.metroButton3.Location; - this.metroButton2.Tag = (object) DialogResult.Cancel; - this.EnableButton(this.metroButton3, false); - break; - case MessageBoxButtons.AbortRetryIgnore: - this.EnableButton(this.metroButton1); - this.metroButton1.Text = ("Abort"); - this.metroButton1.Tag = (object) DialogResult.Abort; - this.EnableButton(this.metroButton2); - this.metroButton2.Text = ("Retry"); - this.metroButton2.Tag = (object) DialogResult.Retry; - this.EnableButton(this.metroButton3); - this.metroButton3.Text = ("Ignore"); - this.metroButton3.Tag = (object) DialogResult.Ignore; - break; - case MessageBoxButtons.YesNoCancel: - this.EnableButton(this.metroButton1); - this.metroButton1.Text = ("Yes"); - this.metroButton1.Tag = (object) DialogResult.Yes; - this.EnableButton(this.metroButton2); - this.metroButton2.Text = ("No"); - this.metroButton2.Tag = (object) DialogResult.No; - this.EnableButton(this.metroButton3); - this.metroButton3.Text = ("Cancel"); - this.metroButton3.Tag = (object) DialogResult.Cancel; - break; - case MessageBoxButtons.YesNo: - this.EnableButton(this.metroButton1); - this.metroButton1.Text = ("Yes"); - this.metroButton1.Location = this.metroButton2.Location; - this.metroButton1.Tag = (object) DialogResult.Yes; - this.EnableButton(this.metroButton2); - this.metroButton2.Text = ("No"); - this.metroButton2.Location = this.metroButton3.Location; - this.metroButton2.Tag = (object) DialogResult.No; - this.EnableButton(this.metroButton3, false); - break; - case MessageBoxButtons.RetryCancel: - this.EnableButton(this.metroButton1); - this.metroButton1.Text = ("Retry"); - this.metroButton1.Location = this.metroButton2.Location; - this.metroButton1.Tag = (object) DialogResult.Retry; - this.EnableButton(this.metroButton2); - this.metroButton2.Text = ("Cancel"); - this.metroButton2.Location = this.metroButton3.Location; - this.metroButton2.Tag = (object) DialogResult.Cancel; - this.EnableButton(this.metroButton3, false); - break; - } - switch (this._properties.Icon) - { - case MessageBoxIcon.Hand: - this.panelbody.BackColor = this._errorColor; - break; - case MessageBoxIcon.Question: - this.panelbody.BackColor = this._question; - break; - case MessageBoxIcon.Exclamation: - this.panelbody.BackColor = this._warningColor; - break; - case MessageBoxIcon.Asterisk: - this.panelbody.BackColor = this._defaultColor; - break; - default: - this.panelbody.BackColor = Color.DarkGray; - break; - } - } + private Label _messageLabel; + private MetroButton _metroButton1; + private MetroButton _metroButton2; + private MetroButton _metroButton3; + private Panel _pnlBottom; - private void EnableButton(MetroButton button) - { - this.EnableButton(button, true); - } + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private Color _success = Color.FromArgb(71, 164, 71); - private void EnableButton(MetroButton button, bool enabled) - { - button.Enabled = enabled; - button.Visible = enabled; - } + private Label _titleLabel; + private TableLayoutPanel _tlpBody; - public void SetDefaultButton() - { - switch (this._properties.DefaultButton) - { - case MessageBoxDefaultButton.Button1: - if (this.metroButton1 == null || !this.metroButton1.Enabled) - break; - this.metroButton1.Focus(); - break; - case MessageBoxDefaultButton.Button2: - if (this.metroButton2 == null || !this.metroButton2.Enabled) - break; - this.metroButton2.Focus(); - break; - case MessageBoxDefaultButton.Button3: - if (this.metroButton3 == null || !this.metroButton3.Enabled) - break; - this.metroButton3.Focus(); - break; - } - } + private IContainer components; - private void button_MouseClick(object sender, MouseEventArgs e) - { - } + public MetroMessageBoxControl() + { + InitializeComponent(); + Properties = new MetroMessageBoxProperties(this); + StylizeButton(_metroButton1); + StylizeButton(_metroButton2); + StylizeButton(_metroButton3); + _metroButton1.Click += button_Click; + _metroButton2.Click += button_Click; + _metroButton3.Click += button_Click; + } - private void button_MouseEnter(object sender, EventArgs e) - { - this.StylizeButton((MetroButton) sender, true); - } + public Panel Body { get; private set; } - private void button_MouseLeave(object sender, EventArgs e) - { - this.StylizeButton((MetroButton) sender); - } + public MetroMessageBoxProperties Properties { get; } - private void StylizeButton(MetroButton button) - { - this.StylizeButton(button, false); - } + public DialogResult Result { get; private set; } - private void StylizeButton(MetroButton button, bool hovered) - { - button.Cursor = Cursors.Hand; - button.MouseClick -= new MouseEventHandler(this.button_MouseClick); - button.MouseClick += new MouseEventHandler(this.button_MouseClick); - button.MouseEnter -= new EventHandler(this.button_MouseEnter); - button.MouseEnter += new EventHandler(this.button_MouseEnter); - button.MouseLeave -= new EventHandler(this.button_MouseLeave); - button.MouseLeave += new EventHandler(this.button_MouseLeave); - } + public void ArrangeApperance() + { + _titleLabel.Text = Properties.Title; + _messageLabel.Text = Properties.Message; + switch (Properties.Icon) + { + case MessageBoxIcon.Hand: + Body.BackColor = _errorColor; + break; + case MessageBoxIcon.Exclamation: + Body.BackColor = _warningColor; + break; + } - private void button_Click(object sender, EventArgs e) - { - MetroButton metroButton = (MetroButton) sender; - if (!metroButton.Enabled) - return; - this._result = (DialogResult) metroButton.Tag; - this.Hide(); - } + switch (Properties.Buttons) + { + case MessageBoxButtons.OK: + EnableButton(_metroButton1); + _metroButton1.Text = "Ok"; + _metroButton1.Location = _metroButton3.Location; + _metroButton1.Tag = DialogResult.OK; + EnableButton(_metroButton2, false); + EnableButton(_metroButton3, false); + break; + case MessageBoxButtons.OKCancel: + EnableButton(_metroButton1); + _metroButton1.Text = "Ok"; + _metroButton1.Location = _metroButton2.Location; + _metroButton1.Tag = DialogResult.OK; + EnableButton(_metroButton2); + _metroButton2.Text = "Cancel"; + _metroButton2.Location = _metroButton3.Location; + _metroButton2.Tag = DialogResult.Cancel; + EnableButton(_metroButton3, false); + break; + case MessageBoxButtons.AbortRetryIgnore: + EnableButton(_metroButton1); + _metroButton1.Text = "Abort"; + _metroButton1.Tag = DialogResult.Abort; + EnableButton(_metroButton2); + _metroButton2.Text = "Retry"; + _metroButton2.Tag = DialogResult.Retry; + EnableButton(_metroButton3); + _metroButton3.Text = "Ignore"; + _metroButton3.Tag = DialogResult.Ignore; + break; + case MessageBoxButtons.YesNoCancel: + EnableButton(_metroButton1); + _metroButton1.Text = "Yes"; + _metroButton1.Tag = DialogResult.Yes; + EnableButton(_metroButton2); + _metroButton2.Text = "No"; + _metroButton2.Tag = DialogResult.No; + EnableButton(_metroButton3); + _metroButton3.Text = "Cancel"; + _metroButton3.Tag = DialogResult.Cancel; + break; + case MessageBoxButtons.YesNo: + EnableButton(_metroButton1); + _metroButton1.Text = "Yes"; + _metroButton1.Location = _metroButton2.Location; + _metroButton1.Tag = DialogResult.Yes; + EnableButton(_metroButton2); + _metroButton2.Text = "No"; + _metroButton2.Location = _metroButton3.Location; + _metroButton2.Tag = DialogResult.No; + EnableButton(_metroButton3, false); + break; + case MessageBoxButtons.RetryCancel: + EnableButton(_metroButton1); + _metroButton1.Text = "Retry"; + _metroButton1.Location = _metroButton2.Location; + _metroButton1.Tag = DialogResult.Retry; + EnableButton(_metroButton2); + _metroButton2.Text = "Cancel"; + _metroButton2.Location = _metroButton3.Location; + _metroButton2.Tag = DialogResult.Cancel; + EnableButton(_metroButton3, false); + break; + } - protected override void Dispose(bool disposing) - { - if (disposing && this.components != null) - this.components.Dispose(); - base.Dispose(disposing); - } + switch (Properties.Icon) + { + case MessageBoxIcon.Hand: + Body.BackColor = _errorColor; + break; + case MessageBoxIcon.Question: + Body.BackColor = _question; + break; + case MessageBoxIcon.Exclamation: + Body.BackColor = _warningColor; + break; + case MessageBoxIcon.Asterisk: + Body.BackColor = _defaultColor; + break; + default: + Body.BackColor = Color.DarkGray; + break; + } + } - private void InitializeComponent() - { - this.panelbody = new Panel(); - this.tlpBody = new TableLayoutPanel(); - this.messageLabel = new Label(); - this.titleLabel = new Label(); - this.metroButton1 = new MetroButton(); - this.metroButton3 = new MetroButton(); - this.metroButton2 = new MetroButton(); - this.pnlBottom = new Panel(); - this.panelbody.SuspendLayout(); - this.tlpBody.SuspendLayout(); - this.pnlBottom.SuspendLayout(); - this.SuspendLayout(); - this.panelbody.BackColor = Color.DarkGray; - this.panelbody.Controls.Add((Control) this.tlpBody); - this.panelbody.Dock = DockStyle.Fill; - this.panelbody.Location = new Point(0, 0); - this.panelbody.Margin = new Padding(0); - this.panelbody.Name = "panelbody"; - this.panelbody.Size = new Size(804, 211); - this.panelbody.TabIndex = 2; - this.tlpBody.ColumnCount = 3; - this.tlpBody.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10f)); - this.tlpBody.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80f)); - this.tlpBody.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10f)); - this.tlpBody.Controls.Add((Control) this.messageLabel, 1, 2); - this.tlpBody.Controls.Add((Control) this.titleLabel, 1, 1); - this.tlpBody.Controls.Add((Control) this.pnlBottom, 1, 3); - this.tlpBody.Dock = DockStyle.Fill; - this.tlpBody.Location = new Point(0, 0); - this.tlpBody.Name = "tlpBody"; - this.tlpBody.RowCount = 4; - this.tlpBody.RowStyles.Add(new RowStyle(SizeType.Absolute, 5f)); - this.tlpBody.RowStyles.Add(new RowStyle(SizeType.Absolute, 25f)); - this.tlpBody.RowStyles.Add(new RowStyle(SizeType.Percent, 100f)); - this.tlpBody.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f)); - this.tlpBody.Size = new Size(804, 211); - this.tlpBody.TabIndex = 6; - this.messageLabel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - this.messageLabel.BackColor = Color.Transparent; - this.messageLabel.ForeColor = Color.White; - this.messageLabel.Location = new Point(83, 30); - this.messageLabel.Margin = new Padding(3, 0, 0, 0); - this.messageLabel.Name = "messageLabel"; - this.messageLabel.Size = new Size(640, 141); - this.messageLabel.TabIndex = 0; - this.messageLabel.Text = "message here"; - this.titleLabel.AutoSize = true; - this.titleLabel.BackColor = Color.Transparent; - this.titleLabel.Font = new Font("Segoe UI Semibold", 14.25f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0); - this.titleLabel.ForeColor = Color.WhiteSmoke; - this.titleLabel.Location = new Point(80, 5); - this.titleLabel.Margin = new Padding(0); - this.titleLabel.Name = "titleLabel"; - this.titleLabel.Size = new Size(125, 25); - this.titleLabel.TabIndex = 1; - this.titleLabel.Text = "message title"; - this.metroButton1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - this.metroButton1.BackColor = Color.ForestGreen; - this.metroButton1.Location = new Point(357, 1); - this.metroButton1.Name = "metroButton1"; - this.metroButton1.Size = new Size(90, 26); - this.metroButton1.TabIndex = 3; - this.metroButton1.Text = "button 1"; - this.metroButton3.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - this.metroButton3.Location = new Point(553, 1); - this.metroButton3.Name = "metroButton3"; - this.metroButton3.Size = new Size(90, 26); - this.metroButton3.TabIndex = 5; - this.metroButton3.Text = "button 3"; - this.metroButton2.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - this.metroButton2.Location = new Point(455, 1); - this.metroButton2.Name = "metroButton2"; - this.metroButton2.Size = new Size(90, 26); - this.metroButton2.TabIndex = 4; - this.metroButton2.Text = "button 2"; - this.pnlBottom.BackColor = Color.Transparent; - this.pnlBottom.Controls.Add((Control) this.metroButton2); - this.pnlBottom.Controls.Add((Control) this.metroButton1); - this.pnlBottom.Controls.Add((Control) this.metroButton3); - this.pnlBottom.Dock = DockStyle.Fill; - this.pnlBottom.Location = new Point(80, 171); - this.pnlBottom.Margin = new Padding(0); - this.pnlBottom.Name = "pnlBottom"; - this.pnlBottom.Size = new Size(643, 40); - this.pnlBottom.TabIndex = 2; - this.AutoScaleDimensions = new SizeF(8f, 21f); - this.AutoScaleMode = AutoScaleMode.Font; - this.ClientSize = new Size(804, 211); - this.ControlBox = false; - this.Controls.Add((Control) this.panelbody); - this.Font = new Font("Segoe UI Light", 12f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0); - this.FormBorderStyle = FormBorderStyle.None; - this.Margin = new Padding(4, 5, 4, 5); - this.Name = nameof (MetroMessageBoxControl); - this.StartPosition = FormStartPosition.Manual; - this.panelbody.ResumeLayout(false); - this.tlpBody.ResumeLayout(false); - this.tlpBody.PerformLayout(); - this.pnlBottom.ResumeLayout(false); - this.ResumeLayout(false); + private void EnableButton(MetroButton button) + { + EnableButton(button, true); + } + + private void EnableButton(MetroButton button, bool enabled) + { + button.Enabled = enabled; + button.Visible = enabled; + } + + public void SetDefaultButton() + { + switch (Properties.DefaultButton) + { + case MessageBoxDefaultButton.Button1: + if (_metroButton1 == null || !_metroButton1.Enabled) + break; + _metroButton1.Focus(); + break; + case MessageBoxDefaultButton.Button2: + if (_metroButton2 == null || !_metroButton2.Enabled) + break; + _metroButton2.Focus(); + break; + case MessageBoxDefaultButton.Button3: + if (_metroButton3 == null || !_metroButton3.Enabled) + break; + _metroButton3.Focus(); + break; + } + } + + private void button_MouseClick(object sender, MouseEventArgs e) + { + } + + private void button_MouseEnter(object sender, EventArgs e) + { + StylizeButton((MetroButton) sender, true); + } + + private void button_MouseLeave(object sender, EventArgs e) + { + StylizeButton((MetroButton) sender); + } + + private void StylizeButton(MetroButton button) + { + StylizeButton(button, false); + } + + private void StylizeButton(MetroButton button, bool hovered) + { + button.Cursor = Cursors.Hand; + button.MouseClick -= button_MouseClick; + button.MouseClick += button_MouseClick; + button.MouseEnter -= button_MouseEnter; + button.MouseEnter += button_MouseEnter; + button.MouseLeave -= button_MouseLeave; + button.MouseLeave += button_MouseLeave; + } + + private void button_Click(object sender, EventArgs e) + { + MetroButton metroButton = (MetroButton) sender; + if (!metroButton.Enabled) + return; + Result = (DialogResult) metroButton.Tag; + Hide(); + } + + protected override void Dispose(bool disposing) + { + if (disposing && components != null) + components.Dispose(); + base.Dispose(disposing); + } + + private void InitializeComponent() + { + Body = new Panel(); + _tlpBody = new TableLayoutPanel(); + _messageLabel = new Label(); + _titleLabel = new Label(); + _metroButton1 = new MetroButton(); + _metroButton3 = new MetroButton(); + _metroButton2 = new MetroButton(); + _pnlBottom = new Panel(); + Body.SuspendLayout(); + _tlpBody.SuspendLayout(); + _pnlBottom.SuspendLayout(); + SuspendLayout(); + Body.BackColor = Color.DarkGray; + Body.Controls.Add(_tlpBody); + Body.Dock = DockStyle.Fill; + Body.Location = new Point(0, 0); + Body.Margin = new Padding(0); + Body.Name = "Body"; + Body.Size = new Size(804, 211); + Body.TabIndex = 2; + _tlpBody.ColumnCount = 3; + _tlpBody.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10f)); + _tlpBody.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80f)); + _tlpBody.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 10f)); + _tlpBody.Controls.Add(_messageLabel, 1, 2); + _tlpBody.Controls.Add(_titleLabel, 1, 1); + _tlpBody.Controls.Add(_pnlBottom, 1, 3); + _tlpBody.Dock = DockStyle.Fill; + _tlpBody.Location = new Point(0, 0); + _tlpBody.Name = "_tlpBody"; + _tlpBody.RowCount = 4; + _tlpBody.RowStyles.Add(new RowStyle(SizeType.Absolute, 5f)); + _tlpBody.RowStyles.Add(new RowStyle(SizeType.Absolute, 25f)); + _tlpBody.RowStyles.Add(new RowStyle(SizeType.Percent, 100f)); + _tlpBody.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f)); + _tlpBody.Size = new Size(804, 211); + _tlpBody.TabIndex = 6; + _messageLabel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + _messageLabel.BackColor = Color.Transparent; + _messageLabel.ForeColor = Color.White; + _messageLabel.Location = new Point(83, 30); + _messageLabel.Margin = new Padding(3, 0, 0, 0); + _messageLabel.Name = "_messageLabel"; + _messageLabel.Size = new Size(640, 141); + _messageLabel.TabIndex = 0; + _messageLabel.Text = "message here"; + _titleLabel.AutoSize = true; + _titleLabel.BackColor = Color.Transparent; + _titleLabel.Font = new Font("Segoe UI Semibold", 14.25f, FontStyle.Bold, GraphicsUnit.Point, 0); + _titleLabel.ForeColor = Color.WhiteSmoke; + _titleLabel.Location = new Point(80, 5); + _titleLabel.Margin = new Padding(0); + _titleLabel.Name = "_titleLabel"; + _titleLabel.Size = new Size(125, 25); + _titleLabel.TabIndex = 1; + _titleLabel.Text = "message title"; + _metroButton1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + _metroButton1.BackColor = Color.ForestGreen; + _metroButton1.Location = new Point(357, 1); + _metroButton1.Name = "_metroButton1"; + _metroButton1.Size = new Size(90, 26); + _metroButton1.TabIndex = 3; + _metroButton1.Text = "button 1"; + _metroButton3.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + _metroButton3.Location = new Point(553, 1); + _metroButton3.Name = "_metroButton3"; + _metroButton3.Size = new Size(90, 26); + _metroButton3.TabIndex = 5; + _metroButton3.Text = "button 3"; + _metroButton2.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + _metroButton2.Location = new Point(455, 1); + _metroButton2.Name = "_metroButton2"; + _metroButton2.Size = new Size(90, 26); + _metroButton2.TabIndex = 4; + _metroButton2.Text = "button 2"; + _pnlBottom.BackColor = Color.Transparent; + _pnlBottom.Controls.Add(_metroButton2); + _pnlBottom.Controls.Add(_metroButton1); + _pnlBottom.Controls.Add(_metroButton3); + _pnlBottom.Dock = DockStyle.Fill; + _pnlBottom.Location = new Point(80, 171); + _pnlBottom.Margin = new Padding(0); + _pnlBottom.Name = "_pnlBottom"; + _pnlBottom.Size = new Size(643, 40); + _pnlBottom.TabIndex = 2; + AutoScaleDimensions = new SizeF(8f, 21f); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(804, 211); + ControlBox = false; + Controls.Add(Body); + Font = new Font("Segoe UI Light", 12f, FontStyle.Regular, GraphicsUnit.Point, 0); + FormBorderStyle = FormBorderStyle.None; + Margin = new Padding(4, 5, 4, 5); + Name = nameof(MetroMessageBoxControl); + StartPosition = FormStartPosition.Manual; + Body.ResumeLayout(false); + _tlpBody.ResumeLayout(false); + _tlpBody.PerformLayout(); + _pnlBottom.ResumeLayout(false); + ResumeLayout(false); + } } - } -} +} \ No newline at end of file diff --git a/cashew/MessageBox/MetroMessageBoxProperties.cs b/cashew/MessageBox/MetroMessageBoxProperties.cs index 6907c87..0d99e82 100644 --- a/cashew/MessageBox/MetroMessageBoxProperties.cs +++ b/cashew/MessageBox/MetroMessageBoxProperties.cs @@ -1,17 +1,10 @@ -using System.Diagnostics; -using System.Windows.Forms; +using System.Windows.Forms; namespace cashew.MessageBox { public class MetroMessageBoxProperties { - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private MetroMessageBoxControl _owner; - - public MetroMessageBoxProperties(MetroMessageBoxControl owner) - { - this._owner = owner; - } + public MetroMessageBoxProperties(MetroMessageBoxControl owner) => Owner = owner; public MessageBoxButtons Buttons { get; set; } @@ -21,13 +14,7 @@ namespace cashew.MessageBox public string Message { get; set; } - public MetroMessageBoxControl Owner - { - get - { - return this._owner; - } - } + public MetroMessageBoxControl Owner { get; } public string Title { get; set; } } diff --git a/cashew/Resources.Designer.cs b/cashew/Resources.Designer.cs index 4cbfc84..ec57d4f 100644 --- a/cashew/Resources.Designer.cs +++ b/cashew/Resources.Designer.cs @@ -8,10 +8,15 @@ // //------------------------------------------------------------------------------ +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Resources; +using System.Runtime.CompilerServices; + namespace cashew { - using System; - - /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,27 +24,27 @@ namespace cashew { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [DebuggerNonUserCode()] + [CompilerGenerated()] internal class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [EditorBrowsable(EditorBrowsableState.Advanced)] + internal static ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("cashew.Resources", typeof(Resources).Assembly); + if (ReferenceEquals(resourceMan, null)) { + ResourceManager temp = new ResourceManager("cashew.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -50,8 +55,8 @@ namespace cashew { /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. ///
    - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [EditorBrowsable(EditorBrowsableState.Advanced)] + internal static CultureInfo Culture { get { return resourceCulture; } diff --git a/cashew/Splash.Designer.cs b/cashew/Splash.Designer.cs index 41a63f2..98b5886 100644 --- a/cashew/Splash.Designer.cs +++ b/cashew/Splash.Designer.cs @@ -1,11 +1,14 @@ -namespace cashew +using System.ComponentModel; +using System.Windows.Forms; + +namespace cashew { partial class Splash { /// /// Required designer variable. /// - private System.ComponentModel.IContainer components = null; + private IContainer components = null; /// /// Clean up any resources being used. @@ -65,6 +68,6 @@ #endregion - private System.Windows.Forms.Label label1; + private Label label1; } } \ No newline at end of file