private void CommonCustomClassifyMenuPlugin_Click(object sender, EventArgs e) { ToolStripMenuItem tsmi = sender as ToolStripMenuItem; if (tsmi != null) { CommonCustomClassify _Classify = tsmi.Tag as CommonCustomClassify; foreach (ViewBase _View in this.m_Application.Views) { if (_View is ControlView) { ControlView _ControlView = _View as ControlView; if (_ControlView.GetControl() is CommonCustomClassifyListControlView) { CommonCustomClassifyListControlView _CommonCustomClassifyListControlView = _ControlView.GetControl() as CommonCustomClassifyListControlView; if (_CommonCustomClassifyListControlView.Classify != null && _CommonCustomClassifyListControlView.Classify.Equals(_Classify)) { _ControlView.Focus(); return; } } } } CommonCustomClassifyListControlView ctlControlView = new CommonCustomClassifyListControlView(); ctlControlView.SetApplication(this.m_Application); ctlControlView.Classify = _Classify; ControlView view = new ControlView(this.m_Application, ctlControlView, _Classify.Name, _Classify.GetIcon16()); this.m_Application.Views.Load(view, ViewDockOptions.Left); } }
private void tsbDelete_Click(object sender, EventArgs e) { CommonCustomClassify _Classify = this.tvClassify.SelectedNode.Tag as CommonCustomClassify; if (MessageBox.Show("确实要删除“" + _Classify.Name + "”及其子分类吗?", "公共分类", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { _Classify.Delete(); this.tvClassify.SelectedNode.Remove(); } }
public CommonCustomClassifyManageTabPage(CommonCustomClassify classify) { this.Classify = classify; base.Text = this.Classify.Name; tvClassify = new TreeView(); tvClassify.HideSelection = false; tvClassify.Dock = System.Windows.Forms.DockStyle.Fill; tvClassify.AfterSelect += new TreeViewEventHandler(tvClassify_AfterSelect); base.Controls.Add(tvClassify); ToolStrip tsClassify = new ToolStrip(); base.Controls.Add(tsClassify); ToolStripButton tsbAdd = new ToolStripButton(); tsbAdd.Text = "添加"; tsbAdd.Click += new EventHandler(tsbAdd_Click); tsClassify.Items.Add(tsbAdd); tsbAddChildren = new ToolStripButton(); tsbAddChildren.Text = "添加下级"; tsbAddChildren.Enabled = false; tsbAddChildren.Click += new EventHandler(tsbAddChildren_Click); tsClassify.Items.Add(tsbAddChildren); tsbUpdate = new ToolStripButton(); tsbUpdate.Text = "修改"; tsbUpdate.Enabled = false; tsbUpdate.Click += new EventHandler(tsbUpdate_Click); tsClassify.Items.Add(tsbUpdate); tsbDelete = new ToolStripButton(); tsbDelete.Text = "删除"; tsbDelete.Enabled = false; tsbDelete.Click += new EventHandler(tsbDelete_Click); tsClassify.Items.Add(tsbDelete); ImageList img = new ImageList(); img.Images.Add(Properties.Resources.CommonClassifyRoot16); img.Images.Add(Properties.Resources.CommonClassify16); img.Images.Add(Properties.Resources.CommonClassifyItem16); this.tvClassify.ImageList = img; this.Add(this.Classify.Children, this.tvClassify.Nodes); }
public CommonCustomClassifyManageForm(CommonCustomClassify classify, bool isUpdate) { InitializeComponent(); this.Classify = classify; if (isUpdate) { this.gbCommonClassify.Text = "修改公共分类"; } else { this.gbCommonClassify.Text = "新建公共分类"; } }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.ContextMenuStrip == null && e.Node.Tag != null) { if (e.Node.Tag is CommonCustomClassify) { CommonCustomClassify _Classify = e.Node.Tag as CommonCustomClassify; e.Node.ContextMenuStrip = this.m_Application.GetClassifyMenu(new Classify[] { _Classify }); } else if (e.Node.Tag is Device) { Device _Device = e.Node.Tag as Device; e.Node.ContextMenuStrip = this.m_Application.GetDeviceMenu(new Device[] { _Device }); } } }
private void FillClassifyNode(CommonCustomClassify classify, TreeNode treeNode) { treeNode.Text = classify.Name; treeNode.Tag = classify; if (classify.Parent == null) { treeNode.ImageIndex = 1; treeNode.SelectedImageIndex = 1; } else { treeNode.ImageIndex = 2; treeNode.SelectedImageIndex = 2; } }
private void btnDeleteRoot_Click(object sender, EventArgs e) { try { CommonCustomClassifyManageTabPage _ClassifyTabPage = this.tabClassify.SelectedTab as CommonCustomClassifyManageTabPage; CommonCustomClassify _Classify = _ClassifyTabPage.Classify; if (MessageBox.Show("确实要删除“" + _Classify.Name + "”分类及其所有的子分类吗?", "公共分类", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { _Classify.Delete(); this.tabClassify.TabPages.Remove(_ClassifyTabPage); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnUpdateRoot_Click(object sender, EventArgs e) { CommonCustomClassifyManageTabPage _ClassifyTabPage = this.tabClassify.SelectedTab as CommonCustomClassifyManageTabPage; CommonCustomClassify _Classify = _ClassifyTabPage.Classify; CommonCustomClassifyManageForm _CommonCustomClassifyManageForm = new CommonCustomClassifyManageForm(_Classify, true); if (_CommonCustomClassifyManageForm.ShowDialog(this) == DialogResult.OK) { try { _CommonCustomClassifyManageForm.Classify.Save(); _ClassifyTabPage.Text = _CommonCustomClassifyManageForm.Classify.Name; } catch (Exception ex) { MessageBox.Show(ex.Message, "公共分类", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnAddRoot_Click(object sender, EventArgs e) { CommonCustomClassify _Classify = this.m_Application.ClassifyTypes.GetClassifyType(typeof(CommonCustomClassify)).CreateClassify() as CommonCustomClassify; CommonCustomClassifyManageForm _CommonCustomClassifyManageForm = new CommonCustomClassifyManageForm(_Classify, false); if (_CommonCustomClassifyManageForm.ShowDialog(this) == DialogResult.OK) { try { _CommonCustomClassifyManageForm.Classify.Save(); this.tabClassify.TabPages.Add(new CommonCustomClassifyManageTabPage(_CommonCustomClassifyManageForm.Classify)); this.tabClassify.SelectedIndex = this.tabClassify.TabPages.Count - 1; } catch (Exception ex) { MessageBox.Show(ex.Message, "公共分类", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void tsbUpdate_Click(object sender, EventArgs e) { CommonCustomClassify _Classify = this.tvClassify.SelectedNode.Tag as CommonCustomClassify; CommonCustomClassifyManageForm _CommonCustomClassifyManageForm = new CommonCustomClassifyManageForm(_Classify, true); if (_CommonCustomClassifyManageForm.ShowDialog(this) == DialogResult.OK) { try { _CommonCustomClassifyManageForm.Classify.Save(); this.FillClassifyNode(_CommonCustomClassifyManageForm.Classify, this.tvClassify.SelectedNode); } catch (Exception ex) { MessageBox.Show(ex.Message, "公共分类", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void tsbAdd_Click(object sender, EventArgs e) { CommonCustomClassify _Classify = this.Classify.Application.ClassifyTypes.GetClassifyType(typeof(CommonCustomClassify)).CreateClassify(this.Classify) as CommonCustomClassify; CommonCustomClassifyManageForm _CommonCustomClassifyManageForm = new CommonCustomClassifyManageForm(_Classify, false); if (_CommonCustomClassifyManageForm.ShowDialog(this) == DialogResult.OK) { try { _CommonCustomClassifyManageForm.Classify.Save(); TreeNode tn = new TreeNode(); this.FillClassifyNode(_CommonCustomClassifyManageForm.Classify, tn); this.tvClassify.Nodes.Add(tn); } catch (Exception ex) { MessageBox.Show(ex.Message, "公共分类", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public CommonCustomClassifyInfo(CommonCustomClassify classify) { this.Classify = classify; }
/// <summary> /// 按照设备所属分类搜索设备。 /// </summary> /// <param name="classify">设备所属的分类。</param> /// <param name="containsChildren">是否包含所有下级分类中的设备。</param> public CommonCustomClassifyFilter(CommonCustomClassify classify, bool containsChildren) { this.Classify = classify; this.ContainsChildren = containsChildren; }
/// <summary> /// 设置应用程序框架。 /// </summary> /// <param name="application">应用程序框架。</param> public void SetApplication(Forms.FormApplicationClass application) { this.m_Application = (WindowsFormApplicationClass)application; ClassifySearch _Search = new ClassifySearch(this.m_Application); _Search.Filters.Add(new ParentIdFilter(0)); _Search.Filters.Add(new ClassifyTypeFilter(typeof(CommonCustomClassify))); ClassifyCollection _Classifys = _Search.Search(); if (_Classifys.Count > 0) { if (_Classifys.Count == 1) { CommonCustomClassify _Classify = _Classifys[0] as CommonCustomClassify; this.Text = _Classify.Name; this.Tag = _Classify; this.Image = _Classify.GetIcon16(); this.Click += new EventHandler(CommonCustomClassifyMenuPlugin_Click); } else { if (base.OwnerItem is ToolStripMenuItem) { ToolStripMenuItem owner = base.OwnerItem as ToolStripMenuItem; for (int intIndex = 0; intIndex < _Classifys.Count; intIndex++) { CommonCustomClassify _Classify = _Classifys[intIndex] as CommonCustomClassify; if (intIndex == 0) { this.Text = _Classify.Name; this.Tag = _Classify; this.Image = _Classify.GetIcon16(); this.Click += new EventHandler(CommonCustomClassifyMenuPlugin_Click); } else { ToolStripMenuItem tsmi = new ToolStripMenuItem(); tsmi.Text = _Classify.Name; tsmi.Tag = _Classify; tsmi.Image = _Classify.GetIcon16(); tsmi.Click += new EventHandler(CommonCustomClassifyMenuPlugin_Click); owner.DropDownItems.Add(tsmi); } } } else { for (int intIndex = 0; intIndex < _Classifys.Count; intIndex++) { CommonCustomClassify _Classify = _Classifys[intIndex] as CommonCustomClassify; ToolStripMenuItem tsmi = new ToolStripMenuItem(); tsmi.Text = _Classify.Name; tsmi.Tag = _Classify; tsmi.Image = _Classify.GetIcon16(); tsmi.Click += new EventHandler(CommonCustomClassifyMenuPlugin_Click); this.DropDownItems.Add(tsmi); } } } } }