private Icon GetIconForDocument(IDocumentObject document) { Type docType = document.GetType(); // Query factories for an Icon first foreach (var ext in DocumentFactoryManager.Instance.GetExtensions()) { IDocumentFactory factory = GetFactory(ext.ExtensionType); Icon ret = factory.GetIconForDocument(document); if (ret != null) { return(ret); } } // No extension icon, go for defaults if (document is NetGraphDocument) { return(Properties.Resources.NetGraphIcon); } else if (document is ParserDocument) { return(Properties.Resources.ParserComponent); } else if (document is AssemblyDocument) { return(Properties.Resources.Assembly_ProjectEntry); } else if (document is ScriptDocument) { ScriptDocument doc = (ScriptDocument)document; switch (doc.Container.Engine) { case "csharp": return(Properties.Resources.CSScriptIcon); case "python": return(Properties.Resources.PythonScriptIcon); case "visualbasic": return(Properties.Resources.VBScriptIcon); case "fsharp": return(Properties.Resources.CSScriptIcon); } return(Properties.Resources.ScriptIcon); } else if (document is NetServiceDocument) { return(Properties.Resources.Network_Map); } else if (document is TextDocument) { return(Properties.Resources.textdoc); } else if (document is TestDocument) { return(Properties.Resources.otheroptions); } return(Properties.Resources.UtilityText); }
private static Type GetDocumentTestType(IDocumentObject document) { object[] attrs = document.GetType().GetCustomAttributes(typeof(TestDocumentTypeAttribute), true); if (attrs.Length > 0) { return(((TestDocumentTypeAttribute)attrs[0]).DocumentType); } else { return(null); } }
/// <summary> /// /// </summary> /// <param name="document"></param> /// <returns></returns> private static Control GetControlForDocument(IDocumentObject document) { foreach (var ext in DocumentEditorManager.Instance.GetExtensions().Where(e => !e.ExtensionAttribute.SubControl)) { if (ext.ExtensionAttribute.DocumentType == document.GetType()) { return((Control)Activator.CreateInstance(ext.ExtensionType, document)); } } if (document is NetServiceDocument) { return(new NetServiceDocumentControl((NetServiceDocument)document)); } else if (document is StateGraphDocument) { return(new StateGraphDocumentControl(document)); } else if (document is NetGraphDocument) { return(new NetGraphDocumentControl((NetGraphDocument)document)); } else if (document is TextDocument) { return(new TextDocumentControl(document)); } else if (document is PacketLogDocument) { return(new PacketLogDocumentControl(document)); } else if (document is ParserDocument) { return(new ParserDocumentControl(document)); } else if (document is AssemblyDocument) { return(new AssemblyDocumentControl(document)); } else if (document is ScriptDocument) { return(new ScriptDocumentControl(document)); } else if (document is ScriptTestDocument) { return(new ScriptTestDocumentControl(document)); } else if (document is NetGraphTestDocument) { return(new NetGraphTestDocumentControl(document)); } else if (document is BinaryDocument) { return(new BinaryDocumentControl(document)); } else if (document is PacketLogDiffDocument) { return(new PacketLogDiffDocumentControl((PacketLogDiffDocument)document)); } else { throw new ArgumentException( String.Format(CANAPE.Properties.Resources.DocumentForm_NoRegisteredEditor, document.Name)); } }
private Icon GetIconForDocument(IDocumentObject document) { Type docType = document.GetType(); // Query factories for an Icon first foreach (var ext in DocumentFactoryManager.Instance.GetExtensions()) { IDocumentFactory factory = GetFactory(ext.ExtensionType); Icon ret = factory.GetIconForDocument(document); if (ret != null) { return ret; } } // No extension icon, go for defaults if (document is NetGraphDocument) { return Properties.Resources.NetGraphIcon; } else if (document is ParserDocument) { return Properties.Resources.ParserComponent; } else if (document is AssemblyDocument) { return Properties.Resources.Assembly_ProjectEntry; } else if (document is ScriptDocument) { ScriptDocument doc = (ScriptDocument)document; switch (doc.Container.Engine) { case "csharp": return Properties.Resources.CSScriptIcon; case "python": return Properties.Resources.PythonScriptIcon; case "visualbasic": return Properties.Resources.VBScriptIcon; case "fsharp": return Properties.Resources.CSScriptIcon; } return Properties.Resources.ScriptIcon; } else if (document is NetServiceDocument) { return Properties.Resources.Network_Map; } else if (document is TextDocument) { return Properties.Resources.textdoc; } else if (document is TestDocument) { return Properties.Resources.otheroptions; } return Properties.Resources.UtilityText; }
private static Type GetDocumentTestType(IDocumentObject document) { object[] attrs = document.GetType().GetCustomAttributes(typeof(TestDocumentTypeAttribute), true); if (attrs.Length > 0) { return ((TestDocumentTypeAttribute)attrs[0]).DocumentType; } else { return null; } }
/// <summary> /// /// </summary> /// <param name="document"></param> /// <returns></returns> private static Control GetControlForDocument(IDocumentObject document) { foreach (var ext in DocumentEditorManager.Instance.GetExtensions().Where(e => !e.ExtensionAttribute.SubControl)) { if (ext.ExtensionAttribute.DocumentType == document.GetType()) { return (Control)Activator.CreateInstance(ext.ExtensionType, document); } } if (document is NetServiceDocument) { return new NetServiceDocumentControl((NetServiceDocument)document); } else if (document is StateGraphDocument) { return new StateGraphDocumentControl(document); } else if (document is NetGraphDocument) { return new NetGraphDocumentControl((NetGraphDocument)document); } else if (document is TextDocument) { return new TextDocumentControl(document); } else if (document is PacketLogDocument) { return new PacketLogDocumentControl(document); } else if (document is ParserDocument) { return new ParserDocumentControl(document); } else if (document is AssemblyDocument) { return new AssemblyDocumentControl(document); } else if (document is ScriptDocument) { return new ScriptDocumentControl(document); } else if (document is ScriptTestDocument) { return new ScriptTestDocumentControl(document); } else if (document is NetGraphTestDocument) { return new NetGraphTestDocumentControl(document); } else if (document is BinaryDocument) { return new BinaryDocumentControl(document); } else if (document is PacketLogDiffDocument) { return new PacketLogDiffDocumentControl((PacketLogDiffDocument)document); } else { throw new ArgumentException( String.Format(CANAPE.Properties.Resources.DocumentForm_NoRegisteredEditor, document.Name)); } }