Пример #1
0
        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            string ip        = e.Argument as string;
            var    formDatas = new List <FormItemModel>();

            // 文件名
            formDatas.Add(new FormItemModel()
            {
                Key   = "",
                Value = "",
            });

            try
            {
                //提交表单
                var result = FormPost.PostForm("http://" + ip + ":9300/config", null);
                //cameraInfo.IP = ip.Text;
                CameraResponse cr = JsonHelper.FromJSON <CameraResponse>(result);

                Console.WriteLine(result);
                LogHelper.WriteLog(result);
                e.Result = cr;
            }
            catch (Exception)
            {
                e.Result = null;
            }
        }
Пример #2
0
        public bool Init()
        {
            /*
             * string location_json = "";
             * // Http get
             * //location_json = HttpRequestHelper.HttpGet1("http://192.168.0.119:9300/config");
             * //location_json = http_request.HttpGet("http://192.168.0.119:9300/config", "");
             * location_json = http_request.HttpGet("http://" + request_ip + ":9300/config", "");
             *
             * if (location_json == "")
             *  return false;
             * //LogHelper.WriteLog("fffff"+location_json);
             * // test_string
             * cr = JsonHelper.FromJSON<CameraResponse>(location_json);
             * //  MessageBox.Show(cr.SavedParams.Camera_IP);
             */
            cr             = new CameraResponse();// .SavedParams.BlackCell_Position[0] = Leftup_Pos_X;
            cr.SavedParams = new CameraSavedParams();
            cr.SavedParams.BlackCell_Position = new List <float>();
            cr.SavedParams.BlackCell_Position.Add(0.0f);
            cr.SavedParams.BlackCell_Position.Add(0.0f);
            cr.SavedParams.BlackCell_Position.Add(0.0f);
            cr.SavedParams.BlackCell_Position.Add(0.0f);
            if (!Common.FileExists(file_path))
            {
                return(false);
            }

            using (FileStream fs = new FileStream(file_path, FileMode.Open, FileAccess.Read)) //将图片以文件流的形式进行保存

            {
                BinaryReader br         = new BinaryReader(fs);
                byte[]       imgBytesIn = br.ReadBytes((int)fs.Length); //将流读入到字节数组中

                BitmapImage myBitmapImage = new BitmapImage();
                myBitmapImage.BeginInit();
                myBitmapImage.StreamSource = new MemoryStream(imgBytesIn);
                myBitmapImage.EndInit();
                imagebox.Source = myBitmapImage;



                //Leftup_Pos_X = cr.SavedParams.BlackCell_Position[0];
                //Leftup_Pos_Y = cr.SavedParams.BlackCell_Position[1];
                // Rightdown_Pos_X = cr.SavedParams.BlackCell_Position[2];
                // Rightdown_Pos_Y = cr.SavedParams.BlackCell_Position[3];

                float lx = (float)(image_width * Leftup_Pos_X);    // cr.SavedParams.BlackCell_Position[0]);
                float ly = (float)(image_height * Leftup_Pos_Y);   // cr.SavedParams.BlackCell_Position[1]);
                float rx = (float)(image_width * Rightdown_Pos_X); // cr.SavedParams.BlackCell_Position[2]);
                float ry = (float)(image_height * Leftup_Pos_Y);   // cr.SavedParams.BlackCell_Position[3]);

                canvas.Children.Clear();
                Rectangle rect = new Rectangle
                {
                    Stroke          = Brushes.Black,
                    StrokeThickness = 1,
                    Height          = 10,
                    Width           = 10,
                };
                Canvas.SetLeft(rect, lx);
                Canvas.SetTop(rect, ly);
                Canvas.SetRight(rect, rx);
                Canvas.SetBottom(rect, ry);
                canvas.Children.Add(rect);
                return(true);
            }
        }