You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
4.3 KiB
106 lines
4.3 KiB
using Eplan.EplApi.MasterData;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using KPlan.Forms.Bean;
|
|
using KPlan.Util;
|
|
|
|
namespace KPlan.Forms {
|
|
/// <summary>
|
|
/// Interaction logic for Config_Classification.xaml
|
|
/// </summary>
|
|
public partial class Config_Classification : UserControl {
|
|
|
|
private ObservableCollection<PartSyncClassConfigBean> class_config = new ObservableCollection<PartSyncClassConfigBean>();
|
|
public Config_Classification() {
|
|
InitializeComponent();
|
|
this.table_Class.ItemsSource = class_config;
|
|
}
|
|
|
|
public void LoadPartGroups() {
|
|
EPlanTreeItem tree_home = new EPlanTreeItem("Parts");
|
|
tree_Part_Groups.Items.Add(tree_home);
|
|
Init_TopGroup(MDPartsDatabaseItem.Enums.ProductTopGroup.Electric, tree_home);
|
|
Init_TopGroup(MDPartsDatabaseItem.Enums.ProductTopGroup.Mechanic, tree_home);
|
|
Init_TopGroup(MDPartsDatabaseItem.Enums.ProductTopGroup.Fluid, tree_home);
|
|
Init_TopGroup(MDPartsDatabaseItem.Enums.ProductTopGroup.Process, tree_home);
|
|
Init_TopGroup(MDPartsDatabaseItem.Enums.ProductTopGroup.Invaild, tree_home);
|
|
Init_TopGroup(MDPartsDatabaseItem.Enums.ProductTopGroup.Undefined, tree_home);
|
|
this.Dispatcher.Invoke(new Action(delegate {
|
|
tree_home.IsExpanded = true;
|
|
}));
|
|
}
|
|
|
|
|
|
|
|
private void Init_TopGroup(MDPartsDatabaseItem.Enums.ProductTopGroup topGroup, EPlanTreeItem tree_home) {
|
|
EPlanTreeItem tree_TopGroup = new EPlanTreeItem(topGroup);
|
|
//KUtil.Log(tree_TopGroup.Header.ToString());
|
|
tree_home.Items.Add(tree_TopGroup);
|
|
//加载Group
|
|
MDPartsDatabaseItem.Enums.ProductGroup[] groups = MDPartsDatabaseItem.GetAvailableProductGroups(topGroup);
|
|
for (int i = 0; i < groups.Length; i++) {
|
|
MDPartsDatabaseItem.Enums.ProductGroup group = groups[i];
|
|
EPlanTreeItem tree_Group = new EPlanTreeItem(topGroup,group);
|
|
tree_TopGroup.Items.Add(tree_Group);
|
|
}
|
|
tree_TopGroup.Items.SortDescriptions.Add(new SortDescription("Header", ListSortDirection.Ascending));
|
|
tree_TopGroup.Items.Refresh();
|
|
}
|
|
|
|
public void SaveConfiguration() {
|
|
table_Class.Items.Refresh();
|
|
KUtil.ClearConfigSection(KConfigure.PART_SYNC_CLASSIFICATION);
|
|
//eplan to tc
|
|
Dictionary<string, string> classMap = new Dictionary<string, string>();
|
|
for (int i = 0; i < class_config.Count; i++) {
|
|
PartSyncClassConfigBean bean = class_config[i];
|
|
//KUtil.Log(bean.from+"->"+bean.to);
|
|
if (!KUtil.IsEmpty(bean.to) && !KUtil.IsEmpty(bean.from)) {
|
|
classMap.Add(bean.from, bean.to);
|
|
}
|
|
}
|
|
KUtil.SetConfigValue(KConfigure.PART_SYNC_CLASSIFICATION, classMap);
|
|
}
|
|
|
|
public void LoadConfiguration() {
|
|
Dictionary<string, string> eplan_to_tc = KUtil.GetConfigValue(KConfigure.PART_SYNC_CLASSIFICATION);
|
|
foreach (string key in eplan_to_tc.Keys) {
|
|
string val = eplan_to_tc[key];
|
|
//KUtil.Log(key + "->" + val);
|
|
if (!KUtil.IsEmpty(key) && !KUtil.IsEmpty(val)) {
|
|
PartSyncClassConfigBean bean = new PartSyncClassConfigBean() { from = key, to = val };
|
|
class_config.Add(bean);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Tree_Part_Groups_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
|
EPlanTreeItem selectedItem = tree_Part_Groups.SelectedItem as EPlanTreeItem;
|
|
if (selectedItem == null || !selectedItem.isProductGroup) {
|
|
return;
|
|
}
|
|
PartSyncClassConfigBean bean = new PartSyncClassConfigBean() { from = selectedItem.productTopGroup.ToString() + "." + selectedItem.productGroup.ToString() };
|
|
if (!class_config.Contains(bean)) {
|
|
class_config.Add(bean);
|
|
}
|
|
table_Class.Items.Refresh();
|
|
table_Class.SelectedItem = bean;
|
|
table_Class.ScrollIntoView(bean);
|
|
}
|
|
}
|
|
}
|