/// <summary> /// 更新一个主工具栏项目 /// </summary> /// <param name="formEntity"></param> public void Update(ToolStripItemAbstract entity) { Debug.Assert(entity != null, "ToolStripItemAbstract 为 null"); if (entity == null) { return; } //更新索引信息 XElement element = _indexXml.XPathSelectElement(String.Format(XPATH_Index_SelectToolStrip, entity.Id)); Debug.Assert(element != null, "更新主工具栏项目索引时未找到指定主菜单的索引记录"); if (element != null) { element.ReplaceWith(GetArchiveIndex(entity)); SaveIndexFile(); string xml = entity.ToXml(); XElement xElement = XElement.Parse(xml); //更新实体文件 _packageService.Current.AddFileContent(xml, Path.Combine(Constant.PACKAGE_NAVIGATION_TOOLSTRIP_FOLDER, entity.Id)); _cachingService.Add(entity.Id, xElement); //发布事件 ToolStripEventArgs args = new ToolStripEventArgs(entity); _eventAggregator.GetEvent <ToolStripItemUpdatedEvent>().Publish(args); } }
/// <summary> /// 添加一个菜单项 /// </summary> /// <param name="entity"></param> public void Add(ToolStripItemAbstract entity) { Debug.Assert(entity != null, "entity 为 null"); if (entity == null) { return; } //添加索引信息 _indexXml.XPathSelectElement(XPATH_Index_ToolStrip).Add(GetArchiveIndex(entity)); string xml = entity.ToXml(); XElement xElement = XElement.Parse(xml); SaveIndexFile(); //添加数据实体文件 _packageService.Current.AddFileContent(xml, Path.Combine(Constant.PACKAGE_NAVIGATION_TOOLSTRIP_FOLDER, entity.Id)); _cachingService.Add(entity.Id, xElement); //发布事件 ToolStripEventArgs args = new ToolStripEventArgs(entity); _eventAggregator.GetEvent <ToolStripItemAddedEvent>().Publish(args); }
/// <summary> /// 删除菜单项,及其所有子项 /// </summary> /// <param name="code"></param> public void Delete(ToolStripItemAbstract entity) { Debug.Assert(entity != null, "entity 为 null"); if (entity == null) { return; } //移除索引信息 XElement element = _indexXml.XPathSelectElement(String.Format(XPATH_Index_SelectToolStrip, entity.Id)); Debug.Assert(element != null, "删除主工具栏索引时未找到指定主菜单的索引记录"); if (element != null) { element.Remove(); SaveIndexFile(); //移除实体文件 _packageService.Current.DeleteFile(Path.Combine(Constant.PACKAGE_NAVIGATION_TOOLSTRIP_FOLDER, entity.Id)); _cachingService.Remove(entity.Id); //发布事件 ToolStripEventArgs args = new ToolStripEventArgs(entity); _eventAggregator.GetEvent <ToolStripItemRemovedEvent>().Publish(args); } }
public void StripButtonClickHandler(object sender, ToolStripEventArgs e) { switch (e.Action) { case ToolStripAction.Capture: this.ZWPictureBox.LaserFunction = false; CaptureImage(); break; case ToolStripAction.Video: this.ZWPictureBox.LaserFunction = false; break; case ToolStripAction.Archive: this.ZWPictureBox.LaserFunction = false; filesForm = new FilesForm(); filesForm.ShowDialog(); break; case ToolStripAction.ZoomOut: this.ZWPictureBox.LaserFunction = false; this.ZWPictureBox.ZoonOut(); break; case ToolStripAction.ZoomIn: this.ZWPictureBox.LaserFunction = false; this.ZWPictureBox.ZoomIn(); break; case ToolStripAction.ZoomFit: this.ZWPictureBox.LaserFunction = false; this.ZWPictureBox.ZoomFit(); break; case ToolStripAction.Scale: this.ZWPictureBox.LaserFunction = false; ToolStripButton toolStripButton = sender as ToolStripButton; toolStripButton.Checked = !toolStripButton.Checked; this.ZWPictureBox.Rulers.ShowRulers = toolStripButton.Checked; this.ZWPictureBox.Invalidate(); break; case ToolStripAction.Line: case ToolStripAction.Rectangle: case ToolStripAction.Ellipse: case ToolStripAction.Polygon: this.ZWPictureBox.LaserFunction = false; SetMeasureTool(e.Action, false); this.ZWPictureBox.ShowBaseCtrl(true, 2); this.ZWPictureBox.Invalidate(); break; case ToolStripAction.Move: SetMeasureTool(e.Action, false); break; case ToolStripAction.Laser: this.ZWPictureBox.LaserFunction = true; this.ZWPictureBox.ShowBaseCtrl(true, 0); this.ZWPictureBox.GraphicsList.DeleteAll(); this.ZWPictureBox.Invalidate(); break; case ToolStripAction.Setting: this.ZWPictureBox.LaserFunction = false; this.ZWPictureBox.ShowBaseCtrl(true, 4); break; case ToolStripAction.OpenFile: this.ZWPictureBox.LaserFunction = false; OpenFile(); break; case ToolStripAction.PortConfig: this.ZWPictureBox.ShowBaseCtrl(true, 7); break; } }