123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940 |
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Base;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Data.Param;
- using PaintDotNet.ImageCollect;
- using PaintDotNet.Instrument;
- using PaintDotNet.SystemLayer;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Threading;
- using System.Windows.Forms;
- namespace PaintDotNet.Menus
- {
- /// <summary>
- /// 工具菜单
- /// </summary>
- internal sealed class ToolsMenu : PdnMenuItem
- {
- //网格
- private PdnMenuItem menuToolsGridLine;
- //辅助线
- private PdnMenuItem menuToolsAuxiliaryLine;
- //视图标尺
- private PdnMenuItem menuToolsViewRuler;
- //分隔线
- private ToolStripSeparator menuToolsSeperator1;
- //捕获窗口
- private PdnMenuItem menuToolsCaptureWindow;
- //捕获图像
- private PdnMenuItem menuToolsCapturePicture;
- //分割线
- private ToolStripSeparator menuToolsSeperator2;
- //直方图
- private PdnMenuItem menuToolsHistogram;
- //像素跟踪
- private PdnMenuItem menuToolsPixelTracking;
- //三维灰度
- private PdnMenuItem menuToolsSurfacePlot;
- //三维展示
- private PdnMenuItem menuToolsSurfacePlotShow;
- //图像索引
- private PdnMenuItem menuToolsImageIndex;
- //分隔线
- private ToolStripSeparator menuToolsSeperator3;
- //脚本
- private PdnMenuItem menuToolsScript;
- //工作流程
- private PdnMenuItem menuToolsWorkFlow;
- //快捷工具
- private PdnMenuItem menuToolsFast;
- //分隔线
- private ToolStripSeparator menuToolsSeperator4;
- //划痕处理
- private PdnMenuItem menuToolsScratchTreatment;
- //污迹处理
- private PdnMenuItem menuToolsSmudgeTreatment;
- //分隔线
- private ToolStripSeparator menuToolsSeperator5;
- //分栏显示
- private PdnMenuItem menuToolsColumnDisplay;
- //图片对比
- private PdnMenuItem menuToolsPictureComparison;
- //自定义界面
- private PdnMenuItem menuToolsCustomInterface;
- //生成快捷方式
- private PdnMenuItem menuToolsCreateShortcut;
- //图片信息
- private PdnMenuItem menuToolsImageInfo;
- //分隔线
- private ToolStripSeparator menuToolsSeperator6;
- //项目工程
- private PdnMenuItem menuToolsOpenProject;
- //添加到工程
- private PdnMenuItem menuToolsAddToProject;
- //分隔线
- private ToolStripSeparator menuToolsSeperator7;
- //模板管理
- private PdnMenuItem menuToolsTemplateManager;
- //生成报告
- private PdnMenuItem menuToolsCreateReport;
- //分隔线
- private ToolStripSeparator menuToolsSeperator8;
- //重新启动
- private PdnMenuItem menuToolsSelfRestart;
- //恢复图片
- private PdnMenuItem menuToolsRestoreImages;
- //
- // 以下是非模态对话框
- //
- //脚本管理窗口
- private ScriptManageDialog scriptManageDialog;
- public ToolsMenu(int menuId)
- {
- InitializeComponent();
- this.MenuId = menuId;
- }
- private void InitializeComponent()
- {
- this.menuToolsGridLine = new PdnMenuItem(ActionType.GridLine, true);
- this.menuToolsAuxiliaryLine = new PdnMenuItem(ActionType.AuxiliaryLine, true);
- this.menuToolsViewRuler = new PdnMenuItem(ActionType.ViewRuler, true);
- this.menuToolsSeperator1 = new ToolStripSeparator();
- this.menuToolsCaptureWindow = new PdnMenuItem(ActionType.CaptureWindow);
- this.menuToolsCapturePicture = new PdnMenuItem(ActionType.CapturePicture);
- this.menuToolsSeperator2 = new ToolStripSeparator();
- this.menuToolsHistogram = new PdnMenuItem(ActionType.Histogram);
- this.menuToolsPixelTracking = new PdnMenuItem(ActionType.PixelTracking);
- this.menuToolsSurfacePlot = new PdnMenuItem(ActionType.SurfacePlot);
- this.menuToolsSurfacePlotShow = new PdnMenuItem(ActionType.SurfacePlotShow);
- this.menuToolsImageIndex = new PdnMenuItem(ActionType.ImageIndex);
- this.menuToolsSeperator3 = new ToolStripSeparator();
- this.menuToolsScript = new PdnMenuItem(ActionType.Script);
- this.menuToolsWorkFlow = new PdnMenuItem(ActionType.WorkFlow);
- this.menuToolsFast = new PdnMenuItem(ActionType.ToolsFast);
- this.menuToolsSeperator4 = new ToolStripSeparator();
- this.menuToolsScratchTreatment = new PdnMenuItem(ActionType.ScratchTreatment);
- this.menuToolsSmudgeTreatment = new PdnMenuItem(ActionType.SmudgeTreatment);
- this.menuToolsSeperator5 = new ToolStripSeparator();
- this.menuToolsColumnDisplay = new PdnMenuItem(ActionType.ColumnDisplay);
- this.menuToolsPictureComparison = new PdnMenuItem(ActionType.PictureComparison);
- this.menuToolsCustomInterface = new PdnMenuItem(ActionType.CustomInterface);
- this.menuToolsCreateShortcut = new PdnMenuItem(ActionType.CreateShortcut);
- this.menuToolsImageInfo = new PdnMenuItem(ActionType.ImageInfo);
- this.menuToolsSeperator6 = new ToolStripSeparator();
- this.menuToolsOpenProject = new PdnMenuItem(ActionType.OpenProject);
- this.menuToolsAddToProject = new PdnMenuItem(ActionType.AddToProject);
- this.menuToolsSeperator7 = new ToolStripSeparator();
- this.menuToolsTemplateManager = new PdnMenuItem(ActionType.TemplateManager);
- this.menuToolsCreateReport = new PdnMenuItem(ActionType.CreateReport);
- this.menuToolsSeperator8 = new ToolStripSeparator();
- this.menuToolsRestoreImages = new PdnMenuItem(ActionType.RestoreImages);
- this.menuToolsSelfRestart = new PdnMenuItem(ActionType.SelfRestart);
- //
- // ToolsMenu
- //
- this.DropDownItems.AddRange(
- new ToolStripItem[]
- {
- this.menuToolsGridLine,
- this.menuToolsAuxiliaryLine,
- this.menuToolsViewRuler,
- this.menuToolsSeperator1,
- this.menuToolsCaptureWindow,
- this.menuToolsCapturePicture,
- this.menuToolsSeperator2,
- this.menuToolsHistogram,
- this.menuToolsPixelTracking,
- this.menuToolsSurfacePlot,
- this.menuToolsSurfacePlotShow,
- this.menuToolsImageIndex,
- this.menuToolsSeperator3,
- this.menuToolsScript,
- this.menuToolsWorkFlow,
- this.menuToolsFast,
- this.menuToolsSeperator4,
- this.menuToolsScratchTreatment,
- this.menuToolsSmudgeTreatment,
- this.menuToolsSeperator5,
- this.menuToolsColumnDisplay,
- this.menuToolsPictureComparison,
- this.menuToolsCustomInterface,
- this.menuToolsCreateShortcut,
- this.menuToolsImageInfo,
- this.menuToolsSeperator6,
- this.menuToolsOpenProject,
- this.menuToolsAddToProject,
- this.menuToolsSeperator7,
- this.menuToolsTemplateManager,
- this.menuToolsCreateReport,
- this.menuToolsSeperator8,
- this.menuToolsRestoreImages,
- this.menuToolsSelfRestart
- });
- this.Name = "Menu.Tools";
- this.Text = PdnResources.GetString("Menu.Tools.Text");
- //
- // 网格
- //
- this.menuToolsGridLine.Click += new EventHandler(MenuToolsGridLine_Click);
- //
- // 辅助线
- //
- this.menuToolsAuxiliaryLine.Click += new EventHandler(MenuToolsAuxiliaryLine_Click);
- //
- // 视图标尺
- //
- this.menuToolsViewRuler.Click += new EventHandler(MenuToolsViewRuler_Click);
- //
- // 捕获窗口
- //
- this.menuToolsCaptureWindow.Click += new EventHandler(MenuToolsCaptureWindow_Click);
- //
- // 捕获图片
- //
- this.menuToolsCapturePicture.Click += new EventHandler(MenuToolsCapturePicture_Click);
- //
- // 直方图
- //
- this.menuToolsHistogram.Click += new EventHandler(MenuToolsHistogram_Click);
- // 像素跟踪
- //
- this.menuToolsPixelTracking.Click += new EventHandler(MenuToolsPixelTracking_Click);
- //
- // 三维灰度
- //
- this.menuToolsSurfacePlot.Click += new EventHandler(MenuToolsSurfacePlot_Click);
- //
- // 三维展示
- //
- this.menuToolsSurfacePlotShow.Click += new EventHandler(MenuToolsSurfacePlotShow_Click);
- //
- // 图像索引
- //
- this.menuToolsImageIndex.Click += new EventHandler(MenuToolsImageIndex_Click);
- //
- // 脚本管理
- //
- this.menuToolsScript.Click += new EventHandler(MenuToolsScript_Click);
- //
- // 工作流程
- //
- this.menuToolsWorkFlow.Click += new EventHandler(MenuToolsWorkFlow_Click);
- //
- // 快捷菜单
- //
- this.menuToolsFast.Click += new EventHandler(MenuToolsFast_Click);
- //
- // 划痕处理
- //
- this.menuToolsScratchTreatment.Click += new EventHandler(MenuToolsScratchTreatment_Click);
- //
- // 污迹处理
- //
- this.menuToolsSmudgeTreatment.Click += new EventHandler(MenuToolsSmudgeTreatment_Click);
- //
- // 分栏显示
- //
- this.menuToolsColumnDisplay.Click += new EventHandler(MenuToolsColumnDisplay_Click);
- //
- // 图片对比
- //
- this.menuToolsPictureComparison.Click += new EventHandler(MenuToolsPictureComparison_Click);
- //
- // 自定义界面
- //
- this.menuToolsCustomInterface.Click += new EventHandler(MenuToolsCustomInterface_Click);
- //
- // 生成快捷方式
- //
- this.menuToolsCreateShortcut.Click += new EventHandler(MenuToolsCreateShortcut_Click);
- //
- // 图片信息
- //
- this.menuToolsImageInfo.Click += new EventHandler(MenuToolsImageInfo_Click);
- //
- // 项目工程
- //
- this.menuToolsOpenProject.Click += new EventHandler(MenuToolsOpenProject_Click);
- //
- // 添加到工程
- //
- this.menuToolsAddToProject.Click += new EventHandler(MenuToolsAddToProject_Click);
- //
- // 模板管理
- //
- this.menuToolsTemplateManager.Click += new EventHandler(MenuToolsTemplateManager_Click);
- //
- // 生成报告
- //
- this.menuToolsCreateReport.Click += new EventHandler(MenuToolsCreateReport_Click);
- //
- // 恢复图片
- //
- this.menuToolsRestoreImages.Click += new EventHandler(MenuToolsRestoreImages_Click);
- //
- // 重新启动
- //
- this.menuToolsSelfRestart.Click += new EventHandler(MenuToolsSelfRestart_Click);
- //
- // 加载菜单的文字和icon
- //
- this.LoadNames(this.Name);
- this.LoadIcons();
- }
- protected override void OnDropDownOpening(EventArgs e)
- {
- this.menuToolsGridLine.Checked = AppWorkspace.ActiveDocumentWorkspace != null ? AppWorkspace.ActiveDocumentWorkspace.GridLineEnabled : false;
- this.menuToolsAuxiliaryLine.Checked = AppWorkspace.ActiveDocumentWorkspace != null ? AppWorkspace.ActiveDocumentWorkspace.AuxiliaryLineEnabled : false;
- this.menuToolsViewRuler.Checked = Settings.CurrentUser.GetBoolean(SettingNames.Rulers, true);
- this.menuToolsSmudgeTreatment.Checked = AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible;
- this.menuToolsScratchTreatment.Checked = AppWorkspace.Widgets.ScratchTreatmentDialog.Visible;
- this.menuToolsOpenProject.Checked = AppWorkspace.Widgets.ProjectEngineering.Visible;
- this.menuToolsWorkFlow.Checked = AppWorkspace.Widgets.WorkFlowDialog.Visible;
- this.menuToolsHistogram.Checked = AppWorkspace.Widgets.HistogramDialog.Visible;
- this.menuToolsPixelTracking.Checked = AppWorkspace.Widgets.PixelTrackingDialog.Visible;
- this.menuToolsImageIndex.Checked = AppWorkspace.Widgets.ImageIndexDialog.Visible;
- if (SurfacePlotWindow.form != null)
- this.menuToolsSurfacePlot.Checked = true;
- else
- this.menuToolsSurfacePlot.Checked = false;
- base.OnDropDownOpening(e);
- }
- /// <summary>
- /// 网格
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsGridLine_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.ActiveDocumentWorkspace.GridLineEnabled = !AppWorkspace.ActiveDocumentWorkspace.GridLineEnabled;
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.ActiveDocumentWorkspace.GridLineEnabled, "GridLine");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.ActiveDocumentWorkspace.GridLineEnabled, "GridLine");
- AppWorkspace.UpdateBottomButtonSelectionStatus();
- AppWorkspace.ActiveDocumentWorkspace.Refresh();
- }
- }
-
- /// <summary>
- /// 辅助线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsAuxiliaryLine_Click(object sender, EventArgs e)
- {
- if(AppWorkspace.ActiveDocumentWorkspace!=null)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.ActiveDocumentWorkspace.AuxiliaryLineEnabled = !Settings.CurrentUser.GetBoolean(SettingNames.DrawAuxiliaryLine, false);
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.ActiveDocumentWorkspace.AuxiliaryLineEnabled, "AuxiliaryLine");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.ActiveDocumentWorkspace.AuxiliaryLineEnabled, "AuxiliaryLine");
- Settings.CurrentUser.SetBoolean(SettingNames.DrawAuxiliaryLine, AppWorkspace.ActiveDocumentWorkspace.AuxiliaryLineEnabled);
- AppWorkspace.UpdateBottomButtonSelectionStatus();
- AppWorkspace.ActiveDocumentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 隐藏显示标尺
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsViewRuler_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.ActiveDocumentWorkspace.RulersEnabled = !Settings.CurrentUser.GetBoolean(SettingNames.Rulers, false);
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.ActiveDocumentWorkspace.RulersEnabled, "ViewRuler");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.ActiveDocumentWorkspace.RulersEnabled, "ViewRuler");
- Settings.CurrentUser.SetBoolean(SettingNames.Rulers, AppWorkspace.ActiveDocumentWorkspace.RulersEnabled);
- }
- }
- /// <summary>
- /// 捕获屏幕
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsCaptureWindow_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- Bitmap myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- Graphics g = Graphics.FromImage(myImage);
- g.CopyFromScreen(new System.Drawing.Point(0, 0), new System.Drawing.Point(0, 0), new System.Drawing.Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));
- g.Dispose();
- DocumentWorkspace dw = AppWorkspace.AddNewDocumentWorkspace();
- Document document = Document.FromImageMat(Camera.Tools.ToMat(myImage));
- dw.Document = document;
- dw.xmlSaveModel = Startup.instance.ruleDB;
- dw.InitRulerInfo();
- dw.fileText = PdnResources.GetString("Menu.Tools.CaptureWindow.Text")+"-00" + Startup.instance.step_length;
- AppWorkspace.ActiveDocumentWorkspace = dw;
- Startup.instance.step_length += 1;
- }
- /// <summary>
- /// 捕获图片,这个功能临时当作copy的功能
- /// 但是这个功能最终是和定倍有关系的
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsCapturePicture_Click(object sender, EventArgs e)
- {
- if(AppWorkspace.ActiveDocumentWorkspace != null)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.ActiveDocumentWorkspace.ClearDoubleBuffer();
- Document document = Document.FromImageMat(Camera.Tools.ToMat((Bitmap)(AppWorkspace.ActiveDocumentWorkspace.GetClientRangePic())));
- DocumentWorkspace dw = AppWorkspace.AddNewDocumentWorkspace();
- dw.Document = document;
- dw.xmlSaveModel = this.AppWorkspace.ActiveDocumentWorkspace.xmlSaveModel;
- dw.rules = this.AppWorkspace.ActiveDocumentWorkspace.rules;
- dw.fileText = PdnResources.GetString("Menu.Tools.CapturePicture.Text") +"-00" + Startup.instance.step_length;
- AppWorkspace.ActiveDocumentWorkspace = dw;
- Startup.instance.step_length += 1;
- }
- }
- /// <summary>
- /// 直方图
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsHistogram_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- AppWorkspace.Widgets.HistogramDialog.Visible = !AppWorkspace.Widgets.HistogramDialog.Visible;
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.HistogramDialog.Visible, "Histogram");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.HistogramDialog.Visible, "Histogram");
- this.menuToolsHistogram.Checked = AppWorkspace.Widgets.HistogramDialog.Visible;
- }
- else
- {
- if (AppWorkspace.Widgets.HistogramDialog.Visible == false)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseopenthepicture.Text"));//后可以使用直方图
- }
- else
- AppWorkspace.Widgets.HistogramDialog.Visible = false;
- }
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- if (this.AppWorkspace.ActiveDocumentWorkspace.best)
- this.AppWorkspace.ActiveDocumentWorkspace.buttonType = 0;
- else if (this.AppWorkspace.ActiveDocumentWorkspace.maxMin)
- this.AppWorkspace.ActiveDocumentWorkspace.buttonType = 1;
- else if (this.AppWorkspace.ActiveDocumentWorkspace.gamma45)
- this.AppWorkspace.ActiveDocumentWorkspace.buttonType = 2;
- else if (this.AppWorkspace.ActiveDocumentWorkspace.origin)
- this.AppWorkspace.ActiveDocumentWorkspace.buttonType = 3;
- this.AppWorkspace.RefreshHistogram();
- AppWorkspace.ActiveDocumentWorkspace.Focus();
- }
- //using (HistogramDialog dialog = new HistogramDialog(AppWorkspace))
- //{
- // dialog.ShowDialog();
- //}
- }
- /// <summary>
- /// 像素跟踪
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsPixelTracking_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.Widgets.PixelTrackingDialog.Visible = !AppWorkspace.Widgets.PixelTrackingDialog.Visible;
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.PixelTrackingDialog.Visible, "PixelTracking");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.PixelTrackingDialog.Visible, "PixelTracking");
- this.menuToolsPixelTracking.Checked = AppWorkspace.Widgets.PixelTrackingDialog.Visible;
- if (CameraPreviewDialog.cameraPreviewDialog != null)
- CameraPreviewDialog.cameraPreviewDialog.documentWorkspace.Focus();
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- AppWorkspace.ActiveDocumentWorkspace.Focus();
- }
- }
- /// <summary>
- /// 三维灰度
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsSurfacePlot_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- if (SurfacePlotWindow.form != null)
- {
- SurfacePlotWindow.form.Close();
- this.menuToolsSurfacePlot.Checked = false;
- }
- else
- {
- SurfacePlotWindow.Run(this.AppWorkspace);
- this.menuToolsSurfacePlot.Checked = true;
- }
- }
- /*RegularTetrahedron3D*/
-
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseopenthepicture.Text"));
- }
- /// <summary>
- /// 三维显示
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsSurfacePlotShow_Click(object sender, EventArgs e)
- {
- using (ImageThreeDShowDialog imageDepthExtensionDialog = new ImageThreeDShowDialog(this.AppWorkspace))
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- imageDepthExtensionDialog.StartPosition = FormStartPosition.CenterScreen;
- imageDepthExtensionDialog.ShowDialog();
- }
- }
- /// <summary>
- /// 图像索引
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsImageIndex_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.Widgets.ImageIndexDialog.Visible = !AppWorkspace.Widgets.ImageIndexDialog.Visible;
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.ImageIndexDialog.Visible, "ImageIndex");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.ImageIndexDialog.Visible, "ImageIndex");
- AppWorkspace.Widgets.ImageIndexDialog.Width = AppWorkspace.Widgets.ImageIndexDialog.fromMinSize;
- this.menuToolsImageIndex.Checked = AppWorkspace.Widgets.ImageIndexDialog.Visible;
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- AppWorkspace.ActiveDocumentWorkspace.Focus();
- }
- //ImageIndexDialog dialog = new ImageIndexDialog(AppWorkspace,816);
- //dialog.ShowDialog();
- //Form form = Application.OpenForms["ImageIndexDialog"];//尝试获取已经弹出的窗口对象
- //FloatingFormMethod.ShowFloatForm(form, form == null ? new ImageIndexDialog(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace);
- //this.menuToolsImageIndex.Checked = AppWorkspace.Widgets.ImageIndexDialog.Visible;
- }
- /// <summary>
- /// 脚本
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsScript_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- scriptManageDialog = (ScriptManageDialog)Application.OpenForms["ScriptManageDialog"];//尝试获取已经弹出的窗口对象
- bool nullFLag = false;
- if (scriptManageDialog == null)
- {
- nullFLag = true;
- scriptManageDialog = new ScriptManageDialog(AppWorkspace);
- AppWorkspace.ScriptDialog = scriptManageDialog;
- }
- FloatingFormMethod.ShowFloatForm(nullFLag ? null : scriptManageDialog, scriptManageDialog, AppWorkspace);
- //if (scriptManageDialog == null)
- //{
- // scriptManageDialog = new ScriptManageDialog(AppWorkspace);
- // AppWorkspace.ScriptDialog = scriptManageDialog;
- // scriptManageDialog.StartPosition = FormStartPosition.CenterScreen;
- // scriptManageDialog.Show();
- //}
- //else
- //{
- // if (!scriptManageDialog.IsDisposed)
- // {
- // scriptManageDialog.WindowState = FormWindowState.Normal;
- // }
- // else
- // {
- // scriptManageDialog = new ScriptManageDialog(AppWorkspace);
- // AppWorkspace.ScriptDialog = scriptManageDialog;
- // scriptManageDialog.StartPosition = FormStartPosition.CenterScreen;
- // scriptManageDialog.Show();
- // }
- //}
- }
- /// <summary>
- /// 工作流程
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsWorkFlow_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.Widgets.WorkFlowDialog.Visible = !AppWorkspace.Widgets.WorkFlowDialog.Visible;
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.WorkFlowDialog.Visible, "WorkFlow");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.WorkFlowDialog.Visible, "WorkFlow");
- this.menuToolsWorkFlow.Checked = AppWorkspace.Widgets.WorkFlowDialog.Visible;
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- AppWorkspace.ActiveDocumentWorkspace.Focus();
- }
- }
- /// <summary>
- /// 快捷菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsFast_Click(object sender, EventArgs e)
- {
- if (AppWorkspace != null)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.toolsPanel.Visible = !AppWorkspace.toolsPanel.Visible;
- }
- }
- /// <summary>
- /// 划痕处理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsScratchTreatment_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible)
- AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible = false;
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawScratchTreatmentLine;
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible, "SmudgeTreatment");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible, "SmudgeTreatment");
- this.menuToolsSmudgeTreatment.Checked = AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible;
- AppWorkspace.Widgets.ScratchTreatmentDialog.Visible = !AppWorkspace.Widgets.ScratchTreatmentDialog.Visible;
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.ScratchTreatmentDialog.Visible, "ScratchTreatment");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.ScratchTreatmentDialog.Visible, "ScratchTreatment");
- this.menuToolsScratchTreatment.Checked = AppWorkspace.Widgets.ScratchTreatmentDialog.Visible;
- }
- }
- /// <summary>
- /// 污迹处理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsSmudgeTreatment_Click(object sender, EventArgs e)
- {
- //if (AppWorkspace.ActiveDocumentWorkspace != null)
- //{
- // AppWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.DrawSmudgeRectangle;// DrawSmudgePolygon;// DrawSmudgeEllipse;//
- //}
- if (AppWorkspace.Widgets.ScratchTreatmentDialog.Visible)
- AppWorkspace.Widgets.ScratchTreatmentDialog.Visible = false;
- AppWorkspace.Widgets.SmudgeTreatmentDialog.RefreshActiveTool();
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.ScratchTreatmentDialog.Visible, "ScratchTreatment");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.ScratchTreatmentDialog.Visible, "ScratchTreatment");
- this.menuToolsScratchTreatment.Checked = AppWorkspace.Widgets.ScratchTreatmentDialog.Visible;
- AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible = !AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible;
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible, "SmudgeTreatment");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible, "SmudgeTreatment");
- this.menuToolsSmudgeTreatment.Checked = AppWorkspace.Widgets.SmudgeTreatmentDialog.Visible;
- }
- }
- /// <summary>
- /// 自定义界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsCustomInterface_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- CustomInterfaceDialog dialog = new CustomInterfaceDialog(AppWorkspace);
- dialog.ShowDialog();
- }
- /// <summary>
- /// 软件重启
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsSelfRestart_Click(object sender, EventArgs e)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.orestartthesoftwareModifiedimageswillnotbesaved.Text")+"!", PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- if (dr == DialogResult.OK)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- FileOperationHelper.DeleteFolder(Application.StartupPath + "\\BackupImages");//删除备份文件
- FileOperationHelper.DeleteFolder(Application.StartupPath + "\\BackupImagesTemp");//删除备份文件
- Application.ExitThread();
- Restart();
- }
- //Startup.CloseApplication();
- //SystemLayer.Shell.RestartApplication();
- }
- /// <summary>
- /// 恢复图片
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsRestoreImages_Click(object sender, EventArgs e)
- {
- List<string> imageList = FileOperationHelper.RestoreImages();
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- if (imageList != null && imageList.Count > 0)
- {
- foreach (string imgName in imageList)
- {
- //Document document = Document.FromImage(Image.FromFile(imgName));
- Document document = Document.FromImageMat(new OpenCvSharp.Mat(imgName));
- DocumentWorkspace dw = AppWorkspace.AddNewDocumentWorkspace();
- dw.Document = document;
- dw.fileText = Path.GetFileNameWithoutExtension(imgName);
- AppWorkspace.ActiveDocumentWorkspace = dw;
- }
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Therearenopicturestorecover.Text"));
- }
- private void Restart()
- {
- Thread thtmp = new Thread(new ParameterizedThreadStart(run));
- object appName = Application.ExecutablePath;
- Thread.Sleep(2000);
- thtmp.Start(appName);
- }
- private void run(Object obj)
- {
- Process ps = new Process();
- ps.StartInfo.FileName = obj.ToString();
- ps.Start();
- }
- /// <summary>
- /// 分栏显示
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsColumnDisplay_Click(object sender, EventArgs e)
- {
- using (ColumnsShowDialog columnsShowDialog = new ColumnsShowDialog(this.AppWorkspace))
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- columnsShowDialog.StartPosition = FormStartPosition.CenterScreen;
- columnsShowDialog.ShowDialog();
- }
- }
-
- /// <summary>
- /// 图片信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsImageInfo_Click(object sender, EventArgs e)
- {
- using (ImageInformation imageInformation = new ImageInformation(this.AppWorkspace))
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- imageInformation.StartPosition = FormStartPosition.CenterScreen;
- imageInformation.ShowDialog();
- }
- }
- /// <summary>
- /// 项目工程
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsOpenProject_Click(object sender, EventArgs e)
- {
- AppWorkspace.Widgets.ProjectEngineering.Visible = !AppWorkspace.Widgets.ProjectEngineering.Visible;
- if (AppWorkspace.ActiveDocumentWorkspace != null)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- this.AppWorkspace.toolBar.RefreshBtnSelect(AppWorkspace.Widgets.ProjectEngineering.Visible, "OpenProject");
- this.AppWorkspace.toolsPanel.RefreshBtnSelect(AppWorkspace.Widgets.ProjectEngineering.Visible, "OpenProject");
- this.menuToolsOpenProject.Checked = AppWorkspace.Widgets.ProjectEngineering.Visible;
- AppWorkspace.ActiveDocumentWorkspace.Focus();
- }
- }
- /// <summary>
- /// 添加到工程
- /// 1、如果项目工程选择了常规操作,可以任意添加
- /// 2、如果项目工程选择了通用分析、专用分析,则必须选择其下的文件夹或项目进行添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsAddToProject_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- //如果选择了文件夹,则添加到工程
- if (AppWorkspace.Widgets.ProjectEngineering.TreeNode!=null)
- {
- AppWorkspace.Widgets.ProjectEngineering.AddToProject();
- }
- //如果没有选择则提示,用户选择文件夹,并显示出来项目工程窗口
- else
- {
- AppWorkspace.Widgets.ProjectEngineering.Visible = true;
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheprojectprojectnode.Text"));
- }
- }
-
- /// <summary>
- /// 图像对比
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsPictureComparison_Click(object sender, EventArgs e)
- {
- using (ImageComparison imageComparison = new ImageComparison(this.AppWorkspace))
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- imageComparison.StartPosition = FormStartPosition.CenterScreen;
- imageComparison.ShowDialog();
- }
- }
- /// <summary>
- /// 生成快捷方式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsCreateShortcut_Click(object sender, EventArgs e)
- {
- if (AppWorkspace != null)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- AppWorkspace.DoSaveLnk();
- }
- }
- /// <summary>
- /// 模板管理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsTemplateManager_Click(object sender, EventArgs e)
- {
- using (TemplateManagerDialog dialog = new TemplateManagerDialog())
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- dialog.StartPosition = FormStartPosition.CenterParent;
- dialog.ShowDialog();
- }
- }
- /// <summary>
- /// 生成报告
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MenuToolsCreateReport_Click(object sender, EventArgs e)
- {
- if (AppWorkspace.DocumentWorkspaces != null && AppWorkspace.DocumentWorkspaces.Count() > 0)
- {
- if (AppWorkspace.startScriptRecording)
- {
- AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
- }
- using (CreateReportDialog createReportDialog = new CreateReportDialog(this.AppWorkspace))
- {
- createReportDialog.StartPosition = FormStartPosition.CenterScreen;
- createReportDialog.ShowDialog();
- }
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Thereportcannotbegeneratedwithoutanopenim.Text"));
- }
- }
- }
|