refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
+342
@@ -0,0 +1,342 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.CenterViews.Configs.DataConfig.DataConfigView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:converter="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Converter"
|
||||
xmlns:cv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
d:DesignHeight="1024"
|
||||
d:DesignWidth="1900"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<cv:BoolReverseConverter x:Key="BoolReverse" />
|
||||
<cv:BoolCollapsedConverter x:Key="BoolVisibility" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="405" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="80" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:TextBoxEx
|
||||
HorizontalAlignment="Stretch"
|
||||
AllowBackgroundChange="False"
|
||||
Text="{Binding Path=NewGroupName, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Width="70"
|
||||
Height="30"
|
||||
Margin="0"
|
||||
Padding="0"
|
||||
Content="New">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="NewGroup" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
|
||||
<DataGrid
|
||||
Grid.Row="1"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
ItemsSource="{Binding GroupData}"
|
||||
RowHeaderWidth="0"
|
||||
SelectedItem="{Binding CurrentSelection}"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling">
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="200" Header="Name">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Margin="5,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="14"
|
||||
Foreground="{DynamicResource FG_Black}"
|
||||
Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Width="100">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button
|
||||
Width="100"
|
||||
Height="25"
|
||||
Content="Rename"
|
||||
FontSize="14"
|
||||
IsEnabled="{Binding IsFix, Converter={StaticResource BoolReverse}}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="RenameGroup">
|
||||
<micro:Parameter Value="{Binding}" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
|
||||
|
||||
<DataGridTemplateColumn Width="100">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button
|
||||
Width="100"
|
||||
Height="25"
|
||||
Content="Delete"
|
||||
FontSize="14"
|
||||
IsEnabled="{Binding IsFix, Converter={StaticResource BoolReverse}}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="DeleteGroup">
|
||||
<micro:Parameter Value="{Binding}" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150" />
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Title}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="1">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="12"
|
||||
Foreground="{DynamicResource FG_Black}"
|
||||
Text="{Binding CurrentSelection.Name}"
|
||||
TextWrapping="Wrap" />
|
||||
</Border>
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Width="90"
|
||||
Height="30"
|
||||
Margin="0"
|
||||
Padding="0"
|
||||
Content="Save">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SaveSelection" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
Width="90"
|
||||
Height="30"
|
||||
Margin="0"
|
||||
Padding="0"
|
||||
Content="Cancel">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="CancelSelection" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="460" />
|
||||
<ColumnDefinition Width="120" />
|
||||
<ColumnDefinition Width="460" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ListView
|
||||
Grid.Column="0"
|
||||
Width="450"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Unselections}"
|
||||
Style="{x:Null}">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ResourceKey={x:Type ListViewItem}}" TargetType="{x:Type ListViewItem}">
|
||||
<Setter Property="Visibility" Value="{Binding Path=IsSelected, Mode=OneWay, Converter={StaticResource ResourceKey=BoolVisibility}}" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="30">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox
|
||||
x:Name="ckHold"
|
||||
Width="20"
|
||||
Height="25"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Path=IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="390" Header="Name">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Width="390"
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Name}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
|
||||
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
|
||||
|
||||
</ListView>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<StackPanel
|
||||
Margin="0,120,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Vertical">
|
||||
<Button
|
||||
Grid.Column="0"
|
||||
Width="90"
|
||||
Height="30"
|
||||
Margin="0"
|
||||
Padding="0"
|
||||
Content="Select">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Select" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Width="90"
|
||||
Height="30"
|
||||
Margin="0,30,0,0"
|
||||
Padding="0"
|
||||
Content="Unselect">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Unselect" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
<ListView
|
||||
Grid.Column="2"
|
||||
Width="460"
|
||||
Margin="0,5,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Selections}"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ResourceKey={x:Type ListViewItem}}" TargetType="{x:Type ListViewItem}">
|
||||
<Setter Property="Visibility" Value="{Binding Path=IsSelected, Mode=OneWay, Converter={StaticResource ResourceKey=BoolVisibility}}" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="30">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox
|
||||
x:Name="ckHold"
|
||||
Width="20"
|
||||
Height="25"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Path=IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="390" Header="Name">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Width="390"
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Name}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
|
||||
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
|
||||
</ListView>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Configs.DataConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// SystemConfigView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DataConfigView : UserControl
|
||||
{
|
||||
public DataConfigView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+383
@@ -0,0 +1,383 @@
|
||||
using Aitex.Core.RT.Log;
|
||||
using Caliburn.Micro;
|
||||
using MECF.Framework.Common.CommonData;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.UI.Client.CenterViews.Editors;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using OpenSEMI.ClientBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Xml;
|
||||
using SciChart.Core.Extensions;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Configs.DataConfig
|
||||
{
|
||||
public class DataGroupItem : NotifiableItem
|
||||
{
|
||||
private string _name;
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; InvokePropertyChanged(nameof(Name)); }
|
||||
}
|
||||
|
||||
private bool _isFix;
|
||||
public bool IsFix
|
||||
{
|
||||
get { return _isFix; }
|
||||
set { _isFix = value; InvokePropertyChanged(nameof(IsFix)); }
|
||||
}
|
||||
|
||||
private bool _isVisible;
|
||||
public bool IsVisible
|
||||
{
|
||||
get { return _isVisible; }
|
||||
set { _isVisible = value; InvokePropertyChanged(nameof(IsVisible)); }
|
||||
}
|
||||
}
|
||||
|
||||
public class DataConfigViewModel : UiViewModelBase, ISupportMultipleSystem
|
||||
{
|
||||
public class DataItem : NotifiableItem
|
||||
{
|
||||
private string _name;
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; InvokePropertyChanged(nameof(Name)); }
|
||||
}
|
||||
|
||||
private bool _isSelected;
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set { _isSelected = value; InvokePropertyChanged(nameof(IsSelected)); }
|
||||
}
|
||||
|
||||
private bool _isChecked;
|
||||
public bool IsChecked
|
||||
{
|
||||
get { return _isChecked; }
|
||||
set { _isChecked = value; InvokePropertyChanged(nameof(IsChecked)); }
|
||||
}
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
public ObservableCollection<DataGroupItem> GroupData { get; set; }
|
||||
|
||||
private DataGroupItem _currentSelection;
|
||||
|
||||
public DataGroupItem CurrentSelection
|
||||
{
|
||||
get { return _currentSelection; }
|
||||
set
|
||||
{
|
||||
_currentSelection = value;
|
||||
ChangeGroupSelection(_currentSelection);
|
||||
|
||||
NotifyOfPropertyChange(nameof(CurrentSelection));
|
||||
}
|
||||
}
|
||||
|
||||
private string _content;
|
||||
private XmlDocument _xmlContent;
|
||||
|
||||
public ObservableCollection<DataItem> Unselections { get; set; }
|
||||
public ObservableCollection<DataItem> Selections { get; set; }
|
||||
|
||||
public string NewGroupName { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Functions
|
||||
public DataConfigViewModel()
|
||||
{
|
||||
this.DisplayName = "Data Config";
|
||||
|
||||
GroupData = new ObservableCollection<DataGroupItem>();
|
||||
|
||||
Unselections = new ObservableCollection<DataItem>();
|
||||
Selections = new ObservableCollection<DataItem>();
|
||||
}
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
|
||||
var lstItems = (List<string>)QueryDataClient.Instance.Service.GetConfig("System.NumericDataList");
|
||||
|
||||
lstItems.Sort();
|
||||
|
||||
var selection = new ObservableCollection<DataItem>();
|
||||
var unselection = new ObservableCollection<DataItem>();
|
||||
foreach (var item in lstItems)
|
||||
{
|
||||
unselection.Add(new DataItem() { Name = item, IsChecked = false, IsSelected = false });
|
||||
selection.Add(new DataItem() { Name = item, IsChecked = false, IsSelected = false });
|
||||
}
|
||||
|
||||
Unselections = unselection;
|
||||
Selections = selection;
|
||||
|
||||
NotifyOfPropertyChange(nameof(Unselections));
|
||||
NotifyOfPropertyChange(nameof(Selections));
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
UpdateData();
|
||||
}
|
||||
|
||||
|
||||
private void UpdateData()
|
||||
{
|
||||
string content = QueryDataClient.Instance.Service.GetTypedConfigContent("DataGroup", "");
|
||||
|
||||
if (_content == content)
|
||||
return;
|
||||
|
||||
GroupData.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
_xmlContent = new XmlDocument();
|
||||
_xmlContent.LoadXml(content);
|
||||
_content = content;
|
||||
|
||||
var groups = _xmlContent.SelectNodes("DataGroupConfig/DataGroup");
|
||||
|
||||
foreach (var item in groups)
|
||||
{
|
||||
XmlElement element = item as XmlElement;
|
||||
|
||||
string strFix = element.GetAttribute("fix");
|
||||
bool bFix = false;
|
||||
if (!string.IsNullOrEmpty(strFix))
|
||||
{
|
||||
bool.TryParse(strFix, out bFix);
|
||||
}
|
||||
|
||||
string strVisible = element.GetAttribute("visible");
|
||||
bool bVisible = true;
|
||||
if (!string.IsNullOrEmpty(strVisible))
|
||||
{
|
||||
bool.TryParse(strVisible, out bVisible) ;
|
||||
}
|
||||
|
||||
if (!bVisible)
|
||||
continue;
|
||||
|
||||
string name = element.GetAttribute("name");
|
||||
|
||||
GroupData.Add(new DataGroupItem() { Name = name, IsFix = bFix});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void NewGroup()
|
||||
{
|
||||
if (string.IsNullOrEmpty(NewGroupName))
|
||||
{
|
||||
DialogBox.ShowWarning($"Please input new data group name");
|
||||
return;
|
||||
}
|
||||
NewGroupName = NewGroupName.Trim();
|
||||
|
||||
var nodeGroup = _xmlContent.SelectSingleNode($"DataGroupConfig/DataGroup[@name='{NewGroupName}']");
|
||||
|
||||
if (nodeGroup != null)
|
||||
{
|
||||
DialogBox.ShowWarning($"{NewGroupName} Already exist");
|
||||
return;
|
||||
}
|
||||
|
||||
var nodeRoot = _xmlContent.SelectSingleNode($"DataGroupConfig");
|
||||
|
||||
var node = _xmlContent.CreateElement("DataGroup");
|
||||
node.SetAttribute("name", NewGroupName);
|
||||
nodeRoot.AppendChild(node);
|
||||
|
||||
var item = new DataGroupItem()
|
||||
{
|
||||
IsFix = false,
|
||||
Name = NewGroupName
|
||||
};
|
||||
|
||||
GroupData.Add(item);
|
||||
|
||||
CurrentSelection = item;
|
||||
|
||||
QueryDataClient.Instance.Service.SetTypedConfigContent("DataGroup", "", _xmlContent.InnerXml);
|
||||
}
|
||||
|
||||
public void RenameGroup(DataGroupItem group)
|
||||
{
|
||||
InputFileNameDialogViewModel dialog = new InputFileNameDialogViewModel("Input New Config Name");
|
||||
dialog.FileName = group.Name;
|
||||
WindowManager wm = new WindowManager();
|
||||
bool? dialogReturn = wm.ShowDialog(dialog);
|
||||
if (!dialogReturn.HasValue || !dialogReturn.Value)
|
||||
return;
|
||||
|
||||
string name = dialog.FileName.Trim();
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
DialogBox.ShowWarning("Folder name should not be empty");
|
||||
return;
|
||||
}
|
||||
|
||||
var nodeGroup = _xmlContent.SelectSingleNode($"DataGroupConfig/DataGroup[@name='{name}']");
|
||||
|
||||
if (nodeGroup != null)
|
||||
{
|
||||
DialogBox.ShowWarning($"{name} Already exist");
|
||||
return;
|
||||
}
|
||||
|
||||
nodeGroup = _xmlContent.SelectSingleNode($"DataGroupConfig/DataGroup[@name='{group.Name}']");
|
||||
|
||||
(nodeGroup as XmlElement).SetAttribute("name", name);
|
||||
|
||||
group.Name = name;
|
||||
|
||||
QueryDataClient.Instance.Service.SetTypedConfigContent("DataGroup", "", _xmlContent.InnerXml);
|
||||
}
|
||||
|
||||
|
||||
public void DeleteGroup(DataGroupItem group)
|
||||
{
|
||||
if (!DialogBox.Confirm($"Are you sure you want to delete {group.Name}?"))
|
||||
return;
|
||||
|
||||
var nodeGroup = _xmlContent.SelectSingleNode($"DataGroupConfig/DataGroup[@name='{group.Name}']");
|
||||
|
||||
nodeGroup.ParentNode.RemoveChild(nodeGroup);
|
||||
|
||||
QueryDataClient.Instance.Service.SetTypedConfigContent("DataGroup", "", _xmlContent.InnerXml);
|
||||
|
||||
GroupData.RemoveWhere(x=>x.Name == group.Name);
|
||||
|
||||
//CurrentSelection = null;
|
||||
}
|
||||
|
||||
public void Select()
|
||||
{
|
||||
foreach (var unselection in Unselections)
|
||||
{
|
||||
if (unselection.IsChecked)
|
||||
{
|
||||
unselection.IsSelected = false;
|
||||
unselection.IsChecked = false;
|
||||
foreach (var selection in Selections)
|
||||
{
|
||||
if (selection.Name == unselection.Name)
|
||||
{
|
||||
selection.IsChecked = false;
|
||||
selection.IsSelected = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Unselect()
|
||||
{
|
||||
foreach (var selection in Selections)
|
||||
{
|
||||
if (selection.IsChecked)
|
||||
{
|
||||
selection.IsSelected = false;
|
||||
selection.IsChecked = false;
|
||||
foreach (var unselection in Unselections)
|
||||
{
|
||||
if (unselection.Name == selection.Name)
|
||||
{
|
||||
unselection.IsChecked = false;
|
||||
unselection.IsSelected = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveSelection()
|
||||
{
|
||||
var nodeGroup = _xmlContent.SelectSingleNode($"DataGroupConfig/DataGroup[@name='{CurrentSelection.Name}']");
|
||||
|
||||
var nodeItem = _xmlContent.SelectNodes($"DataGroupConfig/DataGroup[@name='{CurrentSelection.Name}']/DataItem");
|
||||
foreach (var nodeGroupChildNode in nodeItem)
|
||||
{
|
||||
var node = nodeGroupChildNode as XmlElement;
|
||||
nodeGroup.RemoveChild(node);
|
||||
}
|
||||
|
||||
foreach (var item in Selections)
|
||||
{
|
||||
if (item.IsSelected)
|
||||
{
|
||||
var node = _xmlContent.CreateElement("DataItem");
|
||||
node.SetAttribute("name", item.Name);
|
||||
nodeGroup.AppendChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
QueryDataClient.Instance.Service.SetTypedConfigContent("DataGroup", "", _xmlContent.InnerXml);
|
||||
}
|
||||
|
||||
public void CancelSelection()
|
||||
{
|
||||
ChangeGroupSelection(CurrentSelection);
|
||||
}
|
||||
|
||||
protected void ChangeGroupSelection(DataGroupItem group)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
foreach (var unselection in Unselections)
|
||||
{
|
||||
unselection.IsSelected = false;
|
||||
}
|
||||
|
||||
foreach (var selection in Selections)
|
||||
{
|
||||
selection.IsSelected = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var items = _xmlContent.SelectNodes($"DataGroupConfig/DataGroup[@name='{group.Name}']/DataItem");
|
||||
|
||||
List<string> names = new List<string>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
var node = item as XmlElement;
|
||||
names.Add(node.GetAttribute("name"));
|
||||
}
|
||||
|
||||
foreach (var unselection in Unselections)
|
||||
{
|
||||
unselection.IsSelected = !names.Contains(unselection.Name);
|
||||
}
|
||||
|
||||
foreach (var selection in Selections)
|
||||
{
|
||||
selection.IsSelected = names.Contains(selection.Name);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user