static void Main(string[] args) { InitializeLanguage(); InitializeLibraries(); string fileName = null; int i = 0; string configDir = GeneralUtils.GetConfigDirectory(true); if (configDir == null) { MessageBox.Show(String.Format(Properties.Resources.Program_ErrorCreatingUserDirectory, GeneralUtils.GetConfigDirectory(false)), Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } for (i = 0; i < args.Length; ++i) { if (args[i].StartsWith("-")) { if (args[i].StartsWith("-ext:")) { CANAPEExtensionManager.LoadExtension(args[i].Substring("-ext:".Length)); } } else { break; } } if (i < args.Length) { fileName = args[i]; } if (Properties.Settings.Default.RunOnce == false) { MessageBox.Show(CANAPE.Properties.Resources.Program_SecurityWarning, CANAPE.Properties.Resources.Program_SecurityWarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Stop); Properties.Settings.Default.RunOnce = true; Program.SaveSettings(); } if (!Debugger.IsAttached) { Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(fileName)); ScriptUtils.DeleteTempFiles(); }
private static Dictionary <string, List <CANAPETemplate> > CreateTemplates() { Dictionary <string, List <CANAPETemplate> > ret = new Dictionary <string, List <CANAPETemplate> >(); ret["Proxy"] = new List <CANAPETemplate>(); ret["Proxy"].AddRange(CANAPEExtensionManager.GetTemplates(typeof(CANAPEProject), "proxy")); ret["Server"] = new List <CANAPETemplate>(); ret["Server"].AddRange(CANAPEExtensionManager.GetTemplates(typeof(CANAPEProject), "server")); return(ret); }
/// <summary> /// Get an array of script templates for a specified engine /// </summary> /// <param name="engine">The engine</param> /// <returns>An array of available templates</returns> public static IEnumerable <CANAPETemplate> GetTemplates(string engine) { Type engineType = ScriptEngineFactory.GetTypeForScriptEngine(engine); if (engineType != null) { return(CANAPEExtensionManager.GetTemplates(engineType, engine)); } else { return(new CANAPETemplate[0]); } }
private void btnOpenDir_Click(object sender, EventArgs e) { string userExtensionDir = CANAPEExtensionManager.GetUserExtensionDirectory(true); if (userExtensionDir != null) { GuiUtils.OpenDocument(userExtensionDir); } else { MessageBox.Show(this, Properties.Resources.ExtensionManagerForm_CouldntCreateExtensionDir, Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Constructor /// </summary> public ExtensionManagerForm() { InitializeComponent(); Dictionary <string, Assembly> assemblies = CANAPEExtensionManager.GetUserExtensionAssemblies(); foreach (Assembly asm in assemblies.Values) { ListViewItem item = new ListViewItem(asm.GetName().Name); item.SubItems.Add(new Uri(asm.CodeBase).LocalPath); item.Tag = asm; listViewExtensions.Items.Add(item); } }
private static void InitializeLibraries() { RegisterEditor(typeof(Dictionary <string, string>), typeof(NodePropertiesEditor)); RegisterEditor(typeof(ColorValue), typeof(ColorValueEditor)); RegisterEditor(typeof(DataFrameFilterFactory[]), typeof(DataFrameFilterEditor)); RegisterEditor(typeof(byte[]), typeof(ByteArrayEditor)); RegisterEditor(typeof(SslNetworkLayerConfig), typeof(SslConfigEditor)); RegisterEditor(typeof(INetworkLayerFactory[]), typeof(LayersEditor)); RegisterEditor(typeof(SequenceChoice[]), typeof(SequenceChoiceEditor)); // Load default extensions CANAPEExtensionManager.LoadExtension(typeof(ScriptDocument).Assembly); CANAPEExtensionManager.LoadExtension(typeof(HTTPData).Assembly); CANAPEExtensionManager.LoadExtension(typeof(HexEditorControl).Assembly); CANAPEExtensionManager.LoadExtensions(AppDomain.CurrentDomain.BaseDirectory); CANAPEExtensionManager.LoadExtensions(GeneralUtils.GetConfigDirectory()); }