diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-27 18:25:51 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-27 18:25:51 +0200 |
| commit | 03970962af1bfbfc5c13109c3f0a465cf9a1dc29 (patch) | |
| tree | 94d97e7aff1e6c0e95495636540c7fa99f5ef16d /Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs | |
| parent | cd974051e442dd0420eb14513a57855e69beef86 (diff) | |
| download | Tango-03970962af1bfbfc5c13109c3f0a465cf9a1dc29.tar.gz Tango-03970962af1bfbfc5c13109c3f0a465cf9a1dc29.zip | |
Create FSE module project template.
Implemented core PPC console components.
Added FSE PPC Console module.
Diffstat (limited to 'Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs b/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs new file mode 100644 index 000000000..e2f1f53c3 --- /dev/null +++ b/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.Console +{ + public class ConsoleTextBox : TextBox + { + private Border _caret; + + static ConsoleTextBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(ConsoleTextBox), new FrameworkPropertyMetadata(typeof(ConsoleTextBox))); + } + + public Brush CaretBottomBrush + { + get { return (Brush)GetValue(CaretBottomBrushProperty); } + set { SetValue(CaretBottomBrushProperty, value); } + } + public static readonly DependencyProperty CaretBottomBrushProperty = + DependencyProperty.Register("CaretBottomBrush", typeof(Brush), typeof(ConsoleTextBox), new PropertyMetadata(null)); + + public ConsoleTextBox() + { + SelectionChanged += (sender, e) => MoveCustomCaret(); + LostFocus += (sender, e) => _caret.Visibility = Visibility.Collapsed; + GotKeyboardFocus += (sender, e) => _caret.Visibility = Visibility.Visible; + LostKeyboardFocus += (sender, e) => _caret.Visibility = Visibility.Collapsed; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _caret = GetTemplateChild("PART_Caret") as Border; + } + + private void MoveCustomCaret() + { + var caretLocation = GetRectFromCharacterIndex(CaretIndex).Location; + + if (!double.IsInfinity(caretLocation.X)) + { + Canvas.SetLeft(_caret, caretLocation.X); + } + } + } +} |
