private void CopyDirectory(object paths) { string desPath = (paths as List <string>)[(paths as List <string>).Count - 1]; for (int i = 0; i < (paths as List <string>).Count; i++) { string srcPath = (paths as List <string>)[i]; string folderName = srcPath.Substring(srcPath.LastIndexOf("\\") + 1); string desfolderdir = desPath + "\\" + folderName; if (srcPath.LastIndexOf("\\") == (desPath.Length - 1)) { desfolderdir = desPath + folderName; } string[] filenames = Directory.GetFileSystemEntries(srcPath); foreach (string file in filenames) { if (Directory.Exists(file)) { string currentdir = desfolderdir + "\\" + file.Substring(file.LastIndexOf("\\") + 1); if (!Directory.Exists(currentdir)) { Directory.CreateDirectory(currentdir); } Common.CopyDirectory(file, desfolderdir); } else { string srcfileName = file.Substring(file.LastIndexOf("\\") + 1); srcfileName = desfolderdir + "\\" + srcfileName; if (!Directory.Exists(desfolderdir)) { Directory.CreateDirectory(desfolderdir); } File.Copy(file, srcfileName); } } } Dispatcher.BeginInvoke(new Action(delegate { ErrorWindow ew = new ErrorWindow(Application.Current.FindResource("updateText1").ToString(), Application.Current.FindResource("updateText2").ToString()); ew.Show(); })); }
private void FilePath_Click(object sender, RoutedEventArgs e) { string file_path; System.Windows.Forms.OpenFileDialog op = new System.Windows.Forms.OpenFileDialog(); op.Multiselect = false; op.AddExtension = true; op.DereferenceLinks = true; if (op.ShowDialog() == System.Windows.Forms.DialogResult.OK) { file_path = op.FileName; if (UpdateCameraFW(op.SafeFileName, op.FileName)) { MessageBox.Show("update ok"); this.DialogResult = false; } } else { ErrorWindow er = new ErrorWindow(Application.Current.FindResource("upError").ToString(), Application.Current.FindResource("error6").ToString()); er.ShowDialog(); this.DialogResult = false; } }
private void okButton_Click(object sender, RoutedEventArgs e) { float black_temp = 0.0f; if (float.TryParse(balckTemp.Text, out black_temp)) { if (!(black_temp >= 33 && black_temp <= 42)) { ErrorWindow ew = new ErrorWindow(Application.Current.FindResource("numError").ToString(), Application.Current.FindResource("error1").ToString()); ew.ShowDialog(); return; } } float cwl = 0.0f; if (float.TryParse(camera_warn_limit.Text, out cwl)) { if (!(cwl >= 35 && cwl <= 42)) { ErrorWindow ew = new ErrorWindow(Application.Current.FindResource("numError").ToString(), Application.Current.FindResource("error2").ToString()); ew.ShowDialog(); return; } } float fl = 0.0f; if (float.TryParse(face_limit.Text, out fl)) { if (!(fl >= 15 && fl <= 80)) { ErrorWindow ew = new ErrorWindow(Application.Current.FindResource("numError").ToString(), Application.Current.FindResource("error3").ToString()); ew.ShowDialog(); return; } } float fc = 0.0f; if (float.TryParse(face_score.Text, out fc)) { if (!(fc >= 0.2 && fc <= 1.0)) { ErrorWindow ew = new ErrorWindow(Application.Current.FindResource("numError").ToString(), Application.Current.FindResource("error4").ToString()); ew.ShowDialog(); return; } } if (ci.state == CamContectingState.ONLINE) { var formDatas = new List <FormItemModel>(); // 温度系数 formDatas.Add(new FormItemModel() { Key = "BlackCell-Temperature", Value = balckTemp.Text // "id-test-id-test-id-test-id-test-id-test-" }); formDatas.Add(new FormItemModel() { Key = "Report-URL", Value = address.Text // "id-test-id-test-id-test-id-test-id-test-" }); formDatas.Add(new FormItemModel() { Key = "Camera-Threshold", Value = camera_warn_limit.Text }); formDatas.Add(new FormItemModel() { Key = "Face-LimitSize", Value = face_limit.Text }); formDatas.Add(new FormItemModel() { Key = "Face-Score", Value = face_score.Text }); if (temp_check.IsChecked == true) { formDatas.Add(new FormItemModel() { Key = "Upgrade-Coefficient", Value = temp_value.Text }); } fi = formDatas; CameraInfo cameraInfo = new CameraInfo(); //cameraInfo.IP = ip.Text; cameraInfo.Name = ci.Name; cameraInfo.IP = ci.IP; cameraInfo.Device_Name = ci.Device_Name; cameraInfo.Date = DateTime.Now; cameraInfo.BlackCell_Temp = balckTemp.Text; cameraInfo.Report_URL = address.Text; AIThermometerAPP.Instance().cameras_config.UpdateCam(cameraInfo); AIThermometerAPP.Instance().SaveCameraConfigs(); DialogResult = true; } else { CameraInfo cameraInfo = new CameraInfo(); cameraInfo.Name = ci.Name; cameraInfo.IP = ip.Text; //.IP; //cameraInfo.Device_Name = ci.Device_Name; cameraInfo.Date = DateTime.Now; //cameraInfo.BlackCell_Temp = balckTemp.Text; //cameraInfo.Report_URL = address.Text; AIThermometerAPP.Instance().cameras_config.UpdateCam(cameraInfo); AIThermometerAPP.Instance().SaveCameraConfigs(); DialogResult = true; } }
private void okButton_Click(object sender, RoutedEventArgs e) { LocalSetting localSetting = new LocalSetting(); localSetting.local_url = ip.Text; try { localSetting.local_port = int.Parse(port.Text); int wn = int.Parse(warn_number.Text); int cd = int.Parse(clean_day.Text); float ts = float.Parse(threshold.Text); localSetting.camera_auto_start = (bool)autoconCheckBox.IsChecked; if (wn > 30 || wn < 10) { ErrorWindow er = new ErrorWindow("Value error", "Our of range.(10-30)"); er.ShowDialog(); return; } else if (cd < 15 || cd > 180) { ErrorWindow er = new ErrorWindow("Value error", "Our of range.(15-180)"); er.ShowDialog(); return; } else if (ts < 35 || ts > 42) { ErrorWindow er = new ErrorWindow("Value error", "Our of range.(35-42)"); er.ShowDialog(); return; } localSetting.warning_bar_length = wn; localSetting.temp_limit = ts; localSetting.clean_day = cd; } catch { ErrorWindow er = new ErrorWindow("Value error", "Input value error, Please check."); er.ShowDialog(); return; } lanageClass dic = lanageCombo.SelectedItem as lanageClass; if (dic != null) { localSetting.language = dic.key; } ErrorWindow ew = null; if (localSetting.language != _lanage) { ew = new ErrorWindow(System.Windows.Application.Current.FindResource("warn").ToString(), System.Windows.Application.Current.FindResource("warn1").ToString()); } AIThermometerAPP.Instance().config = localSetting; AIThermometerAPP.Instance().SaveConfigs(); if (ew == null) { DialogResult = true; return; } ew.ShowDialog(); System.Windows.Forms.Application.Restart(); System.Windows.Application.Current.Shutdown(); }