/// <summary> /// 关闭摄像头 /// </summary> private void CloseVideo() { try { ChannelListItemViewModel lbi = ChannelManageListBox.SelectedItem as ChannelListItemViewModel; if (lbi.IsOpened == true) { currentVideo--; foreach (WindowsFormsHost wfh in wFHList) { if (wfh.Tag != null && wfh.Tag.ToString() == lbi.MyChannelCfg.TcChaneelID) { (wfh.Child as UserControl1).closecamera(); wfh.Child = null; wfh.Tag = null; } } lbi.IsOpened = false; } } catch (Exception ex) { _WriteLog.WriteToLog("CloseVideo", ex); } }
/// <summary> /// 删除频道 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeletePassageWay_Click(object sender, RoutedEventArgs e) { try { int success = -1; if (ChannelManageListBox.SelectedIndex < 0) { MyMessage.showYes("请选中需要删除的通道!"); return; } ChannelListItemViewModel lbi = ChannelManageListBox.SelectedItem as ChannelListItemViewModel; bool?result = MyMessage.Show("是否删除通道?"); if (result == true) { success = thirft.DelChannel(lbi.MyChannelCfg.TcChaneelID); if (success == 0) { MyMessage.showYes("删除通道成功!"); CloseVideo(); _ChannelManageViewModel.RefreshChannelList(); } else { MyMessage.showYes("删除通道失败!"); } } } catch (Exception ex) { MyMessage.showYes("删除通道失败!"); _WriteLog.WriteToLog("btnDeletePassageWay_Click", ex); } }
/// <summary> /// 双击通道打开视频 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChannelManageListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { ChannelListItemViewModel lbi = (sender as ListBox).SelectedItem as ChannelListItemViewModel; if (lbi == null) { return; } string ip = lbi.MyChannelCfg.CaptureCfg.TcAddr; if (ip == string.Empty) { System.Windows.MessageBox.Show("摄像机IP为空!"); return; } if (lbi.IsOpened == false) { lbi.IsOpened = true; currentVideo++; UserControl1 usercontrol = new UserControl1(); usercontrol.opencamera(lbi.MyChannelCfg.CaptureCfg.NCaptureType, lbi.MyChannelCfg.CaptureCfg.TcAddr + "|" + lbi.MyChannelCfg.TcDescription, (uint)lbi.MyChannelCfg.CaptureCfg.NPort, lbi.MyChannelCfg.CaptureCfg.TcUID, lbi.MyChannelCfg.CaptureCfg.TcPSW, 1, 1); foreach (WindowsFormsHost wfh in wFHList) { if (wfh.Tag == null) { wfh.Child = usercontrol; wfh.Tag = lbi.MyChannelCfg.TcChaneelID; break; } } if (currentVideo > currentMaxvideo) { SetVideoGridScreen(currentVideo); } this.UpdateLayout(); } else { currentVideo--; foreach (WindowsFormsHost wfh in wFHList) { if (wfh.Tag != null && wfh.Tag.ToString() == lbi.MyChannelCfg.TcChaneelID) { (wfh.Child as UserControl1).closecamera(); wfh.Child = null; wfh.Tag = null; break; } } lbi.IsOpened = false; } } catch (Exception ex) { _WriteLog.WriteToLog("ChannelManageListBox_MouseDoubleClick", ex); MessageBox.Show(ex.Message); } }
/// <summary> /// 修改频道 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnModifyPassageWay_Click(object sender, RoutedEventArgs e) { //todo(已经完成未测试) 先关闭视频 再进行修改 if (ChannelManageListBox.SelectedIndex < 0) { MyMessage.showYes("请选中需要修改的通道!"); return; } ChannelListItemViewModel lbi = ChannelManageListBox.SelectedItem as ChannelListItemViewModel; ChannelInfo channelInfo = new ChannelInfo(); channelInfo.RefreshChannelDelegate = _ChannelManageViewModel.RefreshChannelList; channelInfo.CloseVideoDelegate = CloseVideo; channelInfo.SetChannelInfo(lbi.MyChannelCfg); channelInfo.ShowDialog(); }
private void IniVideo() { try { lbi = viewModel.CurrentPointChannelListItem; if (lbi == null) { return; } txtChannelname.Text = lbi.MyChannelCfg.Name; string ip = lbi.MyChannelCfg.CaptureCfg.TcAddr; if (ip == string.Empty) { System.Windows.MessageBox.Show("摄像机IP为空!"); return; } lbi.IsOpened = true; UserControl1 usercontrol = new UserControl1(); usercontrol.opencamera(lbi.MyChannelCfg.CaptureCfg.NCaptureType, lbi.MyChannelCfg.CaptureCfg.TcAddr + "|" + lbi.MyChannelCfg.TcDescription, (uint)lbi.MyChannelCfg.CaptureCfg.NPort, lbi.MyChannelCfg.CaptureCfg.TcUID, lbi.MyChannelCfg.CaptureCfg.TcPSW, 1, 1); if (wfh.Tag == null) { wfh.Child = usercontrol; wfh.Tag = lbi.MyChannelCfg.TcChaneelID; } this.VideoPartGrid.Children.Add(wfh); this.UpdateLayout(); } catch (Exception ex) { Logger <OperaExcel> .Log.Error("IniVideo", ex); } }