|
@@ -32,10 +32,12 @@ using Syncfusion.Windows.Controls.Grid;
|
|
|
using Syncfusion.Windows.Shared;
|
|
|
using Syncfusion.Windows.Tools.Controls;
|
|
|
using Syncfusion.XPS;
|
|
|
+using Brush = System.Windows.Media.Brush;
|
|
|
using Color = System.Drawing.Color;
|
|
|
using DataColumn = System.Data.DataColumn;
|
|
|
using DataRow = System.Data.DataRow;
|
|
|
using FilterElement = Syncfusion.UI.Xaml.Grid.FilterElement;
|
|
|
+using FontStyle = System.Windows.FontStyle;
|
|
|
using Geometry = System.Windows.Media.Geometry;
|
|
|
using GridCellToolTipOpeningEventArgs = Syncfusion.UI.Xaml.Grid.GridCellToolTipOpeningEventArgs;
|
|
|
using GridFilterEventArgs = Syncfusion.UI.Xaml.Grid.GridFilterEventArgs;
|
|
@@ -155,13 +157,34 @@ namespace InABox.DynamicGrid
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public class NewDynamicGridStyle : DynamicGridStyle<VirtualizingCellsControl>
|
|
|
+ public class DynamicGridRowStyle : DynamicGridStyle<VirtualizingCellsControl>
|
|
|
{
|
|
|
- public NewDynamicGridStyle() : base(null)
|
|
|
+ public DynamicGridRowStyle() : base(null)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- public NewDynamicGridStyle(IDynamicGridStyle source) : base(source)
|
|
|
+ public DynamicGridRowStyle(IDynamicGridStyle source) : base(source)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public override DependencyProperty FontSizeProperty => Control.FontSizeProperty;
|
|
|
+
|
|
|
+ public override DependencyProperty FontStyleProperty => Control.FontStyleProperty;
|
|
|
+
|
|
|
+ public override DependencyProperty FontWeightProperty => Control.FontWeightProperty;
|
|
|
+
|
|
|
+ public override DependencyProperty BackgroundProperty => Control.BackgroundProperty;
|
|
|
+
|
|
|
+ public override DependencyProperty ForegroundProperty => Control.ForegroundProperty;
|
|
|
+ }
|
|
|
+
|
|
|
+ public class DynamicGridCellStyle : DynamicGridStyle<Control>
|
|
|
+ {
|
|
|
+ public DynamicGridCellStyle() : base(null)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ public DynamicGridCellStyle(IDynamicGridStyle source) : base(source)
|
|
|
{
|
|
|
}
|
|
|
|
|
@@ -392,7 +415,19 @@ namespace InABox.DynamicGrid
|
|
|
public override event EntitySaveEvent? OnAfterSave;
|
|
|
|
|
|
#endregion
|
|
|
-
|
|
|
+
|
|
|
+ private DynamicGridCellStyleConverter<System.Windows.Media.Brush?> CellBackgroundConverter;
|
|
|
+ private DynamicGridCellStyleConverter<System.Windows.Media.Brush?> CellForegroundConverter;
|
|
|
+ private DynamicGridCellStyleConverter<double?> CellFontSizeConverter;
|
|
|
+ private DynamicGridCellStyleConverter<System.Windows.FontStyle?> CellFontStyleConverter;
|
|
|
+ private DynamicGridCellStyleConverter<System.Windows.FontWeight?> CellFontWeightConverter;
|
|
|
+
|
|
|
+ protected virtual Brush? GetCellBackground(CoreRow row, String columnname) => null;
|
|
|
+ protected virtual Brush? GetCellForeground(CoreRow row, String columnname) => null;
|
|
|
+ protected virtual double? GetCellFontSize(CoreRow row, String columnname) => null;
|
|
|
+ protected virtual FontStyle? GetCellFontStyle(CoreRow row, String columnname) => null;
|
|
|
+ protected virtual FontWeight? GetCellFontWeight(CoreRow row, String columnname) => null;
|
|
|
+
|
|
|
public DynamicGrid() : base()
|
|
|
{
|
|
|
IsReady = false;
|
|
@@ -423,6 +458,12 @@ namespace InABox.DynamicGrid
|
|
|
ActionColumns.Add(down);
|
|
|
HiddenColumns.Add(x => (x as ISequenceable)!.Sequence);
|
|
|
}
|
|
|
+
|
|
|
+ CellBackgroundConverter = new DynamicGridCellStyleConverter<System.Windows.Media.Brush?>(this, GetCellBackground);
|
|
|
+ CellForegroundConverter = new DynamicGridCellStyleConverter<System.Windows.Media.Brush?>(this, GetCellForeground);
|
|
|
+ CellFontSizeConverter = new DynamicGridCellStyleConverter<double?>(this, GetCellFontSize);
|
|
|
+ CellFontStyleConverter = new DynamicGridCellStyleConverter<System.Windows.FontStyle?>(this, GetCellFontStyle);
|
|
|
+ CellFontWeightConverter = new DynamicGridCellStyleConverter<System.Windows.FontWeight?>(this, GetCellFontWeight);
|
|
|
|
|
|
VisibleColumns = new DynamicGridColumns();
|
|
|
|
|
@@ -477,7 +518,7 @@ namespace InABox.DynamicGrid
|
|
|
fltstyle.Setters.Add(new Setter(GridFilterControl.SortOptionVisibilityProperty, Visibility.Collapsed));
|
|
|
DataGrid.FilterPopupStyle = fltstyle;
|
|
|
|
|
|
- DataGrid.RowStyleSelector = StyleSelector;
|
|
|
+ DataGrid.RowStyleSelector = RowStyleSelector;
|
|
|
DataGrid.TableSummaryCellStyleSelector = new DynamicGridSummaryStyleSelector(this);
|
|
|
|
|
|
//DataGrid.MouseMove += DataGrid_MouseMove;
|
|
@@ -728,21 +769,21 @@ namespace InABox.DynamicGrid
|
|
|
DuplicateBtn.Visibility = Visibility.Collapsed;
|
|
|
}
|
|
|
|
|
|
- protected override DynamicGridStyleSelector<T> GetStyleSelector()
|
|
|
+ protected override DynamicGridRowStyleSelector<T> GetRowStyleSelector()
|
|
|
{
|
|
|
- return new DynamicGridStyleSelector<T, NewDynamicGridStyle>();
|
|
|
+ return new DynamicGridRowStyleSelector<T, DynamicGridRowStyle>();
|
|
|
}
|
|
|
-
|
|
|
- protected override DynamicGridStyle GetStyle(CoreRow row, DynamicGridStyle style)
|
|
|
+
|
|
|
+ protected override DynamicGridStyle GetRowStyle(CoreRow row, DynamicGridStyle style)
|
|
|
{
|
|
|
- var result = base.GetStyle(row, style);
|
|
|
+ var result = base.GetRowStyle(row, style);
|
|
|
if (ClipBuffer != null)
|
|
|
if (ClipBuffer.Item2.Contains(row))
|
|
|
{
|
|
|
var bgbrush = style.Background as SolidColorBrush;
|
|
|
var bgcolor = bgbrush != null ? bgbrush.Color : Colors.Transparent;
|
|
|
|
|
|
- result = new NewDynamicGridStyle(style);
|
|
|
+ result = new DynamicGridRowStyle(style);
|
|
|
|
|
|
result.Background = ClipBuffer.Item1 == ClipAction.Cut
|
|
|
? new SolidColorBrush(bgcolor.MixColors(0.5, Colors.Orchid))
|
|
@@ -1543,7 +1584,7 @@ namespace InABox.DynamicGrid
|
|
|
{
|
|
|
return !IsSequenced;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void ReloadColumns()
|
|
|
{
|
|
|
|
|
@@ -1563,7 +1604,7 @@ namespace InABox.DynamicGrid
|
|
|
gridRowResizingOptions.ExcludeColumns = new List<string>();
|
|
|
|
|
|
LoadActionColumns(DynamicActionColumnPosition.Start);
|
|
|
-
|
|
|
+
|
|
|
foreach (var column in VisibleColumns)
|
|
|
{
|
|
|
var filtering = true;
|
|
@@ -1808,9 +1849,18 @@ namespace InABox.DynamicGrid
|
|
|
}
|
|
|
|
|
|
cellstyle.Setters.Add(new Setter(ForegroundProperty, new SolidColorBrush(Colors.Black)));
|
|
|
-
|
|
|
newcol.CellStyle = cellstyle;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cellstyle.Setters.Add(new Setter(BackgroundProperty, new Binding() { Path=new PropertyPath("."), Converter = CellBackgroundConverter, ConverterParameter = column.ColumnName}));
|
|
|
+ cellstyle.Setters.Add(new Setter(ForegroundProperty, new Binding() { Converter = CellForegroundConverter, ConverterParameter = column.ColumnName}));
|
|
|
+ cellstyle.Setters.Add(new Setter(FontSizeProperty, new Binding() { Converter = CellFontSizeConverter, ConverterParameter = column.ColumnName}));
|
|
|
+ cellstyle.Setters.Add(new Setter(FontStyleProperty, new Binding() { Converter = CellFontStyleConverter, ConverterParameter = column.ColumnName}));
|
|
|
+ cellstyle.Setters.Add(new Setter(FontWeightProperty, new Binding() { Converter = CellFontWeightConverter, ConverterParameter = column.ColumnName}));
|
|
|
+ newcol.CellStyle = cellstyle;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
DataGrid.Columns.Add(newcol);
|
|
|
ColumnList.Add(column);
|
|
@@ -1901,10 +1951,12 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
public override void Refresh(bool reloadcolumns, bool reloaddata)
|
|
|
{
|
|
|
- //DataGrid.View.Filter = DoFilterRecord;
|
|
|
-
|
|
|
+
|
|
|
if (bRefreshing)
|
|
|
return;
|
|
|
+
|
|
|
+ if (!DoBeforeRefresh())
|
|
|
+ return;
|
|
|
|
|
|
DataGrid.SelectionForegroundBrush = BaseDynamicGrid.SelectionForeground;
|
|
|
DataGrid.RowSelectionBrush = BaseDynamicGrid.SelectionBackground;
|
|
@@ -1963,7 +2015,9 @@ namespace InABox.DynamicGrid
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
ProcessData(reloadcolumns, reloaddata);
|
|
|
- DoAfterReload();
|
|
|
+ DoAfterRefresh();
|
|
|
+ bRefreshing = false;
|
|
|
+ IsReady = true;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -1972,15 +2026,16 @@ namespace InABox.DynamicGrid
|
|
|
else
|
|
|
{
|
|
|
ProcessData(reloadcolumns, reloaddata);
|
|
|
- DoAfterReload();
|
|
|
+ DoAfterRefresh();
|
|
|
+ bRefreshing = false;
|
|
|
+ IsReady = true;
|
|
|
|
|
|
Loading.BeginAnimation(Label.OpacityProperty, null);
|
|
|
Loading.Visibility = Visibility.Collapsed;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- bRefreshing = false;
|
|
|
- IsReady = true;
|
|
|
+
|
|
|
|
|
|
if (cursor != null)
|
|
|
{
|
|
@@ -1988,7 +2043,35 @@ namespace InABox.DynamicGrid
|
|
|
cursor = null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ protected override bool OnBeforeRefresh()
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool DoBeforeRefresh()
|
|
|
+ {
|
|
|
+ var result = OnBeforeRefresh();
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ var args = new BeforeRefreshEventArgs() { Cancel = false };
|
|
|
+ NotifyBeforeRefresh(args);
|
|
|
+ result = args.Cancel == false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnAfterRefresh()
|
|
|
+ {
|
|
|
+ }
|
|
|
|
|
|
+ protected void DoAfterRefresh()
|
|
|
+ {
|
|
|
+ OnAfterRefresh();
|
|
|
+ NotifyAfterRefresh(new AfterRefreshEventArgs());
|
|
|
+ }
|
|
|
+
|
|
|
public Columns<T> DataColumns()
|
|
|
{
|
|
|
var columns = new Columns<T>();
|
|
@@ -2140,8 +2223,9 @@ namespace InABox.DynamicGrid
|
|
|
result.Rows.Add(newrow);
|
|
|
}
|
|
|
|
|
|
- if (StyleSelector != null)
|
|
|
- StyleSelector.Data = Data;
|
|
|
+ if (RowStyleSelector != null)
|
|
|
+ RowStyleSelector.Data = Data;
|
|
|
+
|
|
|
//int rowIndex = DataGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex;
|
|
|
//int columnIndex = DataGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex;
|
|
|
//int scrollRowIndex = DataGrid.GetVisualContainer().ScrollRows.LastBodyVisibleLineIndex;
|