using OpenCvSharp; using OpenCvSharp.Extensions; using PaintDotNet.Base.CommTool; using PaintDotNet.Data.Param; using PaintDotNet.ImageCollect; using PaintDotNet.ImageCollect.CameraComponent; using PaintDotNet.ImageCollect.CameraEDOF; using PaintDotNet.Setting; using PaintDotNet.Setting.LabelComponent; using StageController; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Globalization; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using TUCAMAPI; using TUCamera; namespace PaintDotNet.Menus { public delegate void UpdateCameraList(List cameras); /// /// 图像采集菜单 /// internal sealed class ImageCollectionMenu : PdnMenuItem { public int index = 0; private PdnMenuItem menuCameraSelection; private PdnMenuItem menuCameraSetting; private PdnMenuItem menuCameraAdjust; private PdnMenuItem menuCameraFrame; private PdnMenuItem menuCameraConventional; private ToolStripSeparator menuSeparator1; private PdnMenuItem menuImageCollectHdr; private ToolStripSeparator menuSeparator2; private PdnMenuItem menuPreviewAction; private PdnMenuItem menuPreviewActionClose; private PdnMenuItem menuShootAction; private ToolStripSeparator menuSeparator3; private PdnMenuItem menuAutofocus; private PdnMenuItem menuRealTimeDepth; private PdnMenuItem menuRealTimeStitching; private PdnMenuItem menuAutomaticDepth; private PdnMenuItem menuImageStitching; private PdnMenuItem menuTimedShooting; private PdnMenuItem menuVideoRecording; private PdnMenuItem menuZaxisScan; private PdnMenuItem menuMultiDimensional; private PdnMenuItem menuListOfLocations; private PdnMenuItem menuTwain; // 曝光 private PdnMenuItem menuAdjustExposure; // 白平衡 private PdnMenuItem menuAdjustWhiteBalance; // 增益 private PdnMenuItem menuAdjustGain; // 饱和度 private PdnMenuItem menuAdjustSaturation; // 相机模式 private PdnMenuItem menuFrameColorMode; // 相机分辨率 private PdnMenuItem menuResolution; // ROI private PdnMenuItem menuROI; // 图像旋转 private PdnMenuItem menuCommonRotate; public ImageCollectionMenu(int menuId) { InitializeComponent(); this.MenuId = menuId; } protected override void OnAppWorkspaceChanged() { base.OnAppWorkspaceChanged(); } private void InitializeComponent() { //相机选择 this.menuCameraSelection = new PdnMenuItem(ActionType.CameraSelection); this.menuCameraSelection.AutomaticScript = false; //相机设置 this.menuCameraSetting = new PdnMenuItem(ActionType.CameraSetting); this.menuCameraSetting.AutomaticScript = false; //调节 this.menuCameraAdjust = new PdnMenuItem(ActionType.CameraAdjust); this.menuCameraAdjust.AutomaticScript = false; //边框 this.menuCameraFrame = new PdnMenuItem(ActionType.CameraFrame); this.menuCameraFrame.AutomaticScript = false; //常规 this.menuCameraConventional = new PdnMenuItem(ActionType.CameraConventional); this.menuCameraConventional.AutomaticScript = false; //分隔线 this.menuSeparator1 = new ToolStripSeparator(); //HDR this.menuImageCollectHdr = new PdnMenuItem(ActionType.ImageCollectHdr); this.menuImageCollectHdr.AutomaticScript = false; this.menuImageCollectHdr.Checked = CameraConfigs.GetInstance().GetCurrentCameraParamModel().parame.HDR == 1; //分隔线 this.menuSeparator2 = new ToolStripSeparator(); //预览 this.menuPreviewAction = new PdnMenuItem(ActionType.PreviewExtraction); this.menuPreviewAction.AutomaticScript = false; //关闭预览 this.menuPreviewActionClose = new PdnMenuItem(ActionType.PreviewExtractionClose); this.menuPreviewActionClose.AutomaticScript = false; //拍摄 this.menuShootAction = new PdnMenuItem(ActionType.ShootAction); this.menuShootAction.AutomaticScript = false; //分隔线 this.menuSeparator3 = new ToolStripSeparator(); //自动聚焦 this.menuAutofocus = new PdnMenuItem(ActionType.Autofocus); this.menuAutofocus.AutomaticScript = false; //实时景深扩展 this.menuRealTimeDepth = new PdnMenuItem(ActionType.RealTimeDepth); this.menuRealTimeDepth.AutomaticScript = false; //实时图像拼接 this.menuRealTimeStitching = new PdnMenuItem(ActionType.RealTimeStitching); this.menuRealTimeStitching.AutomaticScript = false; //自动景深扩展 this.menuAutomaticDepth = new PdnMenuItem(ActionType.AutomaticDepth); this.menuAutomaticDepth.AutomaticScript = false; //图像拼接 this.menuImageStitching = new PdnMenuItem(ActionType.ImageStitching); this.menuImageStitching.AutomaticScript = false; //实时拍摄 this.menuTimedShooting = new PdnMenuItem(ActionType.TimedShooting); this.menuTimedShooting.AutomaticScript = false; //视频录像 this.menuVideoRecording = new PdnMenuItem(ActionType.VideoRecording); this.menuVideoRecording.AutomaticScript = false; //z轴扫描 this.menuZaxisScan = new PdnMenuItem(ActionType.ZaxisScan); this.menuZaxisScan.AutomaticScript = false; //多维图像合成 this.menuMultiDimensional = new PdnMenuItem(ActionType.MultiDimensional); this.menuMultiDimensional.AutomaticScript = false; //位置列表 this.menuListOfLocations = new PdnMenuItem(ActionType.ListOfLocations); this.menuListOfLocations.AutomaticScript = false; // 曝光 this.menuAdjustExposure = new PdnMenuItem(ActionType.AdjustExposure); this.menuAdjustExposure.AutomaticScript = false; // 白平衡 this.menuAdjustWhiteBalance = new PdnMenuItem(ActionType.AdjustWhiteBalance); this.menuAdjustWhiteBalance.AutomaticScript = false; // 增益 this.menuAdjustGain = new PdnMenuItem(ActionType.AdjustGain); this.menuAdjustGain.AutomaticScript = false; // 饱和度 this.menuAdjustSaturation = new PdnMenuItem(ActionType.AdjustSaturation); this.menuAdjustSaturation.AutomaticScript = false; // 相机模式 this.menuFrameColorMode = new PdnMenuItem(ActionType.FrameCameraMode); this.menuFrameColorMode.AutomaticScript = false; // 相机设置 this.menuResolution = new PdnMenuItem(ActionType.FrameCameraSet1); this.menuResolution.AutomaticScript = false; // 相机设置 this.menuROI = new PdnMenuItem(ActionType.FrameCameraSet2); this.menuROI.AutomaticScript = false; // 图像旋转 this.menuCommonRotate = new PdnMenuItem(ActionType.CommonRotate); this.menuCommonRotate.AutomaticScript = false; //Twain this.menuTwain = new PdnMenuItem(ActionType.Twain); this.menuTwain.AutomaticScript = false; // // 主菜单 // this.DropDownItems.AddRange(new ToolStripItem[] { this.menuCameraSelection, this.menuTwain, this.menuCameraSetting, this.menuCameraAdjust, this.menuCameraFrame, this.menuCameraConventional, this.menuSeparator1, this.menuImageCollectHdr, //this.menuSeparator2, this.menuPreviewAction, this.menuPreviewActionClose, this.menuShootAction, this.menuSeparator3, this.menuAutofocus, this.menuRealTimeDepth, this.menuRealTimeStitching, this.menuAutomaticDepth, this.menuImageStitching, this.menuTimedShooting, this.menuVideoRecording, this.menuZaxisScan, this.menuMultiDimensional, this.menuListOfLocations }); this.Name = "Menu.ImageCollection"; this.Text = PdnResources.GetString("Menu.ImageCollection.Text"); // // 相机设置 // this.menuCameraSetting.Click += new System.EventHandler(this.CameraSeting_Click); //调节 this.menuCameraAdjust.Click += null; this.menuCameraAdjust.DropDownItems.AddRange(new ToolStripItem[] { this.menuAdjustExposure, this.menuAdjustWhiteBalance, this.menuAdjustGain, this.menuAdjustSaturation }); // // 调节 - 曝光时间 // this.menuAdjustExposure.NeedWaitKey = true; this.menuAdjustExposure.Click += new System.EventHandler(this.AdjustExposure_Click); this.menuAdjustExposure.Text = PdnResources.GetString("Menu.timeofexposure.text"); this.menuAdjustExposure.Image = PdnResources.GetImageResource("Icons.MenuImageCollectionExposureTimeIcon.png").Reference; // // 调节 - 白平衡 // this.menuAdjustWhiteBalance.NeedWaitKey = true; this.menuAdjustWhiteBalance.Click += new System.EventHandler(this.AdjustWhiteBalance_Click); this.menuAdjustWhiteBalance.Text = PdnResources.GetString("Menu.Image.WhiteBalance.Text"); this.menuAdjustWhiteBalance.Image = PdnResources.GetImageResource("Icons.MenuImageCollectionWhiteBalanceIcon.png").Reference; // // 调节 - 增益 // this.menuAdjustGain.NeedWaitKey = true; this.menuAdjustGain.Click += new System.EventHandler(this.AdjustGain_Click); this.menuAdjustGain.Text = PdnResources.GetString("Menu.imagecapture.adjust.Gain.text"); this.menuAdjustGain.Image = PdnResources.GetImageResource("Icons.MenuImageCollectionGainIcon.png").Reference; // // 调节 - 饱和度 // this.menuAdjustSaturation.NeedWaitKey = true; this.menuAdjustSaturation.Click += new System.EventHandler(this.AdjustSaturation_Click); this.menuAdjustSaturation.Text = PdnResources.GetString("Menu.saturation.text"); this.menuAdjustSaturation.Image = PdnResources.GetImageResource("Icons.MenuImageCollectionSaturationIcon.png").Reference; // // 边框 // this.menuCameraFrame.Click += null; this.menuCameraFrame.DropDownItems.AddRange(new ToolStripItem[] { this.menuFrameColorMode, this.menuResolution, this.menuROI }); // // 黑白、彩色 - 相机模式 // this.menuFrameColorMode.NeedWaitKey = true; this.menuFrameColorMode.Click += new System.EventHandler(this.Color_Click); this.menuFrameColorMode.Text = PdnResources.GetString("Menu.Cameramode.text"); this.menuFrameColorMode.Image = PdnResources.GetImageResource("Icons.MenuImageCollectionFrameCameraModeIcon.png").Reference; // // 边框 - 相机分辨率 // this.menuResolution.NeedWaitKey = true; this.menuResolution.Click += new System.EventHandler(this.Resolution_Click); this.menuResolution.Text = "相机分辨率"; this.menuResolution.Image = PdnResources.GetImageResource("Icons.MenuImageCollectionFrameCameraSetIcon.png").Reference; // // 边框 - ROI // this.menuROI.NeedWaitKey = true; this.menuROI.Click += new System.EventHandler(this.ROI_Click); this.menuROI.Text = "ROI"; this.menuROI.Image = PdnResources.GetImageResource("Icons.MenuImageCollectionROISetIcon.png").Reference; // // 常规 // this.menuCameraConventional.Click += null; this.menuCameraConventional.DropDownItems.AddRange(new ToolStripItem[] { this.menuCommonRotate, }); // // 边框 - 相机设置 // this.menuCommonRotate.NeedWaitKey = true; this.menuCommonRotate.Click += new System.EventHandler(this.CommonRotate_Click); this.menuCommonRotate.Text = PdnResources.GetString("Menu.Imagerotation.text"); this.menuCommonRotate.Image = PdnResources.GetImageResource("Icons.MenuImageCollectionCommonRotateIcon.png").Reference; // //Twain // this.menuTwain.NeedWaitKey = true; this.menuTwain.Click += MenuTwain_Click; this.menuTwain.Text = "TWAIN"; // // HDR // this.menuImageCollectHdr.Click += new System.EventHandler(this.HDR_Click); // // 预览窗口 // this.menuPreviewAction.NeedWaitKey = true; this.menuPreviewAction.Click += new System.EventHandler(this.previewExtraction_Click); // // 关闭预览 // this.menuPreviewActionClose.NeedWaitKey = true; this.menuPreviewActionClose.Click += new System.EventHandler(this.PreviewActionClose_Click); // // 拍摄 // this.menuShootAction.NeedWaitKey = true; this.menuShootAction.Click += new System.EventHandler(this.Shoot_Click); // // 自动聚焦 // this.menuAutofocus.NeedWaitKey = true; this.menuAutofocus.Click += new System.EventHandler(this.Autofocus_Click); // // 实时景深扩展 // this.menuRealTimeDepth.Click += new System.EventHandler(this.CameraRealTimeDepth_Click); // // 实时图像拼接 // this.menuRealTimeStitching.Click += new System.EventHandler(this.CameraRealTimeStitching_Click); // // 自动景深扩展 // this.menuAutomaticDepth.Click += new System.EventHandler(this.CameraAutomaticDepth_Click); // // 图像拼接 // this.menuImageStitching.Click += new System.EventHandler(this.CameraImageStitching_Click); // // 实时拍摄 // this.menuTimedShooting.Click += new System.EventHandler(this.CameraTimedShooting_Click); // // 视频录像 // this.menuVideoRecording.Click += new System.EventHandler(this.CameraVideoRecording_Click); // // Z轴扫描 // this.menuZaxisScan.Click += new System.EventHandler(this.CameraZaxisScan_Click); // // 多维图像合成 // this.menuMultiDimensional.Click += new System.EventHandler(this.MultiDimensiona_Click); // // 位置列表 // this.menuListOfLocations.Click += new System.EventHandler(this.ListOfLocations_Click); // // 加载菜单的文字和icon // this.LoadNames(this.Name); this.LoadIcons(); } const int MSG_TWAIN = 0x444; private void MenuTwain_Click(object sender, EventArgs e) { var f1 = new TwainMessageForm(); f1.CallBack = (s) => { AppWorkspace.OpenFileInNewWorkspace(s); System.IO.File.Delete(s); }; // TUCameraManager.GetInstance().UnInitManager(); try { Process.Start("Saraff.Twain.exe", f1.Handle.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } } class TwainMessageForm : Form { public Action CallBack; protected override void DefWndProc(ref Message m) { switch (m.Msg) { case 444://处理消息 int id = (int)m.WParam; string ss = id + ".jpg"; CallBack?.Invoke(ss); break; default: base.DefWndProc(ref m); break; } } } #region 自动聚焦 /// /// 自动聚焦 /// /// /// private void Autofocus_Click(object sender, EventArgs e) { if (AutoFocusWorkflow.IsWorking) return; TransferProgressDialog.ShowDialog("自动聚焦", "聚焦中......", () => AutoFocusWorkflow.AutoFocus(AxisController.GetInstance(), () => { return m_camera.OneShoot(); }), (s1, e1) => { AutoFocusWorkflow.Stop(); }); } #endregion protected override void OnDropDownOpening(EventArgs e) { InitCameraList(); } public void InitCameraList() { this.menuCameraSelection.DropDownItems.Clear(); Func> func = new Func>(() => { return TUCameraManager.GetInstance().GetCameraList(); ; }); AsyncCallback callback = new AsyncCallback((x) => { var result = func.EndInvoke(x); UpdateCameraList ut = new UpdateCameraList(UpdateCameraListMehod); this.Parent.BeginInvoke(ut, result); }); func.BeginInvoke(callback, ""); } public void UpdateCameraListMehod(List cameras) { this.menuCameraSelection.DropDownItems.Clear(); if (cameras != null && cameras.Count > 0) { for (int i = 0; i < cameras.Count; i++) { ToolStripMenuItem mi = new ToolStripMenuItem(cameras[i].GetName()); mi.Alignment = ToolStripItemAlignment.Right; mi.ImageAlign = ContentAlignment.MiddleRight; mi.ImageScaling = ToolStripItemImageScaling.None; mi.Tag = i; mi.Click += new EventHandler(this.MenuCreameItem_Click); if (this.index == i) mi.Checked = true; this.menuCameraSelection.DropDownItems.Add(mi); } } else { index = 0; } } private void MenuCreameItem_Click(object sender, EventArgs e) { if (sender != null) { foreach (ToolStripMenuItem mi in this.menuCameraSelection.DropDownItems) { mi.Checked = false; } ToolStripMenuItem temp = (ToolStripMenuItem)sender; this.index = (int)(temp.Tag); // 选中相机 TUCameraManager.GetInstance().SetCurrentCamera(index); temp.Checked = true; // 检测相机是否合法 Startup.cameraSNLegal = false; Startup.instance.CheckCameraSN(); // 如果设置界面打开,则刷新相机名称和SN Form form = Application.OpenForms["CameraSettingDialog"]; if (form != null && !form.IsDisposed) { ((CameraSettingDialog)form).InitializeData(); } } } private void CommonRotate_Click(object sender, EventArgs e) { Form form = Application.OpenForms["CommonRotateDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CommonRotateDialog()/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } private void Resolution_Click(object sender, EventArgs e) { Form form = Application.OpenForms["FrameCameraModeDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new FrameCameraModeDialog(FrameCameraMode.Resolution)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } private void ROI_Click(object sender, EventArgs e) { Form form = Application.OpenForms["FrameCameraModeDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new FrameCameraModeDialog(FrameCameraMode.ROI)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } private void Color_Click(object sender, EventArgs e) { Form form = Application.OpenForms["FrameCameraModeDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new FrameCameraModeDialog(FrameCameraMode.Color)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } private void AdjustSaturation_Click(object sender, EventArgs e) { Form form = Application.OpenForms["AdjustSaturationDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new AdjustSaturationDialog()/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } private void AdjustGain_Click(object sender, EventArgs e) { Form form = Application.OpenForms["AdjustGainDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new AdjustGainDialog()/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } private void AdjustWhiteBalance_Click(object sender, EventArgs e) { Form form = Application.OpenForms["AdjustWhiteBalanceDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new AdjustWhiteBalanceDialog()/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } private void AdjustExposure_Click(object sender, EventArgs e) { Form form = Application.OpenForms["AdjustExposureDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new AdjustExposureDialog()/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } private void HDR_Click(object sender, EventArgs e) { menuImageCollectHdr.Checked = !menuImageCollectHdr.Checked; CameraConfigs.GetInstance().GetCurrentCameraParamModel().parame.HDR = menuImageCollectHdr.Checked ? 1 : 0; m_camera.SetHdr(menuImageCollectHdr.Checked ? 1 : 0); } /// /// 预览窗口 /// /// /// private void previewExtraction_Click(object sender, System.EventArgs e) { if (Startup.cameraSNLegal) { Form form = Application.OpenForms["CameraPreviewDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraPreviewDialog(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } else { MessageBox.Show("不支持此相机"); } } /// /// 关闭预览 /// /// /// private void PreviewActionClose_Click(object sender, System.EventArgs e) { if (CameraPreviewDialog.cameraPreviewDialog != null) { CameraPreviewDialog.cameraPreviewDialog.Close(); } } #region 拍摄 private TUCamera.TUCamera m_camera { get { return TUCameraManager.GetInstance().GetCurrentCamera(); } } private CameraConfigs m_cameraConfig; private Bitmap m_bitmap; /// /// 拍摄 /// /// /// private void Shoot_Click(object sender, EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } var bitmap = m_camera.OneShoot(); if (bitmap == null) return; var mode = Startup.instance.configModel.CaptureSaveMode; AppWorkspace.DisplayShoot(bitmap, null, Startup.instance.configModel.CaptureHasRoler, mode); } object obj = new object(); public void CallbackDraw(Bitmap bitmap) { m_camera.m_bufHandler -= CallbackDraw; lock (obj) { try { m_bitmap = bitmap; } catch (Exception) { Console.WriteLine("关闭窗口后接受到数据"); } } } #endregion /// /// 相机设置点击 /// /// /// private void CameraSeting_Click(object sender, System.EventArgs e) { Form form = Application.OpenForms["CameraSettingDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraSettingDialog()/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } /// /// 实时拍摄 /// /// /// private void CameraTimedShooting_Click(object sender, System.EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } Form form = Application.OpenForms["CameraTimedShooting"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraTimedShooting(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } /// /// 视频录像 /// /// /// private void CameraVideoRecording_Click(object sender, System.EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } Form form = Application.OpenForms["CameraVideoRecording"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraVideoRecording()/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } /// /// Z轴扫描 /// /// /// private void CameraZaxisScan_Click(object sender, System.EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } //if (!AxisController.GetInstance().IsOpen) //{ // MessageBox.Show(PdnResources.GetString("Message.AxisController.NotConnected")); // return; //} Form form = Application.OpenForms["CameraZaxisScan"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraZaxisScan(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } /// /// 实时景深扩展 /// /// /// private void CameraRealTimeDepth_Click(object sender, System.EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } Form form = Application.OpenForms["CameraRealTimeDepth"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraRealTimeDepth(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } /// /// 自动景深扩展 /// /// /// private void CameraAutomaticDepth_Click(object sender, System.EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } //if (!AxisController.GetInstance().IsOpen) //{ // MessageBox.Show(PdnResources.GetString("Message.AxisController.NotConnected")); // return; //} Form form = Application.OpenForms["CameraAutomaticDepth"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraAutomaticDepth(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } /// /// 图像拼接 /// /// /// private void CameraImageStitching_Click(object sender, System.EventArgs e) { //if (!Startup.cameraSNLegal) //{ // MessageBox.Show("不支持此相机"); // return; //} Form form = Application.OpenForms["CameraImageStitching"]; FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraImageStitching(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); //if ((form == null) || (form.IsDisposed)) //{ // CameraImageStitching af = new CameraImageStitching(AppWorkspace); // af.StartPosition = FormStartPosition.CenterScreen; // af.Show ##### Dialog(); //} //else //{ // form.Activate(); // form.WindowState = FormWindowState.Normal; //} } /// /// 实时图像拼接 /// /// /// private void CameraRealTimeStitching_Click(object sender, System.EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } Form form = Application.OpenForms["CameraRealTimeStitchingDialog"];//尝试获取已经弹出的窗口对象 FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraRealTimeStitchingDialog(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } /// /// 多维图像合成 /// /// /// private void MultiDimensiona_Click(object sender, EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } Form form = Application.OpenForms["MultiDimensionaDialog"]; FloatingFormMethod.ShowFloatForm(form, form == null ? new MultiDimensionaDialog(AppWorkspace) : null, AppWorkspace); //Form form = Application.OpenForms["MultiDimensionaDialog"]; //if ((form == null) || (form.IsDisposed)) //{ // MultiDimensionaDialog af = new MultiDimensionaDialog(AppWorkspace); // af.StartPosition = FormStartPosition.CenterScreen; // af.Show ##### Dialog(); //} //else //{ // form.Activate(); // form.WindowState = FormWindowState.Normal; //} } /// /// 位置列表 /// /// /// private void ListOfLocations_Click(object sender, EventArgs e) { if (!Startup.cameraSNLegal) { MessageBox.Show("不支持此相机"); return; } Form form = Application.OpenForms["ListOfLocationsDialog"];//尝试获取已经弹出的窗口对象 //using (var form = new ListOfLocationsDialog(AppWorkspace)) form.ShowDialog() ; FloatingFormMethod.ShowFloatForm(form, form == null ? new ListOfLocationsDialog(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace); } 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; } } } }