新增隐藏 RecipeEditor 参数值的功能。参数值隐藏后显示为“***”。

This commit is contained in:
THINKPAD 2022-09-02 10:22:09 +08:00
parent 4eb276c49b
commit 44801dce5a
12 changed files with 213 additions and 23 deletions

View File

@ -42,6 +42,23 @@
/// </summary>
public string Placeholder { get; }
public override bool IsHideValue
{
get
{
if (Name == RecipColNo.Time.ToString())
return false;
return _isHideValue;
}
set
{
_isHideValue = value;
NotifyOfPropertyChange(nameof(IsHideValue));
}
}
public int Resolution
{
get => _resolution;

View File

@ -22,8 +22,14 @@ namespace RecipeEditorLib.RecipeModel.Params
/// </summary>
RecipeStep Parent { get; }
/// <summary>
/// 当前参数在表格中的所属行。
/// </summary>
DataGridRow RowOwner { get; set; }
/// <summary>
/// 当前参数在表格中的所属列。
/// </summary>
DataGridColumn ColumnOwner { get; set; }
/// <summary>
@ -60,6 +66,11 @@ namespace RecipeEditorLib.RecipeModel.Params
/// 返回是否高亮显示当前参数。
/// </summary>
bool IsHighlighted { get; }
/// <summary>
/// 返回是否隐藏参数的值。
/// </summary>
bool IsHideValue { get; set; }
#endregion
@ -86,12 +97,12 @@ namespace RecipeEditorLib.RecipeModel.Params
/// </summary>
/// <returns></returns>
object GetValue();
/// <summary>
/// 高亮显示当前参数。
/// </summary>
void Highlight();
/// <summary>
/// 取消高亮显示。
/// </summary>

View File

@ -20,7 +20,8 @@ namespace RecipeEditorLib.RecipeModel.Params
protected bool _isValidated;
protected string _validationError;
protected bool _isEqualsToPrevious;
private bool _isHighlighted;
protected bool _isHighlighted;
protected bool _isHideValue;
#endregion
@ -35,6 +36,7 @@ namespace RecipeEditorLib.RecipeModel.Params
_isEqualsToPrevious = true;
_visibility = Visibility.Visible;
_isHighlighted = false;
_isHideValue = false;
}
#endregion
@ -162,6 +164,19 @@ namespace RecipeEditorLib.RecipeModel.Params
}
}
/// <summary>
/// 返回是否隐藏参数的值。
/// </summary>
public virtual bool IsHideValue
{
get => _isHideValue;
set
{
_isHideValue = value;
NotifyOfPropertyChange(nameof(IsHideValue));
}
}
public bool IsColumnSelected
{
@ -188,7 +203,7 @@ namespace RecipeEditorLib.RecipeModel.Params
public bool EnableTolerance { get; set; }
public Visibility StepCheckVisibility { get; set; }
/// <summary>
/// 高亮显示当前参数。
/// </summary>

View File

@ -22,19 +22,14 @@
#region Properties
///// <summary>
///// 注意StepParam的Value改变时不改变IsSaved属性。
///// </summary>
//public override string Value
//{
// get => _value;
// set
// {
// _value = value;
// NotifyOfPropertyChange(nameof(Value));
// }
//}
public override bool IsHideValue
{
get => false;
set
{
}
}
public bool IsChecked
{

View File

@ -13,5 +13,25 @@
}
#endregion
#region Properties
public override bool IsHideValue
{
get
{
if (Name == RecipColNo.Name.ToString())
return false;
return _isHideValue;
}
set
{
_isHideValue = value;
NotifyOfPropertyChange(nameof(IsHideValue));
}
}
#endregion
}
}

View File

@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using SciChart.Core.Extensions;
namespace RecipeEditorLib.RecipeModel.Params
{
@ -15,6 +16,9 @@ namespace RecipeEditorLib.RecipeModel.Params
#region Variables
private bool _isHideValue;
/// <summary>
/// 当配方步骤的IsSaved属性发生变化时触发此事件。
/// </summary>
@ -85,6 +89,19 @@ namespace RecipeEditorLib.RecipeModel.Params
/// </summary>
public RecipeStep Next { get; private set;}
/// <summary>
/// 返回是否隐藏当前步骤的参数值。
/// </summary>
public bool IsHideValue
{
get => _isHideValue;
set
{
_isHideValue = value;
this.ToList().ForEach(x => x.IsHideValue = value);
}
}
#endregion
#region Methods

View File

@ -12,6 +12,7 @@ namespace RecipeEditorLib.RecipeModel.Params
#region Variables
private bool _isSaved;
private bool _isHideValue;
#endregion
@ -50,6 +51,20 @@ namespace RecipeEditorLib.RecipeModel.Params
public IReadOnlyList<RecipeStep> SelectedSteps =>
this.ToList().Where(x => x.StepNoParam != null && x.StepNoParam.IsChecked).ToList();
/// <summary>
/// 返回是否隐藏所有步骤的参数值。
/// </summary>
public bool IsHideValue
{
get => _isHideValue;
set
{
_isHideValue = value;
this.ToList().ForEach(x => x.IsHideValue = value);
}
}
#endregion
#region Methods

View File

@ -0,0 +1,30 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace SicUI.Models.RecipeEditors
{
internal class ParamValueDisplayConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
{
// value[0] must be Param.Value
// value[1] must be Param.IsHideValue
if (value == null || value.Length != 2)
return value;
if (value[1] is bool isHideValue)
{
return isHideValue ? "***" : value[0].ToString();
}
return value[0];
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -16,18 +16,17 @@ namespace SicUI
{
InitializeComponent();
Loaded += OnLoaded;
SourceInitialized += OnSourceInitialized;
Closed += OnClosed;
}
private void OnLoaded(object sender, RoutedEventArgs e)
private void OnSourceInitialized(object sender, EventArgs e)
{
var desktopWorkingArea = SystemParameters.WorkArea;
Left = desktopWorkingArea.Right - Width;
Top = desktopWorkingArea.Bottom - Height;
}
private void EventSetter_OnHandler(object sender, MouseButtonEventArgs e)
{
if (!(DataContext is RecipeEditorViewModel vm))

View File

@ -11,18 +11,36 @@
xmlns:egc="clr-namespace:ExtendedGrid.Microsoft.Windows.Controls;assembly=MECF.Framework.UI.Client"
xmlns:micro="clr-namespace:Caliburn.Micro;assembly=MECF.Framework.UI.Client"
xmlns:recipeEditors="clr-namespace:SicUI.Models.RecipeEditors"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
d:DesignHeight="900"
d:DesignWidth="1500"
mc:Ignorable="d">
<UserControl.Resources>
<Geometry x:Key="IconShow">
M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7
,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39
7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z
</Geometry>
<Geometry x:Key="IconHide">
M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35
32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13
144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0
0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23
6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0
0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65
47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92
0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z
</Geometry>
<recipeEditors:ParamToCellTooltipConverter x:Key="CellTooltipConverter"/>
<recipeEditors:IsSavedToNameMarkVisibilityConverter x:Key="IsSavedToNameMarkVisibilityConverter"/>
<recipeEditors:IsHighlightedToBorderThickness x:Key="IsHighlightedToBorderThickness"/>
<recipeEditors:IsHighlightedToBorderBrush x:Key="IsHighlightedToBorderBrush"/>
<recipeEditors:ParamValueDisplayConverter x:Key="ParamValueDisplayConverter"/>
<SolidColorBrush x:Key="ValueChangedCellBackground" Color="#c0f18d"/>
<Style x:Key="DoubleUpDownStyle1" TargetType="{x:Type xctk:DoubleUpDown}">
@ -86,8 +104,15 @@
Padding="5,3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
TextTrimming="CharacterEllipsis">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource ParamValueDisplayConverter}">
<Binding Path="Value"/>
<Binding Path="IsHideValue"/>
</MultiBinding>
</TextBlock.Text>
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
@ -1380,6 +1405,46 @@
Content="Validate"
IsEnabled="{Binding EnableStep}"
micro:Message.Attach="ShowValidationDetailWindow()"/>
<Button
x:Name="btnShowHideParamValue"
Width="50"
Height="30"
Margin="5,0,0,0"
IsEnabled="{Binding EnableStep}"
ToolTip="Show/Hide Param Values"
micro:Message.Attach="ShowHideParamValues()">
<Grid>
<Path
Stretch="Uniform"
Height="16"
Fill="{Binding ElementName=btnShowHideParamValue, Path=Foreground}"
Data="{StaticResource IconShow}"
Visibility="{Binding CurrentRecipe.Steps.IsHideValue,
Converter={StaticResource BoolVisibilityConverter},
ConverterParameter='True'}"/>
<Path
Stretch="Uniform"
Height="16"
Fill="{Binding ElementName=btnShowHideParamValue, Path=Foreground}"
Data="{StaticResource IconHide}"
Visibility="{Binding CurrentRecipe.Steps.IsHideValue,
Converter={StaticResource BoolVisibilityConverter},
ConverterParameter='False'}"/>
</Grid>
</Button>
<!--
Content="{Binding CurrentRecipe.Steps.IsHideValue,
Converter={StaticResource ShowHideValueButtonContentConverter}}"
Content="{Binding CurrentRecipe.Steps.IsHideValue,
Mode=OneWay,
Converter={StaticResource ShowHideValueButtonContentConverter}}"
-->
</StackPanel>
<Border

View File

@ -2433,6 +2433,11 @@ namespace SicUI.Models.RecipeEditors
}
}
public void ShowHideParamValues()
{
CurrentRecipe.Steps.IsHideValue = !CurrentRecipe.Steps.IsHideValue;
}
private TreeViewItem GetParentObjectEx<TreeViewItem>(DependencyObject obj) where TreeViewItem : FrameworkElement
{
var parent = VisualTreeHelper.GetParent(obj);

View File

@ -353,6 +353,7 @@
<Compile Include="Models\RecipeEditors\Converters\IsDgSelectionCountEqualsOneConverter.cs" />
<Compile Include="Models\RecipeEditors\Converters\IsHighlightedToBorderBrush.cs" />
<Compile Include="Models\RecipeEditors\Converters\IsHighlightedToBorderThickness.cs" />
<Compile Include="Models\RecipeEditors\Converters\ParamValueDisplayConverter.cs" />
<Compile Include="Models\RecipeEditors\Converters\RecipeStepsCollectionToSelectedItemsConverter.cs" />
<Compile Include="Models\RecipeEditors\Converters\StepNoToCxtMenuTitleConverter.cs" />
<Compile Include="Models\RecipeEditors\EditorPassChangeView.xaml.cs">