private void OpenOrderUI(int s) { try { UpLoad upload = new UpLoad(mWebsocket); if (Form1.dic_upLoad.Count > 0) { foreach (KeyValuePair <string, UpLoad> kv in Form1.dic_upLoad)//关闭其他窗口并移除 { kv.Value.Close(); kv.Value.Dispose(); websocket w = new websocket(); UpLoad u = new UpLoad(w); Form1.dic_upLoad.TryRemove(kv.Key, out u); } } string str = ""; Form1.dic_upLoad.TryAdd(str, upload); upload.Show(); } catch (Exception ex) { IniHelper.WriteLog(ex); return; } }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { try { if (HeadImageBool) { width = this.pictureBox1.Image.Width; heigth = this.pictureBox1.Image.Height; if ((e.X - x1) > 0 && (e.Y - y1) > 0) //当鼠标从左上角向右下方向开始移动时发生 { IC1 = new ImageCut1(x1, y1, Math.Abs(e.X - x1), Math.Abs(e.Y - y1)); //实例化ImageCut1类 } if ((e.X - x1) < 0 && (e.Y - y1) > 0) //当鼠标从右上角向左下方向开始移动时发生 { IC1 = new ImageCut1(e.X, y1, Math.Abs(e.X - x1), Math.Abs(e.Y - y1)); //实例化ImageCut1类 } if ((e.X - x1) > 0 && (e.Y - y1) < 0) //当鼠标从左下角向右上方向开始移动时发生 { IC1 = new ImageCut1(x1, e.Y, Math.Abs(e.X - x1), Math.Abs(e.Y - y1)); //实例化ImageCut1类 } if ((e.X - x1) < 0 && (e.Y - y1) < 0) //当鼠标从右下角向左上方向开始移动时发生 { IC1 = new ImageCut1(e.X, e.Y, Math.Abs(e.X - x1), Math.Abs(e.Y - y1)); //实例化ImageCut1类 } //this.pictureBox2.Width = (IC1.KiCut1((Bitmap)(this.pictureBox1.Image))).Width; //this.pictureBox2.Height = (IC1.KiCut1((Bitmap)(this.pictureBox1.Image))).Height; Image img = IC1.KiCut1((Bitmap)(this.pictureBox1.Image)); DialogResult dr = MessageBox.Show("是否保存截图", "截图完成", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { Clipboard.SetImage(img); saveFileDialog1.Filter = "jpg|*.jpg|bmp|*.bmp|gif|*.gif"; string iniPath = Form1.dic_process[Form1.processId]; //MessageBox.Show(Form1.processId.ToString()); //MessageBox.Show(iniPath); this.saveFileDialog1.InitialDirectory = @"D:\ETCAD\制版\" + iniPath + @"\result"; if (saveFileDialog1.ShowDialog() != DialogResult.Cancel) { Image image = Clipboard.GetImage(); image.Save(saveFileDialog1.FileName); } this.Close(); } else if (dr == DialogResult.Cancel) { this.Refresh(); } this.Cursor = Cursors.Default; } else { this.Cursor = Cursors.Default; } } catch (Exception ex) { IniHelper.WriteLog(ex); return; } }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { try { Pen pp = new Pen(Color.Red, 6);//画笔 e.Graphics.DrawRectangle(pp, 0, 0, pictureBox1.Width - 6, pictureBox1.Height - 6); if (HeadImageBool) { Pen p = new Pen(Color.Red, 2);//画笔 p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; //Bitmap bitmap = new Bitmap(strHeadImagePath); Bitmap bitmap = Bi; Rectangle rect = new Rectangle(p3, new Size(System.Math.Abs(p2.X - p1.X), System.Math.Abs(p2.Y - p1.Y))); e.Graphics.DrawRectangle(p, rect); } else { } } catch (Exception ex) { IniHelper.WriteLog(ex); return; } }
private void button3_Click(object sender, EventArgs e) { try { string order_path = @"D:\ETCAD\排料\"; foreach (object item in checkedListBox2.CheckedItems) { string businessid = item.ToString();//选择的订单号 string busid = businessid.Substring(0, businessid.IndexOf("[")); string search_path = @order_path + businessid + @"\result"; string[] filedic = Directory.GetFiles(search_path, "*.nc*", SearchOption.AllDirectories);//查找文件里里的所有文件 UploadParam uploadParam = new UploadParam(); uploadParam.Type = "maskList"; uploadParam.businessId = businessid; string businessType = "MaskList"; uploadParam.strParamters.Add("businessType", businessType); List <string> fileNameList = new List <string>(); foreach (string a in filedic) { //if (!a.Contains(@"result\"+ busid)) fileNameList.Add(a); } AddParam(uploadParam, fileNameList); mWebsocket.UpLoad(uploadParam); } this.Close(); } catch (Exception ex) { //MessageBox.Show(ex.Message); IniHelper.WriteLog(ex); } }
void xgate_DeviceErrorCallback(XGate xgate, Device PTLDevice, Exception error) { this.BeginInvoke(new MethodInvoker(() => { IniHelper.WriteLog(error); })); }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { try { if (this.Cursor == Cursors.Cross) { this.p2 = new Point(e.X, e.Y); if ((p2.X - p1.X) > 0 && (p2.Y - p1.Y) > 0) //当鼠标从左上角向开始移动时P3坐标 { this.p3 = new Point(p1.X, p1.Y); } if ((p2.X - p1.X) < 0 && (p2.Y - p1.Y) > 0) //当鼠标从右上角向左下方向开始移动时P3坐标 { this.p3 = new Point(p2.X, p1.Y); } if ((p2.X - p1.X) > 0 && (p2.Y - p1.Y) < 0) //当鼠标从左下角向上开始移动时P3坐标 { this.p3 = new Point(p1.X, p2.Y); } if ((p2.X - p1.X) < 0 && (p2.Y - p1.Y) < 0) //当鼠标从右下角向左方向上开始移动时P3坐标 { this.p3 = new Point(p2.X, p2.Y); } this.pictureBox1.Invalidate(); //使控件的整个图面无效,并导致重绘控件 } } catch (Exception ex) { IniHelper.WriteLog(ex); return; } }
/// <summary> /// 刷新页面 /// </summary> private void ReloadPage(int s) { try { wb.GetBrowser().Reload(); } catch (Exception ex) { IniHelper.WriteLog(ex); } }
void Do(MethodInvoker action) { try { action(); } catch (Exception ex) { IniHelper.WriteLog(ex); } }
public void Check_dir() { try { CheckFile(type); } catch (Exception ex) { IniHelper.WriteLog(ex); MessageBox.Show(ex.Message); } }
private void fileSystemWatcher5_Created(object sender, FileSystemEventArgs e) { try { websocket.Dwon(mWebsocket.path, mWebsocket.embList); Process.Start(this.fileSystemWatcher5.Path + @"\" + mWebsocket.businessId); } catch (Exception ex) { IniHelper.WriteLog(ex); MessageBox.Show("下载失败", "错误提示"); } }
private void Form1_Load(object sender, EventArgs a) { try { //读取websocket地址 //string[] locIps = websocket.GetLocIps(); //string locip = locIps[0]; if (mWebsocket.StartListen("127.0.0.1", "8088"))//开始监听... { //MessageBox.Show("监听成功"); } else { MessageBox.Show("请检查网络和端口!"); } //CEF cefInit(); //wb = new ChromiumWebBrowser(@"http://www.iqiyi.com/"); string web_url = mIni.ReadValue("DPS参数", "url"); if (web_url == "0") { MessageBox.Show("参数配置错误"); } wb = new ChromiumWebBrowser(web_url); wb.Dock = DockStyle.Fill; panel1.Controls.Add(wb); wb.DownloadHandler = new DownloadHandler(); //监听按键事件 GlobalKeyboardHook gHook = new GlobalKeyboardHook(); gHook.KeyDown += new KeyEventHandler(gHook_KeyDown); foreach (Keys key in Enum.GetValues(typeof(Keys))) { gHook.HookedKeys.Add(key); } gHook.hook(); //热键注册 RegisterHotKey(this.Handle, 7890, KeyModifiers.Alt | KeyModifiers.Control, Keys.X); //页面缩放 //wb.SetZoomLevel(0.5); //灯光拣选 executeLigthSort = new XgateDelegate(StartCon); websocket.executeLigthSort = new websocket.XgateDelegate(ExecuteLigthSort); } catch (Exception ex) { IniHelper.WriteLog(ex); MessageBox.Show("网页打开失败", "错误提示"); } }
public void Thread_Watch_fsw2() { try { fsw_2 = new FileSystemWatcher(); fsw_2.Created += new FileSystemEventHandler(fsw_2_Created); fsw_2.Filter = "*.*"; fsw_2.Path = path; fsw_2.EnableRaisingEvents = true; } catch (Exception ex) { IniHelper.WriteLog(ex); MessageBox.Show("请稍后再试"); } }
/// <summary> /// 处理裁剪信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void fileSystemWatcher2_Created(object sender, FileSystemEventArgs e) { try { websocket.Dwon(mWebsocket.path, mWebsocket.maskList); //复制文件到指定目录 string sourcePath = this.fileSystemWatcher2.Path + @"\" + mWebsocket.businessId; string destPath = @"D:\"; HTTP.CopyFile(sourcePath, destPath); MessageBox.Show("裁床可执行NC文件已经保存到D盘根目录!"); } catch (Exception ex) { IniHelper.WriteLog(ex); MessageBox.Show(ex.Message); } }
private void SnapForm_Load(object sender, EventArgs e) { try { //this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Opacity = 0.99; this.ShowIcon = false; //this.ShowInTaskbar = false; this.TopMost = true; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.pictureBox1.Image = iniImg; } catch (Exception ex) { IniHelper.WriteLog(ex); } }
/// <summary> /// CEF初始化参数设置 /// </summary> public void cefInit() { try { //清空缓存 if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "cache\\Cache")) { string[] filedir = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "cache\\Cache", "*.*", SearchOption.TopDirectoryOnly); if (filedir != null) { foreach (string fileName in filedir) { File.Delete(fileName); } } } CefSettings setting = new CefSharp.CefSettings(); //关闭日志文件 setting.LogSeverity = CefSharp.LogSeverity.Disable; //Flash设置 //setting.CefCommandLineArgs.Add("enable-npapi","1"); //string flashPath = @"C:\Users\shallow\AppData\Local\Google\Chrome\User Data\PepperFlash\28.0.0.137\pepflashplayer.dll"; //setting.CefCommandLineArgs.Add("ppapi-flash-path", flashPath); //setting.CefCommandLineArgs.Add("ppapi-flash-version", "28.0.0.137"); //屏幕闪烁设置 setting.CefCommandLineArgs.Add("disable-gpu", "1"); // 禁用gpu setting.Locale = "zh-CN"; // 设置语言 //缓存路径 setting.CachePath = AppDomain.CurrentDomain.BaseDirectory + "cache\\"; setting.PersistSessionCookies = true; CefSharp.Cef.Initialize(setting, true, null); string cookieDirec = AppDomain.CurrentDomain.BaseDirectory + "cache\\cookie\\"; ICookieManager cookieManager = CefSharp.Cef.GetGlobalCookieManager(); cookieManager.SetStoragePath(cookieDirec, false); } catch (Exception ex) { IniHelper.WriteLog(ex); } }
//监测是否有RESULT文件夹生成 public void Check_dir() { try { if (type == "grade")//制版 { bool open = true; while (open) { string[] filedir = Directory.GetFiles(dir.ToString(), "*.*", SearchOption.AllDirectories); foreach (string s in filedir) { if (Regex.Match(s.ToLower(), "result").Value != "") { string watch_path = dir + @"\result";//监测器3的监测路径 thread_checkBuidFile td = new thread_checkBuidFile(watch_path, type); check_fsw_3 = new Thread(new ThreadStart(td.Check_dir)); check_fsw_3.IsBackground = true; check_fsw_3.Start(); open = false; } } Thread.Sleep(2000); } } else if (type == "maskList") { string watch_path = dir + @"\result";//监测器3的监测路径 thread_checkBuidFile td = new thread_checkBuidFile(watch_path, type); check_fsw_3 = new Thread(new ThreadStart(td.Check_dir)); check_fsw_3.IsBackground = true; check_fsw_3.Start(); } } catch (Exception ex) { IniHelper.WriteLog(ex); MessageBox.Show(ex.Message); } }
void xgate_PickedInforCallback(XGate xgate, Device PTLDevice, string[] contents, int[] pickedQuantities, bool FnPressed) { try { this.BeginInvoke(new MethodInvoker(() => { websocket.LightSortReturn(int.Parse(contents[0]), pickedQuantities[0]); xgate.Clear900U(PTLDevice.Address); //xgate.Close(); string info = "设备类型:" + PTLDevice + "\r\n" + "货位号:" + contents[0] + "\r\n" + "拣货数量:" + pickedQuantities[0]; IniHelper.WriteInfo(info); if (que_light.Count != 0) { disPlay900(); } })); } catch (Exception ex) { IniHelper.WriteLog(ex); } }
/// <summary> /// 处理制版信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void fileSystemWatcher1_Created(object sender, FileSystemEventArgs e) { try { string fsw_path = this.fileSystemWatcher1.Path + @e.Name.ToString(); //dic_files.TryAdd(e.Name.ToString(), e.Name.ToString()); thread_fsw2 td = new thread_fsw2("grade", fsw_path, mWebsocket); check_fsw_2 = new Thread(new ThreadStart(td.Thread_Watch_fsw2)); check_fsw_2.IsBackground = true; check_fsw_2.Start(); websocket.Dwon(mWebsocket.spath, mWebsocket.gradeList); } catch (Exception ex) { IniHelper.WriteLog(ex); if (ex.Message.Contains("集合已修改")) { MessageBox.Show("请稍后再试"); } return; } }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { try { this.Cursor = Cursors.Cross; this.p1 = new Point(e.X, e.Y); x1 = e.X; y1 = e.Y; if (this.pictureBox1.Image != null) { HeadImageBool = true; } else { HeadImageBool = false; } } catch (Exception ex) { IniHelper.WriteLog(ex); return; } }
/// <summary> /// F5刷新网页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void gHook_KeyDown(object sender, KeyEventArgs e) { if (this.ContainsFocus) { if (e.KeyValue == 116) { wb.GetBrowser().Reload(); } else if (e.KeyValue == 117) { try { UpLoad upload = new UpLoad(mWebsocket); if (Form1.dic_upLoad.Count > 0) { foreach (KeyValuePair <string, UpLoad> kv in Form1.dic_upLoad)//关闭其他窗口并移除 { kv.Value.Close(); kv.Value.Dispose(); websocket w = new websocket(); UpLoad u = new UpLoad(w); Form1.dic_upLoad.TryRemove(kv.Key, out u); } } string str = ""; Form1.dic_upLoad.TryAdd(str, upload); upload.Show(); } catch (Exception ex) { IniHelper.WriteLog(ex); return; } } } }
/// <summary> /// 处理排料信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void fileSystemWatcher4_Created(object sender, FileSystemEventArgs e) { try { string fsw_path = this.fileSystemWatcher4.Path + "\\" + @e.Name.ToString();//订单号文件夹 thread_fsw2 td = new thread_fsw2("maskList", fsw_path, mWebsocket); check_fsw_2 = new Thread(new ThreadStart(td.Thread_Watch_fsw2)); check_fsw_2.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); IniHelper.WriteLog(ex); } try { websocket.Dwon(mWebsocket.spath, mWebsocket.blowDown); } catch (Exception ex) { MessageBox.Show("下载失败", "错误提示"); IniHelper.WriteLog(ex); } }
public void fsw_2_Created(object sender, FileSystemEventArgs e) { try { //打开程序之前先检测有没有打开过相同的程序 Process[] proList = Process.GetProcesses(); foreach (Process process in proList) { if (process.ProcessName == "ETCOM_WIBU_500" || process.ProcessName == "ETMark_WIBU_TD") { if (!Form1.dic_process.ContainsKey(process.Id)) { Form1.dic_process.TryAdd(process.Id, process.Id.ToString()); } } } //---- string filePath = path + @"\" + e.Name.ToString(); string businessid = path.Substring(path.LastIndexOf(@"\") + 1); if (type == "grade" && e.Name.ToString().Contains("自动放码"))//以指定程序打开指定文件 { //监测result文件夹 check_thread ct = new shell.check_thread(path, type, mWebsocket); Thread check_dir = new Thread(new ThreadStart(ct.Check_dir)); check_dir.IsBackground = true; check_dir.Start(); string exe = mIni.ReadValue("ET", "gradeEXE"); //string exe = @"C:\Windows\notepad.exe"; IniHelper.ShellExecute(IntPtr.Zero, "open", exe, filePath, null, IniHelper.ShowCommands.SW_SHOWNORMAL); //创建新的线程监测打开的进程是否关闭 Process[] procesList = Process.GetProcesses(); foreach (Process process in procesList) { if (process.ProcessName == "ETCOM_WIBU_500") { if (!Form1.dic_process.ContainsKey(process.Id)) { Form1.dic_process.TryAdd(process.Id, businessid); //创建线程监测进程是否关闭 thread_Process tp = new thread_Process(type, businessid, process.Id); Thread td = new Thread(new ThreadStart(tp.Thread_Watch_process)); td.IsBackground = true; td.Start(); } } } } else if (type == "maskList" && (e.Name.ToString().Contains("自动排料") || e.Name.EndsWith("prj"))) { //监测result文件夹 check_thread ct = new shell.check_thread(path, type, mWebsocket); Thread check_dir = new Thread(new ThreadStart(ct.Check_dir)); check_dir.IsBackground = true; check_dir.Start(); ////修改oif文件里面的[define] output内容 //IniHelper mIni2 = new IniHelper(); //mIni2.ImportHelper(filePath); //string newvalue = str + "\\result2"; //mIni2.WriteValue("Define", "output", newvalue); string exe = mIni.ReadValue("ET", "maskListEXE"); IniHelper.ShellExecute(IntPtr.Zero, "open", exe, filePath, null, IniHelper.ShowCommands.SW_SHOWNORMAL); Thread.Sleep(2000); //创建新的线程监测打开的进程是否关闭 Process[] procesList = Process.GetProcesses(); foreach (Process process in procesList) { if (process.ProcessName == "ETMark_WIBU_TD") { if (!Form1.dic_process.ContainsKey(process.Id)) { Form1.dic_process.TryAdd(process.Id, businessid); //创建线程监测进程是否关闭 thread_Process tp = new thread_Process(type, businessid, process.Id); Thread td = new Thread(new ThreadStart(tp.Thread_Watch_process)); td.IsBackground = true; td.Start(); } } } } } catch (Exception ex) { IniHelper.WriteLog(ex); MessageBox.Show(ex.Message); return; } }