private static void GlobalMutex() { // 是否第一次创建mutex bool newMutexCreated = false; string mutexName = "Global\\" + "WareHouseMis"; try { mutex = new Mutex(false, mutexName, out newMutexCreated); } catch (Exception ex) { Console.Write(ex.Message); Thread.Sleep(1000); Environment.Exit(1); } // 第一次创建mutex if (newMutexCreated) { Console.WriteLine("程序已启动"); } else { CommHelp.ShowTips("另一个窗口已在运行,不能重复运行。"); Thread.Sleep(1000); Environment.Exit(1);//退出程序 } }
private void btnEdit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtName.Text)) { CommHelp.ShowTips("请选择要修改的账号"); return; } SetControl(ActionType.Edit); }
private void DeleteCurrentImg() { if (File.Exists($"{dirName}\\{copyInfo.FileName}.ini")) { File.Delete($"{dirName}\\{copyInfo.FileName}.ini"); } CommHelp.ShowTips("图片已经删除,请选择其它图片编辑"); this.Close(); }
private void btnOK_Click(object sender, EventArgs e) { if (currentAction == ActionType.Add || currentAction == ActionType.Edit) { if (string.IsNullOrEmpty(txtName.Text)) { CommHelp.ShowTips("必须输入姓名"); return; } else if (string.IsNullOrEmpty(txtBirthDay.Text)) { CommHelp.ShowTips("必须输入生日"); return; } else { var v = new Patient { FName = txtName.Text, Name = "", Address1 = txtAdress.Text, Address2 = "", Address3 = "", BirthDay = txtBirthDay.Text, SECU = txtNo.Text, Tel1 = txtLink.Text, Tel2 = "" }; if (currentAction == ActionType.Add) { v.Number = CreateNum(); if (User.Patients == null) { User.Patients = new List <Patient>(); } User.Patients.Add(v); } else { v.Number = User.CurrentPatient.Number; if (v.FName != User.CurrentPatient.FName || v.BirthDay != User.CurrentPatient.BirthDay) { try { Directory.Move(User.PatientPath, $"{User.DBPath}\\{v.FName + v.BirthDay}"); } catch (Exception ex) { CommHelp.ShowError($"{GetText("修改信息失败,请检查")}{User.PatientPath}{GetText("没有被占用")}"); return; } } var index = User.Patients.FindIndex(f => f.Number == v.Number); User.CurrentPatient = v; User.Patients[index] = v; } SavePatients(); InitData(); SetControl(ActionType.None); } } }
private void btnSave_Click(object sender, EventArgs e) { //ParmA.Baipingheng = tbBaipinghengA.Value; //ParmA.Baoguang = tbBaoguangA.Value; ParmA.Baohedu = tbBaoheduA.Value; ParmA.Duibidu = tbDuibiduA.Value; ParmA.Gama = tbGamaA.Value; ParmA.Liangdu = tbLiangduA.Value; ParmA.Niguangduibi = tbNiguangduibiA.Value; ParmA.Qingxidu = tbQinxiduA.Value; //ParmA.Sediao = tbSediaoA.Value; ParmA.IsChange = ParmA.Equals(CameraParm); ParmA.Type = ParmType.A; //ParmB.Baipingheng = tbBaipinghengB.Value; //ParmB.Baoguang = tbBaoguangB.Value; ParmB.Baohedu = tbBaoheduB.Value; ParmB.Duibidu = tbDuibiduB.Value; ParmB.Gama = tbGamaB.Value; ParmB.Liangdu = tbLiangduB.Value; ParmB.Niguangduibi = tbNiguangduibiB.Value; ParmB.Qingxidu = tbQinxiduB.Value; //ParmB.Sediao = tbSediaoB.Value; ParmB.IsChange = ParmB.Equals(CameraParm); ParmB.Type = ParmType.B; //ParmC.Baipingheng = tbBaipinghengC.Value; //ParmC.Baoguang = tbBaoguangC.Value; ParmC.Baohedu = tbBaoheduC.Value; ParmC.Duibidu = tbDuibiduC.Value; ParmC.Gama = tbGamaC.Value; ParmC.Liangdu = tbLiangduC.Value; ParmC.Niguangduibi = tbNiguangduibiC.Value; ParmC.Qingxidu = tbQinxiduC.Value; //ParmC.Sediao = tbSediaoC.Value; ParmC.IsChange = ParmC.Equals(CameraParm); ParmC.Type = ParmType.C; var aPath = Path.Combine(path, "Microspur.set"); var bPath = Path.Combine(path, "Panorama.set"); var cPath = Path.Combine(path, "Portrait.set"); File.WriteAllText(aPath, ParmA.ToJson()); File.WriteAllText(bPath, ParmB.ToJson()); File.WriteAllText(cPath, ParmC.ToJson()); CommHelp.ShowTips(LanguageHelp.GetTextLanguage("保存成功")); }
private void btnOK_Click(object sender, System.EventArgs e) { if (rbtUSB.Checked) { User.LinkType = LinkType.USB; this.DialogResult = DialogResult.OK; } else if (rbtWIFI.Checked) { panel2.Location = panel1.Location; panel2.Visible = true; panel1.Visible = false; LoadWifiHotSpot(); } else { CommHelp.ShowTips(label1.Text); } }
/// <summary> /// 裁剪图片并保存 /// </summary> /// <param name="Image">图片信息</param> /// <param name="maxWidth">缩略图宽度</param> /// <param name="maxHeight">缩略图高度</param> /// <param name="cropWidth">裁剪宽度</param> /// <param name="cropHeight">裁剪高度</param> /// <param name="X">X轴</param> /// <param name="Y">Y轴</param> public Bitmap MakeThumbnailImage(Image originalImage, int maxWidth, int maxHeight, int cropWidth, int cropHeight, int X, int Y) { var widthMultiple = originalImage.Width / (pictureBox1.Width * 1.0); var heightMultiple = originalImage.Height / (pictureBox1.Height * 1.0); cropWidth = maxWidth = (int)(cropWidth * widthMultiple); cropHeight = maxHeight = (int)(cropHeight * heightMultiple); X = (int)(X * widthMultiple); Y = (int)(Y * heightMultiple); if (cropWidth == 0 || cropHeight == 0) { CommHelp.ShowTips("裁剪的图片过小,请重新选择"); return(null); } Bitmap b = new Bitmap(cropWidth, cropHeight); try { using (Graphics g = Graphics.FromImage(b)) { //清空画布并以透明背景色填充 g.Clear(Color.Transparent); //在指定位置并且按指定大小绘制原图片的指定部分 g.DrawImage(originalImage, new Rectangle(0, 0, cropWidth, cropHeight), X, Y, cropWidth, cropHeight, GraphicsUnit.Pixel); Image displayImage = new Bitmap(b, maxWidth, maxHeight); Bitmap bit = new Bitmap(b, maxWidth, maxHeight); return(bit); } } catch (System.Exception e) { throw e; } finally { originalImage.Dispose(); b.Dispose(); } }
private void btnDel_Click(object sender, EventArgs e) { if (User.CurrentPatient != null) { if (CommHelp.ShowYesNoAndWarning("所有图像都将被删除") == DialogResult.Yes) { var Number = User.CurrentPatient.Number; if (Directory.Exists(dirName + "//" + Number)) { Directory.Delete(dirName + "//" + Number, true); } var index = User.Patients.FindIndex(f => f.Number == Number); User.Patients.RemoveAt(index); User.CurrentPatient = null; SavePatients(); InitData(); } } else { CommHelp.ShowTips("请选择病人!"); } }
private void btnSave_Click(object sender, EventArgs e) { if (ParmA == null) { ParmA = new VideoParm(); } ParmA.Baipingheng = tbBaipinghengA.Value; ParmA.BaipinghengAuto = chkBaipinghengA.Checked; ParmA.Baoguang = tbBaoguangA.Value; ParmA.BaoguangAuto = chkBaoguangA.Checked; ParmA.Baohedu = tbBaoheduA.Value; ParmA.Duibidu = tbDuibiduA.Value; ParmA.Gama = tbGamaA.Value; ParmA.Liangdu = tbLiangduA.Value; ParmA.Qingxidu = tbQinxiduA.Value; //ParmA.Sediao = tbSediaoA.Value; ParmA.Fenbian = ddlFenbianlvA.Text; ParmA.Gonglv = tbGonglvA.Value; ParmA.Duijiao = tbDuijiaoA.Value; ParmA.DuijiaoAuto = chkDuijiaoA.Checked; ParmA.Zengyi = tbZengyiA.Value; ParmA.IsChange = ParmA.Equals(CameraParm); ParmA.Type = ParmType.A; if (ParmB == null) { ParmB = new VideoParm(); } ParmB.Baipingheng = tbBaipinghengB.Value; ParmB.BaipinghengAuto = chkBaipinghengB.Checked; ParmB.Baoguang = tbBaoguangB.Value; ParmB.BaoguangAuto = chkBaoguangB.Checked; ParmB.Baohedu = tbBaoheduB.Value; ParmB.Duibidu = tbDuibiduB.Value; ParmB.Gama = tbGamaB.Value; ParmB.Liangdu = tbLiangduB.Value; ParmB.Qingxidu = tbQinxiduB.Value; //ParmB.Sediao = tbSediaoB.Value; ParmB.Fenbian = ddlFenbianlvB.Text; ParmB.Gonglv = tbGonglvB.Value; ParmB.Duijiao = tbDuijiaoB.Value; ParmB.DuijiaoAuto = chkDuijiaoB.Checked; ParmB.Zengyi = tbZengyiB.Value; ParmB.IsChange = ParmB.Equals(CameraParm); ParmB.Type = ParmType.B; if (ParmC == null) { ParmC = new VideoParm(); } ParmC.Baipingheng = tbBaipinghengC.Value; ParmC.BaipinghengAuto = chkBaipinghengC.Checked; ParmC.Baoguang = tbBaoguangC.Value; ParmC.BaoguangAuto = chkBaoguangC.Checked; ParmC.Baohedu = tbBaoheduC.Value; ParmC.Duibidu = tbDuibiduC.Value; ParmC.Gama = tbGamaC.Value; ParmC.Liangdu = tbLiangduC.Value; ParmC.Qingxidu = tbQinxiduC.Value; //ParmC.Sediao = tbSediaoC.Value; ParmC.Fenbian = ddlFenbianlvC.Text; ParmC.Gonglv = tbGonglvC.Value; ParmC.Duijiao = tbDuijiaoC.Value; ParmC.DuijiaoAuto = chkDuijiaoC.Checked; ParmC.Zengyi = tbZengyiC.Value; ParmC.IsChange = ParmC.Equals(CameraParm); ParmC.Type = ParmType.C; var aPath = Path.Combine(path, "Microspur.set"); var bPath = Path.Combine(path, "Panorama.set"); var cPath = Path.Combine(path, "Portrait.set"); File.WriteAllText(aPath, ParmA.ToJson()); File.WriteAllText(bPath, ParmB.ToJson()); File.WriteAllText(cPath, ParmC.ToJson()); CommHelp.ShowTips("保存成功"); }