/** * Adds a plugin to the plugin collection */ private void AddPlugin(string fileName) { try { Assembly pluginAssembly = Assembly.LoadFrom(fileName); foreach (Type pluginType in pluginAssembly.GetTypes()) { if (pluginType.IsPublic) { if (!pluginType.IsAbstract) { Type typeInterface = pluginType.GetInterface("PluginCore.IPlugin", true); if (typeInterface != null) { Types.AvailablePlugin newPlugin = new Types.AvailablePlugin(); newPlugin.AssemblyPath = fileName; newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); newPlugin.Instance.Host = this; newPlugin.Instance.Initialize(); this.colAvailablePlugins.Add(newPlugin); newPlugin = null; } typeInterface = null; } } } pluginAssembly = null; } catch (Exception ex) { ErrorHandler.AddToLog(ex); } }
private void HighlightAllMachingDeclaration(string text) { try { classTree.BeginUpdate(); classTree.CollapseAll(); TreeNodeCollection nodes = classTree.Nodes; TreeNode node; TreeNode expandedNode = null; // checking wich node is expanded foreach (TreeNode sub in nodes) { if (sub.IsExpanded) { expandedNode = sub; } } foreach (TreeNode sub in nodes) { node = sub; // hilights the name of the class (if mach) ShowAndHilightNode(node, IsMach(node.Text, text)); // where to start the hilighting int startWith = 0; if (showExtend) { startWith++; // has Extend node } if (showImports) { startWith++; // has Imports node } for (int index = startWith; index < node.Nodes.Count; index++) { TreeNodeCollection groupNodes = node.Nodes[index].Nodes; HilightDeclarationInGroup(groupNodes, text); } } Win32.Scrolling.scrollToLeft(classTree); if (expandedNode != null) { expandedNode.Expand(); } } catch (Exception ex) { // log error and disable search field ErrorHandler.AddToLog(ex); findProcTxt.Visible = false; } finally { classTree.EndUpdate(); } }
/** * Notifies all plugins from an event */ public void NotifyPlugins(object sender, NotifyEvent e) { try { EventType type = e.Type; if (sender == null) { sender = this; } /** * Custom Controls */ if ((UITools.EventMask & type) > 0) { UITools.HandleEvent(sender, e); if (e.Handled) { return; } } /** * Current Document */ try { if ((TabbedDocument.EventMask & type) > 0) { TabbedDocument td = (TabbedDocument)this.mainForm.CurDocument; td.HandleEvent(sender, e); } } catch {} /** * External Plugins */ foreach (Types.AvailablePlugin pluginOn in this.colAvailablePlugins) { if ((pluginOn.Instance.EventMask & type) > 0) { pluginOn.Instance.HandleEvent(sender, e); if (e.Handled) { break; } } } } catch (Exception ex) { ErrorHandler.AddToLog(ex); } }
/** * Disposes all available plugins */ public void ClosePlugins() { foreach (Types.AvailablePlugin pluginOn in colAvailablePlugins) { try { pluginOn.Instance.Dispose(); pluginOn.Instance = null; } catch (Exception ex) { ErrorHandler.AddToLog(ex); } } this.colAvailablePlugins.Clear(); }
/** * Checks that if the file is read only */ public static bool IsReadOnly(string file) { try { FileAttributes fileAttr = File.GetAttributes(file); if ((fileAttr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { return(true); } return(false); } catch (Exception ex) { ErrorHandler.AddToLog(ex); return(false); } }
/** * Processes the user defined arguments */ private string ProcessCustomArgs(string src) { try { string result = src; int count = this.mainForm.Settings.Settings.Count; for (int i = 0; i < count; i++) { string txt = result; SettingEntry se = (SettingEntry)this.mainForm.Settings.Settings[i]; if (se.Key.StartsWith("FlashDevelop.UserDefined.")) { string pKey = se.Key.Replace("FlashDevelop.UserDefined.", ""); result = txt.Replace(pKey, se.Value); } } return(result); } catch (Exception ex) { ErrorHandler.AddToLog(ex); return(src); } }