public ButtonEntry(Options11_ButtonBar parent, int Order, int Index, PluginInformation PluginInfo = null) { this.parent = parent; this.Order = Order; this.Index = Index; this.PluginInfo = PluginInfo; }
public PluginInformation Clone(int index) { PluginInformation information = (PluginInformation)base.MemberwiseClone(); information.Index = index; return(information); }
public int[] GetButtonIndices() { List <int> list = new List <int>(); List <string> list2 = new List <string>(); foreach (object obj2 in listBoxCurrent.Items) { PluginInformation information = obj2 as PluginInformation; if (information != null) { list2.Add(information.PluginID); list.Add(0x10000); if ((information.PluginType == PluginType.BackgroundMultiple) && (information.Index > -1)) { pluginManager.PushBackgroundMultiple(information.PluginID, information.Index); } } else { list.Add((int)obj2); } } PluginManager.ActivatedButtonsOrder = list2; return(list.ToArray()); }
private static void LoadStaticInstance(PluginInformation pi, PluginAssembly pa) { Plugin plugin; if (!dicStaticPluginInstances.TryGetValue(pi.PluginID, out plugin)) { plugin = pa.Load(pi.PluginID); if (plugin == null || plugin.Instance == null) { return; } dicStaticPluginInstances[pi.PluginID] = plugin; if (plugin.PluginInformation.PluginType == PluginType.Static) { try { plugin.Instance.Open(null, null); } catch (Exception exception) { HandlePluginException(exception, IntPtr.Zero, pi.Name, "Loading static plugin."); return; } } } if (plgEncodingDetector == null) { plgEncodingDetector = plugin.Instance as IEncodingDetector; } }
private static bool LoadStatics(PluginInformation pi, PluginAssembly pa, bool fForce) { Plugin plugin = pa.Load(pi.PluginID); if ((plugin != null) && (plugin.Instance != null)) { dicStaticPluginInstances[pi.PluginID] = plugin; if ((plgEncodingDetector == null) || fForce) { QTPlugin.IEncodingDetector instance = plugin.Instance as QTPlugin.IEncodingDetector; if (instance != null) { try { instance.Open(null, null); plgEncodingDetector = instance; return(true); } catch (Exception exception) { HandlePluginException(exception, IntPtr.Zero, pi.Name, "Loading static plugin."); } } } } return(false); }
public PluginAssembly(string path) { Path = path; Title = Author = Description = Version = Name = string.Empty; if (File.Exists(path)) { try { assembly = Assembly.Load(File.ReadAllBytes(path)); AssemblyName name = assembly.GetName(); AssemblyTitleAttribute customAttribute = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute)); AssemblyCompanyAttribute attribute2 = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)); AssemblyDescriptionAttribute attribute3 = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute)); Version = name.Version.ToString(); if (customAttribute != null) { Title = customAttribute.Title; } if (attribute2 != null) { Author = attribute2.Company; } if (attribute3 != null) { Description = attribute3.Description; } Name = Title + Version + "(" + path.GetHashCode().ToString("X") + ")"; foreach (Type type in assembly.GetTypes()) { try { if (ValidateType(type)) { PluginAttribute pluginAtt = Attribute.GetCustomAttribute(type, T_PLUGINATTRIBUTE) as PluginAttribute; if (pluginAtt != null) { string pluginID = Name + "+" + type.FullName; PluginInformation info = new PluginInformation(pluginAtt, path, pluginID, type.FullName); GetImageFromAssembly(assembly, type, info); dicPluginInformations[pluginID] = info; } else { QTUtility2.MakeErrorLog(null, "failed attribute"); } } } catch { } } } catch (ReflectionTypeLoadException exception) { QTUtility2.MakeErrorLog(exception, "Failed to load plugin assembly.\r\n" + exception.LoaderExceptions.StringJoin("\r\n") + "\r\n" + path); } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, "Failed to load plugin assembly.\r\n" + path); } } }
public PluginAssembly(string path) { this.Path = path; this.Title = this.Author = this.Description = this.Version = this.Name = string.Empty; if (File.Exists(path)) { try { this.assembly = Assembly.Load(File.ReadAllBytes(path)); AssemblyName name = this.assembly.GetName(); AssemblyTitleAttribute customAttribute = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTitleAttribute)); AssemblyCompanyAttribute attribute2 = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCompanyAttribute)); AssemblyDescriptionAttribute attribute3 = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyDescriptionAttribute)); this.Version = name.Version.ToString(); if (customAttribute != null) { this.Title = customAttribute.Title; } if (attribute2 != null) { this.Author = attribute2.Company; } if (attribute3 != null) { this.Description = attribute3.Description; } this.Name = this.Title + this.Version + "(" + path.GetHashCode().ToString("X") + ")"; foreach (Type type in this.assembly.GetTypes()) { try { if (ValidateType(type)) { PluginAttribute pluginAtt = Attribute.GetCustomAttribute(type, T_PLUGINATTRIBUTE) as PluginAttribute; if (pluginAtt != null) { string pluginID = this.Name + "+" + type.FullName; PluginInformation info = new PluginInformation(pluginAtt, path, pluginID, type.FullName); GetImageFromAssembly(this.assembly, type, info); this.dicPluginInformations[pluginID] = info; } else { QTUtility2.MakeErrorLog(null, "failed attribute"); } } } catch { } } } catch (Exception exception) { QTUtility2.MakeErrorLog(exception, "failed get asm\r\n" + path); } } }
public int IncrementBackgroundMultiple(PluginInformation pi) { int num; if (this.dicMultiplePluginCounter.TryGetValue(pi.PluginID, out num)) { this.dicMultiplePluginCounter[pi.PluginID] = num + 1; return(num + 1); } this.dicMultiplePluginCounter[pi.PluginID] = 0; return(0); }
public void Close(EndCode code) { if(pluginClient != null) { try { pluginClient.Close(code); } catch(Exception exception) { PluginManager.HandlePluginException(exception, IntPtr.Zero, pluginInfo.Name, "Closing plugin."); } pluginClient = null; } pluginInfo = null; }
public PluginViewItem(PluginInformation pi, PluginAssembly pa) { PluginInfo = pi; PluingAssembly = pa; Name = pi.Name; version = pi.Version; author = pi.Author; description = pi.Description; fEnabled = pi.Enabled; Size = new Size(0x100, 0x37); Margin = Padding.Empty; Dock = DockStyle.Fill; SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); }
public void Close(EndCode code) { if (pluginClient != null) { try { pluginClient.Close(code); } catch (Exception exception) { PluginManager.HandlePluginException(exception, IntPtr.Zero, pluginInfo.Name, "Closing plugin."); } pluginClient = null; } pluginInfo = null; }
public PluginAssembly(string path) { Path = path; Title = Author = Description = Version = Name = string.Empty; if(File.Exists(path)) { try { assembly = Assembly.Load(File.ReadAllBytes(path)); AssemblyName name = assembly.GetName(); AssemblyTitleAttribute customAttribute = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute)); AssemblyCompanyAttribute attribute2 = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)); AssemblyDescriptionAttribute attribute3 = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute)); Version = name.Version.ToString(); if(customAttribute != null) { Title = customAttribute.Title; } if(attribute2 != null) { Author = attribute2.Company; } if(attribute3 != null) { Description = attribute3.Description; } Name = Title + Version + "(" + path.GetHashCode().ToString("X") + ")"; foreach(Type type in assembly.GetTypes()) { try { if(ValidateType(type)) { PluginAttribute pluginAtt = Attribute.GetCustomAttribute(type, T_PLUGINATTRIBUTE) as PluginAttribute; if(pluginAtt != null) { string pluginID = Name + "+" + type.FullName; PluginInformation info = new PluginInformation(pluginAtt, path, pluginID, type.FullName); GetImageFromAssembly(assembly, type, info); dicPluginInformations[pluginID] = info; } else { QTUtility2.MakeErrorLog(null, "failed attribute"); } } } catch { } } } catch(ReflectionTypeLoadException exception) { QTUtility2.MakeErrorLog(exception, "Failed to load plugin assembly.\r\n" + exception.LoaderExceptions.StringJoin("\r\n") + "\r\n" + path); } catch(Exception exception) { QTUtility2.MakeErrorLog(exception, "Failed to load plugin assembly.\r\n" + path); } } }
public Plugin Load(PluginInformation pi, PluginAssembly pa) { try { if ((pa == null) && !dicPluginAssemblies.TryGetValue(pi.Path, out pa)) { return(null); } Plugin plugin = pa.Load(pi.PluginID); if (plugin != null) { string[] strArray; int[] numArray; this.dicPluginInstances[pi.PluginID] = plugin; if ((!this.pluginServer.OpenPlugin(plugin.Instance, out strArray) || (strArray == null)) || (strArray.Length <= 0)) { return(plugin); } pi.ShortcutKeyActions = strArray; if (QTUtility.dicPluginShortcutKeys.TryGetValue(pi.PluginID, out numArray)) { if (numArray == null) { QTUtility.dicPluginShortcutKeys[pi.PluginID] = new int[strArray.Length]; return(plugin); } if (numArray.Length != strArray.Length) { int[] numArray2 = new int[strArray.Length]; int num = Math.Min(numArray.Length, strArray.Length); for (int i = 0; i < num; i++) { numArray2[i] = numArray[i]; } QTUtility.dicPluginShortcutKeys[pi.PluginID] = numArray2; } return(plugin); } QTUtility.dicPluginShortcutKeys[pi.PluginID] = new int[strArray.Length]; } return(plugin); } catch (Exception exception) { HandlePluginException(exception, IntPtr.Zero, pi.Name, "Loading plugin."); QTUtility2.MakeErrorLog(exception, null); } return(null); }
public PluginAssembly(string path) { this.Path = path; this.Title = this.Author = this.Description = this.Version = this.Name = string.Empty; if(File.Exists(path)) { try { this.assembly = Assembly.Load(File.ReadAllBytes(path)); AssemblyName name = this.assembly.GetName(); AssemblyTitleAttribute customAttribute = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyTitleAttribute)); AssemblyCompanyAttribute attribute2 = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyCompanyAttribute)); AssemblyDescriptionAttribute attribute3 = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(this.assembly, typeof(AssemblyDescriptionAttribute)); this.Version = name.Version.ToString(); if(customAttribute != null) { this.Title = customAttribute.Title; } if(attribute2 != null) { this.Author = attribute2.Company; } if(attribute3 != null) { this.Description = attribute3.Description; } this.Name = this.Title + this.Version + "(" + path.GetHashCode().ToString("X") + ")"; foreach(Type type in this.assembly.GetTypes()) { try { if(ValidateType(type)) { PluginAttribute pluginAtt = Attribute.GetCustomAttribute(type, T_PLUGINATTRIBUTE) as PluginAttribute; if(pluginAtt != null) { string pluginID = this.Name + "+" + type.FullName; PluginInformation info = new PluginInformation(pluginAtt, path, pluginID, type.FullName); GetImageFromAssembly(this.assembly, type, info); this.dicPluginInformations[pluginID] = info; } else { QTUtility2.MakeErrorLog(null, "failed attribute"); } } } catch { } } } catch(Exception exception) { QTUtility2.MakeErrorLog(exception, "failed get asm\r\n" + path); } } }
private void buttonRemove_Click(object sender, EventArgs e) { int selectedIndex = listBoxCurrent.SelectedIndex; if (selectedIndex != -1) { fChangedExists = true; object selectedItem = listBoxCurrent.SelectedItem; listBoxCurrent.Items.RemoveAt(selectedIndex); if (listBoxCurrent.Items.Count > selectedIndex) { listBoxCurrent.SelectedIndex = selectedIndex; } else { listBoxCurrent.SelectedIndex = selectedIndex - 1; } if (selectedItem is int) { int num2 = (int)selectedItem; if (num2 != 0) { for (int i = 0; i < listBoxPool.Items.Count; i++) { object obj3 = listBoxPool.Items[i]; if ((obj3 is PluginInformation) || ((obj3 is int) && (num2 < ((int)obj3)))) { listBoxPool.Items.Insert(i, selectedItem); return; } } listBoxPool.Items.Add(selectedItem); } } else { PluginInformation information = selectedItem as PluginInformation; if ((information == null) || (information.Index != -1)) { listBoxPool.Items.Add(selectedItem); } } } }
private static void GetImageFromAssembly(Assembly asm, Type type, PluginInformation info) { try { Type type2 = asm.GetType(type.Namespace + "." + RESNAME); if (type2 != null) { PropertyInfo property = type2.GetProperty(type.Name + IMGLARGE, BindingFlags.NonPublic | BindingFlags.Static); PropertyInfo info3 = type2.GetProperty(type.Name + IMGSMALL, BindingFlags.NonPublic | BindingFlags.Static); if (property != null) { info.ImageLarge = (Image)property.GetValue(null, null); } if (info3 != null) { info.ImageSmall = (Image)info3.GetValue(null, null); } } } catch { } }
private void buttonAdd_Click(object sender, EventArgs e) { int selectedIndex = listBoxPool.SelectedIndex; if (selectedIndex != -1) { fChangedExists = true; object selectedItem = listBoxPool.SelectedItem; bool flag; PluginInformation information = selectedItem as PluginInformation; if (information != null) { flag = information.Index != -1; } else { flag = 0 != ((int)selectedItem); } if (flag) { listBoxPool.Items.RemoveAt(selectedIndex); if (listBoxPool.Items.Count > selectedIndex) { listBoxPool.SelectedIndex = selectedIndex; } else { listBoxPool.SelectedIndex = selectedIndex - 1; } } if (listBoxCurrent.SelectedIndex != -1) { listBoxCurrent.Items.Insert(listBoxCurrent.SelectedIndex, selectedItem); } else { listBoxCurrent.Items.Add(selectedItem); } } }
public Plugin Load(PluginInformation pi, PluginAssembly pa) { try { if (pa == null && !PluginManager.GetAssembly(pi.Path, out pa)) { return(null); } Plugin plugin = pa.Load(pi.PluginID); if (plugin == null) { return(null); } dicPluginInstances[pi.PluginID] = plugin; plugin.Instance.Open(this, shellBrowser); return(plugin); } catch (Exception exception) { PluginManager.HandlePluginException(exception, IntPtr.Zero, pi.Name, "Loading plugin."); QTUtility2.MakeErrorLog(exception); } return(null); }
public void AddPluginViewItem(PluginInformation pi, PluginAssembly pa) { base.SuspendLayout(); PluginViewItem control = new PluginViewItem(pi, pa); control.MouseDown += new MouseEventHandler(this.pvi_MouseDown); control.MouseUp += new MouseEventHandler(this.pvi_MouseUp); control.DoubleClick += new EventHandler(this.pvi_DoubleClick); control.OptionButtonClick += new EventHandler(this.pvi_OptionButtonClick); control.DisableButtonClick += new EventHandler(this.pvi_DisableButtonClick); control.RemoveButtonClick += new EventHandler(this.pvi_RemoveButtonClick); int count = base.Controls.Count; base.RowStyles.Insert(count, new RowStyle(SizeType.Absolute, 55f)); base.Controls.Add(control, 0, count); base.RowCount = base.Controls.Count + 1; base.ResumeLayout(); for (int i = 0; i < base.Controls.Count; i++) { base.SetRow(base.Controls[i], i); } }
public void AddPluginViewItem(PluginInformation pi, PluginAssembly pa) { SuspendLayout(); PluginViewItem control = new PluginViewItem(pi, pa); control.MouseDown += pvi_MouseDown; control.MouseUp += pvi_MouseUp; control.DoubleClick += pvi_DoubleClick; control.OptionButtonClick += pvi_OptionButtonClick; control.DisableButtonClick += pvi_DisableButtonClick; control.RemoveButtonClick += pvi_RemoveButtonClick; int count = Controls.Count; RowStyles.Insert(count, new RowStyle(SizeType.Absolute, 55f)); Controls.Add(control, 0, count); RowCount = Controls.Count + 1; ResumeLayout(); for (int i = 0; i < Controls.Count; i++) { SetRow(Controls[i], i); } }
private bool PluginInfoHasOption(PluginInformation pi) { return((QueryPluginInfoHasOption != null) && QueryPluginInfoHasOption(pi)); }
public PluginEntry(Options12_Plugins parent, PluginInformation pluginInfo, PluginAssembly pluginAssembly) { this.parent = parent; PluginInfo = pluginInfo; PluginAssembly = pluginAssembly; }
public bool TryGetPluginInformation(string pluginID, out PluginInformation info) { return(dicPluginInformations.TryGetValue(pluginID, out info)); }
private void listBoxes_DrawItem(object sender, DrawItemEventArgs e) { ListBox box = (ListBox)sender; if (box.Items.Count >= 1) { e.DrawBackground(); object obj2 = box.Items[e.Index]; string s; PluginInformation information = obj2 as PluginInformation; if (information == null) { int index = (int)obj2; s = ButtonItemsDisplayName[index]; if ((index != 0) && (index < 0x13)) { Rectangle rect = new Rectangle(e.Bounds.Location, fLargeIcon ? new Size(0x18, 0x18) : new Size(0x10, 0x10)); try { Image image2 = fLargeIcon ? imageStripLarge[index - 1] : imageStripSmall[index - 1]; if (image2 != null) { e.Graphics.DrawImage(image2, rect); } } catch { } } } else { Image image = fLargeIcon ? information.ImageLarge : information.ImageSmall; s = information.Name; if ((information.PluginType == PluginType.BackgroundMultiple) && (information.Index != -1)) { foreach (Plugin plugin in pluginManager.Plugins) { if (plugin.PluginInformation.PluginID == information.PluginID) { IBarMultipleCustomItems instance = plugin.Instance as IBarMultipleCustomItems; if (instance == null) { break; } try { image = instance.GetImage(fLargeIcon, information.Index); s = instance.GetName(information.Index); break; } catch { s = "Failed to get name."; break; } } } } if (image != null) { e.Graphics.DrawImage(image, new Rectangle(e.Bounds.Location, fLargeIcon ? new Size(0x18, 0x18) : new Size(0x10, 0x10))); } } bool flag = (e.State & DrawItemState.Selected) != DrawItemState.None; e.Graphics.DrawString(s, Font, flag ? SystemBrushes.HighlightText : SystemBrushes.ControlText, new PointF((e.Bounds.X + 0x1c), (e.Bounds.Y + (fLargeIcon ? 5 : 2)))); } }
private static void LoadStaticInstance(PluginInformation pi, PluginAssembly pa) { Plugin plugin; if(!dicStaticPluginInstances.TryGetValue(pi.PluginID, out plugin)) { plugin = pa.Load(pi.PluginID); if(plugin == null || plugin.Instance == null) return; dicStaticPluginInstances[pi.PluginID] = plugin; if(plugin.PluginInformation.PluginType == PluginType.Static) { try { plugin.Instance.Open(null, null); } catch(Exception exception) { HandlePluginException(exception, IntPtr.Zero, pi.Name, "Loading static plugin."); return; } } } if(plgEncodingDetector == null) { plgEncodingDetector = plugin.Instance as IEncodingDetector; } }
public Plugin(IPluginClient pluginClient, PluginInformation pluginInfo) { this.pluginClient = pluginClient; this.pluginInfo = pluginInfo; fBackgroundButtonIsSupported = ((pluginInfo.PluginType == PluginType.Background) && ((pluginClient is IBarButton) || (pluginClient is IBarCustomItem))) || ((pluginInfo.PluginType == PluginType.BackgroundMultiple) && (pluginClient is IBarMultipleCustomItems)); }
public Plugin Load(PluginInformation pi, PluginAssembly pa) { try { if(pa == null && !PluginManager.GetAssembly(pi.Path, out pa)) { return null; } Plugin plugin = pa.Load(pi.PluginID); if(plugin == null) return null; dicPluginInstances[pi.PluginID] = plugin; plugin.Instance.Open(this, shellBrowser); return plugin; } catch(Exception exception) { PluginManager.HandlePluginException(exception, IntPtr.Zero, pi.Name, "Loading plugin."); QTUtility2.MakeErrorLog(exception); } return null; }
private bool pluginView_QueryPluginInfoHasOption(PluginInformation pi) { Plugin plugin; if(pluginManager.TryGetPlugin(pi.PluginID, out plugin)) { try { return plugin.Instance.HasOption; } catch(Exception exception) { PluginManager.HandlePluginException(exception, Handle, pi.Name, "Checking if the plugin has option."); QTUtility2.MakeErrorLog(exception, "Error at Plugin: " + pi.Name); } } return false; }
private static void GetImageFromAssembly(Assembly asm, Type type, PluginInformation info) { try { Type type2 = asm.GetType(type.Namespace + "." + RESNAME); if(type2 != null) { PropertyInfo property = type2.GetProperty(type.Name + IMGLARGE, BindingFlags.NonPublic | BindingFlags.Static); PropertyInfo info3 = type2.GetProperty(type.Name + IMGSMALL, BindingFlags.NonPublic | BindingFlags.Static); if(property != null) { info.ImageLarge = (Image)property.GetValue(null, null); } if(info3 != null) { info.ImageSmall = (Image)info3.GetValue(null, null); } } } catch { } }
public bool TryGetPluginInformation(string pluginID, out PluginInformation info) { return dicPluginInformations.TryGetValue(pluginID, out info); }