diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-12-20 15:15:37 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-12-20 15:15:37 +0200 |
| commit | 35dfed5a480f1e2316f5e4eaf5e284697679e408 (patch) | |
| tree | e8612de59ccca47bb12780f63d9aef814c3a3bd7 /Software/Visual_Studio/PPC/Tango.PPC.Common | |
| parent | 392131c3594c2a73a1bd961eadd2ab44fa85aa8b (diff) | |
| parent | f67b8d11029ce185b4f13ec0fd866bfe4380be7d (diff) | |
| download | Tango-35dfed5a480f1e2316f5e4eaf5e284697679e408.tar.gz Tango-35dfed5a480f1e2316f5e4eaf5e284697679e408.zip | |
Merged Jobs V2
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common')
6 files changed, 159 insertions, 30 deletions
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 c4d047d39..7a8b2908d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml @@ -17,9 +17,9 @@ <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> - <touch:LightTouchScrollViewer x:Name="scrollViewer" ScrollBarVisibility="Collapsed"> + <touch:LightTouchScrollViewer x:Name="scrollViewer" ScrollBarVisibility="Collapsed" > <!--<Border Background="White">--> - <local:TwineCatalogRenderer x:Name="renderer" Groups="{Binding ColorCatalogsGroups}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=SelectedItem,Mode=TwoWay}"></local:TwineCatalogRenderer> + <local:TwineCatalogRenderer x:Name="renderer" Groups="{Binding ColorCatalogsGroups}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType={ x:Type local:TwineCatalogControl}},Path=SelectedItem,Mode=TwoWay }"></local:TwineCatalogRenderer> <!--</Border>--> </touch:LightTouchScrollViewer> @@ -93,7 +93,7 @@ </touch:TouchListBox.ItemTemplate> </touch:TouchListBox>--> - <Grid Grid.Column="1"> + <Grid Grid.Column="1" Margin="10 60 0 20"> <!--<Rectangle Stroke="{StaticResource TangoDividerBrush}" HorizontalAlignment="Left" />--> <Grid> <Grid.ColumnDefinitions> @@ -130,8 +130,8 @@ </ItemsControl> </Border> - <Grid Grid.Column="1"> - <touch:TouchSlider x:Name="slider" ValueChanged="TouchSlider_ValueChanged" IsSnapToTickEnabled="True" Minimum="0" Maximum="{Binding ColorCatalogsGroups.Count,Converter={StaticResource MathOperatorConverter},ConverterParameter='-1'}" Orientation="Vertical" Width="40" Height="Auto" IsSelectionRangeEnabled="False"> + <Grid Grid.Column="1" > + <touch:TouchSlider x:Name="slider" ValueChanged="TouchSlider_ValueChanged" IsSnapToTickEnabled="True" Minimum="0" Maximum="{Binding ColorCatalogsGroups.Count,Converter={StaticResource MathOperatorConverter},ConverterParameter='-1'}" Orientation="Vertical" Width="40" Height="Auto" IsSelectionRangeEnabled="False"> <touch:TouchSlider.ThumbTemplate> <ControlTemplate> <touch:TouchIcon Foreground="{Binding RelativeSource={RelativeSource AncestorType=touch:TouchSlider},Path=Foreground}" Width="40" Height="40" Icon="Water" Angle="-90" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs index 6ef7d92e8..8b7ea81c5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs @@ -13,6 +13,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Tango.BL.Entities; +using Tango.Touch.Components; using Tango.Touch.Controls; namespace Tango.PPC.Common.Controls @@ -27,6 +28,7 @@ namespace Tango.PPC.Common.Controls private ColorCatalog _catalog; private bool _preventChange; private double _lastScrollPosition = 0; + private bool _findInProcess = false; /// <summary> /// Gets or sets the selected catalog item. @@ -37,7 +39,35 @@ namespace Tango.PPC.Common.Controls set { SetValue(SelectedItemProperty, value); } } public static readonly DependencyProperty SelectedItemProperty = - DependencyProperty.Register("SelectedItem", typeof(ColorCatalogsItem), typeof(TwineCatalogControl), new PropertyMetadata(null)); + DependencyProperty.Register("SelectedItem", typeof(ColorCatalogsItem), typeof(TwineCatalogControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnSelectedItemPropertyChanged))); + + + private static void OnSelectedItemPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + TwineCatalogControl twineCatalogControl = (TwineCatalogControl)d; + if(e.OldValue != e.NewValue) + { + twineCatalogControl.SelectedItemPropertyChanged(); + } + } + + /// <summary> + /// Gets or sets the collection filter. + /// </summary> + public ICollectionFilter CollectionFilter + { + get { return (ICollectionFilter)GetValue(CollectionFilterProperty); } + set { SetValue(CollectionFilterProperty, value); } + } + public static readonly DependencyProperty CollectionFilterProperty = + DependencyProperty.Register("CollectionFilter", typeof(ICollectionFilter), typeof(TwineCatalogControl), new PropertyMetadata(null, (d, e) => (d as TwineCatalogControl).OnCollectionFilterChanged())); + + + public void SelectedItemPropertyChanged() + { + // if(renderer.SelectedItem != this.SelectedItem) + // renderer.SelectedItem = this.SelectedItem; + } /// <summary> /// Initializes a new instance of the <see cref="TwineCatalogControl"/> class. @@ -100,7 +130,7 @@ namespace Tango.PPC.Common.Controls if (!_preventChange) { - if (_catalog != null) + if (_catalog != null && scrollViewer != null) { _preventChange = true; var group = _catalog.ColorCatalogsGroupsOrdered.ElementAt(_catalog.ColorCatalogsGroupsOrdered.Count - 1 - (int)e.NewValue); @@ -114,5 +144,26 @@ namespace Tango.PPC.Common.Controls slider.Foreground = new SolidColorBrush(_catalog.ColorCatalogsGroupsOrdered.ElementAt(_catalog.ColorCatalogsGroupsOrdered.Count - 1 - (int)e.NewValue).Color); } } + + private void OnCollectionFilterChanged() + { + if (_findInProcess) + return; + if (CollectionFilter != null) + { + CollectionFilter.FilterChanged -= CollectionFilter_FilterChanged; + CollectionFilter.FilterChanged += CollectionFilter_FilterChanged; + } + } + + private void CollectionFilter_FilterChanged(object sender, EventArgs e) + { + _findInProcess = true; + if (CollectionFilter != null ) + { + renderer.ScrollToFirstFindItem(CollectionFilter); + } + _findInProcess = false; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs index a3b65d17a..9b865c18b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs @@ -9,7 +9,9 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Imaging; using Tango.BL.Entities; +using Tango.Touch.Components; using Tango.Touch.Controls; namespace Tango.PPC.Common.Controls @@ -21,6 +23,7 @@ namespace Tango.PPC.Common.Controls public DrawingVisual Visual { get; set; } public ColorCatalogsItem Item { get; set; } public double PositionY { get; set; } + public Rect ImageRect { get; set; } } private class GroupContainer @@ -40,14 +43,19 @@ namespace Tango.PPC.Common.Controls private readonly VisualCollection _children; private List<ItemContainer> _catalogItems; private List<GroupContainer> _groupItems; - private double ellipseWidth = 60; - private double ellipseHeight = 60; - private double textHeight = 30; - private double ellipseMargin = 20; - private double textMargin = 5; - private double groupMargin = 60; + private double ellipseWidth = 70; + private double ellipseHeight = 70; + private double textHeight = 20; + private double ellipseMarginX = 18; + private double ellipseMarginY = 50; + private double textMargin = 8; + private double groupMargin = 50; private bool selectedFromClick; private LightTouchScrollViewer _scrollViewer; + private BitmapSource _myColorBitmap; + private double imageWidth = 24; + private double imageHeight = 22; + private Point _lastMouseClickPoint; public IEnumerable<ColorCatalogsGroup> Groups { @@ -92,6 +100,7 @@ namespace Tango.PPC.Common.Controls this.PreviewMouseUp += TwineCatalogRenderer_MouseLeftButtonUp; this.Loaded += TwineCatalogRenderer_Loaded; + _myColorBitmap = new BitmapImage(new Uri($"pack://application:,,,/Tango.PPC.JobsV2;component/Images/ColorSelection/Heart.png", UriKind.Absolute)); } private void TwineCatalogRenderer_Loaded(object sender, RoutedEventArgs e) @@ -136,12 +145,12 @@ namespace Tango.PPC.Common.Controls { // Retreive the coordinates of the mouse button event. Point pt = e.GetPosition((UIElement)this); - + _lastMouseClickPoint = pt; // Initiate the hit test by setting up a hit test result callback method. VisualTreeHelper.HitTest(this, null, HitTestCallback, new PointHitTestParameters(pt)); } } - + // If a child visual object is hit, toggle its opacity to visually indicate a hit. public HitTestResultBehavior HitTestCallback(HitTestResult result) { @@ -152,9 +161,13 @@ namespace Tango.PPC.Common.Controls if (visual != null) { var container = _catalogItems.SingleOrDefault(x => x.Visual == visual); - + if (container != null && container.Item is ColorCatalogsItem) { + if (container.ImageRect.Contains(_lastMouseClickPoint)) + { + // clicked on image + } selectedFromClick = true; SelectedItem = container.Item; selectedFromClick = false; @@ -176,8 +189,9 @@ namespace Tango.PPC.Common.Controls (newItem.Visual.Transform as ScaleTransform).ScaleX = 1.3; (newItem.Visual.Transform as ScaleTransform).ScaleY = 1.3; - if (!selectedFromClick) + if (!selectedFromClick && _scrollViewer != null) { + _scrollViewer.ScrollToPosition(newItem.PositionY - _scrollViewer.ActualHeight / 2); } } @@ -189,7 +203,7 @@ namespace Tango.PPC.Common.Controls } } - private ItemContainer AddCatalogItem(DrawingVisual visual, ColorCatalogsItem item, double y) + private ItemContainer AddCatalogItem(DrawingVisual visual, ColorCatalogsItem item, double y, Rect imageRect) { _children.Add(visual); @@ -198,6 +212,7 @@ namespace Tango.PPC.Common.Controls Visual = visual, Item = item, PositionY = y, + ImageRect = imageRect }; _catalogItems.Add(container); @@ -238,40 +253,49 @@ namespace Tango.PPC.Common.Controls var groupContainer = AddGroupItem(CreateGroup(group.Name, position_y), group, position_y); - position_y += ellipseMargin; + position_y += ellipseMarginX; foreach (var item in group.ColorCatalogsItems.OrderBy(x => x.ItemIndex)) { - double x = position_x + ellipseMargin; + double x = position_x + ellipseMarginX; if (x + ellipseWidth > ActualWidth) { position_x = 0; - position_y += (ellipseHeight + ellipseMargin + textMargin + textHeight); + position_y += (ellipseHeight + ellipseMarginY + textMargin + textHeight); } - - var itemContainer = AddCatalogItem(CreateItem(item, position_x + ellipseMargin, position_y + ellipseMargin), item, position_y + ellipseMargin); + Rect imageRect = new Rect(new Point(position_x + ellipseWidth, position_y + ellipseMarginY/2 + 2), new Size( imageWidth, imageHeight)); + var itemContainer = AddCatalogItem(CreateItem(item, position_x + ellipseMarginX, position_y + ellipseMarginY, imageRect), item, position_y + ellipseMarginY, imageRect); groupContainer.Items.Add(itemContainer); - position_x += ellipseWidth + ellipseMargin; + position_x += ellipseWidth + ellipseMarginX; } - position_y += (ellipseHeight + ellipseMargin + textMargin + textHeight + groupMargin); + position_y += (ellipseHeight + ellipseMarginY + textMargin + textHeight + groupMargin); } Height = position_y; } + + UpdateLayout(); + if (SelectedItem != null) + { + OnSelectedItemChanged( null, SelectedItem); + } + //InvalidateVisual(); } - private DrawingVisual CreateItem(ColorCatalogsItem item, double x, double y) + private DrawingVisual CreateItem(ColorCatalogsItem item, double x, double y, Rect imageRect) { DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); + + drawingContext.DrawImage(_myColorBitmap, imageRect); drawingContext.DrawEllipse(new SolidColorBrush(item.Color), null, new Point(x + ellipseWidth / 2, y + ellipseHeight / 2), ellipseWidth / 2, ellipseHeight / 2); - + var formattedText = new FormattedText(item.Name, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, @@ -279,7 +303,7 @@ namespace Tango.PPC.Common.Controls 16, Foreground); - formattedText.MaxTextWidth = ellipseWidth + ellipseMargin; + formattedText.MaxTextWidth = ellipseWidth + ellipseMarginX; drawingContext.DrawText(formattedText, new Point((x + (ellipseWidth / 2)) - (formattedText.Width / 2), y + ellipseHeight + textMargin)); @@ -313,12 +337,13 @@ namespace Tango.PPC.Common.Controls CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Flexo"), - 25, + 23, Foreground); //formattedText.SetFontWeight(FontWeights.SemiBold); - drawingContext.DrawText(formattedText, new Point((ActualWidth / 2) - (formattedText.Width / 2), y)); + // drawingContext.DrawText(formattedText, new Point((ActualWidth / 2) - (formattedText.Width / 2), y)); + drawingContext.DrawText(formattedText, new Point(ellipseMarginX, y)); drawingContext.Close(); @@ -338,5 +363,20 @@ namespace Tango.PPC.Common.Controls return _children[index]; } + + public void ScrollToFirstFindItem(ICollectionFilter collectionFilter) + { + foreach (var group in _groupItems.Where(x => x.Items.Count > 0).Reverse().ToList()) + { + foreach( var item in group.Items) + { + if(collectionFilter.Filter(item.Item)) + { + _scrollViewer.ScrollToPosition(item.PositionY - _scrollViewer.ActualHeight / 2); + break; + } + } + } + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index e02352b9b..ff6dbce08 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -304,6 +304,11 @@ namespace Tango.PPC.Common public bool EnableProxifier { get; set; } /// <summary> + /// Gets or sets a value indicating whether to use the new jobs module. + /// </summary> + public bool UseJobsModuleV2 { get; set; } + + /// <summary> /// Gets the machine service address. /// </summary> /// <returns></returns> @@ -363,6 +368,7 @@ namespace Tango.PPC.Common EnableSpoolReplacementDialog = true; EnableProxifier = true; + UseJobsModuleV2 = true; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index b742c3b73..bb0a694cf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -10,11 +10,17 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Resources/Colors.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Resources/Fonts.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/Shared.xaml"/> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchSlider.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchToggleSlider.xaml"/> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchToggleButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchIconButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchListBox.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchCheckBox.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchExpander.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchNumericUpDownControl.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchExpander.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchNativeListBox.xaml" /> <!--PPC--> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml index 317b2f13f..bb1890e7f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml @@ -44,6 +44,32 @@ <Setter Property="ItemContainerStyle" Value="{StaticResource BlankListBoxItem}"></Setter> </Style> + <Style TargetType="{x:Type ListBox}" x:Key="SegmentsListBox" BasedOn="{StaticResource BlankListBox}"> + <Setter Property="BorderThickness" Value="0"></Setter> + <Setter Property="VirtualizingPanel.ScrollUnit" Value="Pixel"></Setter> + <Setter Property="ItemsPanel"> + <Setter.Value> + <ItemsPanelTemplate> + <VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel" /> + </ItemsPanelTemplate> + </Setter.Value> + </Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type ListBox}"> + <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> + <touch:TouchScrollViewer CanContentScroll="True" + Padding="{TemplateBinding Padding}" + Focusable="False" + HorizontalScrollBarVisibility="Hidden"> + <ItemsPresenter /> + </touch:TouchScrollViewer> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + <Style TargetType="touch:TouchSimpleDataGrid" x:Key="TechGrid" BasedOn="{StaticResource {x:Type touch:TouchSimpleDataGrid}}"> <Style.Resources> <Style BasedOn="{StaticResource {x:Type DataGridColumnHeader}}" TargetType="{x:Type DataGridColumnHeader}"> |
