From 4c3f0568fd42002c5341d250fe6f83805bdcf531 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 2 Oct 2017 18:04:06 -0400 Subject: [PATCH] SyntheticEditor2 - extend vertical grid lines across group boundaries --- .../Synthetic2/SyntheticEditor2.xaml | 7 ++-- .../Synthetic2/SyntheticEditor2.xaml.cs | 13 +++++++- .../Synthetic2/SyntheticEditorDialog.xaml | 1 - .../SyntheticEditorGridLineAdorner.cs | 33 +++++++++++++++++++ 4 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorGridLineAdorner.cs diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml index a9d49b804..97839e58c 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml @@ -168,15 +168,16 @@ - @@ -194,7 +195,7 @@ - + diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml.cs b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml.cs index 8bd237b86..d3fd7b787 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml.cs +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditor2.xaml.cs @@ -99,8 +99,19 @@ namespace mbts.ui.spark private static void SyncColumns(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((SyntheticEditor2)d)._sync_columns(); } public override void OnApplyTemplate() { _sync_columns(); } + private SyntheticEditorGridLineAdorner _dg_line_adorner; + private void _sync_columns() { - ((DataGrid)GetTemplateChild("PART_DataGrid"))?.Columns.SetItems(LegTuples.Select(l => new DataGridColumnInternal(l.leg.Security, ParameterCellTemplateConverter, ParameterCellEditingTemplateConverter) { Width = 60 })); + _dg_line_adorner?.Dispose(); + var dg = (DataGridEx)GetTemplateChild("PART_DataGrid"); + if (dg != null) { + dg.Columns.SetItems(LegTuples.Select(l => { + var col = new DataGridColumnInternal(l.leg.Security, ParameterCellTemplateConverter, ParameterCellEditingTemplateConverter) { Width = 60 }; + DataGridEx.SetRightBorder(col, new DataGridExVerticalLine(false, true, System.Windows.Media.Colors.DarkGray, 1)); + return col; + })); + _dg_line_adorner = new SyntheticEditorGridLineAdorner(dg); + } } private class DataGridColumnInternal : DataGridDynamicColumn { diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorDialog.xaml b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorDialog.xaml index 71058a275..97260b447 100644 --- a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorDialog.xaml +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorDialog.xaml @@ -4,7 +4,6 @@ xmlns:u="clr-namespace:mbts.ui" xmlns:c="clr-namespace:mbts.ui.controls" xmlns:usp="clr-namespace:mbts.ui.spark" - u:WindowStyle.AllowResize="True" u:WindowStyle.SizeToContent="WidthAndHeight" Style="{StaticResource BTSDialogTitleTemplate}"> diff --git a/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorGridLineAdorner.cs b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorGridLineAdorner.cs new file mode 100644 index 000000000..229ca7221 --- /dev/null +++ b/src/client/spark/mspark/Shell/Securities/Synthetic2/SyntheticEditorGridLineAdorner.cs @@ -0,0 +1,33 @@ +using mbts.ui.controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Controls; +using System.Windows; +using System.Windows.Media; + +namespace mbts.ui.spark +{ + internal partial class SyntheticEditor2 : Control { + internal class SyntheticEditorGridLineAdorner : DataGridExVerticalLineAdorner + { + public SyntheticEditorGridLineAdorner(DataGridEx grid) : base(grid) { } + + private ItemsPresenter _items_presenter; + + protected override IEnumerable get_other_hooks() { + _items_presenter = _grid.visual_children_where(el => el is ItemsPresenter).Cast().FirstOrDefault(); + if (_items_presenter != null) { + _items_presenter.SizeChanged += _items_presenter_SizeChanged; + yield return Disposable.Create(() => _items_presenter.SizeChanged -= _items_presenter_SizeChanged); + } + } + + private void _items_presenter_SizeChanged(object sender, SizeChangedEventArgs e) { InvalidateVisual(); } + + protected override void draw_vertical_line(DrawingContext dc, double x, DataGridExVerticalLine line) { + if (_items_presenter != null) dc.DrawLine(line.pen.Value, new Point(x - 10, 58), new Point(x - 10, _items_presenter.ActualHeight + 58)); + } + } + } +}