private void cmbWeightMethod_SelectedIndexChanged(object sender, EventArgs e) { if (!bEditProject) { string itemvalue = ((KeyValuePair <string, string>)cmbWeightMethod.SelectedItem).Value; curWa = WeightArithmetic.ReadArithmeticData(itemvalue); } OnCurWaChanged(); }
private void btnImport_Click(object sender, EventArgs e) { try { System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog(); dlg.RestoreDirectory = true; dlg.Filter = "Wem files (*.wem)|*.wem"; if (dlg.ShowDialog() != DialogResult.OK) { return; } List <WeightSortData> wsDataList = WeightSortManageForm.GetListWeightSortData(false); WeightArithmetic wa = WeightArithmetic.ReadArithmeticData(dlg.FileName); WeightParameter.GetWeightParameterList()[10].Clear(); if (!QueryWeightSort(wa)) { return; } if (!WeightArithmeticOperForm.WriteArithmeticFile(wa, true)) { return; } //加节点 foreach (TreeNode treenode in treeViewArithmeticList.Nodes[0].Nodes) { if (treenode.Text == wa.SortName) { string filename = "weightCategory\\" + wa.SortName + "\\" + wa.Name + ".wem"; if (!treenode.Nodes.ContainsKey(filename)) { treenode.Nodes.Add(filename, wa.Name, 4, 5); if (treenode.IsExpanded == false) { treenode.Expand(); } } break; } } } catch (Exception ex) { XCommon.XLog.Write("导入重量算法文件错误"); } }
public WeightArithmeticOperForm(string str_Type, TreeNode selNode) { InitializeComponent(); strType = str_Type; List <WeightSortData> wsDataList = WeightSortManageForm.GetListWeightSortData(); for (int i = 0; i < wsDataList.Count; ++i) { comboBoxWeightSort.Items.Add(wsDataList[i].sortName); } string wsortname = null; switch (strType) { case "new": { wsortname = selNode.Text; txtName.ReadOnly = false; txtName.Text = "新建算法"; break; } case "edit": { waData = WeightArithmetic.ReadArithmeticData(selNode.Name); dateTimePickerCreateTime.Text = waData.CreateTime; dateTimePickerLastModifyTime.Text = waData.LastModifyTime; txtRemark.Text = waData.Remark; comboBoxWeightSort.Enabled = false; wsortname = selNode.Parent.Text; txtName.Text = waData.Name; txtName.ReadOnly = true; break; } case "jynew": { if (selNode.Tag == null) { waData = WeightArithmetic.ReadArithmeticData(selNode.Name); wsortname = selNode.Parent.Text; } else { WeightArithmetic tempwa = selNode.Tag as WeightArithmetic; waData = (tempwa != null) ? tempwa.Clone() : (new WeightArithmetic()); wsortname = waData.SortName; } dateTimePickerCreateTime.Text = waData.CreateTime; dateTimePickerLastModifyTime.Text = waData.LastModifyTime; txtRemark.Text = waData.Remark; mapCandidateFormula = new Dictionary <WeightFormula, string>(); foreach (WeightFormula wf in waData.FormulaList) { mapCandidateFormula.Add(wf, wf.NodePath); } txtName.Text = waData.Name + " 副本"; txtName.ReadOnly = false; break; } } int nselindex = 0; for (int i = 0; i < wsDataList.Count; ++i) { if (wsDataList[i].sortName == wsortname) { nselindex = i; break; } } comboBoxWeightSort.SelectedIndex = nselindex; }