public NetServiceDocumentControl(NetServiceDocument document) { InitializeComponent(); if (components == null) { components = new Container(); } _serviceControl = (Control)Activator.CreateInstance(GetControlTypeForDocument(document), document); _readOnlyControl = _serviceControl as IReadOnlyControl; panelSettings.Controls.Add(_serviceControl); _serviceControl.Dock = DockStyle.Fill; _document = document; packetLogControl.LogName = _document.Name; packetLogControl.ReadOnly = !PacketLogMutable; packetLogControl.SetPackets(_document.Packets); metaEditorControl.Meta = _document.GlobalMeta; networkHistoryControl.SetDocument(_document); _defaultGraph = "Default"; _fileLogs = new Dictionary<Guid, FileRedirectLogEntry>(); Disposed += new EventHandler(NetServiceControl_Disposed); credentialsEditorControl.SetCredentials(_document.Credentials); PacketLogControlConfig config = document.GetProperty(PACKETLOG_CONFIG) as PacketLogControlConfig; if (config != null) { packetLogControl.Config = config; } Text = _document.Name; UpdateNetgraphs(); comboBoxNetgraph.SelectedItem = null; foreach (object item in comboBoxNetgraph.Items) { NetGraphDocument doc = item as NetGraphDocument; if (doc == _document.NetGraph) { comboBoxNetgraph.SelectedItem = item; break; } } }
public NetServiceDocumentControl(NetServiceDocument document) { InitializeComponent(); if (components == null) { components = new Container(); } _serviceControl = (Control)Activator.CreateInstance(GetControlTypeForDocument(document), document); _readOnlyControl = _serviceControl as IReadOnlyControl; panelSettings.Controls.Add(_serviceControl); _serviceControl.Dock = DockStyle.Fill; _document = document; packetLogControl.LogName = _document.Name; packetLogControl.ReadOnly = !PacketLogMutable; packetLogControl.SetPackets(_document.Packets); metaEditorControl.Meta = _document.GlobalMeta; networkHistoryControl.SetDocument(_document); _defaultGraph = "Default"; _fileLogs = new Dictionary <Guid, FileRedirectLogEntry>(); Disposed += new EventHandler(NetServiceControl_Disposed); credentialsEditorControl.SetCredentials(_document.Credentials); PacketLogControlConfig config = document.GetProperty(PACKETLOG_CONFIG) as PacketLogControlConfig; if (config != null) { packetLogControl.Config = config; } Text = _document.Name; UpdateNetgraphs(); comboBoxNetgraph.SelectedItem = null; foreach (object item in comboBoxNetgraph.Items) { NetGraphDocument doc = item as NetGraphDocument; if (doc == _document.NetGraph) { comboBoxNetgraph.SelectedItem = item; break; } } }
private Type GetControlTypeForDocument(NetServiceDocument document) { foreach (var ext in DocumentEditorManager.Instance.GetExtensions()) { DocumentEditorAttribute attr = (DocumentEditorAttribute)ext.ExtensionAttribute; if (ext.ExtensionAttribute.DocumentType == document.GetType()) { return(ext.ExtensionType); } } if (document is FixedProxyDocument) { return(typeof(FixedProxyControl)); } else if (document is SocksProxyDocument) { return(typeof(GenericProxyControl)); } else if (document is HttpProxyDocument) { return(typeof(GenericProxyControl)); } else if (document is NetServerDocument) { return(typeof(NetServerControl)); } else if (document is NetAutoClientDocument) { return(typeof(NetAutoClientControl)); } else if (document is FullHttpProxyDocument) { return(typeof(GenericProxyControl)); } throw new ArgumentException("Unknown document type"); }
public void SetDocument(NetServiceDocument document) { _document = document; UpdateHistory(); }
private Type GetControlTypeForDocument(NetServiceDocument document) { foreach(var ext in DocumentEditorManager.Instance.GetExtensions()) { DocumentEditorAttribute attr = (DocumentEditorAttribute)ext.ExtensionAttribute; if (ext.ExtensionAttribute.DocumentType == document.GetType()) { return ext.ExtensionType; } } if (document is FixedProxyDocument) { return typeof(FixedProxyControl); } else if (document is SocksProxyDocument) { return typeof(GenericProxyControl); } else if (document is HttpProxyDocument) { return typeof(GenericProxyControl); } else if (document is NetServerDocument) { return typeof(NetServerControl); } else if (document is NetAutoClientDocument) { return typeof(NetAutoClientControl); } else if (document is FullHttpProxyDocument) { return typeof(GenericProxyControl); } throw new ArgumentException("Unknown document type"); }