using PaintDotNet.Annotation.Enum; using PaintDotNet.Annotation.Label; using PaintDotNet.Base; using PaintDotNet.Data.Param; using PaintDotNet.ImageLabel; using System; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Windows.Forms; namespace PaintDotNet.Menus { /// /// 图像标注菜单 /// internal sealed class LabelActionMenu : PdnMenuItem { private PdnMenuItem menuChoiseAction; private PdnMenuItem menuSelectAllAction; private PdnMenuItem menuContinuousDrawingAction; private PdnMenuItem menuClearAllAction; private ToolStripSeparator menuHelpSeparator1; private PdnMenuItem menuAutoRulerAction; private PdnMenuItem menuPrestoredRulerAction; private PdnMenuItem menuHandRulerAction; private ToolStripSeparator menuHelpSeparator2; private PdnMenuItem menuTextAction; private PdnMenuItem menuMarkAction; private PdnMenuItem menuLineAction; private PdnMenuItem menuCurveLineAction; private PdnMenuItem menuArrowAction; private PdnMenuItem menuCircleAction; private PdnMenuItem menuPolygonAction; private ToolStripSeparator menuHelpSeparator3; private PdnMenuItem menuWaterMarkAction; private PdnMenuItem menuWordLineAction; private ToolStripSeparator menuHelpSeparator4; private PdnMenuItem menuMoveUpAction; private PdnMenuItem menuMoveDownAction; private PdnMenuItem menuMoveTopAction; private PdnMenuItem menuMoveBottomAction; private ToolStripSeparator menuHelpSeparator5; private PdnMenuItem menuLabelListAction; //标记子菜单 private PdnMenuItem menuDateMark; private PdnMenuItem menuTimeMark; private PdnMenuItem menuPointMark; private PdnMenuItem menuNumberMark; private PdnMenuItem menuGainNumber; //直线子菜单 private PdnMenuItem menuLineChildLine; private PdnMenuItem menuLineChildLineSegment; //曲线子菜单 private PdnMenuItem menuCurvePencil; private PdnMenuItem menuCurvePolyline; private PdnMenuItem menuCurveCurve; private PdnMenuItem menuCurveClosedCurve; //箭头子菜单 private PdnMenuItem menuOnewayArrow; private PdnMenuItem menuTwowayArrow; //圆子菜单 private PdnMenuItem menuCircleOval; private PdnMenuItem menuCircleCircle; //多边形子菜单 private PdnMenuItem menuPolygonRectangle; private PdnMenuItem menuPolygonPolygon; private PdnMenuItem menuRoundedRectangle; public LabelActionMenu(int menuId) { InitializeComponent(); this.MenuId = menuId; this.AutomaticScript = false; } protected override void OnAppWorkspaceChanged() { base.OnAppWorkspaceChanged(); } private void InitializeComponent() { this.menuChoiseAction = new PdnMenuItem(ActionType.LabelSelect); this.menuSelectAllAction = new PdnMenuItem(ActionType.SelectAllLabel); this.menuContinuousDrawingAction = new PdnMenuItem(ActionType.ContinuousDrawingLabel, true); this.menuClearAllAction = new PdnMenuItem(ActionType.ClearAllLabel); this.menuHelpSeparator1 = new ToolStripSeparator(); this.menuAutoRulerAction = new PdnMenuItem(ActionType.AutoRuler); this.menuPrestoredRulerAction = new PdnMenuItem(ActionType.PrestoredRuler); this.menuHandRulerAction = new PdnMenuItem(ActionType.HandRuler); this.menuHelpSeparator2 = new ToolStripSeparator(); this.menuTextAction = new PdnMenuItem(ActionType.TextLabel); this.menuMarkAction = new PdnMenuItem(ActionType.MarkAction); this.menuLineAction = new PdnMenuItem(ActionType.LineAction); this.menuCurveLineAction = new PdnMenuItem(ActionType.CurveLineAction); this.menuArrowAction = new PdnMenuItem(ActionType.ArrowAction); this.menuCircleAction = new PdnMenuItem(ActionType.CircleAction); this.menuPolygonAction = new PdnMenuItem(ActionType.PolygonAction); this.menuHelpSeparator3 = new ToolStripSeparator(); this.menuWaterMarkAction = new PdnMenuItem(ActionType.WaterMarkAction); this.menuWordLineAction = new PdnMenuItem(ActionType.WordLineAction); this.menuHelpSeparator4 = new ToolStripSeparator(); this.menuMoveUpAction = new PdnMenuItem(ActionType.MoveUpAction); this.menuMoveDownAction = new PdnMenuItem(ActionType.MoveDownAction); this.menuMoveTopAction = new PdnMenuItem(ActionType.MoveTopAction); this.menuMoveBottomAction = new PdnMenuItem(ActionType.MoveBottomAction); this.menuHelpSeparator5 = new ToolStripSeparator(); this.menuLabelListAction = new PdnMenuItem(ActionType.LabelListAction); this.menuDateMark = new PdnMenuItem(ActionType.DateMark); this.menuTimeMark = new PdnMenuItem(ActionType.TimeMark); this.menuPointMark = new PdnMenuItem(ActionType.PointMark); this.menuNumberMark = new PdnMenuItem(ActionType.NumberMark); this.menuGainNumber = new PdnMenuItem(ActionType.GainNumber); this.menuLineChildLine = new PdnMenuItem(ActionType.LineChildLine); this.menuLineChildLineSegment = new PdnMenuItem(ActionType.LineChildLineSegment); this.menuCurvePencil = new PdnMenuItem(ActionType.CurvePencil); this.menuCurvePolyline = new PdnMenuItem(ActionType.CurvePolyline); this.menuCurveCurve = new PdnMenuItem(ActionType.CurveCurve); this.menuCurveClosedCurve = new PdnMenuItem(ActionType.CurveClosedCurve); this.menuOnewayArrow = new PdnMenuItem(ActionType.OnewayArrow); this.menuTwowayArrow = new PdnMenuItem(ActionType.TwowayArrow); this.menuCircleOval = new PdnMenuItem(ActionType.CircleOval); this.menuCircleCircle = new PdnMenuItem(ActionType.CircleCircle); this.menuPolygonRectangle = new PdnMenuItem(ActionType.PolygonRectangle); this.menuPolygonPolygon = new PdnMenuItem(ActionType.PolygonPolygon); this.menuRoundedRectangle = new PdnMenuItem(ActionType.RoundedRectangle); // // 添加到主菜单 // this.DropDownItems.AddRange(new ToolStripItem[] { this.menuChoiseAction, this.menuSelectAllAction, this.menuContinuousDrawingAction, this.menuClearAllAction, this.menuHelpSeparator1, this.menuAutoRulerAction, this.menuPrestoredRulerAction, this.menuHandRulerAction, this.menuHelpSeparator2, this.menuTextAction, this.menuMarkAction, this.menuLineAction, this.menuCurveLineAction, this.menuArrowAction, this.menuCircleAction, this.menuPolygonAction, this.menuHelpSeparator3, this.menuWaterMarkAction, this.menuWordLineAction, this.menuHelpSeparator4, this.menuMoveUpAction, this.menuMoveDownAction, this.menuMoveTopAction, this.menuMoveBottomAction, this.menuHelpSeparator5, this.menuLabelListAction }); // // 主菜单 // this.Name = "Menu.LabelAction"; this.Text = PdnResources.GetString("Menu.LabelAction.Text"); // // 选择 // this.menuChoiseAction.NeedWaitKey = true; this.menuChoiseAction.Click += new EventHandler(MenuChoiseAction_Click); // // 全选 // this.menuSelectAllAction.NeedWaitKey = true; this.menuSelectAllAction.Click += new EventHandler(MenuSelectAllAction_Click); // // 连续绘制 // this.menuContinuousDrawingAction.NeedWaitKey = true; this.menuContinuousDrawingAction.Click += new EventHandler(MenuContinuousDrawingAction_Click); // // 清空元素 // this.menuClearAllAction.Click += new EventHandler(MenuClearAllAction_Click); // // 自动标尺 // this.menuAutoRulerAction.NeedWaitKey = true; this.menuAutoRulerAction.Click += new EventHandler(MenuAutoRuler_Click); // // 预存标尺 // this.menuPrestoredRulerAction.Click += new EventHandler(MenuPrestoredRuler_Click); // // 手动标尺 // this.menuHandRulerAction.NeedWaitKey = true; this.menuHandRulerAction.Click += new EventHandler(MenuHandRuler_Click); // // 文本 // this.menuTextAction.NeedWaitKey = true; this.menuTextAction.Click += new EventHandler(MenuTextAction_Click); // // 标记 // this.menuMarkAction.DropDownItems.AddRange( new ToolStripItem[] { this.menuDateMark, this.menuTimeMark, this.menuPointMark, this.menuNumberMark, this.menuGainNumber }); // // 直线 // this.menuLineAction.DropDownItems.AddRange( new ToolStripItem[] { this.menuLineChildLine, this.menuLineChildLineSegment }); // // 曲线 // this.menuCurveLineAction.DropDownItems.AddRange( new ToolStripItem[] { this.menuCurvePencil, this.menuCurvePolyline, this.menuCurveCurve, this.menuCurveClosedCurve }); // // 箭头 // this.menuArrowAction.DropDownItems.AddRange( new ToolStripItem[] { this.menuOnewayArrow, this.menuTwowayArrow }); // // 圆 // this.menuCircleAction.DropDownItems.AddRange( new ToolStripItem[] { this.menuCircleOval, this.menuCircleCircle }); // // 多边形 // this.menuPolygonAction.DropDownItems.AddRange( new ToolStripItem[] { this.menuPolygonRectangle, this.menuPolygonPolygon, this.menuRoundedRectangle }); // // 水印 // this.menuWaterMarkAction.NeedWaitKey = true; this.menuWaterMarkAction.Click += new EventHandler(MenuWaterMarkAction_Click); // // 工字线 // this.menuWordLineAction.NeedWaitKey = true; this.menuWordLineAction.Click += new EventHandler(MenuWorkTypeAction_Click); // // 向上移动 // this.menuMoveUpAction.NeedWaitKey = true; this.menuMoveUpAction.Click += new EventHandler(MenuMoveUpAction_Click); // // 向下移动 // this.menuMoveDownAction.NeedWaitKey = true; this.menuMoveDownAction.Click += new EventHandler(MenuMoveDownAction_Click); // // 移动到最上 // this.menuMoveTopAction.NeedWaitKey = true; this.menuMoveTopAction.Click += new EventHandler(MenuMoveTopAction_Click); // // 移动到最下 // this.menuMoveBottomAction.NeedWaitKey = true; this.menuMoveBottomAction.Click += new EventHandler(MenuMoveBottomAction_Click); // // 标注信息列表 // this.menuLabelListAction.NeedWaitKey = true; this.menuLabelListAction.Click += new EventHandler(MenuLabelListAction_Click); // // 以下是子菜单 // // // 标记->日期 // this.menuDateMark.Text = PdnResources.GetString("Menu.LabelAction.DrawDateMark.Text"); this.menuDateMark.NeedWaitKey = true; this.menuDateMark.Click += new EventHandler(MenuDateMark_Click); this.menuDateMark.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawDateMarkIcon.png").Reference; // // 标记->时间 // this.menuTimeMark.Text = PdnResources.GetString("Menu.LabelAction.DrawTimeMark.Text"); this.menuTimeMark.NeedWaitKey = true; this.menuTimeMark.Click += new EventHandler(MenuTimeMark_Click); this.menuTimeMark.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawTimeMarkIcon.png").Reference; // // 标记->点标记 // this.menuPointMark.Text = PdnResources.GetString("Menu.LabelAction.DrawPointMark.Text"); this.menuPointMark.NeedWaitKey = true; this.menuPointMark.Click += new EventHandler(MenuPointMark_Click); this.menuPointMark.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawPointMarkIcon.png").Reference; // // 标记->数字标记 // this.menuNumberMark.Text = PdnResources.GetString("Menu.LabelAction.DrawNumberMark.Text"); this.menuNumberMark.NeedWaitKey = true; this.menuNumberMark.Click += new EventHandler(MenuNumberMark_Click); this.menuNumberMark.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawNumberMarkIcon.png").Reference; // // 放大倍数 // this.menuGainNumber.Text = PdnResources.GetString("Menu.LabelAction.DrawGainNumber.Text"); this.menuGainNumber.NeedWaitKey = true; this.menuGainNumber.Click += new EventHandler(MenuGainNumber_Click); this.menuGainNumber.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawGainNumberIcon.png").Reference; // // 直线->直线 // this.menuLineChildLine.Text = PdnResources.GetString("Menu.LabelAction.DrawLine.Text"); this.menuLineChildLine.NeedWaitKey = true; this.menuLineChildLine.Click += new EventHandler(MenuLineChildLine_Click); this.menuLineChildLine.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawLineIcon.png").Reference; // // 直线->线段 // this.menuLineChildLineSegment.Text = PdnResources.GetString("Menu.LabelAction.DrawLineSegment.Text"); this.menuLineChildLineSegment.NeedWaitKey = true; this.menuLineChildLineSegment.Click += new EventHandler(MenuLineChildLineSegment_Click); this.menuLineChildLineSegment.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawLineSegmentIcon.png").Reference; // // 曲线->铅笔 // this.menuCurvePencil.Text = PdnResources.GetString("Menu.LabelAction.DrawPencil.Text"); this.menuCurvePencil.NeedWaitKey = true; this.menuCurvePencil.Click += new EventHandler(MenuCurvePencil_Click); this.menuCurvePencil.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawPencilIcon.png").Reference; // // 曲线->折线 // this.menuCurvePolyline.Text = PdnResources.GetString("Menu.LabelAction.DrawPolygonLine.Text"); this.menuCurvePolyline.NeedWaitKey = true; this.menuCurvePolyline.Click += new EventHandler(MenuCurvePolyline_Click); this.menuCurvePolyline.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawPolygonLineIcon.png").Reference; // // 曲线->曲线 // this.menuCurveCurve.Text = PdnResources.GetString("Menu.LabelAction.DrawCurve.Text"); this.menuCurveCurve.NeedWaitKey = true; this.menuCurveCurve.Click += new EventHandler(MenuCurveCurve_Click); this.menuCurveCurve.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawCurveIcon.png").Reference; // // 曲线->闭合曲线 // this.menuCurveClosedCurve.Text = PdnResources.GetString("Menu.LabelAction.DrawClosedCurve.Text"); this.menuCurveClosedCurve.NeedWaitKey = true; this.menuCurveClosedCurve.Click += new EventHandler(MenuCurveClosedCurve_Click); this.menuCurveClosedCurve.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawClosedCurveIcon.png").Reference; // // 箭头->单向箭头 // this.menuOnewayArrow.Text = PdnResources.GetString("Menu.LabelAction.DrawOneArrowLine.Text"); this.menuOnewayArrow.NeedWaitKey = true; this.menuOnewayArrow.Click += new EventHandler(MenuOnewayArrow_Click); this.menuOnewayArrow.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawOneArrowLineIcon.png").Reference; // // 箭头->双向箭头 // this.menuTwowayArrow.Text = PdnResources.GetString("Menu.LabelAction.DrawTwoArrowLine.Text"); this.menuTwowayArrow.NeedWaitKey = true; this.menuTwowayArrow.Click += new EventHandler(MenuTwowayArrow_Click); this.menuTwowayArrow.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawTwoArrowLineIcon.png").Reference; // // 圆->椭圆 // this.menuCircleOval.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text"); this.menuCircleOval.NeedWaitKey = true; this.menuCircleOval.Click += new EventHandler(MenuCircleOval_Click); this.menuCircleOval.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawEllipseIcon.png").Reference; // // 圆->圆 // this.menuCircleCircle.Text = PdnResources.GetString("Menu.LabelAction.DrawCircle.Text"); this.menuCircleCircle.NeedWaitKey = true; this.menuCircleCircle.Click += new EventHandler(MenuCircleCircle_Click); this.menuCircleCircle.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawCircleIcon.png").Reference; // // 多边形->矩形 // this.menuPolygonRectangle.Text = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text"); this.menuPolygonRectangle.NeedWaitKey = true; this.menuPolygonRectangle.Click += new EventHandler(MenuPolygonRectangle_Click); this.menuPolygonRectangle.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawRectangleIcon.png").Reference; // // 多边形->多边形 // this.menuPolygonPolygon.Text = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text"); this.menuPolygonPolygon.NeedWaitKey = true; this.menuPolygonPolygon.Click += new EventHandler(MenuPolygonPolygon_Click); this.menuPolygonPolygon.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawPolygonIcon.png").Reference; // // 多边形->圆角矩形 // this.menuRoundedRectangle.Text = PdnResources.GetString("Menu.LabelAction.DrawRoundRectangle.Text"); this.menuRoundedRectangle.NeedWaitKey = true; this.menuRoundedRectangle.Click += new EventHandler(MenuRoundedRectangle_Click); this.menuRoundedRectangle.Image = PdnResources.GetImageResource("Icons.MenuLabelDrawRoundRectangleIcon.png").Reference; // // 加载菜单的文字和icon // this.LoadNames(this.Name); this.LoadIcons(); } protected override void OnDropDownOpening(EventArgs e) { //if (AppWorkspace.ActiveDocumentWorkspace != null/* && !AppWorkspace.ScriptRunning*/) //{ // this.menuLineAction.Enabled = true; //} //else //{ // this.menuLineAction.Enabled = false; //} this.menuLabelListAction.Checked = AppWorkspace.Widgets.LabelListDialog.Visible; this.menuContinuousDrawingAction.Checked = DocumentView.ContinuousDrawing; //this.RecursiveData(this.DropDownItems); base.OnDropDownOpening(e); } /// /// 选择 /// /// /// private void MenuChoiseAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.Pointer; } this.SetCameraPreviewActiveTool(DrawToolType.Pointer); } /// /// 全选 /// /// /// private void MenuSelectAllAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.GraphicsList.SelectAll(); AppWorkspace.ActiveDocumentWorkspace.Refresh(); } if (AppWorkspace.cameraPreviewDialog != null && !AppWorkspace.cameraPreviewDialog.IsDisposed) { AppWorkspace.cameraPreviewDialog.documentWorkspace.GraphicsList.SelectAll(); AppWorkspace.cameraPreviewDialog.documentWorkspace.Refresh(); } } /// /// 连续绘制 /// /// /// private void MenuContinuousDrawingAction_Click(object sender, EventArgs e) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ContinuousDrawing = !AppWorkspace.ContinuousDrawing; } /// /// 清空元素 /// /// /// private void MenuClearAllAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.GraphicsList.Clear(); AppWorkspace.ActiveDocumentWorkspace.Refresh(); } if (AppWorkspace.cameraPreviewDialog != null && !AppWorkspace.cameraPreviewDialog.IsDisposed) { AppWorkspace.cameraPreviewDialog.documentWorkspace.GraphicsList.Clear(); AppWorkspace.cameraPreviewDialog.documentWorkspace.Refresh(); } } /// /// 自动标尺 /// /// /// private void MenuAutoRuler_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawAutoRuler; if (AppWorkspace.ContinuousDrawing) { AppWorkspace.ContinuousDrawing = false; } if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } this.SetCameraPreviewActiveTool(DrawToolType.DrawAutoRuler); } /// /// 手动标尺 /// /// /// private void MenuHandRuler_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawHandModeRuler; } this.SetCameraPreviewActiveTool(DrawToolType.DrawHandModeRuler); } /// /// 预存标尺 /// /// /// private void MenuPrestoredRuler_Click(object sender, EventArgs e) { using (PresetRulerDialog presetRulerDialog = new PresetRulerDialog(this.AppWorkspace)) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } if (AppWorkspace.ContinuousDrawing) { AppWorkspace.ContinuousDrawing = false; } presetRulerDialog.StartPosition = FormStartPosition.CenterScreen; presetRulerDialog.ShowDialog(); } } /// /// 标记->文本 /// /// /// private void MenuTextAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawTextString; } this.SetCameraPreviewActiveTool(DrawToolType.DrawTextString); } /// /// 标记->日期 /// /// /// private void MenuDateMark_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawDateMark; if (AppWorkspace.ContinuousDrawing) { AppWorkspace.ContinuousDrawing = false; } if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } this.SetCameraPreviewActiveTool(DrawToolType.DrawDateMark); } /// /// 标记->时间 /// /// /// private void MenuTimeMark_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawTimeMark; if (AppWorkspace.ContinuousDrawing) { AppWorkspace.ContinuousDrawing = false; } if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } this.SetCameraPreviewActiveTool(DrawToolType.DrawTimeMark); } /// /// 标记->点标记 /// /// /// private void MenuPointMark_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawPointMark; } this.SetCameraPreviewActiveTool(DrawToolType.DrawPointMark); } /// /// 标记->数字标记 /// /// /// private void MenuNumberMark_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawNumberMark; } this.SetCameraPreviewActiveTool(DrawToolType.DrawNumberMark); } /// /// 标记->放大倍数 /// /// /// private void MenuGainNumber_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawGainNumber; if (AppWorkspace.ContinuousDrawing) { AppWorkspace.ContinuousDrawing = false; } if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } this.SetCameraPreviewActiveTool(DrawToolType.DrawGainNumber); } /// /// 直线->直线 /// /// /// private void MenuLineChildLine_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawLine; } this.SetCameraPreviewActiveTool(DrawToolType.DrawLine); } /// /// 直线->线段 /// /// /// private void MenuLineChildLineSegment_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawLineSegment; } this.SetCameraPreviewActiveTool(DrawToolType.DrawLineSegment); } /// /// 曲线->铅笔 /// /// /// private void MenuCurvePencil_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawPencil; } this.SetCameraPreviewActiveTool(DrawToolType.DrawPencil); } /// /// 曲线->折线 /// /// /// private void MenuCurvePolyline_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawPolygonLine; } this.SetCameraPreviewActiveTool(DrawToolType.DrawPolygonLine); } /// /// 曲线->曲线 /// /// /// private void MenuCurveCurve_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawCurve; } this.SetCameraPreviewActiveTool(DrawToolType.DrawCurve); } /// /// 曲线->闭合曲线 /// /// /// private void MenuCurveClosedCurve_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawClosedCurve; } this.SetCameraPreviewActiveTool(DrawToolType.DrawClosedCurve); } /// /// 箭头->单向箭头 /// /// /// private void MenuOnewayArrow_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawOneArrowLine; } this.SetCameraPreviewActiveTool(DrawToolType.DrawOneArrowLine); } /// /// 箭头->双向箭头 /// /// /// private void MenuTwowayArrow_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawTwoArrowLine; } this.SetCameraPreviewActiveTool(DrawToolType.DrawTwoArrowLine); } /// /// 圆->椭圆 /// /// /// private void MenuCircleOval_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawEllipse; } this.SetCameraPreviewActiveTool(DrawToolType.DrawEllipse); } /// /// 圆->圆 /// /// /// private void MenuCircleCircle_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawCircle; } this.SetCameraPreviewActiveTool(DrawToolType.DrawCircle); } /// /// 多边形->矩形 /// /// /// private void MenuPolygonRectangle_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawRectangle; } this.SetCameraPreviewActiveTool(DrawToolType.DrawRectangle); } /// /// 多边形->多边形 /// /// /// private void MenuPolygonPolygon_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawPolygon; } this.SetCameraPreviewActiveTool(DrawToolType.DrawPolygon); } /// /// 多边形->圆角矩形 /// /// /// private void MenuRoundedRectangle_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawRoundRectangle; } this.SetCameraPreviewActiveTool(DrawToolType.DrawRoundRectangle); } /// /// 水印 /// /// /// private void MenuWaterMarkAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawWaterMark; if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } this.SetCameraPreviewActiveTool(DrawToolType.DrawWaterMark); } /// /// 工字线 /// /// /// private void MenuWorkTypeAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.ToolNumber = -1; AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawWorkType; } this.SetCameraPreviewActiveTool(DrawToolType.DrawWorkType); } /// /// 向上移动 /// /// /// private void MenuMoveUpAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.GraphicsList.MoveSelectionToMoveUp(); AppWorkspace.ActiveDocumentWorkspace.Refresh(); if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } } /// /// 向下移动 /// /// /// private void MenuMoveDownAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.GraphicsList.MoveSelectionToMoveDown(); AppWorkspace.ActiveDocumentWorkspace.Refresh(); if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } } /// /// 移动到最上 /// /// /// private void MenuMoveTopAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.GraphicsList.MoveSelectionToFront(); AppWorkspace.ActiveDocumentWorkspace.Refresh(); if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } } /// /// 移动到最下 /// /// /// private void MenuMoveBottomAction_Click(object sender, EventArgs e) { if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } AppWorkspace.ActiveDocumentWorkspace.GraphicsList.MoveSelectionToBack(); AppWorkspace.ActiveDocumentWorkspace.Refresh(); if (AppWorkspace.Widgets.LabelListDialog != null) { AppWorkspace.Widgets.LabelListDialog.RefreshDateGridView(null, null); } } } /// /// 标注列表 /// /// /// private void MenuLabelListAction_Click(object sender, EventArgs e) { AppWorkspace.Widgets.LabelListDialog.Visible = !AppWorkspace.Widgets.LabelListDialog.Visible; if (AppWorkspace.ActiveDocumentWorkspace != null) { if (AppWorkspace.startScriptRecording) { AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List()); } this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.LabelListDialog.Visible, "LabelListAction"); this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.LabelListDialog.Visible, "LabelListAction"); this.menuLabelListAction.Checked = AppWorkspace.Widgets.LabelListDialog.Visible; AppWorkspace.Widgets.LabelListDialog.getData(); AppWorkspace.ActiveDocumentWorkspace.Focus(); } } private void SetCameraPreviewActiveTool(DrawToolType drawToolType) { if (AppWorkspace.cameraPreviewDialog != null && !AppWorkspace.cameraPreviewDialog.IsDisposed) { AppWorkspace.cameraPreviewDialog.documentWorkspace.ActiveTool = drawToolType; } } private string GetCultureInfoName(CultureInfo ci) { CultureInfo en_US = new CultureInfo("en-US"); if (ci.Equals(en_US)) { return GetCultureInfoName(ci.Parent); } else { return ci.NativeName; } } public void checkMenu(bool v) { this.menuContinuousDrawingAction.Checked = v; } } }