diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-28 00:44:38 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-28 00:44:38 +0200 |
| commit | 0fdbc932838bb6e007cfa8a0079d1880c800ed81 (patch) | |
| tree | ce95fc1a7fe455c66aced9fad1650be8bb6067a1 /Software/Visual_Studio/Tango.Touch | |
| parent | 518c9192e4445d82f192edcccb2ffb64ffc88a65 (diff) | |
| download | Tango-0fdbc932838bb6e007cfa8a0079d1880c800ed81.tar.gz Tango-0fdbc932838bb6e007cfa8a0079d1880c800ed81.zip | |
Removed length from job viewer.
Improved FastTextBlock.
Improved PPC segments loading ability from ~40 to ~150.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch')
8 files changed, 218 insertions, 8 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml index 7cc38666e..e0e8f485c 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.xaml @@ -25,9 +25,9 @@ <Border x:Name="PART_Border" ClipToBounds="True" Background="Transparent"> <Grid x:Name="PART_Grid_Content" Background="Transparent" VerticalAlignment="Top" Height="{Binding ElementName=stack,Path=ActualHeight,Mode=OneWay}"> <StackPanel x:Name="stack" VerticalAlignment="Top"> - <StackPanel.CacheMode> + <!--<StackPanel.CacheMode> <BitmapCache SnapsToDevicePixels="False" RenderAtScale="1" EnableClearType="False" /> - </StackPanel.CacheMode> + </StackPanel.CacheMode>--> <ContentPresenter x:Name="PART_Content_Presenter" Content="{TemplateBinding Content}" VerticalAlignment="Top" Height="Auto" /> </StackPanel> </Grid> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchComboBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchComboBox.xaml index 738fe6a3c..83163fcd8 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchComboBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchComboBox.xaml @@ -31,7 +31,7 @@ <DataTemplate> <Border> <DockPanel> - <Label VerticalAlignment="Center" Padding="30" FontSize="{StaticResource TangoComboBoxItemFontSize}"> + <Label VerticalAlignment="Center" Padding="30" FontSize="{StaticResource TangoComboBoxItemFontSize}" Foreground="{StaticResource TangoDarkForegroundBrush}"> <Label.Style> <Style TargetType="Label"> <Setter Property="Background" Value="Transparent"></Setter> @@ -64,7 +64,7 @@ <Setter Property="SelectedItemTemplate"> <Setter.Value> <DataTemplate> - <Label VerticalAlignment="Center" Padding="5 5 5 2"> + <Label VerticalAlignment="Center" Padding="5 5 5 2" Foreground="{StaticResource TangoDarkForegroundBrush}"> <Label.Content> <MultiBinding Converter="{StaticResource DisplayMemberPathConverter}"> <Binding Path="." /> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index da5d5e34b..ccb66d009 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -21,7 +21,7 @@ namespace Tango.Touch.Controls { private TextBox _text_box; private bool _prevent_text_change; - private TextBlock _text_block; + private FastTextBlock _text_block; private double _lastValue; Regex regex_integer = new Regex(@"^-?[0-9]\d*(\d+)?$"); Regex regex_double = new Regex(@"^-?[0-9]\d*(\.\d+)?$"); @@ -124,7 +124,7 @@ namespace Tango.Touch.Controls base.OnApplyTemplate(); _text_box = GetTemplateChild("PART_TextBox") as TextBox; - _text_block = GetTemplateChild("PART_TextDisplay") as TextBlock; + _text_block = GetTemplateChild("PART_TextDisplay") as FastTextBlock; _text_box.PreviewTextInput += _text_box_PreviewTextInput; _text_box.PreviewKeyDown += _text_box_PreviewKeyDown; _text_box.LostFocus += _text_box_LostFocus; diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml index 2710a954f..d347480d6 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml @@ -10,6 +10,7 @@ <ResourceDictionary.MergedDictionaries> <!--<ResourceDictionary Source="../Resources/Colors.xaml" />--> <components:SharedResourceDictionary Source="../Resources/Colors.xaml" /> + <components:SharedResourceDictionary Source="../Resources/Fonts.xaml" /> </ResourceDictionary.MergedDictionaries> <converters:StringNullOrEmptyToBooleanConverter x:Key="StringNullOrEmptyToBooleanConverter" /> @@ -100,7 +101,7 @@ </Style> </TextBox.Style> </TextBox> - <TextBlock x:Name="PART_TextDisplay" FontSize="{TemplateBinding FontSize}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" IsHitTestVisible="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Foreground="{TemplateBinding Foreground}" Padding="0 0 0 4" FocusVisualStyle="{x:Null}" Visibility="{Binding ElementName=PART_TextBox,Path=IsFocused,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></TextBlock> + <controls:FastTextBlock FontFamily="{StaticResource TangoFlexoFontFamily}" x:Name="PART_TextDisplay" FontSize="{TemplateBinding FontSize}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" IsHitTestVisible="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Foreground="{TemplateBinding Foreground}" Padding="0 0 0 4" FocusVisualStyle="{x:Null}" Visibility="{Binding ElementName=PART_TextBox,Path=IsFocused,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></controls:FastTextBlock> </Grid> </components:Ripple> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentReplaceControl.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentReplaceControl.cs new file mode 100644 index 000000000..802d3f538 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentReplaceControl.cs @@ -0,0 +1,188 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +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 System.Windows.Threading; +using Tango.Core.Threading; + +namespace Tango.Touch.Controls +{ + [ContentProperty(nameof(Content))] + public class TouchVirtualizedContentReplaceControl : Control + { + private LightTouchScrollViewer _scrollViewer; + private Border _innerBorder; + private ActionTimer _updateTimer; + private Point _location; + private bool _loaded; + private Image _replaceContent; + private FrameworkElement _element; + private INameScopeDictionary _parentNameScope; + + public DataTemplate Content + { + get { return (DataTemplate)GetValue(ContentProperty); } + set { SetValue(ContentProperty, value); } + } + public static readonly DependencyProperty ContentProperty = + DependencyProperty.Register("Content", typeof(DataTemplate), typeof(TouchVirtualizedContentReplaceControl), new PropertyMetadata(null)); + + public bool CanMovePosition + { + get { return (bool)GetValue(CanMovePositionProperty); } + set { SetValue(CanMovePositionProperty, value); } + } + public static readonly DependencyProperty CanMovePositionProperty = + DependencyProperty.Register("CanMovePosition", typeof(bool), typeof(TouchVirtualizedContentReplaceControl), new PropertyMetadata(false)); + + public LightTouchDataGrid DataGrid + { + get { return (LightTouchDataGrid)GetValue(DataGridProperty); } + set { SetValue(DataGridProperty, value); } + } + public static readonly DependencyProperty DataGridProperty = + DependencyProperty.Register("DataGrid", typeof(LightTouchDataGrid), typeof(TouchVirtualizedContentReplaceControl), new PropertyMetadata(null)); + + public bool Disconnect + { + get { return (bool)GetValue(DisconnectProperty); } + set { SetValue(DisconnectProperty, value); } + } + public static readonly DependencyProperty DisconnectProperty = + DependencyProperty.Register("Disconnect", typeof(bool), typeof(TouchVirtualizedContentReplaceControl), new PropertyMetadata(true)); + + static TouchVirtualizedContentReplaceControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchVirtualizedContentReplaceControl), new FrameworkPropertyMetadata(typeof(TouchVirtualizedContentReplaceControl))); + } + + public TouchVirtualizedContentReplaceControl() + { + _replaceContent = new Image(); + _updateTimer = new ActionTimer(TimeSpan.FromMilliseconds(100)); + Loaded += TouchVirtualizedContentControl_Loaded; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + _innerBorder = GetTemplateChild("PART_innerBorder") as Border; + _innerBorder.Child = _replaceContent; + } + + private void TouchVirtualizedContentControl_Loaded(object sender, System.Windows.RoutedEventArgs e) + { + _scrollViewer = this.FindAncestor<LightTouchScrollViewer>(); + _scrollViewer.Scrolling += _scrollViewer_Scrolling; + + _parentNameScope = NameScope.GetNameScope(this.FindAncestor<UserControl>()) as INameScopeDictionary; + + if (DataGrid != null) + { + DataGrid.SortingChanged += DataGrid_SortingChanged; + DataGrid.FilterChanged += DataGrid_FilterChanged; + } + + _location = this.TranslatePoint(new Point(0, 0), _scrollViewer.GetContentGrid()); + + _scrollViewer.GetContentGrid().SizeChanged += TouchVirtualizedContentControl_SizeChanged; + + ApplyVirtualization(); + _loaded = true; + } + + private void DataGrid_FilterChanged(object sender, EventArgs e) + { + InvalidateVirtualization(); + } + + private void DataGrid_SortingChanged(object sender, EventArgs e) + { + InvalidateVirtualization(); + } + + private void TouchVirtualizedContentControl_SizeChanged(object sender, SizeChangedEventArgs e) + { + InvalidateVirtualization(); + } + + private void _scrollViewer_Scrolling(object sender, DoubleValueChangedEventArgs e) + { + if (_loaded) + { + ApplyVirtualization(); + } + } + + private void InvalidateVirtualization() + { + _updateTimer.ResetReplace(() => + { + Dispatcher.Invoke(new Action(() => + { + _location = this.TranslatePoint(new Point(0, 0), _scrollViewer.GetContentGrid()); + ApplyVirtualization(); + })); + }); + } + + private void ApplyVirtualization() + { + if (!Disconnect && _element != null) + { + _updateTimer.Dispose(); + return; + } + + var _border_viewport = _scrollViewer.GetViewportBorder(); + + if (CanMovePosition) + { + _location = this.TranslatePoint(new Point(0, 0), _scrollViewer.GetContentGrid()); + } + + 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 (Disconnect || _element == null) + { + if (_innerBorder.Child == _replaceContent || _element == null) + { + _element = Content.LoadContent() as FrameworkElement; + + if (_parentNameScope != null) + { + NameScope.SetNameScope(_element, _parentNameScope); + } + + _innerBorder.Child = _element; + _innerBorder.Height = double.NaN; + } + } + } + else + { + if (Disconnect) + { + if (_innerBorder.Child == _element) + { + double height = _element != null ? _element.ActualHeight : MinHeight; + _innerBorder.Child = _replaceContent; + _innerBorder.Height = height; + } + } + } + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentReplaceControl.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentReplaceControl.xaml new file mode 100644 index 000000000..c7fe39b76 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchVirtualizedContentReplaceControl.xaml @@ -0,0 +1,15 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="clr-namespace:Tango.Touch.Controls"> + + <Style TargetType="{x:Type local:TouchVirtualizedContentReplaceControl}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:TouchVirtualizedContentReplaceControl}"> + <Border x:Name="PART_innerBorder"></Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + +</ResourceDictionary>
\ 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 index 7dd560a48..8575548c4 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -101,6 +101,7 @@ <Compile Include="Controls\TouchToggleIconButton.cs" /> <Compile Include="Controls\TouchToggleImageButton.cs" /> <Compile Include="Controls\TouchToggleSlider.cs" /> + <Compile Include="Controls\TouchVirtualizedContentReplaceControl.cs" /> <Compile Include="Controls\TouchVirtualizedContentControl.cs" /> <Compile Include="Converters\BlurRadiusToMarginConverter.cs" /> <Compile Include="Converters\DateTimeToCalendarHeaderConverter.cs" /> @@ -277,6 +278,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Controls\TouchVirtualizedContentReplaceControl.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Controls\TouchVirtualizedContentControl.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -422,7 +427,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ 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 index ed0f289b0..47403f56b 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -46,6 +46,7 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchCalendar.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchDatePicker.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchVirtualizedContentControl.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchVirtualizedContentReplaceControl.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" /> |
