Esempio n. 1
0
        public string CaptureView()
        {
            string day  = DateTime.Now.ToString("yyyyMMdd");       //取系统时间
            string time = DateTime.Now.ToString("yyyyMMddHHmmss"); //取系统时间
            string path = day + "\\c-" + time + ".jpg";

            if (a == 1)
            {
                if (HkAction.CapturePicture(path))//调用SDK截图方法
                {
                    //MessageBox.Show("截图成功,保存在:" + path, "提示", MessageBoxButtons.OK);
                }
                else
                {
                    path = "";
                    MessageBox.Show("截图失败", "提示", MessageBoxButtons.OK);
                }
            }
            else
            {
                MessageBox.Show("请先点击“开始”按钮!", "提示", MessageBoxButtons.OK);
                path = "";
            }
            return(path);
        }
Esempio n. 2
0
        public FormCamera()
        {
            InitializeComponent();
            createBox();
            {
                Ini ini = new Ini(Application.StartupPath + "\\App.ini");
                PhoneNumber = ini.Read("Camera", "PhoneNumber");
                AppKey      = ini.Read("Camera", "AppKey");
                SecretKey   = ini.Read("Camera", "SecretKey");
            }


            HkAction.init(PhoneNumber, AppKey, SecretKey);

            HkAction.MainForm = this;
            try
            {
                HkAction.Start(); //进入系统自动初始化库
            }
            catch (Exception ex)  //出现异常则提示
            {
                MessageBox.Show("异常!" + ex.ToString(), "提示", MessageBoxButtons.OK);
            }
            //this.Show();
            //this.TopMost = true;
        }
Esempio n. 3
0
        private void btnCapt_Click(object sender, EventArgs e)
        {
            HkAction.MainForm.Hide();
            string time = DateTime.Now.ToString("yyyyMMddHHmmss"); //取系统时间

            if (a == 1)
            {
                string path1 = ShowSaveFileDialog(time);//获取用户选择路径
                if (path1 == null)
                {
                    MessageBox.Show("截图取消", "提示", MessageBoxButtons.OK);
                    return;
                }

                string path = path1 + "-" + time + ".jpg";//保存路径和文件名(用户选择路径)
                //string path = @"C:\Users\Administrator\Downloads\"+time + ".jpg";//指定路径

                if (HkAction.CapturePicture(path))//调用SDK截图方法
                {
                    MessageBox.Show("截图成功,保存在:" + path, "提示", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("截图失败", "提示", MessageBoxButtons.OK);
                }
            }
            else
            {
                MessageBox.Show("请先点击“开始”按钮!", "提示", MessageBoxButtons.OK);
            }

            HkAction.MainForm.Show();
        }
Esempio n. 4
0
 private void stopPlay()
 {
     for (int g = 0; g <= j; g++)
     {
         HkAction.Stop(SessionId[g]);
     }
     Array.Clear(cameraid1, 0, cameraid1.Length);
     Array.Clear(SessionId, 0, SessionId.Length);
     Array.Clear(handle, 0, handle.Length);
     Array.Clear(picbox, 0, picbox.Length);
     createBox();
     j = 0;
     a = 0;
 }
Esempio n. 5
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     for (int g = 0; g <= j; g++)
     {
         HkAction.Stop(SessionId[g]);
     }
     Array.Clear(cameraid1, 0, cameraid1.Length);
     Array.Clear(SessionId, 0, SessionId.Length);
     Array.Clear(handle, 0, handle.Length);
     Array.Clear(picbox, 0, picbox.Length);
     createBox();
     j = 0;
     a = 0;
 }
Esempio n. 6
0
        private void picbox_MouseClick(object sender, MouseEventArgs e)
        {
            PictureBox picb1 = sender as PictureBox;//取出点击的控件sender
            string     name  = "";

            if (picb1 != null)//点击则非空,否则为空
            {
                string _name = picb1.Name;
                name = _name.Substring(_name.Length - 1, 1); //取名字中最后一个字,它正好是控件的index
            }
            int n = Util.toInt(name);                        //string 转换int

            JObject oCamera = getCamera(n);

            cameraid = oCamera["cameraId"].ToString();; //取出该摄像头id
            if (a == 1 && c != 1)
            {
                for (int t = 0; t < 9; t++)
                {
                    if (cameraid == cameraid1[t])//检查视频是否已在播放中
                    {
                        MessageBox.Show("该视频已经在播放中,请勿重复点击!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }
            cameraid1[j] = cameraid;
            string isEncrypt = oCamera["isEncrypt"].ToString();; //取出该摄像头id

            statu = jsonHandle1(n);
            if (isEncrypt == "1")//视频已加密,需要调用萤石接口发送短信验证码
            {
                MessageBox.Show("该视频已加密,暂时不能播放!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //return;
            }
            else
            {
                if (c == 1)//单画面
                {
                    handle[0] = picbox[0].Handle;
                    if (a == 1)
                    {
                        bool close = HkAction.Stop(SessionId[j]);
                    }
                    Start_Play1();
                    j = 0;
                }
            }
        }
Esempio n. 7
0
 private void startall()
 {
     try
     {
         for (int s = 0; s < j; s++)
         {
             HkAction.Play(handle[s], cameraid1[s], SessionId[s]);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("异常" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     a = 1;
 }
Esempio n. 8
0
        public int getDeviceList()
        {
            int n = 0;

            this.flowLayoutPanel1.Controls.Clear();
            try
            {
                string getList = HkAction.playList();
                jsonstr = getList;
                n       = jsonHandle(jsonstr);
            }
            catch (Exception ex)//出现异常则提示
            {
                MessageBox.Show("异常!" + ex.ToString(), "提示", MessageBoxButtons.OK);
            }
            return(n);
        }
Esempio n. 9
0
        public bool login()
        {
            bool bret = false;

            try
            {
                if (HkAction.GetAccessToken() != null)
                {
                    bLogin = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("视频用户登录失败!", "警告", MessageBoxButtons.OK);
                bLogin = false;
            }
            return(bLogin);
        }
Esempio n. 10
0
        public void Start_Play(int index)
        {
            JObject oCamera = getCamera(index);

            j            = index;
            cameraid     = oCamera["cameraId"].ToString();;      //取出该摄像头id
            cameraid1[j] = cameraid;
            string isEncrypt = oCamera["isEncrypt"].ToString();; //取出该摄像头id

            if (isEncrypt == "1")                                //视频已加密,需要调用萤石接口发送短信验证码
            {
                MessageBox.Show("该视频已加密,暂时不能播放!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                handle[0] = picbox[0].Handle;
                if (a == 1)
                {
                    bool close = HkAction.Stop(SessionId[j]);
                }
                Start_Play1();
            }
        }
Esempio n. 11
0
 private void Start_Play1()
 {
     SessionId[j] = HkAction.AllocSession(); //每次点击存放session
     if (SessionId[j] != null)               //每次播放申请会话
     {
         bool play;
         try
         {
             play = HkAction.Play(handle[0], cameraid1[j], SessionId[j]);
             if (play == true)
             {
                 a = 1;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("异常:" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("申请会话异常!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }