// Add new page to the collection public void Add(VsPage page) { try { InnerList.Add(page); } catch (Exception err) { logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);; } }
// Remove page from the collection public void Remove(VsPage page) { try { InnerList.Remove(page); } catch (Exception err) { logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);; } }
private void buttonConnecter_Click(object sender, EventArgs e) { switch (vsPropertyType) { case VsDeviceType.CAMERA: { this.vsCamera = vsCoreMonitor.GetCameraByName(vsTypeName); if (vsCamera == null) return; if (vsCamera.Running) vsCoreMonitor.DisconnectCamera(vsTypeName); else vsCoreMonitor.ConnectCamera(vsTypeName, false); } break; case VsDeviceType.CHANNEL: { this.vsChannel = vsCoreMonitor.GetChannelByName(vsTypeName); if (vsChannel == null) return; if (vsChannel.Running) vsCoreMonitor.DisconnectChannel(vsTypeName); else vsCoreMonitor.ConnectChannel(vsTypeName, false); } break; case VsDeviceType.PAGE: { this.vsPage = vsCoreMonitor.GetPageByName(vsTypeName); if (vsPage == null) return; if (vsPage.Running) vsCoreMonitor.DisconnectPage(vsTypeName); else vsCoreMonitor.ConnectPage(vsTypeName, false); } break; } }
public void ActivatePropertyControl(VsDeviceType propType, String propName) { vsPropertyType = propType; vsTypeName = propName; this.Enabled = true; switch (vsPropertyType) { case VsDeviceType.CAMERA: CameraProperty(); this.vsCamera = vsCoreMonitor.GetCameraByName(vsTypeName); break; case VsDeviceType.CHANNEL: ChannelProperty(); this.vsChannel = vsCoreMonitor.GetChannelByName(vsTypeName); break; case VsDeviceType.PAGE: PageProperty(); this.vsPage = vsCoreMonitor.GetPageByName(vsTypeName); break; } }
// Load vsPages private void LoadPages(XmlTextReader reader) { try { // load all vsPages while (reader.Name == "Page") { int depth = reader.Depth; // create new camera VsPage page = new VsPage(reader.GetAttribute("name"), SyncTimer); page.PageID = int.Parse(reader.GetAttribute("id")); page.Description = reader.GetAttribute("desc"); // read vsCameras string[] strIDs = reader.GetAttribute("channels").Split(','); for (int i = 0; i < VsPage.MaxChannel; i++) { int id = int.Parse(strIDs[i]); page.SetChannel(id, GetChannelByID(id)); } // add page vsPages.Add(page); if (page.PageID >= vsNextPageID) vsNextPageID = page.PageID + 1; // move to next node reader.Read(); // move to next element node while (reader.NodeType == XmlNodeType.EndElement) reader.Read(); if (reader.Depth < depth) return; } } catch (Exception err) { logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);; } }
// Check page public bool CheckPage(VsPage page) { try { foreach (VsPage p in vsPages) { if ((page.PageName == p.PageName) && ((page.PageID == 0) || (page.PageID != p.PageID))) return false; } return true; } catch (Exception err) { logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);; } return false; }
// Delete page public bool DeletePage(VsPage page) { try { vsPages.Remove(page); // save if (bSaveConfig) SavePages(); return true; } catch (Exception ex) { Console.WriteLine(ex.Message); } return false; }
// Add channel public bool AddPage(String pageName, String[] channelList) { try { // if this name is already exist if (GetPageByName(pageName) != null) return false; VsPage vsPage = new VsPage(pageName, SyncTimer); foreach (String channelName in channelList) { VsChannel vsChannel = GetChannelByName(channelName); if (vsChannel != null) vsPage.SetChannel(vsChannel.ChannelID, vsChannel); } // add to page collection AddPage(vsPage); return true; } catch (Exception ex) { Console.WriteLine(ex.Message); } return false; }
// Add new page public void AddPage(VsPage page) { try { page.PageID = vsNextPageID++; vsPages.Add(page); // save if (bSaveConfig) SavePages(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }