首次上传
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class CheckBoxColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class ComboxColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public ComboxColumn() : base()
|
||||
{
|
||||
Options = new List<Option>();
|
||||
}
|
||||
|
||||
public List<Option> Options { get; }
|
||||
|
||||
|
||||
public class Option : IEquatable<Option>, IEquatable<Enum> , IEquatable<string>, IComparable<Option>
|
||||
{
|
||||
public Option(string displayName, string controlName, string relatedParameters)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
ControlName = controlName;
|
||||
RelatedParameters = relatedParameters;
|
||||
}
|
||||
|
||||
public Option(string displayName, string controlName) :
|
||||
this(displayName, controlName, string.Empty)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string ControlName { get; }
|
||||
|
||||
public string DisplayName { get; }
|
||||
|
||||
public string RelatedParameters { get; }
|
||||
|
||||
public override bool Equals(object other)
|
||||
{
|
||||
return other switch
|
||||
{
|
||||
null => false,
|
||||
Option destOption => DisplayName == destOption.DisplayName,
|
||||
_ => DisplayName == other.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hashCode = (ControlName != null ? ControlName.GetHashCode() : 0);
|
||||
hashCode = (hashCode * 397) ^ (DisplayName != null ? DisplayName.GetHashCode() : 0);
|
||||
hashCode = (hashCode * 397) ^ (RelatedParameters != null ? RelatedParameters.GetHashCode() : 0);
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public int CompareTo(Option other)
|
||||
{
|
||||
if (DisplayName == other.DisplayName)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool Equals(Option other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return DisplayName == other.DisplayName;
|
||||
}
|
||||
|
||||
public bool Equals(Enum other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return DisplayName == other.ToString();
|
||||
}
|
||||
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (string.IsNullOrEmpty(other))
|
||||
return false;
|
||||
|
||||
return DisplayName == other;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return DisplayName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class DoubleColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public double Minimun { get; set; }
|
||||
public double Maximun { get; set; }
|
||||
public int Resolution { get; set; }
|
||||
public string InputMode { get; set; }
|
||||
}
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using MECF.Framework.Common.Account;
|
||||
using MECF.Framework.Common.Account.Permissions;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class EditorDataGridTemplateColumnBase: ExtendedGrid.Microsoft.Windows.Controls.DataGridTemplateColumn
|
||||
{
|
||||
#region Variables
|
||||
|
||||
private MenuPermissionEnum _permission;
|
||||
|
||||
#endregion
|
||||
|
||||
public EditorDataGridTemplateColumnBase()
|
||||
{
|
||||
IsReadOnly = false;
|
||||
IsEnable = true;
|
||||
IsEditable = true;
|
||||
_permission = MenuPermissionEnum.MP_NONE;
|
||||
Visibility = Visibility.Visible;
|
||||
IsExpander = false;
|
||||
}
|
||||
public string ModuleName { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public string UnitName { get; set; }
|
||||
|
||||
public string ControlName { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string StringCellTemplate { get; set; }
|
||||
|
||||
public string StringCellEditingTemplate { get; set; }
|
||||
|
||||
public string StringHeaderTemplate { get; set; }
|
||||
|
||||
public bool IsEnable { get; set; }
|
||||
|
||||
public bool IsEditable { get; set; }
|
||||
|
||||
public bool IgnoreGasFlowCalculate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前列是否为列扩展器。
|
||||
/// </summary>
|
||||
public bool IsExpander { get; protected set; }
|
||||
|
||||
public string Default { get; set; }
|
||||
|
||||
public bool EnableConfig { get; set; }
|
||||
|
||||
public bool EnableTolerance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前列权限。
|
||||
/// </summary>
|
||||
public MenuPermissionEnum Permission
|
||||
{
|
||||
get => _permission;
|
||||
set
|
||||
{
|
||||
_permission = value;
|
||||
UpdateVisibility();
|
||||
UpdatePermission();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsColumnSelected
|
||||
{
|
||||
get => (bool)GetValue(IsColumnSelectedProperty);
|
||||
set => SetValue(IsColumnSelectedProperty, value);
|
||||
}
|
||||
/// <summary>
|
||||
/// The DependencyProperty that represents the IsReadOnly property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsColumnSelectedProperty =
|
||||
DependencyProperty.Register("IsColumnSelected", typeof(bool), typeof(EditorDataGridTemplateColumnBase), new FrameworkPropertyMetadata(false, OnNotifyCellPropertyChanged));
|
||||
|
||||
public Action<Param> PermissionChangedCallback { get; private set; }
|
||||
|
||||
public Func<Param,bool> Check { get; set; }
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// 当前列的权限发生变化时执行的回调函数。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 该回调函数中,设置当前列下所有配方参数的访问权限。
|
||||
/// </remarks>
|
||||
private void UpdatePermission()
|
||||
{
|
||||
switch (Permission)
|
||||
{
|
||||
default:
|
||||
case MenuPermissionEnum.MP_NONE:
|
||||
PermissionChangedCallback = (p) =>
|
||||
{
|
||||
p.ColumnPermission = Permission;
|
||||
};
|
||||
break;
|
||||
|
||||
case MenuPermissionEnum.MP_READ:
|
||||
PermissionChangedCallback = (p) =>
|
||||
{
|
||||
p.ColumnPermission = Permission;
|
||||
};
|
||||
break;
|
||||
|
||||
case MenuPermissionEnum.MP_READ_WRITE:
|
||||
|
||||
PermissionChangedCallback = (p) =>
|
||||
{
|
||||
p.ColumnPermission = Permission;
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据权限更新当前列的可见状态。
|
||||
/// </summary>
|
||||
public void UpdateVisibility()
|
||||
{
|
||||
if (!IsExpander)
|
||||
{
|
||||
Visibility = _permission == MenuPermissionEnum.MP_NONE
|
||||
? Visibility.Collapsed
|
||||
: Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class ExpanderColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public ExpanderColumn()
|
||||
{
|
||||
IsExpander = true;
|
||||
ChildColumns = new List<EditorDataGridTemplateColumnBase>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public static DependencyProperty IsExpanderProperty = DependencyProperty.Register("IsExpanded", typeof(bool),
|
||||
typeof(ExpanderColumn), new PropertyMetadata(true));
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => (bool)GetValue(IsExpanderProperty);
|
||||
set => SetValue(IsExpanderProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前组的所有列。
|
||||
/// </summary>
|
||||
public List<EditorDataGridTemplateColumnBase> ChildColumns { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class FlowModeColumn : ComboxColumn
|
||||
{
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class IntColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public double Minimun { get; set; }
|
||||
public double Maximun { get; set; }
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class LoopComboxColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public LoopComboxColumn() : base()
|
||||
{
|
||||
this.Options = new ObservableCollection<Option>();
|
||||
}
|
||||
public class Option
|
||||
{
|
||||
public string ControlName { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public string RelatedParameters { get; set; }
|
||||
}
|
||||
public ObservableCollection<Option> Options { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class MultipleSelectColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public MultipleSelectColumn() : base()
|
||||
{
|
||||
this.Options = new ObservableCollection<Option>();
|
||||
}
|
||||
public class Option
|
||||
{
|
||||
public MultipleSelectParam parent { get; set; }
|
||||
|
||||
public string ControlName { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public string RelatedParameters { get; set; }
|
||||
|
||||
public bool IsChecked
|
||||
{
|
||||
get { return this.isChecked; }
|
||||
set
|
||||
{
|
||||
this.isChecked = value;
|
||||
if (this.parent != null)
|
||||
this.parent.IsSaved = false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isChecked;
|
||||
}
|
||||
public ObservableCollection<Option> Options { get; set; }
|
||||
public List<Option> CloneOptions(MultipleSelectParam _parent = null)
|
||||
{
|
||||
List<Option> opts = new List<Option>();
|
||||
this.Options.ToList().ForEach(opt =>
|
||||
{
|
||||
opts.Add(new Option()
|
||||
{
|
||||
parent = _parent,
|
||||
ControlName = opt.ControlName,
|
||||
DisplayName = opt.DisplayName,
|
||||
RelatedParameters = opt.RelatedParameters
|
||||
});
|
||||
});
|
||||
|
||||
return opts;
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class NumColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public double Minimun { get; set; }
|
||||
public double Maximun { get; set; }
|
||||
|
||||
public string InputMode { get; set; }
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class PopSettingColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class PositionColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public PositionColumn() : base()
|
||||
{
|
||||
this.Options = new ObservableCollection<ComboxColumn.Option>();
|
||||
}
|
||||
public ObservableCollection<ComboxColumn.Option> Options { get; set; }
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
/// <summary>
|
||||
/// 比例输入列。
|
||||
/// </summary>
|
||||
public class RatioColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public int MaxSets { get; set; }
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class RecipeSelectColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public string RecipeProcessType { get; set; }
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class StepColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class TextBlockColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class TextBoxColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
public int MaxLength { get; set; }
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class TuneColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn
|
||||
{
|
||||
public class VatColumn : EditorDataGridTemplateColumnBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,645 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.DataGridRecipe"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:ExtendedGrid.Microsoft.Windows.Controls"
|
||||
xmlns:controls1="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:converters="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:cv="clr-namespace:MECF.Framework.UI.Client.RecipeEditorLib.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:local="clr-namespace:MECF.Framework.UI.Client.RecipeEditorLib.DGExtension"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
|
||||
<!--#region Converters-->
|
||||
|
||||
<converters:BoolCollapsedConverter x:Key="BoolCollapsedConverter" />
|
||||
<converters:BoolReverseConverter x:Key="boolRConverter" />
|
||||
<cv:ParamToCellTooltipConverter x:Key="CellTooltipConverter" />
|
||||
<cv:IsHighlightedToBorderThickness x:Key="IsHighlightedToBorderThickness" />
|
||||
<cv:IsHighlightedToBorderBrush x:Key="IsHighlightedToBorderBrush" />
|
||||
<cv:ParamValueDisplayConverter x:Key="ParamValueDisplayConverter" />
|
||||
<cv:PermissionToIsEnabledConverter x:Key="PermissionToIsEnabledConverter" />
|
||||
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Column Header Template-->
|
||||
<DataTemplate x:Key="ColumnHeaderTemplateCommon">
|
||||
<Grid Width="320" Margin="0,5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="280" />
|
||||
<ColumnDefinition Width="40" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Grid.LayoutTransform>
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="16"
|
||||
Text="{Binding DisplayName}" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="16"
|
||||
Text="{Binding UnitName}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="ColumnHeaderTemplateStepNo">
|
||||
<Grid Width="320" Margin="0,5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="280" />
|
||||
<ColumnDefinition Width="40" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Grid.LayoutTransform>
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="16"
|
||||
Text="{Binding DisplayName}" />
|
||||
<CheckBox
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding DataContext.CurrentRecipe.Steps.IsAllStepsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="ColumnHeaderTemplateExpander">
|
||||
<Border
|
||||
Width="340"
|
||||
Margin="-5,-8,-6,-8"
|
||||
Background="LightGray">
|
||||
<Expander
|
||||
Margin="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Left"
|
||||
VerticalContentAlignment="Stretch"
|
||||
Collapsed="Expander_OnCollapsed"
|
||||
Expanded="Expander_OnExpanded"
|
||||
FontSize="14"
|
||||
Header="{Binding DisplayName}"
|
||||
IsExpanded="{Binding IsExpanded}" />
|
||||
<Border.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Border.LayoutTransform>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<!--#endregion-->
|
||||
|
||||
<Style x:Key="DoubleUpDownStyle1" TargetType="{x:Type xctk:DoubleUpDown}">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="TextAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type xctk:DoubleUpDown}">
|
||||
<xctk:WatermarkTextBox
|
||||
x:Name="PART_TextBox"
|
||||
MinWidth="20"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
AcceptsReturn="false"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="0"
|
||||
ContextMenu="{TemplateBinding ContextMenu}"
|
||||
FontFamily="{TemplateBinding FontFamily}"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
FontStretch="{TemplateBinding FontStretch}"
|
||||
FontStyle="{TemplateBinding FontStyle}"
|
||||
FontWeight="{TemplateBinding FontWeight}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectAllOnGotFocus="{Binding SelectAllOnGotFocus, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Style="{StaticResource GenericTextBoxStyle}"
|
||||
TabIndex="{TemplateBinding TabIndex}"
|
||||
TextAlignment="{Binding TextAlignment, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
TextWrapping="NoWrap"
|
||||
Watermark="{Binding Watermark, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
WatermarkTemplate="{Binding WatermarkTemplate, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--#region Cell Templates-->
|
||||
|
||||
<DataTemplate x:Key="CellTemplateDisplay">
|
||||
<Border
|
||||
BorderBrush="{Binding IsHighlighted, Mode=OneWay, Converter={StaticResource IsHighlightedToBorderBrush}}"
|
||||
BorderThickness="{Binding IsHighlighted, Mode=OneWay, Converter={StaticResource IsHighlightedToBorderThickness}}"
|
||||
IsHitTestVisible="{Binding IsEnabled}"
|
||||
PreviewMouseDown="DataGridCell_OnPreviewMouseDown"
|
||||
ToolTip="{Binding Converter={StaticResource CellTooltipConverter}}">
|
||||
<Border.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Border.LayoutTransform>
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background" Value="#00FFFFFF" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsSaved}" Value="False">
|
||||
<Setter Property="Background" Value="{StaticResource DataGrid_BG_CellValueChangedWithoutSave}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<Border Margin="1" Background="{Binding StepBackgroundColorBrush}">
|
||||
<TextBlock
|
||||
Padding="5,3"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis">
|
||||
<TextBlock.Text>
|
||||
<!-- 是否隐藏单元格内容 -->
|
||||
<MultiBinding Converter="{StaticResource ParamValueDisplayConverter}">
|
||||
<Binding Path="Value" />
|
||||
<Binding Path="Permission" />
|
||||
<Binding Path="IsHideValue" />
|
||||
<Binding Path="HiddenValueMasking" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsEqualsToPrevious}" Value="False" />
|
||||
<Condition Binding="{Binding IsValid}" Value="False" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Foreground" Value="{StaticResource DataGrid_FG_CellValueNotValid}" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsEqualsToPrevious}" Value="True" />
|
||||
<Condition Binding="{Binding IsValid}" Value="False" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Foreground" Value="{StaticResource DataGrid_FG_CellValueNotValid}" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsEqualsToPrevious}" Value="False" />
|
||||
<Condition Binding="{Binding IsValid}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Foreground" Value="{StaticResource DataGrid_FG_CellValueNotEquFront}" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</Border>
|
||||
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateStepNo">
|
||||
<Grid>
|
||||
<Grid.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Grid.LayoutTransform>
|
||||
<Border
|
||||
Padding="5,1"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0"
|
||||
IsHitTestVisible="{Binding IsEnabled}">
|
||||
<StackPanel
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<CheckBox
|
||||
Margin="4"
|
||||
IsChecked="{Binding IsChecked}"
|
||||
Visibility="{Binding StepCheckVisibility}" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Foreground="Black"
|
||||
Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Visibility="{Binding Visible}" />
|
||||
</StackPanel>
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Visible}" Value="false">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsSaved}" Value="False">
|
||||
<Setter Property="Background" Value="{StaticResource DataGrid_BG_CellValueChangedWithoutSave}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateReadOnly">
|
||||
<Grid>
|
||||
<Grid.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Grid.LayoutTransform>
|
||||
<Border
|
||||
Padding="1,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderThickness="0,0,1,1">
|
||||
<TextBlock
|
||||
Padding="5,3"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
Text="{Binding Value}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateText">
|
||||
<Grid>
|
||||
<Grid.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Grid.LayoutTransform>
|
||||
<Border
|
||||
Padding="1,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderThickness="0,0,1,1"
|
||||
IsHitTestVisible="{Binding IsEnabled}">
|
||||
<controls1:TextBoxEx
|
||||
Padding="5,3"
|
||||
AllowBackgroundChange="True"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
IsHitTestVisible="{Binding IsEnabled}"
|
||||
Text="{Binding Value, Mode=TwoWay}"
|
||||
TextSaved="{Binding IsSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsColumnSelected}" Value="True">
|
||||
<Setter Property="BorderBrush" Value="DarkBlue" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsColumnSelected}" Value="False">
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Visible}" Value="false">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateSets3Ratio">
|
||||
<Border IsHitTestVisible="{Binding IsEnabled}">
|
||||
<Border.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Border.LayoutTransform>
|
||||
<TextBox
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
IsHitTestVisible="{Binding IsEnabled}"
|
||||
Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
|
||||
<TextBox.Style>
|
||||
<Style BasedOn="{StaticResource GenericTextBoxStyle}" TargetType="TextBox">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsValid}" Value="False">
|
||||
<Setter Property="Foreground" Value="#9c0006" />
|
||||
<Setter Property="Background" Value="#ffc7ce" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBox.Style>
|
||||
</TextBox>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateNumber">
|
||||
<Border IsHitTestVisible="{Binding IsEnabled}">
|
||||
<Border.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Border.LayoutTransform>
|
||||
<xctk:DoubleUpDown
|
||||
IsHitTestVisible="{Binding IsEnabled}"
|
||||
SelectAllOnGotFocus="True"
|
||||
ShowButtonSpinner="False"
|
||||
Value="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, FallbackValue=0}">
|
||||
<xctk:DoubleUpDown.Style>
|
||||
<Style BasedOn="{StaticResource DoubleUpDownStyle1}" TargetType="xctk:DoubleUpDown">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsValid}" Value="False">
|
||||
<Setter Property="Foreground" Value="#9c0006" />
|
||||
<Setter Property="Background" Value="#ffc7ce" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</xctk:DoubleUpDown.Style>
|
||||
</xctk:DoubleUpDown>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateNumberText">
|
||||
<Grid>
|
||||
<Grid.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Grid.LayoutTransform>
|
||||
<Border
|
||||
Padding="1,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderThickness="0,0,1,1"
|
||||
IsHitTestVisible="{Binding IsEnabled}">
|
||||
<controls1:TextBoxEx
|
||||
Padding="5,3"
|
||||
AllowBackgroundChange="True"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
IsHitTestVisible="{Binding IsEnabled}"
|
||||
MaxValue="{Binding Maximun}"
|
||||
MinValue="{Binding Minimun}"
|
||||
Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsColumnSelected}" Value="True">
|
||||
<Setter Property="BorderBrush" Value="DarkBlue" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsColumnSelected}" Value="False">
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateComboBox">
|
||||
<Grid>
|
||||
<Grid.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Grid.LayoutTransform>
|
||||
<Border
|
||||
Padding="1,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderThickness="0,0,1,1">
|
||||
<controls1:ComboTextBlock
|
||||
Padding="5,3"
|
||||
AllowBackgroundChange="True"
|
||||
IsEditable="{Binding IsEditable}"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
IsHitTestVisible="{Binding IsEnabled}"
|
||||
IsLoopItem="{Binding IsLoopItem}"
|
||||
ItemsSource="{Binding Options}"
|
||||
Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsColumnSelected}" Value="True">
|
||||
<Setter Property="BorderBrush" Value="DarkBlue" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsColumnSelected}" Value="False">
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Visible}" Value="false">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateComboBoxEx">
|
||||
<Border>
|
||||
<Border.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Border.LayoutTransform>
|
||||
<ComboBox
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
DisplayMemberPath="DisplayName"
|
||||
IsEditable="{Binding IsEditable}"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
ItemsSource="{Binding Options}"
|
||||
SelectedItem="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Delay=10}" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplatePopSetting">
|
||||
<Grid>
|
||||
<Grid.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Grid.LayoutTransform>
|
||||
<Border
|
||||
Padding="15,1"
|
||||
Background="{DynamicResource Table_BG_Content}"
|
||||
BorderThickness="0,0,1,1"
|
||||
IsHitTestVisible="{Binding IsEnabled}">
|
||||
<Button
|
||||
Content="{Binding DisplayName}"
|
||||
Foreground="Black"
|
||||
IsEnabled="{Binding IsEnabled}"
|
||||
IsHitTestVisible="{Binding IsEnabled}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="PopSetting">
|
||||
<micro:Parameter Value="{Binding Name}" />
|
||||
<micro:Parameter Value="{Binding}" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsColumnSelected}" Value="True">
|
||||
<Setter Property="BorderBrush" Value="DarkBlue" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsColumnSelected}" Value="False">
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CellTemplateExpander">
|
||||
<Border
|
||||
Width="Auto"
|
||||
MinWidth="90"
|
||||
Margin="0,-5"
|
||||
Background="LightGray"
|
||||
IsHitTestVisible="{Binding IsEnabled}">
|
||||
<Border.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Border.LayoutTransform>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Visible}" Value="false">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<!--#endregion-->
|
||||
|
||||
<!--<Style TargetType="controls:DataGridCell" BasedOn="{x:Null}">
|
||||
<Setter
|
||||
Property="IsEnabled"
|
||||
Value="{Binding Permission,
|
||||
Converter={StaticResource PermissionToIsEnabledConverter}}"/>
|
||||
</Style>-->
|
||||
|
||||
<Style
|
||||
x:Key="RecipeEditorDataGrid"
|
||||
BasedOn="{x:Null}"
|
||||
TargetType="local:XDataGrid">
|
||||
<Setter Property="AutoGenerateColumns" Value="False" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="CanUserAddRows" Value="False" />
|
||||
<Setter Property="CanUserDeleteRows" Value="False" />
|
||||
<Setter Property="CanUserReorderColumns" Value="False" />
|
||||
<Setter Property="CanUserResizeColumns" Value="False" />
|
||||
<Setter Property="CanUserResizeRows" Value="False" />
|
||||
<Setter Property="FrozenColumnCount" Value="4" />
|
||||
<Setter Property="GridLinesVisibility" Value="None" />
|
||||
<Setter Property="HeadersVisibility" Value="Column" />
|
||||
<Setter Property="SelectionUnit" Value="Cell" />
|
||||
<Setter Property="SelectionMode" Value="Single" />
|
||||
<Setter Property="UseHorizontalScrolling" Value="True" />
|
||||
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
|
||||
<Setter Property="CellStyle" Value="{x:Null}" />
|
||||
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
|
||||
<Setter Property="LayoutTransform">
|
||||
<Setter.Value>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="-90" />
|
||||
<ScaleTransform ScaleX="1" ScaleY="-1" />
|
||||
</TransformGroup>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="RowStyle">
|
||||
<Setter.Value>
|
||||
<Style TargetType="controls:DataGridRow">
|
||||
<Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BoolCollapsedConverter}}" />
|
||||
<Setter Property="Background" Value="{StaticResource DataGrid_BG_Selected}" />
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsSelected}" Value="false" />
|
||||
<Condition Binding="{Binding IsProcessed}" Value="false" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Background" Value="{StaticResource DataGrid_BG_First}" />
|
||||
</MultiDataTrigger>
|
||||
<DataTrigger Binding="{Binding IsSelected}" Value="True" />
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--#region Drag-to-Fill Style-->
|
||||
|
||||
<SolidColorBrush x:Key="DragToFillFrameColor" Color="ForestGreen" />
|
||||
|
||||
<Style
|
||||
x:Key="DragToFillThumbStyle"
|
||||
BasedOn="{x:Null}"
|
||||
TargetType="Thumb">
|
||||
<Setter Property="Height" Value="10" />
|
||||
<Setter Property="Width" Value="10" />
|
||||
<Setter Property="Background" Value="{StaticResource DragToFillFrameColor}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Rectangle Fill="{TemplateBinding Background}" StrokeThickness="0" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--#endregion-->
|
||||
|
||||
</UserControl.Resources>
|
||||
<local:XDataGrid
|
||||
x:Name="dgCustom"
|
||||
Width="{Binding Path=ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
|
||||
Height="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
|
||||
AllowDragToFill="{Binding AllowDragToFill, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
|
||||
BeginningEdit="DgCustom_OnBeginningEdit"
|
||||
CellEditEnding="DgCustom_OnCellEditEnding"
|
||||
DragToFillAdornerColorBrush="{StaticResource DragToFillFrameColor}"
|
||||
DragToFillAdornerThumbStyle="{StaticResource DragToFillThumbStyle}"
|
||||
HeadersVisibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=ComperHeadersVisibility}"
|
||||
LoadingRow="DgCustom_OnLoadingRow"
|
||||
ScrollViewer.ScrollChanged="dgCustom_ScrollChanged"
|
||||
Style="{StaticResource RecipeEditorDataGrid}"
|
||||
UnloadingRow="DgCustom_OnUnloadingRow" />
|
||||
</UserControl>
|
||||
+381
@@ -0,0 +1,381 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Diagnostics;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
|
||||
using MECF.Framework.Common.Account.Permissions;
|
||||
using OpenSEMI.ClientBase;
|
||||
using DataGridRowEventArgs = ExtendedGrid.Microsoft.Windows.Controls.DataGridRowEventArgs;
|
||||
using DataGridCellEditEndingEventArgs = ExtendedGrid.Microsoft.Windows.Controls.DataGridCellEditEndingEventArgs;
|
||||
using DataGridBeginningEditEventArgs = ExtendedGrid.Microsoft.Windows.Controls.DataGridBeginningEditEventArgs;
|
||||
using ExDataGridRow = ExtendedGrid.Microsoft.Windows.Controls.DataGridRow;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for DataGridRecipe.xaml
|
||||
/// </summary>
|
||||
public partial class DataGridRecipe : UserControl
|
||||
{
|
||||
enum Scroll
|
||||
{
|
||||
VerticalOffset,
|
||||
HorizontalOffset
|
||||
}
|
||||
|
||||
#region Constructors
|
||||
|
||||
ScrollViewer scroll;
|
||||
public DataGridRecipe()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void dgCustom_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
|
||||
if (scroll==null)
|
||||
scroll = (ScrollViewer)e.OriginalSource;
|
||||
|
||||
if (ScrollViewerOffset == null)
|
||||
ScrollViewerOffset=new double[2];
|
||||
|
||||
var _verticalOffset = scroll.VerticalOffset < scroll.ScrollableHeight ? scroll.VerticalOffset :
|
||||
ScrollViewerOffset[(int)Scroll.VerticalOffset] <= scroll.ScrollableHeight? scroll.VerticalOffset : ScrollViewerOffset[(int)Scroll.VerticalOffset];
|
||||
|
||||
var _horizontalOffset= scroll.HorizontalOffset < scroll.ScrollableWidth ? scroll.HorizontalOffset :
|
||||
ScrollViewerOffset[(int)Scroll.HorizontalOffset] <= scroll.ScrollableWidth ? scroll.HorizontalOffset: ScrollViewerOffset[(int)Scroll.HorizontalOffset];
|
||||
|
||||
ScrollViewerOffset = new double[] { _verticalOffset, _horizontalOffset };
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dependency Properties
|
||||
|
||||
public static readonly DependencyProperty AllowDragToFillProperty = DependencyProperty.Register(
|
||||
nameof(AllowDragToFill), typeof(bool), typeof(DataGridRecipe), new PropertyMetadata(true));
|
||||
|
||||
public bool AllowDragToFill
|
||||
{
|
||||
get => (bool)GetValue(AllowDragToFillProperty);
|
||||
set => SetValue(AllowDragToFillProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public double[] ScrollViewerOffset
|
||||
{
|
||||
get { return (double[])GetValue(ScrollViewerOffsetProperty); }
|
||||
set { SetValue(ScrollViewerOffsetProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for ScrollViewerOffset. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty ScrollViewerOffsetProperty =
|
||||
DependencyProperty.Register("ScrollViewerOffset", typeof(double[]), typeof(DataGridRecipe), new PropertyMetadata(new double[2], ScrollViewerOffsetPropertyChangedCallback));
|
||||
|
||||
#region RecipeData
|
||||
|
||||
|
||||
public static readonly DependencyProperty RecipeProperty = DependencyProperty.Register(
|
||||
nameof(Recipe), typeof(RecipeData), typeof(DataGridRecipe), new PropertyMetadata(default(RecipeData), RecipePropertyChangedCallback));
|
||||
|
||||
public ExtendedGrid.Microsoft.Windows.Controls.DataGridHeadersVisibility ComperHeadersVisibility
|
||||
{
|
||||
get { return (ExtendedGrid.Microsoft.Windows.Controls.DataGridHeadersVisibility)GetValue(ComperHeadersVisibilityProperty); }
|
||||
set { SetValue(ComperHeadersVisibilityProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for ComperHeadersVisibility. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty ComperHeadersVisibilityProperty =
|
||||
DependencyProperty.Register("ComperHeadersVisibility", typeof(ExtendedGrid.Microsoft.Windows.Controls.DataGridHeadersVisibility), typeof(DataGridRecipe), new PropertyMetadata(ExtendedGrid.Microsoft.Windows.Controls.DataGridHeadersVisibility.Column));
|
||||
|
||||
|
||||
private static void ScrollViewerOffsetPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DataGridRecipe self)
|
||||
{
|
||||
if (self.scroll != null)
|
||||
{
|
||||
if (e.NewValue != null)
|
||||
{
|
||||
var _scOffset = (double[])e.NewValue;
|
||||
|
||||
self.scroll.ScrollToVerticalOffset(_scOffset[(int)Scroll.VerticalOffset] <= self.scroll.ScrollableHeight ? _scOffset[(int)Scroll.VerticalOffset] : self.scroll.ScrollableHeight);
|
||||
self.scroll.ScrollToHorizontalOffset(_scOffset[(int)Scroll.HorizontalOffset] <= self.scroll.ScrollableWidth ? _scOffset[(int)Scroll.HorizontalOffset] : self.scroll.ScrollableWidth);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void RecipePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DataGridRecipe dg)
|
||||
{
|
||||
if (e.NewValue is RecipeData recipe)
|
||||
{
|
||||
dg.dgCustom.ItemsSource = recipe.Steps;
|
||||
recipe.PropertyChanged += (sender, e) =>
|
||||
{
|
||||
// 同步白名单编辑模式
|
||||
if (e.PropertyName == nameof(RecipeData.IsAccessibleWhitelistEditMode))
|
||||
{
|
||||
dg.dgCustom.IsAccessibleWhitelistEditMode = recipe.IsAccessibleWhitelistEditMode;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 创建DataGrid列
|
||||
dg.ClearColumns();
|
||||
|
||||
if (recipe.Columns != null)
|
||||
{
|
||||
foreach (var col in recipe.Columns)
|
||||
dg.AddColumn(col);
|
||||
}
|
||||
}
|
||||
else
|
||||
dg.dgCustom.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回编辑器正在编辑的Recipe。
|
||||
/// </summary>
|
||||
public RecipeData Recipe
|
||||
{
|
||||
get => (RecipeData)GetValue(RecipeProperty);
|
||||
set => SetValue(RecipeProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FrozenColumnCount
|
||||
|
||||
public static readonly DependencyProperty FrozenColumnCountProperty = DependencyProperty.Register(
|
||||
nameof(FrozenColumnCount), typeof(int), typeof(DataGridRecipe), new PropertyMetadata(default(int), FrozenColumnCountPropertyChangedCallback));
|
||||
|
||||
private static void FrozenColumnCountPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DataGridRecipe dg)
|
||||
{
|
||||
if (e.NewValue is int count)
|
||||
dg.dgCustom.FrozenColumnCount = count;
|
||||
else
|
||||
dg.dgCustom.FrozenColumnCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回编辑器冻结的列数。
|
||||
/// </summary>
|
||||
public int FrozenColumnCount
|
||||
{
|
||||
get => (int)GetValue(FrozenColumnCountProperty);
|
||||
set => SetValue(FrozenColumnCountProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private void RowOnSelected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!(e.Source is ExDataGridRow dgr))
|
||||
return;
|
||||
|
||||
if (!(dgr.DataContext is RecipeStep recipeStep))
|
||||
return;
|
||||
|
||||
var param = recipeStep.FindParamByControlName(RecipeControlNames.STEP_NO);
|
||||
if (param is StepParam sp)
|
||||
{
|
||||
sp.IsChecked = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void RowOnUnselected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!(e.Source is ExDataGridRow dgr))
|
||||
return;
|
||||
|
||||
if (!(dgr.DataContext is RecipeStep recipeStep))
|
||||
return;
|
||||
|
||||
var param = recipeStep.FindParamByControlName(RecipeControlNames.STEP_NO);
|
||||
if (param is StepParam sp)
|
||||
{
|
||||
sp.IsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearColumns()
|
||||
{
|
||||
dgCustom.Columns.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成编辑器的列。
|
||||
/// </summary>
|
||||
private void AddColumn(EditorDataGridTemplateColumnBase col)
|
||||
{
|
||||
// 设置ColumnHeaderTemplate和DataGridCellTemplate
|
||||
if (string.IsNullOrEmpty(col.StringCellTemplate) == false)
|
||||
col.CellTemplate = (DataTemplate)FindResource(col.StringCellTemplate);
|
||||
|
||||
if (string.IsNullOrEmpty(col.StringCellEditingTemplate) == false)
|
||||
col.CellEditingTemplate = (DataTemplate)FindResource(col.StringCellEditingTemplate);
|
||||
|
||||
if (string.IsNullOrEmpty(col.StringHeaderTemplate) == false)
|
||||
col.HeaderTemplate = (DataTemplate)FindResource(col.StringHeaderTemplate);
|
||||
|
||||
// 通过Columns重建XDataGrid列
|
||||
dgCustom.Columns.Add(col);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 滚动到并高亮指定的参数单元格。
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
public void FocusToParam(IParam param)
|
||||
{
|
||||
if (param == null)
|
||||
return;
|
||||
|
||||
Recipe.Steps.ResetHighlight();
|
||||
|
||||
var row = param.RowOwner;
|
||||
var col = param.ColumnOwner;
|
||||
|
||||
if (row != null && col != null)
|
||||
{
|
||||
dgCustom.ScrollIntoView(param.Parent, col);
|
||||
param.Highlight();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
private void DgCustom_OnBeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
||||
{
|
||||
Debug.Assert(e.Row.Item is RecipeStep, "The content of row is not RecipeStep.");
|
||||
if (e.Row.Item is RecipeStep step)
|
||||
{
|
||||
var param = step[e.Column.DisplayIndex];
|
||||
|
||||
if (param is IValueParam && param.Permission != MenuPermissionEnum.MP_READ_WRITE || param.IsHideValue)
|
||||
{
|
||||
e.Cancel = true;
|
||||
|
||||
// 如果单元格为只读权限、或设置了隐藏参数值,则提示不能编辑
|
||||
var reason = "";
|
||||
if (param.ColumnPermission != MenuPermissionEnum.MP_READ_WRITE)
|
||||
reason = "Recipe Row Access Denied!\r\n\r\nPlease check the RecipeRow Access Permission.";
|
||||
else if (param.StepPermission != MenuPermissionEnum.MP_READ_WRITE)
|
||||
reason = "Recipe Step Access Denied!\r\n\r\nPlease check the RecipeCol Access Permission.";
|
||||
else if (param.IsHideValue)
|
||||
reason = "Hidden Cell is denied editing.";
|
||||
else
|
||||
reason = "Cell Access Denied!\r\n\r\nPlease check the RecipeRow/RecipeCol Access Permission.";
|
||||
|
||||
|
||||
DialogBox.ShowError(reason);
|
||||
}
|
||||
}
|
||||
else
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
private void DataGridCell_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
// 仅在编辑AccessPermissionWhitelist编辑模式下有效。
|
||||
if (!Recipe.IsAccessibleWhitelistEditMode)
|
||||
return;
|
||||
|
||||
if (sender is Border bdr && bdr.DataContext is Param param)
|
||||
{
|
||||
if (param.IsHighlighted)
|
||||
param.ResetHighlight();
|
||||
else
|
||||
param.Highlight();
|
||||
}
|
||||
}
|
||||
|
||||
private void DgCustom_OnLoadingRow(object sender, DataGridRowEventArgs e)
|
||||
{
|
||||
e.Row.Selected += RowOnSelected;
|
||||
e.Row.Unselected += RowOnUnselected;
|
||||
|
||||
if (sender is XDataGrid dg && e.Row.DataContext is RecipeStep step)
|
||||
{
|
||||
for (var i = 0; i < step.Count; i++)
|
||||
{
|
||||
step[i].RowOwner = e.Row;
|
||||
step[i].ColumnOwner = dg.Columns[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DgCustom_OnUnloadingRow(object sender, DataGridRowEventArgs e)
|
||||
{
|
||||
e.Row.Selected -= RowOnSelected;
|
||||
e.Row.Unselected -= RowOnUnselected;
|
||||
}
|
||||
|
||||
|
||||
private void DgCustom_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
||||
{
|
||||
if (e.Row.Item is RecipeStep step)
|
||||
{
|
||||
step.CalculateGasFlow();
|
||||
step.Parent.Validate();
|
||||
}
|
||||
}
|
||||
|
||||
private void Expander_OnExpanded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Expander expander && expander.DataContext is ExpanderColumn col)
|
||||
{
|
||||
foreach (var subCol in col.ChildColumns)
|
||||
{
|
||||
subCol.UpdateVisibility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Expander_OnCollapsed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Expander expander && expander.DataContext is ExpanderColumn col)
|
||||
{
|
||||
foreach (var subCol in col.ChildColumns)
|
||||
{
|
||||
subCol.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 滚动DataGrid视图到指定的配方步骤。
|
||||
/// </summary>
|
||||
/// <param name="step"></param>
|
||||
public void ScrollToRecipeStep(RecipeStep step)
|
||||
{
|
||||
dgCustom.ScrollIntoView(step);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using MECF.Framework.Common.Account;
|
||||
using MECF.Framework.Common.Account.Permissions;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using MECF.Framework.UI.Client.DataGridTransform.DataGrid.Microsoft.Windows.Controls.Primitives;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
|
||||
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
|
||||
using EGC = ExtendedGrid.Microsoft.Windows.Controls;
|
||||
using Point = System.Windows.Point;
|
||||
using Size = System.Windows.Size;
|
||||
|
||||
namespace MECF.Framework.UI.Client.RecipeEditorLib.DGExtension
|
||||
{
|
||||
public sealed class XDataGrid : ExtendedGrid.Microsoft.Windows.Controls.DataGrid
|
||||
{
|
||||
#region Variables
|
||||
|
||||
public ScrollViewer ref_scrollviewer;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public XDataGrid()
|
||||
{
|
||||
SelectionChanged += OnSelectionChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public static readonly DependencyProperty SelectedItemsListProperty = DependencyProperty.Register(
|
||||
nameof(SelectedItemsList), typeof(IList), typeof(XDataGrid), new PropertyMetadata(default(IList)));
|
||||
|
||||
public IList SelectedItemsList
|
||||
{
|
||||
get => (IList)GetValue(SelectedItemsListProperty);
|
||||
set => SetValue(SelectedItemsListProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty UseHorizontalScrollingProperty = DependencyProperty.RegisterAttached("UseHorizontalScrolling", typeof(bool), typeof(XDataGrid),
|
||||
new PropertyMetadata(default(bool), UseHorizontalScrollingChangedCallback));
|
||||
|
||||
public bool UseHorizontalScrolling
|
||||
{
|
||||
get => (bool)GetValue(UseHorizontalScrollingProperty);
|
||||
set => SetValue(UseHorizontalScrollingProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsAccessibleWhitelistEditModeProperty = DependencyProperty.Register(
|
||||
nameof(IsAccessibleWhitelistEditMode), typeof(bool), typeof(XDataGrid), new PropertyMetadata(default(bool), IsCellAccessPermissionEditModePropertyChangedCallback));
|
||||
|
||||
private static void IsCellAccessPermissionEditModePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is XDataGrid grid && e.NewValue is bool isAweMode)
|
||||
{
|
||||
if (isAweMode)
|
||||
{
|
||||
// 如果进入单元格访问权限编辑模式,清除之前的拖拽框。
|
||||
grid.ClearCellSelectionAdorner();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回当前DataGrid是否处于单元格访问权限编辑模式。
|
||||
/// </summary>
|
||||
public bool IsAccessibleWhitelistEditMode
|
||||
{
|
||||
get => (bool)GetValue(IsAccessibleWhitelistEditModeProperty);
|
||||
set => SetValue(IsAccessibleWhitelistEditModeProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DPs
|
||||
|
||||
public static readonly DependencyProperty AllowDragToFillProperty = DependencyProperty.Register(
|
||||
nameof(AllowDragToFill), typeof(bool), typeof(XDataGrid), new PropertyMetadata(true));
|
||||
|
||||
public bool AllowDragToFill
|
||||
{
|
||||
get => (bool)GetValue(AllowDragToFillProperty);
|
||||
set => SetValue(AllowDragToFillProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DragToFillAdornerThumbStyleProperty = DependencyProperty.Register(
|
||||
nameof(DragToFillAdornerThumbStyle), typeof(Style), typeof(XDataGrid),
|
||||
new PropertyMetadata(default(Style)));
|
||||
|
||||
public Style DragToFillAdornerThumbStyle
|
||||
{
|
||||
get => (Style)GetValue(DragToFillAdornerThumbStyleProperty);
|
||||
set => SetValue(DragToFillAdornerThumbStyleProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DragToFillAdornerColorBrushProperty = DependencyProperty.Register(
|
||||
nameof(DragToFillAdornerColorBrush), typeof(Brush), typeof(XDataGrid), new PropertyMetadata(default(Brush)));
|
||||
|
||||
public Brush DragToFillAdornerColorBrush
|
||||
{
|
||||
get => (Brush)GetValue(DragToFillAdornerColorBrushProperty);
|
||||
set => SetValue(DragToFillAdornerColorBrushProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Excel-Like Cell Drag-To-Fill Adorner
|
||||
|
||||
private DataGridCellDragToFillAdorner _lastAdorner;
|
||||
|
||||
private void ClearCellSelectionAdorner()
|
||||
{
|
||||
// 清空之前的Adorner
|
||||
if (_lastAdorner != null && _lastAdorner.AdornedElement is EGC.DataGridCell cell)
|
||||
{
|
||||
var al = AdornerLayer.GetAdornerLayer(cell);
|
||||
var ads = al?.GetAdorners(cell)?.ToList();
|
||||
if (ads != null && ads.Any())
|
||||
foreach (var ad in ads)
|
||||
al.Remove(ad);
|
||||
}
|
||||
|
||||
if (_lastAdorner != null)
|
||||
{
|
||||
(_lastAdorner.AdornedElement as EGC.DataGridCell).KeyDown -= Cell_KeyDown;
|
||||
|
||||
_lastAdorner.OnDragStart -= LastAdornerOnOnDragStart;
|
||||
_lastAdorner.OnDragDelta -= LastAdornerOnOnDragDelta;
|
||||
_lastAdorner.OnDragCompleted -= LastAdornerOnOnDragCompleted;
|
||||
}
|
||||
|
||||
_lastAdorner = null;
|
||||
}
|
||||
|
||||
private void CreateCellSelectionAdorner(EGC.DataGridCellInfo? cellInfo)
|
||||
{
|
||||
ClearCellSelectionAdorner();
|
||||
|
||||
if (!AllowDragToFill)
|
||||
return;
|
||||
|
||||
// 如果选中了单元格,并且没有在编辑模式,显示Adorner
|
||||
if (CurrentCellContainer.IsEditing || !cellInfo.HasValue)
|
||||
return;
|
||||
|
||||
if (!CheckIsCellSupportDragToFill(TryFindCell(cellInfo.Value)))
|
||||
return;
|
||||
|
||||
var cell = TryFindCell(cellInfo.Value);
|
||||
cell.KeyDown += Cell_KeyDown;
|
||||
|
||||
if (cell != null && cell.DataContext is Param param)
|
||||
{
|
||||
// 根据Cell中Param的权限决定是否禁用拖拽填充功能
|
||||
var isEnabled = param.Permission != MenuPermissionEnum.MP_NONE;
|
||||
|
||||
_lastAdorner =
|
||||
new DataGridCellDragToFillAdorner(cell, new Size(cell.ActualWidth, cell.ActualHeight))
|
||||
{
|
||||
IsEnabled = isEnabled,
|
||||
ThumbStyle = DragToFillAdornerThumbStyle,
|
||||
Stroke = DragToFillAdornerColorBrush
|
||||
};
|
||||
_lastAdorner.OnDragStart += LastAdornerOnOnDragStart;
|
||||
_lastAdorner.OnDragDelta += LastAdornerOnOnDragDelta;
|
||||
_lastAdorner.OnDragCompleted += LastAdornerOnOnDragCompleted;
|
||||
AdornerLayer.GetAdornerLayer(cell).Add(_lastAdorner);
|
||||
}
|
||||
}
|
||||
|
||||
private Param GetParamFromCell(EGC.DataGridCellInfo? cellInfo)
|
||||
{
|
||||
if (cellInfo is { Item: RecipeStep rs, Column: EditorDataGridTemplateColumnBase col })
|
||||
{
|
||||
return rs.FirstOrDefault(x => x.ControlName == col.ControlName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Param GetParamFromCell(EGC.DataGridCell cell)
|
||||
{
|
||||
return GetParamFromCell(new EGC.DataGridCellInfo(cell));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查指定的单元格是否支持拖动填充功能。
|
||||
/// </summary>
|
||||
/// <param name="cell"></param>
|
||||
/// <returns></returns>
|
||||
private bool CheckIsCellSupportDragToFill(EGC.DataGridCell cell)
|
||||
{
|
||||
// 仅当单元格绑定的参数为数值型参数、并且参数访问权限不为MP_NONE、并且所属列不为ReadOnly,可以开启拖动填充功能
|
||||
if (cell.DataContext is Param param and IValueParam
|
||||
&& cell.Column is EditorDataGridTemplateColumnBase { IsExpander: false, IsReadOnly: false })
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If ESC key down when dragging, cancel the dragging.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Cell_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
_lastAdorner?.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void LastAdornerOnOnDragStart(object sender, DragStartedEventArgs e)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void LastAdornerOnOnDragCompleted(object sender, DragCompletedEventArgs e)
|
||||
{
|
||||
if (sender is DataGridCellDragToFillAdorner adorner
|
||||
&& adorner.AdornedElement is EGC.DataGridCell cell
|
||||
&& _selectionAnchor != null)
|
||||
{
|
||||
// 源单元格不支持拖放填充
|
||||
if (!CheckIsCellSupportDragToFill(cell))
|
||||
return;
|
||||
|
||||
if (adorner.StartCellIndex != adorner.EndCellIndex)
|
||||
{
|
||||
// 复制值
|
||||
var srcParam = GetParamFromCell(_selectionAnchor);
|
||||
|
||||
if (srcParam is IValueParam param)
|
||||
{
|
||||
// 获取源数据
|
||||
var value = param.GetValue();
|
||||
|
||||
var itemsHost = InternalItemsHost;
|
||||
if (itemsHost != null)
|
||||
{
|
||||
|
||||
var start = Math.Min(adorner.StartCellIndex, adorner.EndCellIndex);
|
||||
var end = Math.Max(adorner.StartCellIndex, adorner.EndCellIndex);
|
||||
for (var i = start; i <= end; i++)
|
||||
{
|
||||
if (itemsHost.Children[i] is EGC.DataGridRow row)
|
||||
{
|
||||
var targetCell = row.TryGetCell(_selectionAnchor.Value.Column.DisplayIndex);
|
||||
|
||||
// 如果当前行被设置为Visibility.Collapsed,则无法通过TryGetCell方法获取Cell对象
|
||||
if(targetCell == null)
|
||||
continue;
|
||||
|
||||
// 获取目标单元格绑定的Recipe参数对象
|
||||
var targetParam = GetParamFromCell(targetCell);
|
||||
|
||||
// 如果目标参数没有写权限,则不要赋值
|
||||
if(targetParam.Permission != MenuPermissionEnum.MP_READ_WRITE)
|
||||
continue;
|
||||
|
||||
// 如果目标参数是值型参数,则写入源参数数值
|
||||
if (targetParam is IValueParam p)
|
||||
p.SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新adorner尺寸
|
||||
//adorner.Arrange(adorner.GetSelectionBound());
|
||||
}
|
||||
}
|
||||
|
||||
private void LastAdornerOnOnDragDelta(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
if (sender is DataGridCellDragToFillAdorner adorner && adorner.AdornedElement is EGC.DataGridCell cell)
|
||||
{
|
||||
// 检查当前Cell是否支持拖动填充
|
||||
if (!CheckIsCellSupportDragToFill(cell))
|
||||
return;
|
||||
|
||||
var itemsHost = InternalItemsHost;
|
||||
if (itemsHost == null)
|
||||
return;
|
||||
|
||||
// 获取当前鼠标附近的Cell
|
||||
var closestCell = MouseOverCell ?? GetCellNearMouse();
|
||||
if (closestCell != null)
|
||||
{
|
||||
var originCellInfo = new EGC.DataGridCellInfo(cell);
|
||||
var closestCellInfo = new EGC.DataGridCellInfo(closestCell);
|
||||
|
||||
var startIndex = Items.IndexOf(originCellInfo.Item);
|
||||
var endIndex = Items.IndexOf(closestCellInfo.Item);
|
||||
|
||||
// 判断当前鼠标的Y坐标是否超过了当前Row高度的一半。
|
||||
// 如果超过一半,则选中当前行对应的单元格;否则不选择。
|
||||
var closestRow = closestCell.RowOwner;
|
||||
var pt = Mouse.GetPosition(closestRow);
|
||||
var rowBounds = new Rect(new Point(), closestRow.RenderSize);
|
||||
|
||||
// 默认选择当前单元格
|
||||
var recRender = new Rect(0, 0, cell.ActualWidth, cell.ActualHeight);
|
||||
|
||||
// 判断鼠标是否划过当前Cell一半的位置,超过一半选中,没超过则不选中。
|
||||
if (endIndex > startIndex) // Select the cells below the origin cell.
|
||||
{
|
||||
if (pt.Y < (rowBounds.Height / 2.0))
|
||||
endIndex -= 1; // don't select the cell nearby mouse
|
||||
|
||||
recRender.Height = 0;
|
||||
for (var i = startIndex; i <= endIndex; i++)
|
||||
{
|
||||
if (itemsHost.Children[i] is EGC.DataGridRow row)
|
||||
recRender.Height += row.RenderSize.Height;
|
||||
}
|
||||
}
|
||||
else if (endIndex < startIndex) // Select the cells above the origin cell.
|
||||
{
|
||||
if (pt.Y > (rowBounds.Height / 2.0))
|
||||
endIndex += 1; // don't select the cell nearby mouse
|
||||
|
||||
recRender.Height = 0;
|
||||
for (var i = endIndex; i <= startIndex; i++)
|
||||
{
|
||||
if (itemsHost.Children[i] is EGC.DataGridRow row)
|
||||
recRender.Height += row.RenderSize.Height;
|
||||
}
|
||||
|
||||
/*Debug.WriteLine($"Start: {startIndex}, End: {endIndex}", "Adorner");
|
||||
Debug.WriteLine($"Rendering Adorner: {recRender}", "Adorner");
|
||||
Debug.WriteLine($"Cell Height: {cell.ActualHeight}, Render Height: {recRender.Height}", "Adorner");*/
|
||||
|
||||
recRender.Y = cell.ActualHeight - recRender.Height;
|
||||
|
||||
//Debug.WriteLine($"Render Y: {recRender.Y}", "Adorner");
|
||||
}
|
||||
|
||||
// 重新计算Adorner尺寸
|
||||
adorner.ArrangeSelectionBound(recRender, startIndex, endIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void EnsureInternalScrollControls()
|
||||
{
|
||||
base.EnsureInternalScrollControls();
|
||||
|
||||
if (_internalScrollHost != null)
|
||||
_internalScrollHost.ScrollChanged += (sender, args) =>
|
||||
{
|
||||
// Clear the cell adorner while the view is scrolling.
|
||||
ClearCellSelectionAdorner();
|
||||
};
|
||||
}
|
||||
|
||||
protected override void MakeFullRowSelection(object dataItem, bool allowsExtendSelect, bool allowsMinimalSelect)
|
||||
{
|
||||
base.MakeFullRowSelection(dataItem, allowsExtendSelect, allowsMinimalSelect);
|
||||
/*if (CurrentCell != null)
|
||||
CreateCellSelectionAdorner(CurrentCell);*/
|
||||
}
|
||||
|
||||
protected override void MakeCellSelection(EGC.DataGridCellInfo cellInfo, bool allowsExtendSelect, bool allowsMinimalSelect)
|
||||
{
|
||||
base.MakeCellSelection(cellInfo, allowsExtendSelect, allowsMinimalSelect);
|
||||
|
||||
// 如果是单元格访问权限编辑模式,则不要启用Drag-To-Fill功能
|
||||
if (IsAccessibleWhitelistEditMode)
|
||||
return;
|
||||
|
||||
if (_selectionAnchor != null)
|
||||
CreateCellSelectionAdorner(_selectionAnchor);
|
||||
}
|
||||
|
||||
public override bool BeginEdit(RoutedEventArgs editingEventArgs)
|
||||
{
|
||||
if (IsAccessibleWhitelistEditMode)
|
||||
return false;
|
||||
|
||||
return base.BeginEdit(editingEventArgs);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
SelectedItemsList = SelectedItems;
|
||||
}
|
||||
|
||||
protected override void OnArrowKeyDown(KeyEventArgs e)
|
||||
{
|
||||
//TODO 重映射方向键后,拖拽填充控件的位置不对,此功能还需要调试。
|
||||
var remapKey = e.Key;
|
||||
|
||||
remapKey = remapKey switch
|
||||
{
|
||||
Key.Left => Key.Down,
|
||||
Key.Down => Key.Right,
|
||||
Key.Right => Key.Up,
|
||||
Key.Up => Key.Left,
|
||||
_ => remapKey
|
||||
};
|
||||
|
||||
var args = new KeyEventArgs(e.KeyboardDevice, e.InputSource, e.Timestamp, remapKey);
|
||||
args.RoutedEvent = e.RoutedEvent;
|
||||
|
||||
base.OnArrowKeyDown(e);
|
||||
}
|
||||
|
||||
private void _UseHorizontalScrollingChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
PreviewMouseWheel += delegate (object sender, MouseWheelEventArgs args)
|
||||
{
|
||||
ScrollViewer scrollViewer = GetTemplateChild("DG_ScrollViewer") as ScrollViewer;
|
||||
if (scrollViewer != null)
|
||||
{
|
||||
if (args.Delta > 0)
|
||||
scrollViewer.LineLeft();
|
||||
else
|
||||
scrollViewer.LineRight();
|
||||
}
|
||||
ref_scrollviewer = scrollViewer;
|
||||
args.Handled = true;
|
||||
};
|
||||
}
|
||||
|
||||
private static void UseHorizontalScrollingChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
if (!(dependencyObject is XDataGrid dg))
|
||||
throw new ArgumentException("Element is not an ItemsControl");
|
||||
|
||||
dg._UseHorizontalScrollingChangedCallback(dependencyObject, dependencyPropertyChangedEventArgs);
|
||||
}
|
||||
|
||||
public static void SetUseHorizontalScrolling(ItemsControl element, bool value)
|
||||
{
|
||||
element.SetValue(UseHorizontalScrollingProperty, value);
|
||||
}
|
||||
|
||||
public static bool GetUseHorizontalScrolling(ItemsControl element)
|
||||
{
|
||||
return (bool)element.GetValue(UseHorizontalScrollingProperty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user