From 26ede873b194b0df70979b6f1b62e0c91ca19341 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 20 Apr 2019 21:48:32 +0300 Subject: Working on PPC performance... --- .../Controls/TouchVirtualizedContentControl.cs | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs') diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs new file mode 100644 index 000000000..8e3db84fa --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs @@ -0,0 +1,99 @@ +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.Markup; +using System.Windows.Shapes; +using Tango.Core.Threading; + +namespace Tango.Touch.Controls +{ + [ContentProperty(nameof(Content))] + public class TouchVirtualizedContentControl : Control + { + private LightTouchScrollViewer _scrollViewer; + private ContentPresenter _innerBorder; + private ActionTimer _updateTimer; + private Point _location; + private bool _loaded; + + public UIElement Content + { + get { return (UIElement)GetValue(ContentProperty); } + set { SetValue(ContentProperty, value); } + } + public static readonly DependencyProperty ContentProperty = + DependencyProperty.Register("Content", typeof(UIElement), typeof(TouchVirtualizedContentControl), new PropertyMetadata(null)); + + static TouchVirtualizedContentControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchVirtualizedContentControl), new FrameworkPropertyMetadata(typeof(TouchVirtualizedContentControl))); + } + + public TouchVirtualizedContentControl() + { + _updateTimer = new ActionTimer(TimeSpan.FromMilliseconds(200)); + Loaded += TouchVirtualizedContentControl_Loaded; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + _innerBorder = GetTemplateChild("PART_innerBorder") as ContentPresenter; + } + + private void TouchVirtualizedContentControl_Loaded(object sender, System.Windows.RoutedEventArgs e) + { + _scrollViewer = this.FindAncestor(); + _scrollViewer.Scrolling += _scrollViewer_Scrolling; + + _location = this.TranslatePoint(new Point(0, 0), _scrollViewer); + + ApplyOptimization(); + _loaded = true; + } + + private void _scrollViewer_Scrolling(object sender, DoubleValueChangedEventArgs e) + { + if (_loaded) + { + //_updateTimer.ResetReplace(() => + //{ + // Dispatcher.BeginInvoke(new Action(() => + // { + ApplyOptimization(); + // })); + //}); + } + } + + private void ApplyOptimization() + { + var _border_viewport = _scrollViewer.GetViewportBorder(); + + if (_border_viewport.IsAncestorOf(this)) + { + //Point relativeLocation = this.TranslatePoint(new Point(0, 0), _border_viewport); + //Rect bounds = this.TransformToAncestor(_border_viewport).TransformBounds(new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight)); + //Rect rect = new Rect(0.0, 0.0, _border_viewport.ActualWidth, _border_viewport.ActualHeight); + if (_location.Y > _scrollViewer.GetScrollPosition() && _location.Y < _scrollViewer.GetScrollPosition() + _border_viewport.ActualHeight) + { + if (_innerBorder.Visibility == Visibility.Hidden) + { + _innerBorder.Visibility = Visibility.Visible; + } + } + else + { + if (_innerBorder.Visibility == Visibility.Visible) + { + _innerBorder.Visibility = Visibility.Hidden; + } + } + } + } + } +} -- cgit v1.3.1 From 13887d7b53fec7e2d357fd377a6a1fbd0e875e65 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 22 Apr 2019 09:33:28 +0300 Subject: Working on PPC optimizations... --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml | 20 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 17 +- .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 1142 ++++++++++---------- .../Controls/TwineCatalogControl.xaml | 15 +- .../PPC/Tango.PPC.UI/MainWindow.xaml.cs | 14 + .../Notifications/DefaultNotificationProvider.cs | 10 +- .../PPC/Tango.PPC.UI/Views/LoginView.xaml | 7 - .../PPC/Tango.PPC.UI/Views/MainView.xaml | 4 +- .../Visual_Studio/Tango.BL/Entities/BrushStop.cs | 12 +- .../Visual_Studio/Tango.BL/Entities/Segment.cs | 1 + .../Tango.DragAndDrop/DragAndDropService.cs | 14 +- .../Tango.SharedUI/Controls/FastTextBlock.cs | 28 +- .../Components/SharedResourceDictionary.cs | 55 + .../Tango.Touch/Controls/TouchAutoComplete.cs | 4 + .../Tango.Touch/Controls/TouchLoadingPanel.xaml | 2 +- .../Tango.Touch/Controls/TouchNumericTextBox.cs | 5 +- .../Tango.Touch/Controls/TouchNumericTextBox.xaml | 22 +- .../Tango.Touch/Controls/TouchPanel.cs | 14 + .../Tango.Touch/Controls/TouchPanel.xaml | 124 ++- .../Tango.Touch/Controls/TouchTextBox.xaml | 2 +- .../Controls/TouchVirtualizedContentControl.cs | 42 +- .../Tango.Touch/Resources/Colors.xaml | 4 +- .../Visual_Studio/Tango.Touch/Resources/Fonts.xaml | 4 +- .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 1 + 26 files changed, 882 insertions(+), 681 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 1d4f688b1..e66689c76 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index dc895c719..42942dacd 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml index e7a416623..be151678d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml @@ -7,7 +7,7 @@ xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:local="clr-namespace:Tango.PPC.Jobs.Controls" mc:Ignorable="d" - d:DesignHeight="60" d:DesignWidth="500" Height="38" d:DataContext="{d:DesignInstance Type=entities:Job, IsDesignTimeCreatable=False}"> + d:DesignHeight="60" d:DesignWidth="500" Height="38" d:DataContext="{d:DesignInstance Type=entities:Job, IsDesignTimeCreatable=False}" x:Name="control"> @@ -20,7 +20,7 @@ - + @@ -28,12 +28,12 @@ - + - - - + + + @@ -42,13 +42,13 @@ - + @@ -67,7 +67,7 @@ - + @@ -102,7 +102,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 9aaf9fcbd..c7946ee6a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -396,7 +396,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Loading selected job '{_job_to_load.Name}'..."); - NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + //NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + IsFree = false; _can_navigate_back = false; @@ -433,10 +434,6 @@ namespace Tango.PPC.Jobs.ViewModels SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); - InvokeUIOnIdle(() => - { - NotificationProvider.ReleaseGlobalBusyMessage(); - }); _job_to_load = null; } @@ -471,10 +468,16 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log(ex, $"Error loading job '{_job_to_load.Name}'"); await NotificationProvider.ShowError("An error occurred while trying to load the selected job."); } + finally + { + InvokeUIOnIdle(() => + { + IsFree = true; + //NotificationProvider.ReleaseGlobalBusyMessage(); + }); + } } - - /// /// Saves the job. /// diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 893cdc973..cb12805f5 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -17,11 +17,15 @@ xmlns:localControls="clr-namespace:Tango.PPC.Jobs.Controls" xmlns:local="clr-namespace:Tango.PPC.Jobs.Views" mc:Ignorable="d" - d:DesignHeight="2000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:JobViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.JobViewVM}"> + d:DesignHeight="2000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:JobViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.JobViewVM}" x:Name="view"> + + + + - + - + - + - - + + - - - - - + + - + - - - - - - + + + Color & Length + - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + - - - - - - - SOLID SEGMENT - - - - - - - - - - - - - GRADIENT SEGMENT - - - + + + + + + + + + + + SOLID SEGMENT + + + + + + + + + + + + + GRADIENT SEGMENT + + + - - - Include white gap between segments - - + + + Include white gap between segments + + - + - + - - - - + + + + - + - - - Output - + + + Output + - - - - - - - - + + + + + + + - - - - - Job Summary - + + + + + Job Summary + - - - - + + + + - + - - + + - - - - - + + + + + (+%) - - + + - - + + - + - + - % + % - - - + + + + - - + - - Additional Tools - + + Additional Tools + - - - - - - Sample Dye - - + + + + + Sample Dye + + - - - - - - - - - - START - - - - + + + + + + + + + + + + START + + + + - - - - - - How to continue? + + + + + + How to continue? + + + + + + + DONE + + - - - - - - DONE - - + The sample is approved + - The sample is approved - + + + + + REPEAT + + - - + Dye more samples + + + + + + + + + + + + + + + Sample Approved: + + + - - REPEAT + + ANOTHER SAMPLE + + + + + + + + + + - Dye more samples - - - - - - - - - - - - - - - Sample Approved: - - - - - - ANOTHER SAMPLE - - - - - - + + + - - - - - - - - - + + - - - + + + You can use the color fine tuning tool to adjust the colors. - + + - - + - - - - - Color Fine Tuning - - - - - - - - - - - - - - - - - - + + + + + Color Fine Tuning + + - - Reset + - - START - - - - - - - - - - - - - - 1 - - Select the best variation for each color: - + + + + + + + + + + + + + + + + + 2 + + How to continue - - - - - REPEAT - - + + + + + + DONE + + - Some color need more fine tuning - - - - - - + All colors are approved + - - - - - - + + + + + REPEAT + + + + Some color need more fine tuning + + + + + + + + + + + + + Colors Approved: - - - - - REPEAT FINE TUNING - - - - - - - - - - - - - + + + + + REPEAT FINE TUNING + + + + + + + + + + + + + + - - - - - - - - - - + + - - - - - - - - - + + + - - + + + - + - - + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml index 897810c99..f99b299cc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.PPC.Common.Controls" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:catalog="clr-namespace:Tango.BL.Catalogs;assembly=Tango.BL" mc:Ignorable="d" @@ -20,8 +21,8 @@ - - + + @@ -45,8 +46,8 @@ - - + + @@ -54,8 +55,8 @@ - - + + @@ -68,7 +69,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs index 364ca8ee7..b90a1afff 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs @@ -11,7 +11,9 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Forms; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; @@ -32,6 +34,8 @@ namespace Tango.PPC.UI { Instance = this; + //Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline),new FrameworkPropertyMetadata { DefaultValue = 30 }); + InitializeComponent(); bool has_touch = false; @@ -77,6 +81,16 @@ namespace Tango.PPC.UI Closing += MainWindow_Closing; } + protected override void OnSourceInitialized(EventArgs e) + { + //var hwndSource = PresentationSource.FromVisual(this) as HwndSource; + + //if (hwndSource != null) + // hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly; + + base.OnSourceInitialized(e); + } + private void LockAspectRatio() { this.Width = (this.Height * (800d / 1280d)) - 10; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index d7dca484e..5062df1d6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -140,7 +140,7 @@ namespace Tango.PPC.UI.Notifications return ShowMessageBox(new MessageBoxVM() { Message = message, - Icon = TouchIconKind.AlertOctagon, + Icon = TouchIconKind.AlertCircleOutline, Title = "Error", Brush = Application.Current.Resources["TangoMessageBoxErrorBrush"] as Brush, }); @@ -156,7 +156,7 @@ namespace Tango.PPC.UI.Notifications return ShowMessageBox(new MessageBoxVM() { Message = message, - Icon = TouchIconKind.InfoCircleSolid, + Icon = TouchIconKind.AlertCircleOutline, Title = "Information", Brush = Application.Current.Resources["TangoMessageBoxInfoBrush"] as Brush, }); @@ -172,7 +172,7 @@ namespace Tango.PPC.UI.Notifications return ShowMessageBox(new MessageBoxVM() { Message = message, - Icon = TouchIconKind.Alert, + Icon = TouchIconKind.AlertCircleOutline, Title = "Warning", Brush = Application.Current.Resources["TangoMessageBoxWarningBrush"] as Brush, }); @@ -188,7 +188,7 @@ namespace Tango.PPC.UI.Notifications return ShowMessageBox(new MessageBoxVM() { Message = message, - Icon = TouchIconKind.QuestionCircleSolid, + Icon = TouchIconKind.QuestionCircleRegular, Title = "Confirm", HasCancel = true, Brush = Application.Current.Resources["TangoMessageBoxQuestionBrush"] as Brush, @@ -218,6 +218,8 @@ namespace Tango.PPC.UI.Notifications /// private Task ShowMessageBox(MessageBoxVM vm) { + ReleaseGlobalBusyMessage(); + LogManager.Log($"Displaying MessagBox '{vm.Message}'."); TaskCompletionSource source = new TaskCompletionSource(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml index 179d1dde3..dee4e9c7b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml @@ -27,13 +27,6 @@ Forgot password? - - - - - - - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index c63ef1e13..604c79aeb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -28,7 +28,9 @@ ItemExpandedPropertyPath="IsExpanded" HasDialog="{Binding NotificationProvider.HasDialog}" CurrentDialog="{Binding NotificationProvider.CurrentDialog}" - NotificationBarVisibility="{Binding NotificationProvider.NotificationsVisible,Converter={StaticResource BooleanToVisibilityConverter}}"> + NotificationBarVisibility="{Binding NotificationProvider.NotificationsVisible,Converter={StaticResource BooleanToVisibilityConverter}}" + IsBusy="{Binding NotificationProvider.IsInGlobalBusyState}" + BusyMessage="{Binding NotificationProvider.GlobalBusyMessage}"> diff --git a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs index 8816d9825..6738ad99c 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs @@ -211,11 +211,15 @@ namespace Tango.BL.Entities get { return _isOutOfGamut; } set { - _isOutOfGamut = value; RaisePropertyChangedAuto(); - - if (Segment != null) + if (_isOutOfGamut != value) { - Segment.RaiseHasOutOfGamutBrushStop(); + _isOutOfGamut = value; + RaisePropertyChangedAuto(); + + if (Segment != null) + { + Segment.RaiseHasOutOfGamutBrushStop(); + } } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Segment.cs b/Software/Visual_Studio/Tango.BL/Entities/Segment.cs index 7e15b9ea5..a15cb32ab 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Segment.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Segment.cs @@ -139,6 +139,7 @@ namespace Tango.BL.Entities } [NotMapped] + [JsonIgnore] public bool HasOutOfGamutBrushStop { get { return BrushStops.Any(x => x.IsOutOfGamut); } diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs index 1c84b8768..e814985e6 100644 --- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs +++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs @@ -579,7 +579,7 @@ namespace Tango.DragAndDrop //element.AddHandler(FrameworkElement.PreviewMouseDownEvent, (MouseButtonEventHandler)Draggable_PreviewMouseDown, true); //element.AddHandler(FrameworkElement.MouseMoveEvent, (MouseEventHandler)Draggable_MouseMove, true); //element.AddHandler(FrameworkElement.PreviewMouseUpEvent, (MouseButtonEventHandler)Draggable_PreviewMouseUp, true); - element.Unloaded += Element_Unloaded; + element.Unloaded += Draggable_Unloaded; } } @@ -592,7 +592,7 @@ namespace Tango.DragAndDrop if (!_dropElements.Contains(element)) { _dropElements.Add(element); - element.Unloaded += Element_Unloaded1; + element.Unloaded += Droppable_Unloaded; } } @@ -601,12 +601,10 @@ namespace Tango.DragAndDrop /// /// The source of the event. /// The instance containing the event data. - private static void Element_Unloaded(object sender, RoutedEventArgs e) + private static void Draggable_Unloaded(object sender, RoutedEventArgs e) { FrameworkElement element = sender as FrameworkElement; UnRegisterDraggable(element); - element.PreviewMouseUp -= Draggable_PreviewMouseUp; - element.Unloaded -= Element_Unloaded; } /// @@ -614,11 +612,10 @@ namespace Tango.DragAndDrop /// /// The source of the event. /// The instance containing the event data. - private static void Element_Unloaded1(object sender, RoutedEventArgs e) + private static void Droppable_Unloaded(object sender, RoutedEventArgs e) { FrameworkElement element = sender as FrameworkElement; UnRegisterDroppable(element); - element.Unloaded -= Element_Unloaded1; } /// @@ -628,6 +625,8 @@ namespace Tango.DragAndDrop private static void UnRegisterDraggable(FrameworkElement element) { _dragElements.Remove(element); + element.PreviewMouseUp -= Draggable_PreviewMouseUp; + element.Unloaded -= Draggable_Unloaded; } /// @@ -637,6 +636,7 @@ namespace Tango.DragAndDrop private static void UnRegisterDroppable(FrameworkElement element) { _dropElements.Remove(element); + element.Unloaded -= Droppable_Unloaded; } /// diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs index 5b2808ab1..141fa6e27 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs @@ -9,6 +9,7 @@ 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; @@ -16,14 +17,24 @@ using System.Windows.Shapes; namespace Tango.SharedUI.Controls { - + [ContentProperty(nameof(Text))] public class FastTextBlock : Control { private FormattedText _formattedText; static FastTextBlock() { - + + } + + public FastTextBlock() + { + Loaded += FastTextBlock_Loaded; + } + + private void FastTextBlock_Loaded(object sender, RoutedEventArgs e) + { + Init(); } public static readonly DependencyProperty TextProperty = @@ -31,19 +42,24 @@ namespace Tango.SharedUI.Controls "Text", typeof(string), typeof(FastTextBlock), - new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure, + new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, (o, e) => ((FastTextBlock)o).TextPropertyChanged((string)e.NewValue))); private void TextPropertyChanged(string text) { - if (text != null) + Init(); + } + + private void Init() + { + if (Text != null) { var typeface = new Typeface( FontFamily, - FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); + FontStyle, FontWeight, FontStretch); _formattedText = new FormattedText( - text, CultureInfo.CurrentCulture, + Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground); } } diff --git a/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs b/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs new file mode 100644 index 000000000..efa1e77e4 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Tango.Touch.Components +{ + /// + /// The shared resource dictionary is a specialized resource dictionary + /// that loads it content only once. If a second instance with the same source + /// is created, it only merges the resources from the cache. + /// + public class SharedResourceDictionary : ResourceDictionary + { + /// + /// Internal cache of loaded dictionaries + /// + public static Dictionary _sharedDictionaries = + new Dictionary(); + + /// + /// Local member of the source uri + /// + private Uri _sourceUri; + + /// + /// Gets or sets the uniform resource identifier (URI) to load resources from. + /// + public new Uri Source + { + get { return _sourceUri; } + set + { + _sourceUri = value; + + if (!_sharedDictionaries.ContainsKey(value)) + { + // If the dictionary is not yet loaded, load it by setting + // the source of the base class + base.Source = value; + + // add it to the cache + _sharedDictionaries.Add(value, this); + } + else + { + // If the dictionary is already loaded, get it from the cache + MergedDictionaries.Add(_sharedDictionaries[value]); + } + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.cs index a684cbf5a..4e1ced33b 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.cs @@ -203,6 +203,10 @@ namespace Tango.Touch.Controls _textBox.CaretIndex = _textBox.Text.Length; } } + else if (_textBox != null) + { + _textBox.Text = null; + } if (_popup != null) { diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml index 4a4cdbba2..9a2a51017 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchLoadingPanel.xaml @@ -17,7 +17,7 @@ - + - - - + + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs index 6c29e4652..bb715abba 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs @@ -256,7 +256,21 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty NotificationBarVisibilityProperty = DependencyProperty.Register("NotificationBarVisibility", typeof(Visibility), typeof(TouchPanel), new PropertyMetadata(Visibility.Visible)); + public bool IsBusy + { + get { return (bool)GetValue(IsBusyProperty); } + set { SetValue(IsBusyProperty, value); } + } + public static readonly DependencyProperty IsBusyProperty = + DependencyProperty.Register("IsBusy", typeof(bool), typeof(TouchPanel), new PropertyMetadata(false)); + public String BusyMessage + { + get { return (String)GetValue(BusyMessageProperty); } + set { SetValue(BusyMessageProperty, value); } + } + public static readonly DependencyProperty BusyMessageProperty = + DependencyProperty.Register("BusyMessage", typeof(String), typeof(TouchPanel), new PropertyMetadata(null)); #region Attached Properties diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml index e80bd7daa..e7f822bb5 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml @@ -73,9 +73,9 @@ - - - + + + @@ -135,18 +135,18 @@ @@ -173,24 +173,24 @@ - + - + + - - - - - - - - - - + + + + + + + + + + - - + + CANCEL + OK + - + - + + + + + - + + + + + - - CANCEL - OK - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml index c00bd40b9..e6acda366 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchTextBox.xaml @@ -8,7 +8,7 @@ xmlns:local="clr-namespace:Tango.Touch.Controls"> - + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs index 8e3db84fa..02240ecc8 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentControl.cs @@ -72,28 +72,28 @@ namespace Tango.Touch.Controls private void ApplyOptimization() { - var _border_viewport = _scrollViewer.GetViewportBorder(); + //var _border_viewport = _scrollViewer.GetViewportBorder(); - if (_border_viewport.IsAncestorOf(this)) - { - //Point relativeLocation = this.TranslatePoint(new Point(0, 0), _border_viewport); - //Rect bounds = this.TransformToAncestor(_border_viewport).TransformBounds(new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight)); - //Rect rect = new Rect(0.0, 0.0, _border_viewport.ActualWidth, _border_viewport.ActualHeight); - if (_location.Y > _scrollViewer.GetScrollPosition() && _location.Y < _scrollViewer.GetScrollPosition() + _border_viewport.ActualHeight) - { - if (_innerBorder.Visibility == Visibility.Hidden) - { - _innerBorder.Visibility = Visibility.Visible; - } - } - else - { - if (_innerBorder.Visibility == Visibility.Visible) - { - _innerBorder.Visibility = Visibility.Hidden; - } - } - } + //if (_border_viewport.IsAncestorOf(this)) + //{ + // //Point relativeLocation = this.TranslatePoint(new Point(0, 0), _border_viewport); + // //Rect bounds = this.TransformToAncestor(_border_viewport).TransformBounds(new Rect(0.0, 0.0, this.ActualWidth, this.ActualHeight)); + // //Rect rect = new Rect(0.0, 0.0, _border_viewport.ActualWidth, _border_viewport.ActualHeight); + // if (_location.Y > _scrollViewer.GetScrollPosition() && _location.Y < _scrollViewer.GetScrollPosition() + _border_viewport.ActualHeight) + // { + // if (_innerBorder.Visibility == Visibility.Hidden) + // { + // _innerBorder.Visibility = Visibility.Visible; + // } + // } + // else + // { + // if (_innerBorder.Visibility == Visibility.Visible) + // { + // _innerBorder.Visibility = Visibility.Hidden; + // } + // } + //} } } } diff --git a/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml b/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml index 1a77b76be..c8a6d0e8d 100644 --- a/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml +++ b/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml @@ -52,7 +52,7 @@ #757373 #C3F2F5FA - #DDE7FD + #DDE7FD #4E5470 @@ -117,7 +117,7 @@ #121212 #F1F1F1 - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml b/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml index 387977e0a..a4732966e 100644 --- a/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml +++ b/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml @@ -13,8 +13,8 @@ 20 20 - 30 - 20 + 24 + 22 22 23 diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 3177f206d..7600d4c14 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -59,6 +59,7 @@ GlobalVersionInfo.cs + -- cgit v1.3.1