public Plugin Load(string pluginID) { if (File.Exists(Path)) { try { PluginInformation information; if (dicPluginInformations.TryGetValue(pluginID, out information)) { IPluginClient pluginClient = assembly.CreateInstance(information.TypeFullName) as IPluginClient; if (pluginClient != null) { Plugin plugin = new Plugin(pluginClient, information); IBarButton button = pluginClient as IBarButton; if (button != null) { Image imageLarge = information.ImageLarge; Image imageSmall = information.ImageSmall; try { Image image = button.GetImage(true); Image image4 = button.GetImage(false); if (image != null) { information.ImageLarge = image; if (imageLarge != null) { imageLarge.Dispose(); } } if (image4 != null) { information.ImageSmall = image4; if (imageSmall != null) { imageSmall.Dispose(); } } } catch (Exception exception) { PluginManager.HandlePluginException(exception, IntPtr.Zero, information.Name, "Getting image from pluging."); throw; } } return(plugin); } } } catch (Exception exception2) { QTUtility2.MakeErrorLog(exception2, null); } } return(null); }
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; }
private static string LoadTextFile(string path, out bool fLoadedAll) { byte[] buffer; int count = 0x400; string str = string.Empty; fLoadedAll = false; try { using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { if (stream.Length < count) { fLoadedAll = true; count = (int)stream.Length; } buffer = new byte[count]; stream.Read(buffer, 0, count); } } catch (IOException exception) { ioException = exception; return(" *Access Error!"); } if (buffer.Length <= 0) { return(str); } Encoding encoding = null; if (PluginManager.IEncodingDetector != null) { try { encoding = PluginManager.IEncodingDetector.GetEncoding(ref buffer); } catch (Exception exception2) { PluginManager.HandlePluginException(exception2, IntPtr.Zero, "Unknown IEncodingDetector", "Getting Enconding object."); QTUtility2.MakeErrorLog(exception2, null, false); } } if (encoding == null) { encoding = TxtEnc.GetEncoding(ref buffer); if ((encoding == null) || ((((Encoding.Default.CodePage != 0x3a4) && (encoding.CodePage != 0xfde8)) && ((encoding.CodePage != 0xfde9) && (encoding.CodePage != 0x4b0))) && (encoding.CodePage != 0x2ee0))) { encoding = Encoding.Default; } } return(encoding.GetString(buffer)); }
private void btnPluginOptions_Click(object sender, RoutedEventArgs e) { PluginEntry entry = (PluginEntry)((Button)sender).DataContext; string pid = entry.PluginID; // Unfortunately, we can't call Plugin.OnOption on plugins that are // loaded in a non-static context. InstanceManager.InvokeMain(tabbar => { Plugin p; if (!tabbar.pluginServer.TryGetPlugin(pid, out p) || p.Instance == null) { return; } try { p.Instance.OnOption(); } catch (Exception ex) { PluginManager.HandlePluginException(ex, new WindowInteropHelper(Window.GetWindow(this)).Handle, entry.Name, "Open plugin option."); } }); }
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 ButtonBarOptionForm(int[] currentItemIndexes, bool fLargeIcon, string currentImagePath, PluginManager pluginManager) { InitializeComponent(); this.fLargeIcon = fLargeIcon; this.pluginManager = pluginManager; ButtonItemsDisplayName = QTUtility.TextResourcesDic["ButtonBar_BtnName"]; string[] strArray = QTUtility.TextResourcesDic["ButtonBar_Option"]; string[] strArray2 = QTUtility.TextResourcesDic["DialogButtons"]; buttonOK.Text = strArray2[0]; buttonCancel.Text = strArray2[1]; buttonRestoreDefault.Text = strArray[3]; buttonUp.Text = strArray[4]; buttonDown.Text = strArray[5]; buttonBrowseImage.Text = strArray[6]; buttonResetImage.Text = strArray[11]; comboBoxImageSize.Items.AddRange(new string[] { strArray[7], strArray[8] }); comboBoxImageText.Items.AddRange(new string[] { strArray[12], strArray[13], strArray[14] }); chbLockSearchBox.Text = strArray[15]; comboBoxImageSize.SelectedIndex = this.fLargeIcon ? 1 : 0; if ((QTButtonBar.ConfigValues[0] & 0x20) == 0x20) { comboBoxImageText.SelectedIndex = ((QTButtonBar.ConfigValues[0] & 0x10) == 0x10) ? 1 : 0; } else { comboBoxImageText.SelectedIndex = 2; } comboBoxImageSize.SelectedIndexChanged += comboBoxes_ImageSizeAndText_SelectedIndexChanged; comboBoxImageText.SelectedIndexChanged += comboBoxes_ImageSizeAndText_SelectedIndexChanged; chbLockSearchBox.Checked = (QTButtonBar.ConfigValues[0] & 8) != 0; InitializeImages(currentImagePath, true); List <PluginInformation> list = new List <PluginInformation>(); foreach (int item in currentItemIndexes) { if (item >= 0x10000) { int count = list.Count; if (PluginManager.ActivatedButtonsOrder.Count > count) { string key = PluginManager.ActivatedButtonsOrder[count]; foreach (PluginInformation information in PluginManager.PluginInformations .Where(information => information.PluginID == key)) { list.Add(information); if (information.PluginType == PluginType.BackgroundMultiple) { int num3; if (dicActivePluginMulti.TryGetValue(key, out num3)) { dicActivePluginMulti[key] = num3 + 1; } else { dicActivePluginMulti[key] = 1; } listBoxCurrent.Items.Add(information.Clone(num3)); } else { listBoxCurrent.Items.Add(information); } break; } } } else if (item != 0x15) { listBoxCurrent.Items.Add(item); } } listBoxPool.Items.Add(0); for (int j = 1; j < ButtonItemsDisplayName.Length; j++) { if (Array.IndexOf(currentItemIndexes, j) == -1) { listBoxPool.Items.Add(j); } } listBoxPool.Items.AddRange(PluginManager.PluginInformations .Where(info => info.Enabled && info.PluginType == PluginType.Interactive) .Except(list).ToArray()); if (this.pluginManager == null) { return; } foreach (Plugin plugin in this.pluginManager.Plugins) { if (plugin.PluginInformation.PluginType == PluginType.BackgroundMultiple) { IBarMultipleCustomItems instance = plugin.Instance as IBarMultipleCustomItems; if (instance != null) { try { int num5 = instance.Count; if (num5 > 0) { int num6; dicActivePluginMulti.TryGetValue(plugin.PluginInformation.PluginID, out num6); for (int k = 0; k < (num5 - num6); k++) { listBoxPool.Items.Add(plugin.PluginInformation.Clone(num6 + k)); } } else if (num5 == -1) { listBoxPool.Items.Add(plugin.PluginInformation.Clone(-1)); } } catch (Exception exception) { PluginManager.HandlePluginException(exception, IntPtr.Zero, plugin.PluginInformation.Name, "Adding multi items to pool."); } } } else if (plugin.BackgroundButtonSupported && !plugin.BackgroundButtonEnabled) { listBoxPool.Items.Add(plugin.PluginInformation); } } }
private void buttonRestoreDefault_Click(object sender, EventArgs e) { fChangedExists = true; listBoxCurrent.SuspendLayout(); listBoxPool.SuspendLayout(); listBoxCurrent.Items.Clear(); listBoxPool.Items.Clear(); dicActivePluginMulti.Clear(); foreach (int index in QTButtonBar.DefaultButtonIndices) { listBoxCurrent.Items.Add(index); } listBoxPool.Items.Add(0); for (int j = 1; j < ButtonItemsDisplayName.Length; j++) { if (Array.IndexOf(QTButtonBar.DefaultButtonIndices, j) == -1) { listBoxPool.Items.Add(j); } } listBoxPool.Items.AddRange(PluginManager.PluginInformations.Where(info => info.Enabled && info.PluginType == PluginType.Interactive).ToArray()); if (pluginManager != null) { foreach (Plugin plugin in pluginManager.Plugins) { if (plugin.PluginInformation.PluginType == PluginType.BackgroundMultiple) { IBarMultipleCustomItems instance = plugin.Instance as IBarMultipleCustomItems; if (instance != null) { try { int count = instance.Count; if (count > 0) { for (int k = 0; k < count; k++) { listBoxPool.Items.Add(plugin.PluginInformation.Clone(k)); } } else if (count == -1) { listBoxPool.Items.Add(plugin.PluginInformation.Clone(-1)); } } catch (Exception exception) { PluginManager.HandlePluginException(exception, Handle, plugin.PluginInformation.Name, "Adding multi items to pool."); } } continue; } if (plugin.BackgroundButtonSupported) { listBoxPool.Items.Add(plugin.PluginInformation); } } } InitializeImages(string.Empty, true); listBoxPool.ResumeLayout(); listBoxCurrent.ResumeLayout(); }