private void BlackcellButton_Click(object sender, RoutedEventArgs e)
        {
            string shot_path = AIThermometerAPP.Instance().TmpPath() + "\\" + Guid.NewGuid().ToString() + ".jpeg";

            if (!Shot(shot_path, CamMode.IR))
            {
                ErrorWindow ew = new ErrorWindow(Application.Current.FindResource("errorText").ToString(), Application.Current.FindResource("errorText2").ToString());
                ew.ShowDialog();
                return;
            }

            BlackCellSettingWindow bc = new BlackCellSettingWindow(shot_path, vlcWindow.ip);

            if (bc.Init())
            {
                if (bc.ShowDialog() == true)
                {
                    Thread t = new Thread(new ThreadStart(new Action(() =>
                    {
                        PostToHW(bc.POSJSON, vlcWindow.ip);
                    }
                                                                     )));
                    t.Start();
                }
            }
        }
        private void delCamButton_Click(object sender, RoutedEventArgs e)
        {
            CameraController camera = listView.SelectedItem as CameraController;

            if (camera == null)
            {
                return;
                //MessageBox.Show(Application.Current.FindResource("delCameraWarnText").ToString());
            }

            if (camera.ConnectState() == CamContectingState.ONLINE)
            {
                ErrorWindow er = new ErrorWindow(Application.Current.FindResource("errorText").ToString(), Application.Current.FindResource("pleaseDisconnect").ToString());
                er.ShowDialog();
                //MessageBox.Show(Application.Current.FindResource("delCameraWarnText").ToString());
                return;
            }
            MessageWindow mw = new MessageWindow(Application.Current.FindResource("delText").ToString(), Application.Current.FindResource("delText1").ToString());

            mw.ShowDialog();
            if (mw.DialogResult == true)
            {
                AIThermometerAPP.Instance().cameras_config.DeleteCamByName(camera.c_name);
                AIThermometerAPP.Instance().SaveCameraConfigs();
                listView.Items.Remove(camera);
            }
        }
        // 添加摄像头
        private void addCamButton_Click(object sender, RoutedEventArgs e)
        {
            AddCameraWindow ac = new AddCameraWindow();

            ac.ShowDialog();
            // 点击确定的话
            if (ac.DialogResult == true)
            {
                // 锁定添加
                if (AIThermometerAPP.Instance().cameras_config.Cameras.Count >= 1)
                {
                    ErrorWindow er = new ErrorWindow(Application.Current.FindResource("errorText").ToString(), Application.Current.FindResource("errorText1").ToString());
                    er.ShowDialog();
                    return;
                }

                Dispatcher.BeginInvoke(new Action(delegate
                {
                    CameraController cameraController = new CameraController(ac.GetCameraInfo());
                    listView.Items.Add(cameraController);
                }));
                // 储存camera信息到系统单例,然后保存到文件
                if (AIThermometerAPP.Instance().cameras_config.AddCam(ac.GetCameraInfo()))
                {
                    AIThermometerAPP.Instance().SaveCameraConfigs();
                    LogHelper.WriteLog("Added camerainfo to camera list. And saved!");
                }
                else
                {
                    // 添加不成功
                }
                //AIThermometerAPP.Instance().cameras_config.Cameras.Add(ac.GetCameraInfo());
            }
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
        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;
            }
        }
예제 #6
0
        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();
        }