From cb779c3d5f828844a3ea843ccab930fe912efb57 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Mon, 18 Mar 2019 12:08:30 +0200 Subject: visualization of job view control for better performance --- .../Tango.MachineStudio.Developer.csproj | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index c2bdf669c..f1bdcf97b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -93,6 +93,7 @@ GlobalVersionInfo.cs + @@ -337,9 +338,7 @@ - - - + @@ -361,7 +360,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From e6be03de10afc55c2ceac18dbd690e2ed127c8d8 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Mon, 18 Mar 2019 13:33:45 +0200 Subject: Improved Job Outline Control. Improved job events grid performance. --- .../Controls/JobOutlineControl.cs | 99 +++++++++++++++------- .../Converters/StringToEllipsisConverter.cs | 31 +++++++ .../Tango.MachineStudio.Developer.csproj | 3 +- .../Views/RunningJobView.xaml | 9 +- 4 files changed, 104 insertions(+), 38 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/StringToEllipsisConverter.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Controls/JobOutlineControl.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Controls/JobOutlineControl.cs index 7c06543ce..ee570ac34 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Controls/JobOutlineControl.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Controls/JobOutlineControl.cs @@ -34,12 +34,31 @@ namespace Tango.MachineStudio.Developer.Controls } private double _verticalOffset = 0; private double _viewportHeight = 0; + private const double HEADER_FONT_HEIGHT = 35; + private const double TITLE_FONT_HEIGHT = 22; + private const double SUB_TITLE_FONT_HEIGHT = 19; + private const double NORMAL_FONT_HEIGHT = 17; + private const double WIDTH = 330; + #endregion members public JobOutlineControl() : base() { Unloaded += JobOutlineControl_Unloaded; + DataContextChanged += JobOutlineControl_DataContextChanged; + Width = WIDTH; } + + private void JobOutlineControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (_parentScrollViewer != null) + { + _parentScrollViewer.ScrollToTop(); + } + + InvalidateVisual(); + } + #region events private void JobOutlineControl_Unloaded(object sender, RoutedEventArgs e) { @@ -48,7 +67,7 @@ namespace Tango.MachineStudio.Developer.Controls _parentScrollViewer.ScrollChanged -= ScrollViewer_ScrollChanged; } } - + private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e) { if (e.VerticalChange == 0.0) @@ -77,25 +96,30 @@ namespace Tango.MachineStudio.Developer.Controls _sizeControl = new Size(); _sizeControl.Height += 10; DrawHeaderText(drawingContext, "JOB OUTLINE", 30, LevelOffset.level_0); - + _sizeControl.Height += HEADER_FONT_HEIGHT; + _sizeControl.Height += 20; DrawHeaderText(drawingContext, "BASIC", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; _sizeControl.Height += 5.0; var basicProps = GetNameValueList(job); foreach (var prop in basicProps) { DrawNameValueText(drawingContext, prop, LevelOffset.level_1, PackIconKind.Pencil); + _sizeControl.Height += NORMAL_FONT_HEIGHT; } //JobTicket.Spool if (job.Spool != null) { _sizeControl.Height += 20; DrawHeaderText(drawingContext, "SPOOL", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; _sizeControl.Height += 5.0; basicProps = GetNameValueList(job.Spool); foreach (var prop in basicProps) { DrawNameValueText(drawingContext, prop, LevelOffset.level_1, PackIconKind.Pencil); + _sizeControl.Height += NORMAL_FONT_HEIGHT; } } //JobTicket.ProcessParameters @@ -103,11 +127,13 @@ namespace Tango.MachineStudio.Developer.Controls { _sizeControl.Height += 20; DrawHeaderText(drawingContext, "PROCESS PARAMETERS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; _sizeControl.Height += 5.0; basicProps = GetNameValueList(job.ProcessParameters); foreach (var prop in basicProps) { DrawNameValueText(drawingContext, prop, LevelOffset.level_1, PackIconKind.Settings); + _sizeControl.Height += NORMAL_FONT_HEIGHT; } } //JobTicket.Segments @@ -115,48 +141,56 @@ namespace Tango.MachineStudio.Developer.Controls { _sizeControl.Height += 20; DrawHeaderText(drawingContext, "SEGMENTS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; _sizeControl.Height += 10.0; int index = 0; foreach (JobSegment seg in job.Segments) { DrawHeaderText(drawingContext, string.Format("#{0} SEGMENT", ++index), 14, LevelOffset.level_1); + _sizeControl.Height += SUB_TITLE_FONT_HEIGHT; basicProps = GetNameValueList(seg); foreach (var prop in basicProps) { DrawNameValueText(drawingContext, prop, LevelOffset.level_2, PackIconKind.Pencil); + _sizeControl.Height += NORMAL_FONT_HEIGHT; } //BrushStops DrawHeaderText(drawingContext, "BRUSH STOPS", 12, LevelOffset.level_3); + _sizeControl.Height += NORMAL_FONT_HEIGHT; int indexBrush = 0; foreach (JobBrushStop brushstop in seg.BrushStops) { _sizeControl.Height += 5.0; DrawHeaderText(drawingContext, string.Format("#{0} STOP", ++indexBrush), 11, LevelOffset.level_4); + _sizeControl.Height += NORMAL_FONT_HEIGHT; var brushStops = GetNameValueList(brushstop); foreach (var brushstopprop in brushStops) { DrawNameValueText(drawingContext, brushstopprop, LevelOffset.level_5, PackIconKind.Pencil); + _sizeControl.Height += NORMAL_FONT_HEIGHT; } DrawHeaderText(drawingContext, "DISPENSERS", 12, LevelOffset.level_6); + _sizeControl.Height += NORMAL_FONT_HEIGHT; _sizeControl.Height += 5.0; int indexDispenser = 0; foreach (JobDispenser disp in brushstop.Dispensers) { DrawHeaderText(drawingContext, string.Format("#{0} DISPENSER", ++indexDispenser), 11, LevelOffset.level_6); + _sizeControl.Height += NORMAL_FONT_HEIGHT; var dispProperties = GetNameValueList(disp); foreach (var dispprop in dispProperties) { DrawNameValueText(drawingContext, dispprop, LevelOffset.level_7, PackIconKind.ArrowRightBoldCircle); + _sizeControl.Height += NORMAL_FONT_HEIGHT; } } } } } - if (Height != _sizeControl.Height || Width != _sizeControl.Width) + if (Height != _sizeControl.Height) { Height = _sizeControl.Height; - Width = _sizeControl.Width; } } public IEnumerable> GetNameValueList(object value) @@ -175,46 +209,51 @@ namespace Tango.MachineStudio.Developer.Controls #region drawing protected void DrawNameValueText(DrawingContext drawingContext, Tuple text, double levelOfOffset, PackIconKind? icon) { + if (IsInViewPort()) + { + FormattedText formattedName = new FormattedText(text.Item1 + ": ", System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal), + 12, Foreground); + DrawIconTextIfVisible(drawingContext, levelOfOffset, formattedName, icon); + double widthOfNameText = formattedName.WidthIncludingTrailingWhitespace + 17 + levelOfOffset;//17 pix for draw icon before text - FormattedText formattedName = new FormattedText(text.Item1 + ": ", System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal), - 12, Foreground); - DrawIconTextIfVisible(drawingContext, levelOfOffset, formattedName, icon); - double widthOfNameText = formattedName.WidthIncludingTrailingWhitespace + 17 + levelOfOffset;//17 pix for draw icon before text + FormattedText formattedValue = new FormattedText(text.Item2, System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.SemiBold, FontStretches.Normal), + 12, Foreground); + DrawIconTextIfVisible(drawingContext, widthOfNameText, formattedValue); + _sizeControl.Width = Math.Max(_sizeControl.Width, (widthOfNameText + formattedValue.WidthIncludingTrailingWhitespace)); + } + } - FormattedText formattedValue = new FormattedText(text.Item2, System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.SemiBold, FontStretches.Normal), - 12, Foreground); - DrawIconTextIfVisible(drawingContext, widthOfNameText, formattedValue); - _sizeControl.Height += Math.Max(formattedName.Height, formattedValue.Height) + 5.0; - _sizeControl.Width = Math.Max(_sizeControl.Width, (widthOfNameText + formattedValue.WidthIncludingTrailingWhitespace )); + private bool IsInViewPort() + { + return (_sizeControl.Height >= _verticalOffset && _sizeControl.Height <= (_verticalOffset + _viewportHeight + 5)); } protected void DrawHeaderText(DrawingContext drawingContext, string text, int fontSize, double levelOfOffset) { - FormattedText formattedtext = new FormattedText(text, System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.SemiBold, FontStretches.Normal), - fontSize, Foreground); - DrawIconTextIfVisible(drawingContext, levelOfOffset, formattedtext); - _sizeControl.Width = Math.Max(_sizeControl.Width, (formattedtext.Width + levelOfOffset)); - _sizeControl.Height += formattedtext.Height + 5.0; + if (IsInViewPort()) + { + FormattedText formattedtext = new FormattedText(text, System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.SemiBold, FontStretches.Normal), + fontSize, Foreground); + DrawIconTextIfVisible(drawingContext, levelOfOffset, formattedtext); + _sizeControl.Width = Math.Max(_sizeControl.Width, (formattedtext.Width + levelOfOffset)); + } } - + private void DrawIconTextIfVisible(DrawingContext drawingContext, double levelOfOffset, FormattedText formattedText, PackIconKind? icon = null) { - if (_sizeControl.Height >= _verticalOffset && _sizeControl.Height <= (_verticalOffset + _viewportHeight + 5)) + if (icon is PackIconKind) { - if (icon is PackIconKind) - { - DrawIcon(drawingContext, (PackIconKind)icon, new Point(levelOfOffset, _sizeControl.Height)); - levelOfOffset += 17; - } - drawingContext.DrawText(formattedText, new Point(levelOfOffset, _sizeControl.Height)); + DrawIcon(drawingContext, (PackIconKind)icon, new Point(levelOfOffset, _sizeControl.Height)); + levelOfOffset += 17; } + drawingContext.DrawText(formattedText, new Point(levelOfOffset, _sizeControl.Height)); } private void DrawIcon(DrawingContext drawingContext, PackIconKind kind, Point point) { - GeometryGroup group = GetGeometryByIcon(kind); - SetGeometryPosition(group, point); - drawingContext.DrawGeometry(Foreground, new Pen(Brushes.White, 1), group); - + GeometryGroup group = GetGeometryByIcon(kind); + SetGeometryPosition(group, point); + drawingContext.DrawGeometry(Foreground, new Pen(Brushes.White, 1), group); + } private GeometryGroup GetGeometryByIcon(PackIconKind kind) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/StringToEllipsisConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/StringToEllipsisConverter.cs new file mode 100644 index 000000000..2a14bce1e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/StringToEllipsisConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.MachineStudio.Developer.Converters +{ + public class StringToEllipsisConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + String text = value as String; + int length = 0; + + if (text != null && parameter != null && int.TryParse(parameter.ToString(), out length)) + { + return text.Ellipsis(length); + } + + return String.Empty; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index f1bdcf97b..190e8d0fe 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -113,6 +113,7 @@ + @@ -360,7 +361,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml index 0cecf7a29..dbe0d835b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml @@ -17,6 +17,7 @@ + @@ -193,13 +194,7 @@ - - - - - - - + -- cgit v1.3.1