public void CompleteMonitorSetting(string subscribeIP, string monitorDirectory) { if (MonitorCollection.Any(m => m.MonitorDirectory == monitorDirectory && m.SubscribeIP == subscribeIP)) { return; } var monitor = MonitorCollection.FirstOrDefault(m => m.MonitorDirectory == monitorDirectory); if (monitor == null) { return; } if (string.IsNullOrEmpty(monitor.SubscribeIP)) { monitor.SubscribeIP = subscribeIP; } else { App.Current.Dispatcher.BeginInvoke(new Action(() => { MonitorCollection.Add(new MonitorModel() { MonitorDirectory = monitorDirectory, SubscribeIP = subscribeIP }); })); } }
public void DeserializeMonitors(MonitorCollection destination, XmlReader xmlReader) { int i = 1; if (xmlReader.Name.Equals("Monitors")) { if (!xmlReader.IsEmptyElement) { xmlReader.ReadStartElement("Monitors"); while (xmlReader.NodeType != XmlNodeType.EndElement) { Monitor display = DeserializeMonitor(xmlReader); if (display != null) { display.Name = "Monitor " + i++; destination.Add(display); } } xmlReader.ReadEndElement(); } else { xmlReader.Read(); } } }
private void ExecuteAddMonitorCommand() { var dlg = new FolderBrowserDialog(); dlg.Description = @"请选择监控文件夹目录"; if (dlg.ShowDialog() == DialogResult.OK) { string selectedPath = dlg.SelectedPath; if (MonitorCollection.FirstOrDefault(m => m.MonitorDirectory == selectedPath) == null) { MonitorCollection.Add(new MonitorModel() { MonitorDirectory = selectedPath }); } else { MessageBox.Show("所选文件夹已在监控目录中!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private bool MonitorEnum(IntPtr hMonitor, IntPtr hdcMonitor, ref System.Drawing.Rectangle lprcMonitor, IntPtr dwData) { _monitorCollection.Add(hMonitor); return(true); }