private void AutoComplete_SelectItemEvent(object sender, DataAutoComplete e)
 {
     preset           = new Code.Camera_Preset();
     preset.camera_id = int.Parse(e.key);
     for (int i = 0; i < App.DataCamera.Count; i++)
     {
         if (App.DataCamera[i].id == preset.camera_id)
         {
             this.Camera = App.DataCamera[i];
             if (this.Camera.m_lUserID == -1)
             {
                 this.Camera.Login();
             }
             if (this.Camera.m_lUserID != -1)
             {
                 this.Preview();
             }
             else
             {
                 MessageBox.Show("Không thể đăng nhập camera");
             }
             break;
         }
     }
 }
Exemple #2
0
 private void SaveCamera(object sender, MouseButtonEventArgs e)
 {
     if (this.UIName.isEmpty())
     {
         MessageBox.Show("Tên Camera không được để trống", "Thông báo");
         return;
     }
     if (this.UIIP.isEmpty())
     {
         MessageBox.Show("Địa chỉ ip không được để trống", "Thông báo");
         return;
     }
     if (this.UIUser.isEmpty())
     {
         MessageBox.Show("Tên đăng nhập không được phép để trống", "Thông báo");
         return;
     }
     if (this.UIPass.Password == "")
     {
         MessageBox.Show("Mật khấu đăng nhập không được phép để trống", "Thông báo");
         return;
     }
     if (this.UIPass.Password != UIPass_Copy.Password)
     {
         MessageBox.Show("Xác nhập mật khẩu không khớp", "Thông báo");
         return;
     }
     if (this.UIPort.isEmpty())
     {
         MessageBox.Show("Cổng truy câp camera không được phép để trống", "Thông báo");
         return;
     }
     if (this.UIPortRtsp.isEmpty())
     {
         MessageBox.Show("Cổng truy cập rtsp không được phép để trống", "Thông báo");
         return;
     }
     Code.Camera cam = new Code.Camera(this.UIIP.Text.Trim());
     cam.admin     = this.UIUser.Text.Trim();
     cam.pass      = this.UIPass.Password;
     cam.name      = this.UIName.Text;
     cam.port      = Convert.ToInt32(this.UIPort.Text);
     cam.port_rtsp = Convert.ToInt32(this.UIPortRtsp.Text);
     App.DataCamera.Add(cam);
     if (this.CloseEvent != null)
     {
         this.CloseEvent(this, new EventArgs());
     }
 }
 private void SaveCamera(object sender, MouseButtonEventArgs e)
 {
     if (this.UIName.isEmpty())
     {
         MessageBox.Show("Tên Camera không được để trống", "Thông báo");
         return;
     }
     if (this.UIIP.isEmpty())
     {
         MessageBox.Show("Địa chỉ ip không được để trống", "Thông báo");
         return;
     }
     if (this.UIUser.isEmpty())
     {
         MessageBox.Show("Tên đăng nhập không được phép để trống","Thông báo");
         return;
     }
     if (this.UIPass.Password == "")
     {
         MessageBox.Show("Mật khấu đăng nhập không được phép để trống", "Thông báo");
         return;
     }
     if (this.UIPass.Password != UIPass_Copy.Password)
     {
         MessageBox.Show("Xác nhập mật khẩu không khớp", "Thông báo");
         return;
     }
     if (this.UIPort.isEmpty())
     {
         MessageBox.Show("Cổng truy câp camera không được phép để trống", "Thông báo");
         return;
     }
     if (this.UIPortRtsp.isEmpty())
     {
         MessageBox.Show("Cổng truy cập rtsp không được phép để trống", "Thông báo");
         return;
     }
     Code.Camera cam = new Code.Camera(this.UIIP.Text.Trim());
     cam.admin = this.UIUser.Text.Trim();
     cam.pass = this.UIPass.Password;
     cam.name = this.UIName.Text;
     cam.port = Convert.ToInt32(this.UIPort.Text);
     cam.port_rtsp = Convert.ToInt32(this.UIPortRtsp.Text);
     App.DataCamera.Add(cam);
     if (this.CloseEvent != null)
     {
         this.CloseEvent(this, new EventArgs());
     }
 }
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (this.Camera != null)
     {
         if (this.Camera.m_lUserID == -1)
         {
             this.Camera.Login();
         }
         if (this.Camera.m_lUserID != -1)
         {
             this.Preview();
         }
         else
         {
             MessageBox.Show("Không thể đăng nhập camera");
         }
     }
     else if (preset != null)
     {
         isEdit = true;
         for (int i = 0; i < App.DataCamera.Count; i++)
         {
             if (App.DataCamera[i].id == preset.camera_id)
             {
                 this.Camera = App.DataCamera[i];
                 if (this.Camera.m_lUserID == -1)
                 {
                     this.Camera.Login();
                 }
                 if (this.Camera.m_lUserID != -1)
                 {
                     this.Preview();
                 }
                 else
                 {
                     MessageBox.Show("Không thể đăng nhập camera");
                 }
                 break;
             }
         }
     }
 }
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
    
     if (this.Camera != null)
     {
         if (this.Camera.m_lUserID == -1)
             this.Camera.Login();
         if (this.Camera.m_lUserID != -1)
         {
             this.Preview();
         }
         else
         {
             MessageBox.Show("Không thể đăng nhập camera");
         }
     }
     else if(preset!=null)
     {
         isEdit = true;
         for (int i = 0; i < App.DataCamera.Count; i++)
         {
             if (App.DataCamera[i].id == preset.camera_id)
             {
                 this.Camera = App.DataCamera[i];
                 if (this.Camera.m_lUserID == -1)
                     this.Camera.Login();
                 if (this.Camera.m_lUserID != -1)
                 {
                     this.Preview();
                 }
                 else
                 {
                     MessageBox.Show("Không thể đăng nhập camera");
                 }
                 break;
             }
         }
     }
 }
 private void AutoComplete_SelectItemEvent(object sender, DataAutoComplete e)
 {
     preset = new Code.Camera_Preset();
     preset.camera_id = int.Parse(e.key);
     for (int i = 0; i < App.DataCamera.Count; i++)
     {
         if (App.DataCamera[i].id == preset.camera_id)
         {
             this.Camera = App.DataCamera[i];
             if (this.Camera.m_lUserID == -1)
                 this.Camera.Login();
             if (this.Camera.m_lUserID != -1)
             {
                 this.Preview();
             }
             else
             {
                 MessageBox.Show("Không thể đăng nhập camera");
             }
             break;
         }
     }
 }