diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch')
29 files changed, 270 insertions, 732 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs index 25d73c8fe..79e6739af 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs @@ -18,7 +18,6 @@ using System.Windows.Media.Animation; using Tango.Core.Commands; using Tango.Core.EventArguments; using Tango.Core.ExtensionMethods; -using Tango.Core.Threading; using Tango.DragAndDrop; using Tango.SharedUI.Helpers; using Tango.Touch.Components; @@ -32,8 +31,6 @@ namespace Tango.Touch.Controls private bool _isLoaded; private List<LightTouchDataGridRow> _awaitingSelectionRows; private LightTouchDataGridRow _firstMultiSelectionRow; - private ActionTimer _layoutRowsTimer; - private ActionTimer _updateLayoutTimer; #region Events @@ -222,8 +219,6 @@ namespace Tango.Touch.Controls /// </summary> public LightTouchDataGrid() { - _layoutRowsTimer = new ActionTimer(TimeSpan.FromMilliseconds(200)); - _updateLayoutTimer = new ActionTimer(TimeSpan.FromMilliseconds(200)); Columns = new ObservableCollection<LightTouchDataGridColumn>(); _awaitingSelectionRows = new List<LightTouchDataGridRow>(); SortCommand = new RelayCommand<LightTouchDataGridColumn>(HandleSortCommand); @@ -464,20 +459,14 @@ namespace Tango.Touch.Controls { if (_items_control_rows.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated) { - _updateLayoutTimer.ResetReplace(() => - { - Dispatcher.BeginInvoke(new Action(() => - { - _items_control_rows.UpdateLayout(); - LayoutRows(); - })); - }); + _items_control_rows.UpdateLayout(); + LayoutRows(); } } private void CollectionFilter_FilterChanged(object sender, EventArgs e) { - LayoutRows(); + LayoutRows(false); FilterChanged?.Invoke(this, new EventArgs()); } @@ -537,17 +526,6 @@ namespace Tango.Touch.Controls /// </summary> public void LayoutRows(bool allowAnimation = false) { - _layoutRowsTimer.ResetReplace(() => - { - Dispatcher.BeginInvoke(new Action(() => - { - LayoutRowsInternal(allowAnimation); - })); - }); - } - - private void LayoutRowsInternal(bool allowAnimation) - { if (_items_control_rows == null || !_isLoaded || !IsLoaded) return; var rows = _items_control_rows.ItemContainerGenerator.Items.Select(x => _items_control_rows.ItemContainerGenerator.ContainerFromItem(x) as ContentPresenter).ToList(); @@ -571,73 +549,65 @@ namespace Tango.Touch.Controls for (int i = 0; i < ordered.Count; i++) { - try - { - ContentPresenter contentPresenter = ordered[i]; - - LightTouchDataGridRow row = contentPresenter.FindChild<LightTouchDataGridRow>(); + ContentPresenter contentPresenter = ordered[i]; + LightTouchDataGridRow row = contentPresenter.FindChild<LightTouchDataGridRow>(); - bool display = true; + bool display = true; - if (CollectionFilter != null && row != null) - { - row.Visibility = CollectionFilter.Filter(row.DataContext) ? Visibility.Visible : Visibility.Collapsed; - display = row.Visibility == Visibility.Visible; - } + if (CollectionFilter != null && row != null) + { + row.Visibility = CollectionFilter.Filter(row.DataContext) ? Visibility.Visible : Visibility.Collapsed; + display = row.Visibility == Visibility.Visible; + } - if (display) + if (display) + { + if (AnimateSorting && allowAnimation) { - if (AnimateSorting && allowAnimation) + if (double.IsNaN(Canvas.GetTop(contentPresenter))) { - if (double.IsNaN(Canvas.GetTop(contentPresenter))) - { - Canvas.SetTop(contentPresenter, current_top); - Canvas.SetLeft(contentPresenter, 0); - } - else - { - int duration = _rnd.Next(200, 500); - - DoubleAnimation aniY = new DoubleAnimation(); - aniY.To = current_top; - aniY.Duration = TimeSpan.FromMilliseconds(duration); - contentPresenter.BeginAnimation(Canvas.TopProperty, aniY); - - DoubleAnimation aniX = new DoubleAnimation(); - aniX.FillBehavior = FillBehavior.Stop; - aniX.To = _rnd.Next(-20, 20); - aniX.AutoReverse = true; - aniX.Duration = TimeSpan.FromMilliseconds(duration / 2); - contentPresenter.BeginAnimation(Canvas.LeftProperty, aniX, HandoffBehavior.SnapshotAndReplace); - } + Canvas.SetTop(contentPresenter, current_top); + Canvas.SetLeft(contentPresenter, 0); } else { - if (AnimateSorting) - { - contentPresenter.BeginAnimation(Canvas.TopProperty, null); - } + int duration = _rnd.Next(200, 500); - Canvas.SetTop(contentPresenter, current_top); - Canvas.SetLeft(contentPresenter, 0); - } + DoubleAnimation aniY = new DoubleAnimation(); + aniY.To = current_top; + aniY.Duration = TimeSpan.FromMilliseconds(duration); + contentPresenter.BeginAnimation(Canvas.TopProperty, aniY); - if (row != null) - { - current_top += (row.Margin.Top + row.ActualHeight + row.Margin.Bottom); + DoubleAnimation aniX = new DoubleAnimation(); + aniX.FillBehavior = FillBehavior.Stop; + aniX.To = _rnd.Next(-20, 20); + aniX.AutoReverse = true; + aniX.Duration = TimeSpan.FromMilliseconds(duration / 2); + contentPresenter.BeginAnimation(Canvas.LeftProperty, aniX, HandoffBehavior.SnapshotAndReplace); } - - if (row != null && row.Tag == null) + } + else + { + if (AnimateSorting) { - row.RegisterForPreviewMouseOrTouchUp(OnRowMouseTouchUp); - row.RegisterForPreviewMouseOrTouchDown(OnRowMouseTouchDown); - row.Tag = 1; + contentPresenter.BeginAnimation(Canvas.TopProperty, null); } + + Canvas.SetTop(contentPresenter, current_top); + Canvas.SetLeft(contentPresenter, 0); + } + + if (row != null) + { + current_top += (row.Margin.Top + row.ActualHeight + row.Margin.Bottom); + } + + if (row != null && row.Tag == null) + { + row.RegisterForPreviewMouseOrTouchUp(OnRowMouseTouchUp); + row.RegisterForPreviewMouseOrTouchDown(OnRowMouseTouchDown); + row.Tag = 1; } - } - catch (Exception ex) - { - Debug.WriteLine(ex); } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs index a20f52d7b..934c22295 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs @@ -668,39 +668,7 @@ namespace Tango.Touch.Controls IsScrolling = false; } } - /// <summary> - /// Invoked when an unhandled <see cref="E:System.Windows.Input.Mouse.MouseWheel" /> attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. - /// </summary> - /// <param name="e">The <see cref="T:System.Windows.Input.MouseWheelEventArgs" /> that contains the event data.</param> - protected override void OnMouseWheel( MouseWheelEventArgs e) - { - base.OnMouseWheel(e); - if (DisableScrolling) - { - return; - } - base.OnMouseWheel(e); - if (!e.Handled ) - { - if (e.Delta != 0) - { - var scrollPos = GetScrollPosition(); - if (e.Delta > 0) - { - scrollPos -= 15; - } - else if(e.Delta < 0) - { - scrollPos += 15; - } - ScrollToPosition(scrollPos); - SetThumbPosition(); - } - } - - e.Handled = false; - } #endregion #region Private Methods diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchButton.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchButton.cs index e54cb6e86..38e3a9858 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchButton.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchButton.cs @@ -12,8 +12,6 @@ namespace Tango.Touch.Controls { public class TouchButton : Button, ITouchControl { - private bool _executingDelayCommand; - #region ITouchControl public CornerRadius CornerRadius @@ -86,7 +84,7 @@ namespace Tango.Touch.Controls set { SetValue(DelayCommandProperty, value); } } public static readonly DependencyProperty DelayCommandProperty = - DependencyProperty.Register("DelayCommand", typeof(ICommand), typeof(TouchButton), new PropertyMetadata(null, (d, e) => (d as TouchButton).OnDelayCommandChanged())); + DependencyProperty.Register("DelayCommand", typeof(ICommand), typeof(TouchButton), new PropertyMetadata(null,(d,e) => (d as TouchButton).OnDelayCommandChanged())); public Duration DelayCommandDuration { @@ -103,49 +101,18 @@ namespace Tango.Touch.Controls } - protected override void OnPreviewMouseDoubleClick(MouseButtonEventArgs e) - { - e.Handled = true; - } - - protected override void OnPreviewMouseDown(MouseButtonEventArgs e) - { - if (e.ClickCount >= 2) - { - e.Handled = true; - return; - } - - base.OnPreviewMouseDown(e); - } - protected override void OnClick() { - if (IsEnabled) - { - base.OnClick(); - PerformDelayCommand(); - } + base.OnClick(); + PerformDelayCommand(); } private async void PerformDelayCommand() { - if (DelayCommand != null && !_executingDelayCommand) + if (DelayCommand != null) { - try - { - _executingDelayCommand = true; - await Task.Delay(DelayCommandDuration.TimeSpan); - DelayCommand.Execute(CommandParameter); - } - catch (Exception) - { - throw; - } - finally - { - _executingDelayCommand = false; - } + await Task.Delay(DelayCommandDuration.TimeSpan); + DelayCommand.Execute(CommandParameter); } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchCheckBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchCheckBox.xaml index 3ece097fa..2e16aadd0 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchCheckBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchCheckBox.xaml @@ -35,12 +35,6 @@ </ControlTemplate> </Setter.Value> </Setter> - <Style.Triggers> - <Trigger Property="IsEnabled" Value="False"> - <Setter Property="BorderBrush" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> - <Setter Property="Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> - </Trigger> - </Style.Triggers> </Style> </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchClickableControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchClickableControl.cs deleted file mode 100644 index b14917846..000000000 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchClickableControl.cs +++ /dev/null @@ -1,129 +0,0 @@ -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.Input; -using System.Windows.Media; - -namespace Tango.Touch.Controls -{ - public class TouchClickableControl : Grid - { - private bool _isMouseDown; - - #region Properties - - public object CommandParameter - { - get { return (object)GetValue(CommandParameterProperty); } - set { SetValue(CommandParameterProperty, value); } - } - public static readonly DependencyProperty CommandParameterProperty = - DependencyProperty.Register("CommandParameter", typeof(object), typeof(TouchClickableControl), new PropertyMetadata(null)); - - #endregion - - #region Routed Events - - public static readonly RoutedEvent ClickEvent = EventManager.RegisterRoutedEvent("Click", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TouchClickableControl)); - public event RoutedEventHandler Click - { - add - { - AddHandler(ClickEvent, value); - } - remove - { - RemoveHandler(ClickEvent, value); - } - } - - #endregion - - #region Commands - - public ICommand Command - { - get { return (ICommand)GetValue(CommandProperty); } - set { SetValue(CommandProperty, value); } - } - public static readonly DependencyProperty CommandProperty = - DependencyProperty.Register("Command", typeof(ICommand), typeof(TouchClickableControl), new PropertyMetadata(null, (d, e) => (d as TouchClickableControl).OnCommandChanged())); - - #endregion - - #region Constructors - - public TouchClickableControl() - { - Background = Brushes.Transparent; - } - - #endregion - - #region Private Methods - - private void OnCommandChanged() - { - if (Command != null) - { - Command.CanExecuteChanged -= Command_CanExecuteChanged; - Command.CanExecuteChanged += Command_CanExecuteChanged; - } - } - - private void Command_CanExecuteChanged(object sender, EventArgs e) - { - IsEnabled = Command != null && Command.CanExecute(CommandParameter); - } - - #endregion - - #region Override Methods - - protected override void OnMouseDown(MouseButtonEventArgs e) - { - base.OnMouseDown(e); - _isMouseDown = true; - } - - protected override void OnMouseUp(MouseButtonEventArgs e) - { - base.OnMouseUp(e); - if (_isMouseDown) - { - OnClick(); - } - - _isMouseDown = false; - } - - protected override void OnMouseLeave(MouseEventArgs e) - { - base.OnMouseLeave(e); - _isMouseDown = false; - } - - #endregion - - #region Virtual Methods - - /// <summary> - /// Raises the click event and executes the command. - /// </summary> - protected virtual void OnClick() - { - RoutedEventArgs args = new RoutedEventArgs(TouchClickableControl.ClickEvent, this); - RaiseEvent(args); - if (Command != null && Command.CanExecute(CommandParameter)) - { - Command.Execute(CommandParameter); - } - } - - #endregion - } -} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchGifAnimation.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchGifAnimation.cs index 0f3eefb9b..38a2175d8 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchGifAnimation.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchGifAnimation.cs @@ -51,12 +51,12 @@ namespace Tango.Touch.Controls public TouchGifAnimation() { - //Loaded += TouchGifAnimation_Loaded; + Loaded += TouchGifAnimation_Loaded; } private void TouchGifAnimation_Loaded(object sender, RoutedEventArgs e) { - //EnableAnimation = EnableAnimation; + EnableAnimation = EnableAnimation; } static TouchGifAnimation() diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchIcon.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchIcon.cs index de5b8e90e..a41a56748 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchIcon.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchIcon.cs @@ -19,7 +19,7 @@ namespace Tango.Touch.Controls { private static IDictionary<TouchIconKind,String> _icons; - public static IDictionary<TouchIconKind,string> Icons + internal static IDictionary<TouchIconKind,string> Icons { get { diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchKeyboardContainer.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchKeyboardContainer.cs deleted file mode 100644 index 044791e4b..000000000 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchKeyboardContainer.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Controls; - -namespace Tango.Touch.Controls -{ - public class TouchKeyboardContainer : Grid - { - } -} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs index 4fa50b7e6..87e7717be 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs @@ -138,6 +138,8 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty ScrollBarVisibilityProperty = DependencyProperty.Register("ScrollBarVisibility", typeof(Visibility), typeof(TouchListBox), new PropertyMetadata(Visibility.Visible)); + + public String ValuePath { get { return (String)GetValue(ValuePathProperty); } @@ -228,7 +230,7 @@ namespace Tango.Touch.Controls } } - public List<TouchListBoxItem> GetItems() + private List<TouchListBoxItem> GetItems() { return _items_control.FindVisualChildren<TouchListBoxItem>().ToList(); } @@ -297,7 +299,6 @@ namespace Tango.Touch.Controls } else { - SelectedItem = item.DataContext; ItemSelectedCommand?.Execute(item.DataContext); } } @@ -359,7 +360,5 @@ namespace Tango.Touch.Controls var element = ScrollViewer.FindVisualChildren<FrameworkElement>().FirstOrDefault(x => x.DataContext == item); ScrollViewer.ScrollToElement(element); } - - } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchMultiLineTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchMultiLineTextBox.cs deleted file mode 100644 index f3c554a8c..000000000 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchMultiLineTextBox.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; - -namespace Tango.Touch.Controls -{ - public class TouchMultiLineTextBox : TextBox - { - public CornerRadius CornerRadius - { - get { return (CornerRadius)GetValue(CornerRadiusProperty); } - set { SetValue(CornerRadiusProperty, value); } - } - public static readonly DependencyProperty CornerRadiusProperty = - DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(TouchMultiLineTextBox), new PropertyMetadata(new CornerRadius(0))); - - - - static TouchMultiLineTextBox() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchMultiLineTextBox), new FrameworkPropertyMetadata(typeof(TouchMultiLineTextBox))); - } - } -} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchMultiLineTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchMultiLineTextBox.xaml deleted file mode 100644 index 494e7442e..000000000 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchMultiLineTextBox.xaml +++ /dev/null @@ -1,43 +0,0 @@ -<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard" - xmlns:local="clr-namespace:Tango.Touch.Controls"> - - <ResourceDictionary.MergedDictionaries> - <ResourceDictionary Source="../Resources/Colors.xaml" /> - </ResourceDictionary.MergedDictionaries> - - - <Style TargetType="{x:Type local:TouchMultiLineTextBox}"> - <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter> - <Setter Property="BorderBrush" Value="{StaticResource TangoDividerBrush}"></Setter> - <Setter Property="Foreground" Value="{StaticResource TangoDarkForegroundBrush}"></Setter> - <Setter Property="AcceptsReturn" Value="True"></Setter> - <Setter Property="TextWrapping" Value="Wrap"></Setter> - <Setter Property="Height" Value="60"></Setter> - <Setter Property="Padding" Value="5"></Setter> - <Setter Property="CornerRadius" Value="3"></Setter> - <Setter Property="BorderThickness" Value="1"></Setter> - <Setter Property="keyboard:KeyboardView.Mode" Value="AlphaNumeric"></Setter> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="{x:Type local:TouchMultiLineTextBox}"> - <Border x:Name="border" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"> - <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/> - </Border> - <ControlTemplate.Triggers> - <Trigger Property="IsEnabled" Value="false"> - <Setter Property="Opacity" TargetName="border" Value="0.56"/> - </Trigger> - <Trigger Property="IsMouseOver" Value="true"> - <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TangoDarkForegroundBrush}"/> - </Trigger> - <Trigger Property="IsKeyboardFocused" Value="true"> - <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TangoDarkForegroundBrush}"/> - </Trigger> - </ControlTemplate.Triggers> - </ControlTemplate> - </Setter.Value> - </Setter> - </Style> -</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs index 8ed4ead69..ef7e24ff4 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs @@ -27,7 +27,6 @@ namespace Tango.Touch.Controls public class TouchNotificationBar : ContentControl { private const double HEIGHT_RATIO = 0.75; - private const double DRAGPATH_HEIGH = 20.0; private bool _isMouseDown; private Point _mouseDownLocation; @@ -48,9 +47,18 @@ namespace Tango.Touch.Controls private Grid _notification_counter_grid; private LightTouchScrollViewer _scrollViewer; + static TouchNotificationBar() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchNotificationBar), new FrameworkPropertyMetadata(typeof(TouchNotificationBar))); + } - - #region Dep_Properties + public String ItemExpandedPropertyPath + { + get { return (String)GetValue(ItemExpandedPropertyPathProperty); } + set { SetValue(ItemExpandedPropertyPathProperty, value); } + } + public static readonly DependencyProperty ItemExpandedPropertyPathProperty = + DependencyProperty.Register("ItemExpandedPropertyPath", typeof(String), typeof(TouchNotificationBar), new PropertyMetadata(null)); public bool HasNotifications { @@ -107,18 +115,8 @@ namespace Tango.Touch.Controls } public static readonly DependencyProperty NotificationBarVisibilityProperty = DependencyProperty.Register("NotificationBarVisibility", typeof(Visibility), typeof(TouchNotificationBar), new PropertyMetadata(Visibility.Visible)); - - #endregion - - #region constructors - - static TouchNotificationBar() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchNotificationBar), new FrameworkPropertyMetadata(typeof(TouchNotificationBar))); - } public TouchNotificationBar() { - IsExpanded = false; Loaded += TouchNotificationBar_Loaded; NotificationPressedCommand = new RelayCommand(() => @@ -130,10 +128,10 @@ namespace Tango.Touch.Controls }); } - #endregion - - - #region Override_Base + private void TouchNotificationBar_Loaded(object sender, RoutedEventArgs e) + { + _border_drag.MaxHeight = ActualHeight; + } public override void OnApplyTemplate() { @@ -145,121 +143,169 @@ namespace Tango.Touch.Controls _items_control = GetTemplateChild("PART_ItemsControl") as ItemsControl; _notification_counter_grid = GetTemplateChild("PART_NotificationCounterGrid") as Grid; _scrollViewer = GetTemplateChild("PART_ScrollViewer") as LightTouchScrollViewer; - + + //border_notifications.IsManipulationEnabled = true; _border_drag.RegisterForPreviewMouseOrTouchDown(GridNotificationMouseDown); _border_drag.RegisterForMouseOrTouchMove(GridNotificationMouseMove); _border_drag.RegisterForPreviewMouseOrTouchUp(GridNotificationMouseUp); - _border_drag.SizeChanged += Drag_Border_SizeChanged; + _border_drag.SizeChanged += Drag_Border_SizeChanged; + _items_control.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged; } - #endregion + private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e) + { + if (_items_control.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) + { + if (_items_control.Items.Count > 0) + { + var element = _items_control.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement; + if (element != null) + { + element.RegisterForLoadedOrNow((x, y) => + { + CurrentMinHeight = element.ActualHeight; + ResizeNotification(element); + }); + } + } + else + { + CurrentMinHeight = 0; + } + } + } private FrameworkElement GetLastNotification() { return _items_control.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement; } - private void TouchNotificationBar_Loaded(object sender, RoutedEventArgs e) - { - _border_drag.MaxHeight = ActualHeight; - } private void Drag_Border_SizeChanged(object sender, SizeChangedEventArgs e) { _grid_mask.Opacity = _border_drag.ActualHeight / ActualHeight; - if (e.NewSize.Height > CurrentMinHeight && CurrentMinHeight > 0 ) + ResizeNotifications(); + + if (e.NewSize.Height > CurrentMinHeight && CurrentMinHeight > 0) { _notification_counter_grid.Visibility = Visibility.Hidden; } - else if(Notifications.Count > 1 && CurrentMinHeight > 0) + else { _notification_counter_grid.Visibility = Visibility.Visible; } } - /// <summary> - /// Called when has notifications items or all items removed - /// </summary> - private void OnHasNotificationsChanged() + private void ResizeNotifications() { - if (HasNotifications) + for (int i = 0; i < _items_control.Items.Count; i++) { - UpdateMinHeightByDispalyedItem(); + FrameworkElement element = _items_control.ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement; + ResizeNotification(element); } - else + } + + private void ResizeNotification(FrameworkElement element) + { + var control = element.FindChild<UserControl>(); + + if (control != null && !double.IsNaN(_border_drag.Height)) { - CurrentMinHeight = 0; - if (IsExpanded) - { - CloseNotifications(); - } - _border_notifications.Height = CurrentMinHeight; - _grid_container.MinHeight = 0; - _grid_container.Height = 0; + control.Height = ((_border_drag.Height - CurrentMinHeight) / ActualHeight) * (control.MaxHeight - control.MinHeight) + control.MinHeight; } } - private void UpdateMinHeightByDispalyedItem() + private void OnHasNotificationsChanged() { - var last = GetLastNotification(); - if(last != null) + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(0.2); + + _grid_container.EnsureHeight(); + + if (HasNotifications) { - last.RegisterForLoadedOrNow((x, y) => + var last = GetLastNotification(); + + last.RegisterForLoadedOrNow((x, e) => { - CurrentMinHeight = last.ActualHeight; + ani.To = last.ActualHeight; + _grid_container.BeginAnimation(Grid.HeightProperty, ani); _border_notifications.Height = last.ActualHeight; - _grid_container.MinHeight = last.ActualHeight; - _grid_container.Height = CurrentMinHeight; }); } + else + { + CurrentMinHeight = 0; + ani.To = 0; + CloseNotifications(); + _grid_container.BeginAnimation(Grid.HeightProperty, ani); + } } - /// <summary> - /// Callback function on Notifications property - /// </summary> - private void OnNotificationsChanged() + + private void OnNotificationsChanged() { + UpdateExpanded(IsExpanded); + if (Notifications is INotifyCollectionChanged) { - (Notifications as INotifyCollectionChanged).CollectionChanged += (_, e) => + (Notifications as INotifyCollectionChanged).CollectionChanged += (_, __) => { this.BeginInvoke(() => { - if(Notifications.Count > 0) - { - UpdateMinHeightByDispalyedItem(); - } - if (IsExpanded == false && Notifications.Count > 1) - { - _notification_counter_grid.Visibility = Visibility.Visible; - } - else - { - _notification_counter_grid.Visibility = Visibility.Hidden; - } + UpdateExpanded(IsExpanded); }); - }; - + }; } } - - #region Mouse handlers + + private void UpdateExpanded(bool expanded) + { + if (ItemExpandedPropertyPath != null) + { + foreach (var item in Notifications.Cast<Object>().ToList()) + { + item.SetPropertyValueByPath(ItemExpandedPropertyPath, expanded); + } + } + } + private void OpenNotifications() { + _border_drag.EnsureHeight(); + _border_notifications.EnsureHeight(); + _border_drag.StartDoubleAnimation(Border.HeightProperty, TimeSpan.FromSeconds(0.2), _border_drag.MaxHeight, null, null, 1, () => - { - IsExpanded = true; - }); + { + IsExpanded = true; + }); _border_notifications.StartDoubleAnimation(Border.HeightProperty, TimeSpan.FromSeconds(0.2), ActualHeight * HEIGHT_RATIO, null, null, 1); + + UpdateExpanded(true); } private void CloseNotifications() { + _border_drag.EnsureHeight(); + _border_notifications.EnsureHeight(); + _border_notifications.StartDoubleAnimation(Border.HeightProperty, TimeSpan.FromSeconds(0.2), CurrentMinHeight, null, 1, null, () => { _border_notifications.BeginAnimation(Border.HeightProperty, null); _border_notifications.Height = CurrentMinHeight; + + for (int i = 0; i < _items_control.Items.Count; i++) + { + FrameworkElement element = _items_control.ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement; + + var control = element.FindChild<UserControl>(); + + if (control != null) + { + control.Height = control.MinHeight; + } + } }); _border_drag.StartDoubleAnimation(Border.HeightProperty, TimeSpan.FromSeconds(0.2), CurrentMinHeight, null, 1, null, () => @@ -272,7 +318,9 @@ namespace Tango.Touch.Controls tAni.Duration = TimeSpan.FromSeconds(0.3); tAni.To = new Thickness(0); _border_notifications.BeginAnimation(Border.BorderThicknessProperty, tAni); - + + UpdateExpanded(false); + IsExpanded = false; Task.Delay(400).ContinueWith((x) => @@ -365,7 +413,7 @@ namespace Tango.Touch.Controls if (_border_notifications.ActualHeight > CurrentMinHeight) { - _border_notifications.BorderThickness = new Thickness(0, 0, 0, DRAGPATH_HEIGH); + _border_notifications.BorderThickness = new Thickness(0, 0, 0, 20); } else { @@ -388,7 +436,5 @@ namespace Tango.Touch.Controls _isMouseDown = true; } } - - #endregion } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml index 689981de6..d097aa2bb 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml @@ -8,6 +8,7 @@ <ResourceDictionary Source="../Resources/Colors.xaml" /> </ResourceDictionary.MergedDictionaries> + <converters:GreaterThanToBooleanConverter x:Key="GreaterThanToBooleanConverter" /> <Style TargetType="{x:Type local:TouchNotificationBar}"> <Setter Property="Template"> @@ -26,6 +27,7 @@ <ContentPresenter Grid.Row="1" Content="{TemplateBinding Content}" /> <Grid x:Name="PART_GridMask" Grid.RowSpan="2" Background="{StaticResource TangoNotificationBarMaskBrush}" Opacity="0" IsHitTestVisible="False"> + </Grid> <Grid x:Name="PART_Grid_Container" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent},Path=NotificationBarVisibility}" VerticalAlignment="Top" Background="Transparent" ClipToBounds="False"> @@ -34,7 +36,6 @@ <Border x:Name="PART_BorderNotifications" VerticalAlignment="Top" BorderBrush="{StaticResource TangoNotificationBarBottomBorderBrush}" Background="{StaticResource TangoNotificationBarBackgroundBrush}"> <local:LightTouchScrollViewer x:Name="PART_ScrollViewer"> <ItemsControl x:Name="PART_ItemsControl" ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Notifications}"> - <ItemsControl.ItemTemplate> <DataTemplate> <Border Background="{StaticResource TangoNotificationBackgroundBrush}" BorderBrush="{StaticResource TangoNotificationBorderBrush}" BorderThickness="0 0 0 0"> @@ -52,9 +53,20 @@ </Border> </Border> - <Grid x:Name="PART_NotificationCounterGrid" Canvas.Left="41" Canvas.Top="19" Width="24" Height="24" HorizontalAlignment="Left" VerticalAlignment="Bottom" IsHitTestVisible="False" Visibility="Collapsed"> + <Grid x:Name="PART_NotificationCounterGrid" Canvas.Left="41" Canvas.Top="19" Width="24" Height="24" HorizontalAlignment="Left" VerticalAlignment="Bottom" IsHitTestVisible="False"> <Grid> - <Ellipse Fill="White" StrokeThickness="1" Stroke="{StaticResource TangoPrimaryAccentBrush}"/> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=Notifications.Count,Converter={StaticResource GreaterThanToBooleanConverter},ConverterParameter=1}" Value="True"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + <Ellipse Fill="White" StrokeThickness="1" Stroke="{StaticResource TangoPrimaryAccentBrush}"> + </Ellipse> <TextBlock HorizontalAlignment="Center" FontSize="12" VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=Notifications.Count}"></TextBlock> </Grid> </Grid> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index 2a0caf13e..bf571f36a 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -175,16 +175,6 @@ namespace Tango.Touch.Controls } _text_block.Text = Value.ToString(StringFormat); - - BindingExpression b = GetBindingExpression(ValueProperty); - - if (b != null) - { - b.UpdateSource(); - } - - DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(ValueChangedEvent, this, Value); - RaiseEvent(args); } private void _text_box_PreviewKeyDown(object sender, KeyEventArgs e) diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs index 1993e8cae..6aa92d15e 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -23,7 +22,6 @@ namespace Tango.Touch.Controls private TouchIconButton _comboBoxCloseButton; private TouchCalendar _calendar; private Grid _calendar_grid; - private bool _isDialogGridMaskMouseDown; static TouchPanel() { @@ -32,19 +30,19 @@ namespace Tango.Touch.Controls public TouchPanel() { - ComboBoxPickedCommand = new RelayCommand((x) => + ComboBoxPickedCommand = new RelayCommand((x) => { CurrentComboBox.SetResultFromTouchPanel(x); CurrentComboBox = null; }); - DateSelectedCommand = new RelayCommand(() => + DateSelectedCommand = new RelayCommand(() => { CurrentDatePicker.SetResultFromTouchPanel(_calendar.SelectedDate.Value); CurrentDatePicker = null; }); - CancelDateCommand = new RelayCommand(() => + CancelDateCommand = new RelayCommand(() => { CurrentDatePicker = null; }); @@ -72,9 +70,6 @@ namespace Tango.Touch.Controls _comboBoxCloseButton = GetTemplateChild("PART_comboboxCloseButton") as TouchIconButton; _calendar_grid = GetTemplateChild("PART_datepicker_grid") as Grid; _calendar = GetTemplateChild("PART_calendar") as TouchCalendar; - var gridDialogsMask = GetTemplateChild("PART_gridDialogsMask") as Grid; - gridDialogsMask.MouseUp += GridDialogsMask_MouseUp; - gridDialogsMask.MouseDown += GridDialogsMask_MouseDown; _comboBoxCloseButton.RegisterForPreviewMouseOrTouchUp(OnComboBoxClose); _combobox_grid.RegisterForMouseOrTouchDown(OnComboBoxGridDown); @@ -84,34 +79,6 @@ namespace Tango.Touch.Controls _calendar.SelectedDatesChanged += _calendar_SelectedDatesChanged; } - private void GridDialogsMask_MouseDown(object sender, MouseButtonEventArgs e) - { - _isDialogGridMaskMouseDown = true; - } - - private void GridDialogsMask_MouseUp(object sender, MouseButtonEventArgs e) - { - if (_isDialogGridMaskMouseDown) - { - if (e.Source == sender) - { - try - { - if ((CurrentDialog.DataContext as DialogViewVM).CanClose) - { - (CurrentDialog.DataContext as DialogViewVM).CloseCommand?.Execute(null); - } - } - catch (Exception ex) - { - Debug.WriteLine($"Error in touch panel {ex.ToString()}"); - } - } - } - - _isDialogGridMaskMouseDown = false; - } - private void _calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) { Mouse.Capture(null); @@ -181,7 +148,7 @@ namespace Tango.Touch.Controls set { SetValue(CurrentComboBoxProperty, value); } } internal static readonly DependencyProperty CurrentComboBoxProperty = - DependencyProperty.Register("CurrentComboBox", typeof(TouchComboBox), typeof(TouchPanel), new PropertyMetadata(null, (d, e) => (d as TouchPanel).OnCurrentComboBoxChanged())); + DependencyProperty.Register("CurrentComboBox", typeof(TouchComboBox), typeof(TouchPanel), new PropertyMetadata(null,(d,e) => (d as TouchPanel).OnCurrentComboBoxChanged())); internal TouchDatePicker CurrentDatePicker { diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml index dd405a6c3..2b35a5ede 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml @@ -43,44 +43,6 @@ <!--</local:TouchNotificationBar>--> </DockPanel> - <!--Dialogs--> - <Grid> - <Grid.Style> - <Style TargetType="Grid"> - <!--<Setter Property="Opacity" Value="0"></Setter>--> - <Setter Property="Visibility" Value="Hidden"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent},Path=HasDialog}" Value="True"> - <Setter Property="Visibility" Value="Visible"></Setter> - <!--<DataTrigger.EnterActions> - <BeginStoryboard> - <Storyboard> - <DoubleAnimation To="1" Storyboard.TargetProperty="Opacity" Duration="00:00:0.2" /> - </Storyboard> - </BeginStoryboard> - </DataTrigger.EnterActions>--> - </DataTrigger> - </Style.Triggers> - </Style> - </Grid.Style> - - <Grid Background="#9E000000" x:Name="PART_gridDialogsMask"> - <!--<i:Interaction.Triggers> - <i:EventTrigger EventName="MouseUp"> - <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource TemplatedParent},Path=CurrentDialog.DataContext.CloseCommand}" /> - </i:EventTrigger> - </i:Interaction.Triggers>--> - </Grid> - - <Border Background="{StaticResource TangoPrimaryBackgroundBrush}" CornerRadius="5" Padding="10" HorizontalAlignment="Center" VerticalAlignment="Center"> - <Border.Effect> - <DropShadowEffect BlurRadius="10" /> - </Border.Effect> - - <ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent},Path=CurrentDialog}" /> - </Border> - </Grid> - <!--Combo Box PopUp--> <Grid Background="#9E000000" x:Name="PART_combobox_grid"> <Grid.Style> @@ -169,6 +131,44 @@ </Grid> </Grid> + <!--Dialogs--> + <Grid> + <Grid.Style> + <Style TargetType="Grid"> + <!--<Setter Property="Opacity" Value="0"></Setter>--> + <Setter Property="Visibility" Value="Hidden"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent},Path=HasDialog}" Value="True"> + <Setter Property="Visibility" Value="Visible"></Setter> + <!--<DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation To="1" Storyboard.TargetProperty="Opacity" Duration="00:00:0.2" /> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions>--> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + + <Grid Background="#9E000000"> + <i:Interaction.Triggers> + <i:EventTrigger EventName="MouseDown"> + <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource TemplatedParent},Path=CurrentDialog.DataContext.CloseCommand}" /> + </i:EventTrigger> + </i:Interaction.Triggers> + </Grid> + + <Border Background="{StaticResource TangoPrimaryBackgroundBrush}" CornerRadius="5" Padding="10" HorizontalAlignment="Center" VerticalAlignment="Center"> + <Border.Effect> + <DropShadowEffect BlurRadius="10" /> + </Border.Effect> + + <ContentPresenter Content="{Binding RelativeSource={RelativeSource TemplatedParent},Path=CurrentDialog}" /> + </Border> + </Grid> + <!--Messages--> <Grid Background="#9E000000"> <Grid.Style> @@ -242,7 +242,7 @@ <local:TouchButton x:Name="btnOK" FontWeight="Normal" Width="220" CornerRadius="25" FontSize="{StaticResource TangoMessageBoxButtonFontSize}" Margin="30 0 0 0" Style="{StaticResource TangoHollowButton}" Command="{Binding OKCommand}">OK</local:TouchButton> </StackPanel> - <TextBlock FontSize="{StaticResource TangoMessageBoxMessageFontSize}" Text="{Binding Message}" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" Margin="10 0"></TextBlock> + <TextBlock FontSize="{StaticResource TangoMessageBoxMessageFontSize}" Text="{Binding Message}" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap"></TextBlock> </DockPanel> </Grid> @@ -263,7 +263,7 @@ </Style> </Grid.Style> - <Grid MinHeight="390" Margin="20" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Center"> + <Grid Height="360" Margin="20" RenderTransformOrigin="0.5,0.5"> <Grid.Style> <Style TargetType="Grid"> <Setter Property="RenderTransform"> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchRadioButton.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchRadioButton.cs deleted file mode 100644 index 88fd4906d..000000000 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchRadioButton.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Controls; -using System.Windows; - -namespace Tango.Touch.Controls -{ - public class TouchRadioButton : RadioButton - { - static TouchRadioButton() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchRadioButton), new FrameworkPropertyMetadata(typeof(TouchRadioButton))); - } - } -} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchRadioButton.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchRadioButton.xaml deleted file mode 100644 index e854f9fcb..000000000 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchRadioButton.xaml +++ /dev/null @@ -1,41 +0,0 @@ -<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:components="clr-namespace:Tango.Touch.Components" - xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" - xmlns:fa="http://schemas.fontawesome.io/icons/" - xmlns:local="clr-namespace:Tango.Touch.Controls"> - <ResourceDictionary.MergedDictionaries> - <ResourceDictionary Source="../Resources/Colors.xaml" /> - <ResourceDictionary> - <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> - </ResourceDictionary> - </ResourceDictionary.MergedDictionaries> - <Style TargetType="{x:Type local:TouchRadioButton}"> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> - <Setter Property="BorderThickness" Value="1"></Setter> - <Setter Property="BorderBrush" Value="{StaticResource TangoGrayBrush}"></Setter> - <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter> - <Setter Property="MinHeight" Value="40"></Setter> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="{x:Type local:TouchRadioButton}"> - <Border Padding="{TemplateBinding Padding}" Background="Transparent"> - <components:Ripple RippleBrush="{StaticResource TangoRippleDarkBrush}" RippleFactor="20" > - <BulletDecorator Background="Transparent" VerticalAlignment="Center"> - <BulletDecorator.Bullet> - <Grid Width="30" Height="30"> - <Ellipse x:Name="Ellipse_Border" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/> - <Ellipse Margin="8" x:Name="CheckMark" Fill="{TemplateBinding Foreground}" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchRadioButton},Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter}}"/> - </Grid> - </BulletDecorator.Bullet> - <ContentPresenter TextElement.Foreground="{StaticResource TangoDarkForegroundBrush}" Margin="10 0 0 0" VerticalAlignment="Center" Content="{TemplateBinding Content}"></ContentPresenter> - </BulletDecorator> - </components:Ripple> - </Border> - </ControlTemplate> - </Setter.Value> - </Setter> - </Style> - -</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchSimpleDataGrid.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchSimpleDataGrid.cs index c0b455a55..7cc2f3d2a 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchSimpleDataGrid.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchSimpleDataGrid.cs @@ -14,15 +14,5 @@ namespace Tango.Touch.Controls { DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchSimpleDataGrid), new FrameworkPropertyMetadata(typeof(TouchSimpleDataGrid))); } - - public TouchSimpleDataGrid() - { - SelectionChanged += TouchSimpleDataGrid_SelectionChanged; - } - - private void TouchSimpleDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - SelectedItem = null; - } } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs index be9e4abcf..224de18a8 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.cs @@ -34,17 +34,6 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(String), typeof(TouchTextBox), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, (d, e) => (d as TouchTextBox).OnTextChanged())); - - public int MaxLength - { - get { return (int)GetValue(MaxLengthProperty); } - set { SetValue(MaxLengthProperty, value); } - } - public static readonly DependencyProperty MaxLengthProperty = - DependencyProperty.Register("MaxLength", typeof(int), typeof(TouchTextBox), new PropertyMetadata(0)); - - - private void OnTextChanged() { TextChanged?.Invoke(this, new EventArgs()); diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml index dcb52859e..e6acda366 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml @@ -104,8 +104,8 @@ <Grid> <components:Ripple RippleBrush="{StaticResource TangoRippleDarkBrush}" RippleFactor="15"> <Grid> - <TextBox MaxLength="{TemplateBinding MaxLength}" IsReadOnly="{TemplateBinding IsReadOnly}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Foreground="{TemplateBinding Foreground}" Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_TextBox" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=Text,UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=IsPassword,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></TextBox> - <PasswordBox MaxLength="{TemplateBinding MaxLength}" Foreground="{TemplateBinding Foreground}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_PasswordBox" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=IsPassword,Converter={StaticResource BooleanToVisibilityConverter}}"></PasswordBox> + <TextBox IsReadOnly="{TemplateBinding IsReadOnly}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Foreground="{TemplateBinding Foreground}" Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_TextBox" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=Text,UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=IsPassword,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></TextBox> + <PasswordBox Foreground="{TemplateBinding Foreground}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Padding="0 0 0 4" CaretBrush="{StaticResource TangoPrimaryAccentBrush}" FocusVisualStyle="{x:Null}" x:Name="PART_PasswordBox" BorderThickness="0" Background="Transparent" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchTextBox},Path=IsPassword,Converter={StaticResource BooleanToVisibilityConverter}}"></PasswordBox> <TextBlock IsHitTestVisible="False" Text="{TemplateBinding Watermark}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Foreground="{StaticResource TangoTextWatermarkBrush}"> <TextBlock.Style> <Style TargetType="TextBlock"> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs index bb9f260c0..72bb7dd06 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs @@ -128,30 +128,26 @@ namespace Tango.Touch.Controls Rect bounds = new Rect(_location.X, _location.Y, ActualWidth, ActualHeight); Rect rect = new Rect(0.0, _scrollViewer.GetScrollPosition(), _border_viewport.ActualWidth, _border_viewport.ActualHeight); - - if (_innerBorder != null) + if (bounds.IntersectsWith(rect)) { - if (bounds.IntersectsWith(rect)) + if (_innerBorder.Visibility == Visibility.Hidden) { - if (_innerBorder.Visibility == Visibility.Hidden) + //Debug.WriteLine("Visible"); + Dispatcher.BeginInvoke(new Action(() => { - //Debug.WriteLine("Visible"); - Dispatcher.BeginInvoke(new Action(() => - { - _innerBorder.Visibility = Visibility.Visible; - }), DispatcherPriority.Background); - } + _innerBorder.Visibility = Visibility.Visible; + }), DispatcherPriority.Background); } - else + } + else + { + if (_innerBorder.Visibility == Visibility.Visible) { - if (_innerBorder.Visibility == Visibility.Visible) + Dispatcher.BeginInvoke(new Action(() => { - Dispatcher.BeginInvoke(new Action(() => - { //Debug.WriteLine("Hidden"); _innerBorder.Visibility = Visibility.Hidden; - }), DispatcherPriority.Background); - } + }), DispatcherPriority.Background); } } } diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardOutputMode.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardOutputMode.cs deleted file mode 100644 index 978ae61ca..000000000 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardOutputMode.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Touch.Keyboard -{ - public enum KeyboardOutputMode - { - Wpf, - Windows, - } -} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs index 3f9106089..786a1799a 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.cs @@ -26,8 +26,6 @@ namespace Tango.Touch.Keyboard [ContentProperty(nameof(View))] public partial class KeyboardView : Control { - public event EventHandler KeyboardOpened; - public event EventHandler KeyboardClosed; private static KeyboardView _instance; private List<Object> _has_focus_objects = new List<object>(); @@ -45,19 +43,6 @@ namespace Tango.Touch.Keyboard #region Properties - public static KeyboardView Default - { - get { return _instance; } - } - - public static TouchKeyboard Keyboard - { - get - { - return Default.keyboard; - } - } - public bool IsOpened { get { return (bool)GetValue(IsOpenedProperty); } @@ -74,14 +59,6 @@ namespace Tango.Touch.Keyboard public static readonly DependencyProperty ViewProperty = DependencyProperty.Register("View", typeof(FrameworkElement), typeof(KeyboardView), new PropertyMetadata(null)); - public KeyboardOutputMode OutputMode - { - get { return (KeyboardOutputMode)GetValue(OutputModeProperty); } - set { SetValue(OutputModeProperty, value); } - } - public static readonly DependencyProperty OutputModeProperty = - DependencyProperty.Register("OutputMode", typeof(KeyboardOutputMode), typeof(KeyboardView), new PropertyMetadata(KeyboardOutputMode.Wpf)); - #endregion #region Attached Properties @@ -135,30 +112,21 @@ namespace Tango.Touch.Keyboard { if (!IsOpened) { - if (OutputMode == KeyboardOutputMode.Wpf) + if (GetContainer(_lastFocusedElement) != null) { - if (GetContainer(_lastFocusedElement) != null) - { - var scrollViewers = this.FindVisualChildren<LightTouchScrollViewer>().ToList(); + var scrollViewers = this.FindVisualChildren<LightTouchScrollViewer>().ToList(); - scrollViewers.ForEach(x => x.DisableScrolling = true); + scrollViewers.ForEach(x => x.DisableScrolling = true); - ThicknessAnimation ani = new ThicknessAnimation(); - ani.Completed += (_, __) => - { - scrollViewers.ForEach(x => x.DisableScrolling = false); - }; - ani.To = new Thickness(0); - ani.Duration = TimeSpan.FromSeconds(0.2); - GetContainer(_lastFocusedElement).BeginAnimation(FrameworkElement.MarginProperty, ani); - } + ThicknessAnimation ani = new ThicknessAnimation(); + ani.Completed += (_, __) => + { + scrollViewers.ForEach(x => x.DisableScrolling = false); + }; + ani.To = new Thickness(0); + ani.Duration = TimeSpan.FromSeconds(0.2); + GetContainer(_lastFocusedElement).BeginAnimation(FrameworkElement.MarginProperty, ani); } - - KeyboardClosed?.Invoke(this, new EventArgs()); - } - else - { - KeyboardOpened?.Invoke(this, new EventArgs()); } } @@ -350,7 +318,7 @@ namespace Tango.Touch.Keyboard private void OnMouseDown(object sender, MouseOrTouchEventArgs e) { - if (e.OriginalSource.GetType().Name != "TextBoxView" && e.Source == _content_presenter && IsOpened && OutputMode == KeyboardOutputMode.Wpf) + if (e.OriginalSource.GetType().Name != "TextBoxView" && e.Source == _content_presenter && IsOpened) { IsOpened = false; } diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml index 8458b4cab..328820913 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/KeyboardView.xaml @@ -42,7 +42,7 @@ </Style> </Grid.Style> <Border BorderThickness="0 1 0 0" BorderBrush="#404040"> - <local:TouchKeyboard x:Name="PART_Keyboard" OutputMode="{TemplateBinding OutputMode}"></local:TouchKeyboard> + <local:TouchKeyboard x:Name="PART_Keyboard"></local:TouchKeyboard> </Border> </Grid> </Grid> diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs index 9a6b7227f..1856fd2ac 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs @@ -67,14 +67,6 @@ namespace Tango.Touch.Keyboard public static readonly DependencyProperty ModeProperty = DependencyProperty.Register("Mode", typeof(TouchKeyboardMode), typeof(TouchKeyboard), new PropertyMetadata(TouchKeyboardMode.AlphaNumeric)); - public KeyboardOutputMode OutputMode - { - get { return (KeyboardOutputMode)GetValue(OutputModeProperty); } - set { SetValue(OutputModeProperty, value); } - } - public static readonly DependencyProperty OutputModeProperty = - DependencyProperty.Register("OutputMode", typeof(KeyboardOutputMode), typeof(TouchKeyboard), new PropertyMetadata(KeyboardOutputMode.Wpf)); - public KeyboardActionKeyMode ActionKeyMode { get { return (KeyboardActionKeyMode)GetValue(ActionKeyModeProperty); } @@ -497,7 +489,7 @@ namespace Tango.Touch.Keyboard } - if (key.Length > 1 || (isSpecialChar && definition.KeysLinesDefinitions.SelectMany(x => x.KeyDefinitions).Select(x => x.StandardText).Contains(key)) || OutputMode == KeyboardOutputMode.Windows) + if (key.Length > 1 || (isSpecialChar && definition.KeysLinesDefinitions.SelectMany(x => x.KeyDefinitions).Select(x => x.StandardText).Contains(key))) { Core.Threading.ThreadFactory.StartNew(() => { @@ -505,13 +497,9 @@ namespace Tango.Touch.Keyboard { Forms.SendKeys.SendWait(key); } - else if (key != " ") - { - Forms.SendKeys.SendWait("{" + key + "}"); - } else { - Forms.SendKeys.SendWait(" "); + Forms.SendKeys.SendWait("{" + key + "}"); } Forms.SendKeys.Flush(); diff --git a/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml b/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml index b4eb5a9e1..2fd056b6d 100644 --- a/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml +++ b/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml @@ -37,11 +37,6 @@ <Setter Property="Padding" Value="10 5"></Setter> <Setter Property="RippleBrush" Value="{StaticResource TangoRippleDarkBrush}"></Setter> <Setter Property="FontSize" Value="{StaticResource TangoDefaultFontSize}"></Setter> - <Style.Triggers> - <Trigger Property="IsEnabled" Value="False"> - <Setter Property="Foreground" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> - </Trigger> - </Style.Triggers> </Style> <Style x:Key="TangoHollowButton" TargetType="{x:Type controls:TouchButton}"> diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 7dd560a48..cac9f47e4 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -70,7 +70,6 @@ <Compile Include="Controls\TouchAutoComplete.cs" /> <Compile Include="Controls\TouchCalendar.cs" /> <Compile Include="Controls\TouchCheckBox.cs" /> - <Compile Include="Controls\TouchClickableControl.cs" /> <Compile Include="Controls\TouchComboBox.cs" /> <Compile Include="Controls\TouchDatePicker.cs" /> <Compile Include="Controls\TouchDropShadowBorder.cs" /> @@ -81,14 +80,11 @@ <Compile Include="Controls\TouchIconKind.cs" /> <Compile Include="Controls\TouchImageButton.cs" /> <Compile Include="Controls\TouchInput.cs" /> - <Compile Include="Controls\TouchKeyboardContainer.cs" /> <Compile Include="Controls\TouchListBox.cs" /> <Compile Include="Controls\TouchListBoxItem.cs" /> - <Compile Include="Controls\TouchMultiLineTextBox.cs" /> <Compile Include="Controls\TouchNativeListBox.cs" /> <Compile Include="Controls\TouchNumericTextBox.cs" /> <Compile Include="Controls\TouchProgressBar.cs" /> - <Compile Include="Controls\TouchRadioButton.cs" /> <Compile Include="Controls\TouchRingProgress.cs" /> <Compile Include="Controls\TouchSimpleDataGrid.cs" /> <Compile Include="Controls\TouchSlider.cs" /> @@ -169,10 +165,6 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="Controls\TouchMultiLineTextBox.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> <Page Include="Controls\TouchNativeListBox.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -221,10 +213,6 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="Controls\TouchRadioButton.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> <Page Include="Controls\TouchRingProgress.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -363,7 +351,6 @@ <Compile Include="Keyboard\KeyboardDefinition.cs" /> <Compile Include="Keyboard\KeyboardModeToVisibilityConverter.cs" /> <Compile Include="Keyboard\KeyboardModeToVisibilityInverseConverter.cs" /> - <Compile Include="Keyboard\KeyboardOutputMode.cs" /> <Compile Include="Keyboard\KeyboardView.cs" /> <Compile Include="Keyboard\KeyDefinition.cs" /> <Compile Include="Keyboard\KeysLineDefinition.cs" /> diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index ed0f289b0..f5b8f3caa 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -28,7 +28,6 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchTextBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchListBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchCheckBox.xaml" /> - <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchRadioButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchComboBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchExpander.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchToggleSlider.xaml" /> @@ -48,7 +47,6 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchVirtualizedContentControl.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchDropShadowBorder.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchSimpleDataGrid.xaml" /> - <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchMultiLineTextBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchToggleImageButton.xaml" /> |
