From 6faef62d683a670aa85ca4a4ff0c39cf1b3002ed Mon Sep 17 00:00:00 2001 From: Roy Date: Tue, 22 May 2018 22:50:06 +0300 Subject: Started working on Tango.Touch project --- .../Tango.Touch/Keyboard/CapsLockMode.cs | 15 + .../Tango.Touch/Keyboard/KeyDefinition.cs | 15 + .../Tango.Touch/Keyboard/KeyboardActionKeyMode.cs | 15 + .../Tango.Touch/Keyboard/KeyboardDefinition.cs | 448 ++++++++++++++++++++ .../Keyboard/KeyboardModeToVisibilityConverter.cs | 25 ++ .../KeyboardModeToVisibilityInverseConverter.cs | 25 ++ .../Tango.Touch/Keyboard/KeyboardView.cs | 186 +++++++++ .../Tango.Touch/Keyboard/KeyboardView.xaml | 53 +++ .../Tango.Touch/Keyboard/KeysLineDefinition.cs | 25 ++ .../Tango.Touch/Keyboard/SpecialKeyDefinition.cs | 21 + .../SpecialKeyDefinitionToWidthConverter.cs | 27 ++ .../Tango.Touch/Keyboard/SpecialKeyType.cs | 14 + .../Tango.Touch/Keyboard/TouchKeyboard.cs | 465 +++++++++++++++++++++ .../Tango.Touch/Keyboard/TouchKeyboard.xaml | 451 ++++++++++++++++++++ .../Tango.Touch/Keyboard/TouchKeyboardMode.cs | 16 + .../Tango.Touch/Properties/AssemblyInfo.cs | 17 + .../Tango.Touch/Properties/Resources.Designer.cs | 62 +++ .../Tango.Touch/Properties/Resources.resx | 117 ++++++ .../Tango.Touch/Properties/Settings.Designer.cs | 30 ++ .../Tango.Touch/Properties/Settings.settings | 7 + .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 123 ++++++ .../Visual_Studio/Tango.Touch/Themes/Generic.xaml | 11 + Software/Visual_Studio/Tango.Touch/app.config | 47 +++ Software/Visual_Studio/Tango.Touch/packages.config | 5 + Software/Visual_Studio/Tango.sln | 44 +- .../Utilities/Tango.UITests/App.config | 2 +- .../Utilities/Tango.UITests/MainWindow.xaml | 4 +- .../Utilities/Tango.UITests/Tango.UITests.csproj | 4 + 28 files changed, 2270 insertions(+), 4 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/CapsLockMode.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/KeyDefinition.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardActionKeyMode.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardDefinition.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardModeToVisibilityConverter.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardModeToVisibilityInverseConverter.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/KeysLineDefinition.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyDefinition.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyDefinitionToWidthConverter.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyType.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.xaml create mode 100644 Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboardMode.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Properties/Resources.resx create mode 100644 Software/Visual_Studio/Tango.Touch/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Properties/Settings.settings create mode 100644 Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj create mode 100644 Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml create mode 100644 Software/Visual_Studio/Tango.Touch/app.config create mode 100644 Software/Visual_Studio/Tango.Touch/packages.config (limited to 'Software') diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/CapsLockMode.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/CapsLockMode.cs new file mode 100644 index 000000000..633899aa8 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/CapsLockMode.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Touch.Keyboard +{ + public enum CapsLockMode + { + None, + SingleChar, + Locked + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyDefinition.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyDefinition.cs new file mode 100644 index 000000000..270645743 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyDefinition.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Touch.Keyboard +{ + public class KeyDefinition + { + public String StandardText { get; set; } + public String CapsText { get; set; } + public String HoldText { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardActionKeyMode.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardActionKeyMode.cs new file mode 100644 index 000000000..fb574e476 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardActionKeyMode.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Touch.Keyboard +{ + public enum KeyboardActionKeyMode + { + Tab, + Enter, + Search, + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardDefinition.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardDefinition.cs new file mode 100644 index 000000000..1486b6717 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardDefinition.cs @@ -0,0 +1,448 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; + +namespace Tango.Touch.Keyboard +{ + public class KeyboardDefinition + { + public String Name { get; set; } + + public String LanguageCode { get; set; } + + public String EnterText { get; set; } + + public String TabText { get; set; } + + public List KeysLinesDefinitions { get; set; } + + public KeyboardDefinition() + { + KeysLinesDefinitions = new List(); + } + + private static KeyboardDefinition _default; + + public static KeyboardDefinition Default + { + get + { + if (_default == null) + { + _default = CreateDefaultAlphaNumeric(); + } + + return _default; + } + set { _default = value; } + } + + internal static KeyboardDefinition CreateDefaultHebrewAlphaNumeric() + { + KeyboardDefinition definition = new KeyboardDefinition(); + + definition.Name = "Hebrew"; + definition.LanguageCode = "HE"; + definition.EnterText = "בצע"; + definition.TabText = "הבא"; + + KeysLineDefinition line1 = new KeysLineDefinition(); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = ",", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = ".", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ק", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ר", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "א", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ט", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ו", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ן", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ם", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "פ", + }); + + KeysLineDefinition line2 = new KeysLineDefinition(); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ש", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ד", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ג", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "כ", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ע", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "י", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ח", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ל", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ך", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ף", + }); + + KeysLineDefinition line3 = new KeysLineDefinition(); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ז", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ס", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ב", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ה", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "נ", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "מ", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "צ", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ת", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "ץ", + }); + + line3.SpecialRightKeyDefinitions.Add(new SpecialKeyDefinition() + { + Type = SpecialKeyType.StandardText, + VectorMarkup = "M561 76.5H178.5c-17.85 0-30.6 7.65-40.8 22.95L0 306l137.7 206.55c10.2 12.75 22.95 22.95 40.8 22.95H561 c28.05 0 51-22.95 51-51v-357C612 99.45 589.05 76.5 561 76.5z M484.5 397.8l-35.7 35.7L357 341.7l-91.8 91.8l-35.7-35.7 l91.8-91.8l-91.8-91.8l35.7-35.7l91.8 91.8l91.8-91.8l35.7 35.7L392.7 306L484.5 397.8z", + Output = "{BACKSPACE}", + }); + + definition.KeysLinesDefinitions.Add(line1); + definition.KeysLinesDefinitions.Add(line2); + definition.KeysLinesDefinitions.Add(line3); + + return definition; + } + + private static KeyboardDefinition CreateDefaultAlphaNumeric() + { + KeyboardDefinition definition = new KeyboardDefinition(); + + definition.Name = "English"; + definition.LanguageCode = "EN"; + definition.EnterText = "GO"; + definition.TabText = "NEXT"; + + KeysLineDefinition line1 = new KeysLineDefinition(); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "q", + CapsText = "Q", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "w", + CapsText = "W", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "e", + CapsText = "E", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "r", + CapsText = "R", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "t", + CapsText = "T", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "y", + CapsText = "Y", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "u", + CapsText = "U", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "i", + CapsText = "I", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "o", + CapsText = "O", + }); + + line1.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "p", + CapsText = "P", + }); + + KeysLineDefinition line2 = new KeysLineDefinition(); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "a", + CapsText = "A", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "s", + CapsText = "S", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "d", + CapsText = "D", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "f", + CapsText = "F", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "g", + CapsText = "G", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "h", + CapsText = "H", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "j", + CapsText = "J", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "k", + CapsText = "K", + }); + + line2.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "l", + CapsText = "L", + }); + + KeysLineDefinition line3 = new KeysLineDefinition(); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "z", + CapsText = "Z", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "x", + CapsText = "X", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "c", + CapsText = "C", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "v", + CapsText = "V", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "b", + CapsText = "B", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "n", + CapsText = "N", + }); + + line3.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "m", + CapsText = "M", + }); + + line3.SpecialLeftKeyDefinitions.Add(new SpecialKeyDefinition() + { + VectorMarkup = "M235.252 13.406l-0.447-0.998c-3.417-7.622-11.603-12.854-19.677-12.375l-0.3 0.016l-0.302-0.016 C214.194 0.011 213.856 0 213.524 0c-7.706 0-15.386 5.104-18.674 12.413l-0.452 0.998L13.662 176.079 c-6.871 6.183-6.495 12.657-4.971 16.999c2.661 7.559 10.361 13.373 18.313 13.82l1.592 0.297c0.68 0.168 1.356 0.348 2.095 0.427 c23.036 2.381 45.519 2.876 64.472 3.042l5.154 0.048V407.93c0 11.023 7.221 15.152 11.522 16.635l0.967 0.33l0.77 0.671 c3.105 2.717 7.02 4.093 11.644 4.093h179.215c4.626 0 8.541-1.376 11.639-4.093l0.771-0.671l0.965-0.33 c4.307-1.482 11.532-5.611 11.532-16.635V210.706l5.149-0.048c18.961-0.17 41.446-0.666 64.475-3.042 c0.731-0.079 1.407-0.254 2.082-0.422l1.604-0.302c7.952-0.447 15.65-6.262 18.312-13.82c1.528-4.336 1.899-10.811-4.972-16.998 L235.252 13.406z M344.114 173.365c-11.105 0.18-22.216 0.254-33.337 0.254c-5.153 0-9.363 1.607-12.507 4.768 c-3.372 3.4-5.296 8.48-5.266 13.932l0.005 0.65l-0.157 0.629c-0.437 1.767-0.64 3.336-0.64 4.928v194.001H137.458V198.526 c0-1.597-0.201-3.161-0.638-4.928l-0.157-0.629l0.005-0.65c0.031-5.456-1.892-10.537-5.271-13.937 c-3.141-3.161-7.353-4.763-12.507-4.768c-11.124 0-22.224-0.074-33.337-0.254l-13.223-0.218L214.834 44.897l142.503 128.249 L344.114 173.365z", + Output = "{CAPSLOCK}", + Type = SpecialKeyType.CapsLock, + }); + + line3.SpecialRightKeyDefinitions.Add(new SpecialKeyDefinition() + { + Type = SpecialKeyType.StandardText, + VectorMarkup = "M561 76.5H178.5c-17.85 0-30.6 7.65-40.8 22.95L0 306l137.7 206.55c10.2 12.75 22.95 22.95 40.8 22.95H561 c28.05 0 51-22.95 51-51v-357C612 99.45 589.05 76.5 561 76.5z M484.5 397.8l-35.7 35.7L357 341.7l-91.8 91.8l-35.7-35.7 l91.8-91.8l-91.8-91.8l35.7-35.7l91.8 91.8l91.8-91.8l35.7 35.7L392.7 306L484.5 397.8z", + Output = "{BACKSPACE}", + ColumnSpan = 2, + }); + + definition.KeysLinesDefinitions.Add(line1); + definition.KeysLinesDefinitions.Add(line2); + definition.KeysLinesDefinitions.Add(line3); + + return definition; + } + + internal static List CreateDefaultSpecialCharacters() + { + KeysLineDefinition line1 = CreateLine("+", "x", "÷", "=", "%", "/", "\\", "$", "€", "£"); + KeysLineDefinition line2 = CreateLine("@", "*", "!", "#", ":", ";", "&", "_", "(", ")"); + KeysLineDefinition line3 = CreateLine("-", "'", "\"", ",", ".", "?"); + + line3.SpecialRightKeyDefinitions.Add(new SpecialKeyDefinition() + { + Type = SpecialKeyType.StandardText, + VectorMarkup = "M561 76.5H178.5c-17.85 0-30.6 7.65-40.8 22.95L0 306l137.7 206.55c10.2 12.75 22.95 22.95 40.8 22.95H561 c28.05 0 51-22.95 51-51v-357C612 99.45 589.05 76.5 561 76.5z M484.5 397.8l-35.7 35.7L357 341.7l-91.8 91.8l-35.7-35.7 l91.8-91.8l-91.8-91.8l35.7-35.7l91.8 91.8l91.8-91.8l35.7 35.7L392.7 306L484.5 397.8z", + Output = "{BACKSPACE}", + ColumnSpan = 2, + }); + + return new List() + { + line1, + line2, + line3 + }; + } + + private static KeysLineDefinition CreateLine(params String[] chars) + { + KeysLineDefinition line = new KeysLineDefinition(); + + foreach (var c in chars) + { + line.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = c, + }); + } + + return line; + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardModeToVisibilityConverter.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardModeToVisibilityConverter.cs new file mode 100644 index 000000000..bda8e5568 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardModeToVisibilityConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.Touch.Keyboard +{ + public class KeyboardModeToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if ((TouchKeyboardMode)value == (TouchKeyboardMode)parameter) return Visibility.Visible; + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardModeToVisibilityInverseConverter.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardModeToVisibilityInverseConverter.cs new file mode 100644 index 000000000..41035d329 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardModeToVisibilityInverseConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.Touch.Keyboard +{ + public class KeyboardModeToVisibilityInverseConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if ((TouchKeyboardMode)value == (TouchKeyboardMode)parameter) return Visibility.Collapsed; + return Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs new file mode 100644 index 000000000..36bdaced1 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs @@ -0,0 +1,186 @@ +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.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.Touch.Keyboard +{ + /// + /// Interaction logic for KeyboardView.xaml + /// + [ContentProperty(nameof(View))] + public partial class KeyboardView : Control + { + private static KeyboardView _instance; + + private TouchKeyboard keyboard; + + #region Properties + + public bool IsOpened + { + get { return (bool)GetValue(IsOpenedProperty); } + set { SetValue(IsOpenedProperty, value); } + } + public static readonly DependencyProperty IsOpenedProperty = + DependencyProperty.Register("IsOpened", typeof(bool), typeof(KeyboardView), new PropertyMetadata(false)); + + public FrameworkElement View + { + get { return (FrameworkElement)GetValue(ViewProperty); } + set { SetValue(ViewProperty, value); } + } + public static readonly DependencyProperty ViewProperty = + DependencyProperty.Register("View", typeof(FrameworkElement), typeof(KeyboardView), new PropertyMetadata(null)); + + #endregion + + #region Attached Properties + + #region Mode + + public static readonly DependencyProperty ModeProperty = + DependencyProperty.RegisterAttached("Mode", + typeof(TouchKeyboardMode?), typeof(KeyboardView), + new FrameworkPropertyMetadata(null, ModeChanged)); + + /// + /// Mode changed. + /// + /// The d. + /// The instance containing the event data. + private static void ModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + RegisterElement(d as FrameworkElement); + } + + /// + /// Sets the Mode attached property. + /// + /// The element. + /// if set to true [value]. + public static void SetMode(FrameworkElement element, TouchKeyboardMode? value) + { + element.SetValue(ModeProperty, value); + } + + /// + /// Gets the Mode attached property. + /// + /// The element. + /// + public static TouchKeyboardMode? GetMode(FrameworkElement element) + { + return (TouchKeyboardMode?)element.GetValue(ModeProperty); + } + + private static void RegisterElement(FrameworkElement element) + { + element.PreviewMouseUp += (_, __) => OnElementFocused(element); + element.PreviewTouchUp += (_, __) => OnElementFocused(element); + element.GotFocus += (_, __) => OnElementFocused(element); + element.LostFocus += (_, __) => OnElementLostFocus(element); + } + + private async static void OnElementFocused(FrameworkElement element) + { + _instance.keyboard.ActionKeyMode = GetAction(element); + _instance.keyboard.Mode = GetMode(element).Value; + _instance.IsOpened = true; + await Task.Delay(200); + element.BringIntoView(); + } + + private static void OnElementLostFocus(FrameworkElement element) + { + _instance.IsOpened = false; + } + + #endregion + + #region Action + + public static readonly DependencyProperty ActionProperty = + DependencyProperty.RegisterAttached("Action", + typeof(KeyboardActionKeyMode), typeof(KeyboardView), + new FrameworkPropertyMetadata(KeyboardActionKeyMode.Tab, ActionChanged)); + + /// + /// Action changed. + /// + /// The d. + /// The instance containing the event data. + private static void ActionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + RegisterElement(d as FrameworkElement); + } + + /// + /// Sets the Action attached property. + /// + /// The element. + /// if set to true [value]. + public static void SetAction(FrameworkElement element, KeyboardActionKeyMode value) + { + element.SetValue(ActionProperty, value); + } + + /// + /// Gets the Action attached property. + /// + /// The element. + /// + public static KeyboardActionKeyMode GetAction(FrameworkElement element) + { + return (KeyboardActionKeyMode)element.GetValue(ActionProperty); + } + + #endregion + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public KeyboardView() + { + _instance = this; + } + + #endregion + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + keyboard = GetTemplateChild("PART_Keyboard") as TouchKeyboard; + keyboard.ActionKeyPressed += OnActionKeyPressed; + } + + private void OnActionKeyPressed(object sender, KeyboardActionKeyMode mode) + { + if (mode == KeyboardActionKeyMode.Enter || mode == KeyboardActionKeyMode.Search) + { + IsOpened = false; + } + } + + static KeyboardView() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(KeyboardView), new FrameworkPropertyMetadata(typeof(KeyboardView))); + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml new file mode 100644 index 000000000..db5ba6f3d --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeysLineDefinition.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeysLineDefinition.cs new file mode 100644 index 000000000..4b5a32b2a --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeysLineDefinition.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Tango.Touch.Keyboard +{ + public class KeysLineDefinition + { + public List KeyDefinitions { get; set; } + + public List SpecialLeftKeyDefinitions { get; set; } + + public List SpecialRightKeyDefinitions { get; set; } + + public KeysLineDefinition() + { + KeyDefinitions = new List(); + SpecialLeftKeyDefinitions = new List(); + SpecialRightKeyDefinitions = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyDefinition.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyDefinition.cs new file mode 100644 index 000000000..eeba9aa45 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyDefinition.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Touch.Keyboard +{ + public class SpecialKeyDefinition + { + public SpecialKeyType Type { get; set; } + public String VectorMarkup { get; set; } + public int ColumnSpan { get; set; } + public String Output { get; set; } + + public SpecialKeyDefinition() + { + ColumnSpan = 1; + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyDefinitionToWidthConverter.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyDefinitionToWidthConverter.cs new file mode 100644 index 000000000..a22203214 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyDefinitionToWidthConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.Touch.Keyboard +{ + public class SpecialKeyDefinitionToWidthConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + Size size = (Size)values[0]; + int columnSpan = (int)values[1]; + + return size.Width * (double)columnSpan; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyType.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyType.cs new file mode 100644 index 000000000..4fdbdc710 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/SpecialKeyType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Touch.Keyboard +{ + public enum SpecialKeyType + { + StandardText, + CapsLock, + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs new file mode 100644 index 000000000..d92fe4bb8 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs @@ -0,0 +1,465 @@ +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 Forms = System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Core.Commands; +using System.Threading; +using System.Collections.ObjectModel; + +namespace Tango.Touch.Keyboard +{ + /// + /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file. + /// + /// Step 1a) Using this custom control in a XAML file that exists in the current project. + /// Add this XmlNamespace attribute to the root element of the markup file where it is + /// to be used: + /// + /// xmlns:MyNamespace="clr-namespace:Tango.Touch.Keyboard" + /// + /// + /// Step 1b) Using this custom control in a XAML file that exists in a different project. + /// Add this XmlNamespace attribute to the root element of the markup file where it is + /// to be used: + /// + /// xmlns:MyNamespace="clr-namespace:Tango.Touch.Keyboard;assembly=Tango.Touch.Keyboard" + /// + /// You will also need to add a project reference from the project where the XAML file lives + /// to this project and Rebuild to avoid compilation errors: + /// + /// Right click on the target project in the Solution Explorer and + /// "Add Reference"->"Projects"->[Browse to and select this project] + /// + /// + /// Step 2) + /// Go ahead and use your control in the XAML file. + /// + /// + /// + /// + public class TouchKeyboard : Control + { + static TouchKeyboard() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchKeyboard), new FrameworkPropertyMetadata(typeof(TouchKeyboard))); + } + + private bool _isInitialized; + + public event EventHandler ActionKeyPressed; + + public bool IsSpecialCharactersOn + { + get { return (bool)GetValue(IsSpecialCharactersOnProperty); } + set { SetValue(IsSpecialCharactersOnProperty, value); } + } + public static readonly DependencyProperty IsSpecialCharactersOnProperty = + DependencyProperty.Register("IsSpecialCharactersOn", typeof(bool), typeof(TouchKeyboard), new PropertyMetadata(false, (d, e) => (d as TouchKeyboard).OnSpecialCharactersOnChanged())); + + public TouchKeyboardMode Mode + { + get { return (TouchKeyboardMode)GetValue(ModeProperty); } + set { SetValue(ModeProperty, value); } + } + public static readonly DependencyProperty ModeProperty = + DependencyProperty.Register("Mode", typeof(TouchKeyboardMode), typeof(TouchKeyboard), new PropertyMetadata(TouchKeyboardMode.AlphaNumeric)); + + public KeyboardActionKeyMode ActionKeyMode + { + get { return (KeyboardActionKeyMode)GetValue(ActionKeyModeProperty); } + set { SetValue(ActionKeyModeProperty, value); } + } + public static readonly DependencyProperty ActionKeyModeProperty = + DependencyProperty.Register("ActionKeyMode", typeof(KeyboardActionKeyMode), typeof(TouchKeyboard), new PropertyMetadata(KeyboardActionKeyMode.Tab, (d, e) => (d as TouchKeyboard).OnActionKeyModeChanged())); + + public String ActionKeyText + { + get { return (String)GetValue(ActionKeyTextProperty); } + private set { SetValue(ActionKeyTextProperty, value); } + } + public static readonly DependencyProperty ActionKeyTextProperty = + DependencyProperty.Register("ActionKeyText", typeof(String), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public KeyboardDefinition CurrentKeyboardDefinition + { + get { return (KeyboardDefinition)GetValue(CurrentKeyboardDefinitionProperty); } + set { SetValue(CurrentKeyboardDefinitionProperty, value); } + } + public static readonly DependencyProperty CurrentKeyboardDefinitionProperty = + DependencyProperty.Register("CurrentKeyboardDefinition", typeof(KeyboardDefinition), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public int CurrentKeyboardDefinitionIndex + { + get { return (int)GetValue(CurrentKeyboardDefinitionIndexProperty); } + set { SetValue(CurrentKeyboardDefinitionIndexProperty, value); } + } + public static readonly DependencyProperty CurrentKeyboardDefinitionIndexProperty = + DependencyProperty.Register("CurrentKeyboardDefinitionIndex", typeof(int), typeof(TouchKeyboard), new PropertyMetadata(0)); + + public ObservableCollection KeyboardDefinitions + { + get { return (ObservableCollection)GetValue(KeyboardDefinitionsProperty); } + set { SetValue(KeyboardDefinitionsProperty, value); } + } + public static readonly DependencyProperty KeyboardDefinitionsProperty = + DependencyProperty.Register("KeyboardDefinitions", typeof(ObservableCollection), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public Size KeySize + { + get { return (Size)GetValue(KeySizeProperty); } + set { SetValue(KeySizeProperty, value); } + } + public static readonly DependencyProperty KeySizeProperty = + DependencyProperty.Register("KeySize", typeof(Size), typeof(TouchKeyboard), new PropertyMetadata(Size.Empty)); + + public double MaxSpecialKeyWidth + { + get { return (double)GetValue(MaxSpecialKeyWidthProperty); } + set { SetValue(MaxSpecialKeyWidthProperty, value); } + } + public static readonly DependencyProperty MaxSpecialKeyWidthProperty = + DependencyProperty.Register("MaxSpecialKeyWidth", typeof(double), typeof(TouchKeyboard), new PropertyMetadata(0.0)); + + public KeysLineDefinition NumbersLineDefinition + { + get { return (KeysLineDefinition)GetValue(NumbersLineDefinitionProperty); } + set { SetValue(NumbersLineDefinitionProperty, value); } + } + public static readonly DependencyProperty NumbersLineDefinitionProperty = + DependencyProperty.Register("NumbersLineDefinition", typeof(KeysLineDefinition), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public Brush CharactersBackground + { + get { return (Brush)GetValue(CharactersBackgroundProperty); } + set { SetValue(CharactersBackgroundProperty, value); } + } + public static readonly DependencyProperty CharactersBackgroundProperty = + DependencyProperty.Register("CharactersBackground", typeof(Brush), typeof(TouchKeyboard), new PropertyMetadata(Brushes.Gainsboro)); + + public Brush CharactersForeground + { + get { return (Brush)GetValue(CharactersForegroundProperty); } + set { SetValue(CharactersForegroundProperty, value); } + } + public static readonly DependencyProperty CharactersForegroundProperty = + DependencyProperty.Register("CharactersForeground", typeof(Brush), typeof(TouchKeyboard), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(20, 20, 20)))); + + public Brush SpecialCharactersBackground + { + get { return (Brush)GetValue(SpecialCharactersBackgroundProperty); } + set { SetValue(SpecialCharactersBackgroundProperty, value); } + } + public static readonly DependencyProperty SpecialCharactersBackgroundProperty = + DependencyProperty.Register("SpecialCharactersBackground", typeof(Brush), typeof(TouchKeyboard), new PropertyMetadata(Brushes.Gray)); + + public Brush SpecialCharactersForeground + { + get { return (Brush)GetValue(SpecialCharactersForegroundProperty); } + set { SetValue(SpecialCharactersForegroundProperty, value); } + } + public static readonly DependencyProperty SpecialCharactersForegroundProperty = + DependencyProperty.Register("SpecialCharactersForeground", typeof(Brush), typeof(TouchKeyboard), new PropertyMetadata(Brushes.Gainsboro)); + + public double VectorMarkupSize + { + get { return (double)GetValue(VectorMarkupSizeProperty); } + set { SetValue(VectorMarkupSizeProperty, value); } + } + public static readonly DependencyProperty VectorMarkupSizeProperty = + DependencyProperty.Register("VectorMarkupSize", typeof(double), typeof(TouchKeyboard), new PropertyMetadata(10.0)); + + public double DotsSize + { + get { return (double)GetValue(DotsSizeProperty); } + set { SetValue(DotsSizeProperty, value); } + } + public static readonly DependencyProperty DotsSizeProperty = + DependencyProperty.Register("DotsSize", typeof(double), typeof(TouchKeyboard), new PropertyMetadata(5.0)); + + public double CharactersCornerRadius + { + get { return (double)GetValue(CharactersCornerRadiusProperty); } + set { SetValue(CharactersCornerRadiusProperty, value); } + } + public static readonly DependencyProperty CharactersCornerRadiusProperty = + DependencyProperty.Register("CharactersCornerRadius", typeof(double), typeof(TouchKeyboard), new PropertyMetadata(5.0)); + + public CapsLockMode CapsLockMode + { + get { return (CapsLockMode)GetValue(CapsLockModeProperty); } + set { SetValue(CapsLockModeProperty, value); } + } + public static readonly DependencyProperty CapsLockModeProperty = + DependencyProperty.Register("CapsLockMode", typeof(CapsLockMode), typeof(TouchKeyboard), new PropertyMetadata(CapsLockMode.None)); + + public bool IsCapsLockOn + { + get { return (bool)GetValue(IsCapsLockOnProperty); } + private set { SetValue(IsCapsLockOnProperty, value); } + } + public static readonly DependencyProperty IsCapsLockOnProperty = + DependencyProperty.Register("IsCapsLockOn", typeof(bool), typeof(TouchKeyboard), new PropertyMetadata(false)); + + public RelayCommand KeyDefinitionCommand + { + get { return (RelayCommand)GetValue(KeyDefinitionCommandProperty); } + set { SetValue(KeyDefinitionCommandProperty, value); } + } + public static readonly DependencyProperty KeyDefinitionCommandProperty = + DependencyProperty.Register("KeyDefinitionCommand", typeof(RelayCommand), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public RelayCommand SpecialKeyDefinitionCommand + { + get { return (RelayCommand)GetValue(SpecialKeyDefinitionCommandProperty); } + set { SetValue(SpecialKeyDefinitionCommandProperty, value); } + } + public static readonly DependencyProperty SpecialKeyDefinitionCommandProperty = + DependencyProperty.Register("SpecialKeyDefinitionCommand", typeof(RelayCommand), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public RelayCommand SpecialCharactersCommand + { + get { return (RelayCommand)GetValue(SpecialCharactersCommandProperty); } + set { SetValue(SpecialCharactersCommandProperty, value); } + } + public static readonly DependencyProperty SpecialCharactersCommandProperty = + DependencyProperty.Register("SpecialCharactersCommand", typeof(RelayCommand), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public RelayCommand FreeTextCommand + { + get { return (RelayCommand)GetValue(FreeTextCommandProperty); } + set { SetValue(FreeTextCommandProperty, value); } + } + public static readonly DependencyProperty FreeTextCommandProperty = + DependencyProperty.Register("FreeTextCommand", typeof(RelayCommand), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public RelayCommand NextLanguageCommand + { + get { return (RelayCommand)GetValue(NextLanguageCommandProperty); } + set { SetValue(NextLanguageCommandProperty, value); } + } + public static readonly DependencyProperty NextLanguageCommandProperty = + DependencyProperty.Register("NextLanguageCommand", typeof(RelayCommand), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public RelayCommand ActionKeyCommand + { + get { return (RelayCommand)GetValue(ActionKeyCommandProperty); } + set { SetValue(ActionKeyCommandProperty, value); } + } + public static readonly DependencyProperty ActionKeyCommandProperty = + DependencyProperty.Register("ActionKeyCommand", typeof(RelayCommand), typeof(TouchKeyboard), new PropertyMetadata(null)); + + public RelayCommand NumericKeyCommand + { + get { return (RelayCommand)GetValue(NumericKeyCommandProperty); } + set { SetValue(NumericKeyCommandProperty, value); } + } + public static readonly DependencyProperty NumericKeyCommandProperty = + DependencyProperty.Register("NumericKeyCommand", typeof(RelayCommand), typeof(TouchKeyboard), new PropertyMetadata(null)); + + + public TouchKeyboard() + { + KeyboardDefinitions = new ObservableCollection(); + Initialize(); + + this.SizeChanged += (_, __) => SetKeySize(); + KeyDefinitionCommand = new RelayCommand(InvokeKeyDefinition); + SpecialKeyDefinitionCommand = new RelayCommand(InvokeSpecialKeyDefinition); + SpecialCharactersCommand = new RelayCommand(ToggleSpecialKeys); + FreeTextCommand = new RelayCommand((x) => SendKeys(x)); + NextLanguageCommand = new RelayCommand(NextLanguage); + ActionKeyCommand = new RelayCommand(InvokeActionKey); + NumericKeyCommand = new RelayCommand((x) => SendKeys(x.ToString().Replace("'", ""))); + } + + private void Initialize() + { + if (!_isInitialized) + { + var numbers = new KeysLineDefinition(); + + for (int i = 1; i < 10; i++) + { + numbers.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = i.ToString(), + }); + } + + numbers.KeyDefinitions.Add(new KeyDefinition() + { + StandardText = "0", + }); + + NumbersLineDefinition = numbers; + + CurrentKeyboardDefinition = KeyboardDefinition.Default; + KeyboardDefinitions.Add(CurrentKeyboardDefinition); + KeyboardDefinitions.Add(KeyboardDefinition.CreateDefaultHebrewAlphaNumeric()); + + SetKeySize(); + + OnActionKeyModeChanged(); + + _isInitialized = true; + } + } + + private void SetKeySize() + { + KeySize = new Size(ActualWidth / NumbersLineDefinition.KeyDefinitions.Count, (ActualWidth / NumbersLineDefinition.KeyDefinitions.Count) * 0.90); + MaxSpecialKeyWidth = KeySize.Width * 2; + } + + private void InvokeKeyDefinition(KeyDefinition key) + { + if (IsCapsLockOn) + { + SendKeys(key.CapsText); + } + else + { + //UIAutomationHelper.GetActiveWindow(); + + //IInputElement focusedControl = FocusManager.GetFocusedElement(this); + + SendKeys(key.StandardText); + } + } + + private void InvokeSpecialKeyDefinition(SpecialKeyDefinition key) + { + switch (key.Type) + { + case SpecialKeyType.StandardText: + SendKeys(key.Output); + break; + case SpecialKeyType.CapsLock: + + if (CapsLockMode == CapsLockMode.None) + { + CapsLockMode = CapsLockMode.SingleChar; + } + else if (CapsLockMode == CapsLockMode.SingleChar) + { + CapsLockMode = CapsLockMode.Locked; + } + else + { + CapsLockMode = CapsLockMode.None; + } + + IsCapsLockOn = CapsLockMode != CapsLockMode.None; + + break; + } + } + + private Task SendKeys(String key) + { + Application.Current.MainWindow.Activate(); + + var isSpecialChar = IsSpecialCharactersOn; + var definition = CurrentKeyboardDefinition; + + if (CapsLockMode == CapsLockMode.SingleChar) + { + CapsLockMode = CapsLockMode.None; + IsCapsLockOn = false; + } + + return Task.Factory.StartNew(() => + { + if (isSpecialChar && definition.KeysLinesDefinitions.SelectMany(x => x.KeyDefinitions).Select(x => x.StandardText).Contains(key)) + { + Forms.SendKeys.SendWait("{" + key + "}"); + } + else + { + Forms.SendKeys.SendWait(key); + } + }); + } + + private void OnSpecialCharactersOnChanged() + { + if (!IsSpecialCharactersOn) + { + CurrentKeyboardDefinition = KeyboardDefinitions[CurrentKeyboardDefinitionIndex]; + } + else + { + KeyboardDefinition definition = new KeyboardDefinition(); + definition.EnterText = CurrentKeyboardDefinition.EnterText; + definition.KeysLinesDefinitions = KeyboardDefinition.CreateDefaultSpecialCharacters(); + CurrentKeyboardDefinition = definition; + } + } + + private void ToggleSpecialKeys() + { + IsSpecialCharactersOn = !IsSpecialCharactersOn; + } + + private void NextLanguage() + { + IsCapsLockOn = false; + + CurrentKeyboardDefinitionIndex++; + + if (CurrentKeyboardDefinitionIndex > KeyboardDefinitions.Count - 1) + { + CurrentKeyboardDefinitionIndex = 0; + } + + CurrentKeyboardDefinition = KeyboardDefinitions[CurrentKeyboardDefinitionIndex]; + + OnActionKeyModeChanged(); + } + + private void OnActionKeyModeChanged() + { + switch (ActionKeyMode) + { + case KeyboardActionKeyMode.Enter: + ActionKeyText = CurrentKeyboardDefinition.EnterText; + break; + case KeyboardActionKeyMode.Tab: + ActionKeyText = CurrentKeyboardDefinition.TabText; + break; + case KeyboardActionKeyMode.Search: + ActionKeyText = "Search"; // TODO: Make trigger in view and vector path. + break; + } + } + + private void InvokeActionKey() + { + switch (ActionKeyMode) + { + case KeyboardActionKeyMode.Enter: + SendKeys("{ENTER}"); + break; + case KeyboardActionKeyMode.Tab: + SendKeys("{TAB}"); + break; + case KeyboardActionKeyMode.Search: + SendKeys("{ENTER}"); + break; + } + + ActionKeyPressed?.Invoke(this, ActionKeyMode); + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.xaml b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.xaml new file mode 100644 index 000000000..b429d1a31 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.xaml @@ -0,0 +1,451 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 2 + 3 + + + + + + 4 + 5 + 6 + + 7 + 8 + 9 + + + 0 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboardMode.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboardMode.cs new file mode 100644 index 000000000..a087ebb4d --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboardMode.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Touch.Keyboard +{ + public enum TouchKeyboardMode + { + AlphaNumeric, + Integer, + Float, + Alpha + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.Touch/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..8ffc1d7c8 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Properties/AssemblyInfo.cs @@ -0,0 +1,17 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Touch Components")] +[assembly: ComVisible(false)] + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/Tango.Touch/Properties/Resources.Designer.cs b/Software/Visual_Studio/Tango.Touch/Properties/Resources.Designer.cs new file mode 100644 index 000000000..c664b142f --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.Touch.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // 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", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("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 { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.Touch.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 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 { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Properties/Resources.resx b/Software/Visual_Studio/Tango.Touch/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Properties/Settings.Designer.cs b/Software/Visual_Studio/Tango.Touch/Properties/Settings.Designer.cs new file mode 100644 index 000000000..4fcc7b647 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.Touch.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Properties/Settings.settings b/Software/Visual_Studio/Tango.Touch/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj new file mode 100644 index 000000000..347abe525 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -0,0 +1,123 @@ + + + + + Debug + AnyCPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A} + library + Tango.Touch + Tango.Touch + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\Build\Release\ + TRACE + prompt + 4 + + + + ..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll + + + + + + ..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll + True + + + + + + + + + 4.0 + + + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + GlobalVersionInfo.cs + + + + + + + + + + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml new file mode 100644 index 000000000..c31d2045f --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Touch/app.config b/Software/Visual_Studio/Tango.Touch/app.config new file mode 100644 index 000000000..462d17b27 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/app.config @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/packages.config b/Software/Visual_Studio/Tango.Touch/packages.config new file mode 100644 index 000000000..6d40ff3dd --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index e141547e8..879a7618c 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 +VisualStudioVersion = 15.0.26430.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Protobuf", "Tango.Protobuf\Tango.Protobuf.csproj", "{40073806-914E-4E78-97AB-FA9639308EBE}" EndProject @@ -183,6 +183,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialDesignThemes.Wpf", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tango.Emulations.Native", "Native\Tango.Emulations.Native\Tango.Emulations.Native.vcxproj", "{43ECCD8D-EE54-44EF-A51A-D77E3DF7263F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Touch", "Tango.Touch\Tango.Touch.csproj", "{FD86424C-6E84-491B-8DF9-3D0F5C236A2A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AppVeyor|Any CPU = AppVeyor|Any CPU @@ -3181,6 +3183,46 @@ Global {43ECCD8D-EE54-44EF-A51A-D77E3DF7263F}.Release|x64.Build.0 = Release|x64 {43ECCD8D-EE54-44EF-A51A-D77E3DF7263F}.Release|x86.ActiveCfg = Release|Win32 {43ECCD8D-EE54-44EF-A51A-D77E3DF7263F}.Release|x86.Build.0 = Release|Win32 + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|ARM.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|ARM.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|ARM64.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|x64.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|x64.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|x86.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.AppVeyor|x86.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|ARM.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|ARM.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|ARM64.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|x64.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|x64.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|x86.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Debug|x86.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|Any CPU.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|ARM.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|ARM.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|ARM64.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|ARM64.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|x64.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|x64.Build.0 = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|x86.ActiveCfg = Release|Any CPU + {FD86424C-6E84-491B-8DF9-3D0F5C236A2A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/App.config b/Software/Visual_Studio/Utilities/Tango.UITests/App.config index 11bd4153f..af8f0f852 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/App.config +++ b/Software/Visual_Studio/Utilities/Tango.UITests/App.config @@ -1,7 +1,7 @@  - + diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml index d7437894c..66d694084 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml @@ -5,13 +5,13 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Tango.UITests" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" - xmlns:keyboard="clr-namespace:Tango.SharedUI.Keyboard;assembly=Tango.SharedUI" + xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard;assembly=Tango.Touch" mc:Ignorable="d" Title="MainWindow" Height="280" Width="400"> - + 1 diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj b/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj index c669c67e7..a6053c44e 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj +++ b/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj @@ -98,6 +98,10 @@ {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI + + {fd86424c-6e84-491b-8df9-3d0f5c236a2a} + Tango.Touch + \ No newline at end of file -- cgit v1.3.1