完成删除变量
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
||||
xmlns:ex="clr-namespace:DMS.Extensions"
|
||||
xmlns:helper="clr-namespace:DMS.WPF.Helper"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
@@ -61,19 +63,12 @@
|
||||
</ui:AppBarButton.Icon>
|
||||
</ui:AppBarButton>
|
||||
|
||||
<ui:AppBarButton Click="DeleteVarData_Click" Label="删除变量">
|
||||
<ui:AppBarButton Command="{Binding DeleteVariableCommand}" Label="删除变量">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
</ui:AppBarButton>
|
||||
|
||||
|
||||
<ui:AppBarButton Command="{Binding SaveModifiedVarDataCommand}" Label="保存变量">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
|
||||
</ui:AppBarButton>
|
||||
<ui:AppBarButton
|
||||
Command="{Binding ImprotFromTiaVarTableCommand}"
|
||||
Label="从TIA变量表导入"
|
||||
@@ -149,6 +144,10 @@
|
||||
SelectedItem="{Binding SelectedVariable}"
|
||||
SelectionMode="Extended"
|
||||
Style="{StaticResource DataGridBaseStyle}">
|
||||
<i:Interaction.Behaviors>
|
||||
<helper:SelectedItemsBehavior SelectedItems="{Binding SelectedVariables}" />
|
||||
</i:Interaction.Behaviors>
|
||||
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem
|
||||
@@ -167,16 +166,11 @@
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Click="DeleteVarData_Click" Header="删除变量">
|
||||
<MenuItem Command="{Binding DeleteVariableCommand}" Header="删除变量">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Command="{Binding SaveModifiedVarDataCommand}" Header="保存变量">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
Command="{Binding ImprotFromTiaVarTableCommand}"
|
||||
Header="从TIA变量表导入"
|
||||
|
||||
@@ -48,75 +48,5 @@ public partial class VariableTableView : UserControl
|
||||
IsLoadCompletion = true;
|
||||
}
|
||||
|
||||
private void DataGrid_OnCellEditEnding(object? sender, DataGridCellEditEndingEventArgs args)
|
||||
{
|
||||
if (args.EditAction != DataGridEditAction.Commit)
|
||||
return;
|
||||
|
||||
// try
|
||||
// {
|
||||
// // 获取到改变后的值和绑定的属性名
|
||||
// Variable var = (Variable)args.Row.Item;
|
||||
// var element = args.EditingElement;
|
||||
// object newValue = null;
|
||||
// string bindingPath = "";
|
||||
//
|
||||
// if (element is TextBox textBox)
|
||||
// {
|
||||
// newValue = textBox.Text;
|
||||
// DataGridTextColumn textColumn = (DataGridTextColumn)args.Column;
|
||||
// bindingPath = (textColumn.Binding as Binding)?.Path.Path;
|
||||
// }
|
||||
// else if (element is CheckBox checkBox)
|
||||
// {
|
||||
// newValue = checkBox.IsChecked;
|
||||
// DataGridCheckBoxColumn checkBoxColumn = (DataGridCheckBoxColumn)args.Column;
|
||||
// bindingPath = (checkBoxColumn.Binding as Binding)?.Path.Path;
|
||||
// }
|
||||
// else if (args.Column.Header.ToString() == "信号类型")
|
||||
// {
|
||||
// var comboBox = VisualTreeHelper.GetChild(element, 0) as ComboBox;
|
||||
// if (comboBox != null)
|
||||
// {
|
||||
// newValue = comboBox.SelectedItem;
|
||||
// bindingPath = "SignalType";
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (newValue == null || string.IsNullOrEmpty(bindingPath))
|
||||
// return;
|
||||
// // 通过反射拿到值
|
||||
// var pathPropertyInfo = var.GetType()
|
||||
// .GetProperty(bindingPath);
|
||||
// var oldValue = pathPropertyInfo.GetValue(var);
|
||||
// // 判断值是否相等
|
||||
// if (newValue.ToString() != oldValue?.ToString())
|
||||
// {
|
||||
// var.IsModified = true;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// NotificationHelper.ShowError("变量表编辑的过过程中发生了错误:" + e.Message, e);
|
||||
// }
|
||||
}
|
||||
|
||||
private async void DeleteVarData_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// _viewModel = (VariableTableViewModel)this.DataContext;
|
||||
// var selectedVariables = BasicGridView.SelectedItems.Cast<Variable>().ToList();
|
||||
// if (selectedVariables.Any())
|
||||
// {
|
||||
// await _viewModel.DeleteVarData(selectedVariables);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// NotificationHelper.ShowInfo("请选择要删除的变量");
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user