Sic.Framework-Nanjing-Baishi/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorView.xaml.cs

101 lines
3.2 KiB
C#
Raw Normal View History

using System.Windows;
2023-04-13 11:51:03 +08:00
using System.Windows.Controls;
using System.Windows.Input;
using MECF.Framework.UI.Client.Ctrlib.Controls;
using MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.CustomColumn;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel;
using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params;
using DataGridRowEventArgs = ExtendedGrid.Microsoft.Windows.Controls.DataGridRowEventArgs;
using ExDataGridRow = ExtendedGrid.Microsoft.Windows.Controls.DataGridRow;
2023-04-13 11:51:03 +08:00
namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
{
/// <summary>
/// Interaction logic for RecipePM1View.xaml
/// </summary>
public partial class RecipeEditorView
2023-04-13 11:51:03 +08:00
{
public RecipeEditorView()
{
InitializeComponent();
}
EditorDataGridTemplateColumnBase _PreColumn = null;
private void DgCustom_OnLoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Selected += RowOnSelected;
e.Row.Unselected += RowOnUnselected;
}
private void DgCustom_OnUnloadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Selected -= RowOnSelected;
e.Row.Unselected -= RowOnUnselected;
}
private void RowOnSelected(object sender, RoutedEventArgs e)
2023-04-13 11:51:03 +08:00
{
if (!(e.Source is ExDataGridRow dgr))
return;
2023-04-13 11:51:03 +08:00
if (!(dgr.DataContext is RecipeStep recipeStep))
return;
2023-04-13 11:51:03 +08:00
var param = recipeStep.FindParamByControlName(RecipeControlNames.STEP_NO);
if (param is StepParam sp)
2023-04-13 11:51:03 +08:00
{
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;
2023-04-13 11:51:03 +08:00
}
}
private void UIElement_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (DataContext is RecipeEditorViewModel vm)
2023-04-13 11:51:03 +08:00
{
// 仅在编辑AccessPermissionWhitelist编辑模式下有效。
if (!vm.IsCellAccessPermissionEditMode)
return;
if (sender is Border bdr && bdr.DataContext is Param param)
2023-04-13 11:51:03 +08:00
{
if (param.IsHighlighted)
param.ResetHighlight();
else
param.Highlight();
2023-04-13 11:51:03 +08:00
}
vm.CountHaveAccessPermParams();
//vm.SelectedGridCellCollection = e.AddedCells;
//vm.ToggleCellAccessPermissionWhitelistMark();
2023-04-13 11:51:03 +08:00
}
}
private void btnLock_Click(object sender, RoutedEventArgs e)
{
editorLocker.Lock();
}
private void btnChangePassword_Click(object sender, RoutedEventArgs e)
{
var dlg = new PanelLockerPasswordChanger();
dlg.ShowDialog();
}
2023-04-13 11:51:03 +08:00
}
}