diff options
| author | pfg <[email protected]> | 2017-03-12 09:45:11 -0700 |
|---|---|---|
| committer | pfg <[email protected]> | 2017-03-12 09:45:11 -0700 |
| commit | 5ee6043b9ea5baef45c08b5fb92fdebadd610dc0 (patch) | |
| tree | 947cffe3f4693f9559cc7aaf5a2f3500e23f2b53 /ShiftOS.WinForms/Controls | |
| parent | 6460ccee378e15408768337dcdc1bc77da07da53 (diff) | |
| parent | 11da99a43bb3225ebd5fc82cb4765309804f8eba (diff) | |
| download | shiftos_thereturn-5ee6043b9ea5baef45c08b5fb92fdebadd610dc0.tar.gz shiftos_thereturn-5ee6043b9ea5baef45c08b5fb92fdebadd610dc0.tar.bz2 shiftos_thereturn-5ee6043b9ea5baef45c08b5fb92fdebadd610dc0.zip | |
Command theming complete
Diffstat (limited to 'ShiftOS.WinForms/Controls')
| -rw-r--r-- | ShiftOS.WinForms/Controls/TerminalBox.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 4fcb429..9e4c61c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -24,11 +24,14 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Controls { @@ -53,13 +56,60 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; + this.Select(this.TextLength, 0); + this.SelectionFont = ConstructFont(); + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } + private Font ConstructFont() + { + FontStyle fs = FontStyle.Regular; + if (ConsoleEx.Bold) + fs = fs | FontStyle.Bold; + if (ConsoleEx.Italic) + fs = fs | FontStyle.Italic; + if (ConsoleEx.Underline) + fs = fs | FontStyle.Underline; + + return new Font(this.Font, fs); + } + public void WriteLine(string text) { + this.HideSelection = true; + this.Select(this.TextLength, 0); + this.SelectionFont = ConstructFont(); + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); + this.HideSelection = false; + } + + bool quickCopying = false; + + protected override void OnMouseDown(MouseEventArgs e) + { + //if right-clicking, then we initiate a quick-copy. + if (e.Button == MouseButtons.Right) + quickCopying = true; + + //Override the mouse event so that it's a left-click at all times. + base.OnMouseDown(new MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta)); + } + + protected override void OnMouseUp(MouseEventArgs mevent) + { + if(quickCopying == true) + { + if (!string.IsNullOrWhiteSpace(this.SelectedText)) + { + this.Copy(); + } + } + base.OnMouseUp(mevent); } } } |
