Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public void RefreshPluginAssembly(PluginAssembly pa, bool fStatic)
 {
     foreach (PluginInformation information in pa.PluginInformations)
     {
         if (!information.Enabled)
         {
             this.UnloadPluginInstance(information.PluginID, EndCode.Unloaded, fStatic);
             continue;
         }
         if (information.PluginType == PluginType.Background)
         {
             if (!this.PluginInstantialized(information.PluginID))
             {
                 Plugin plugin = this.Load(information, pa);
                 if (plugin != null)
                 {
                     if (this.plgIFilter == null)
                     {
                         this.plgIFilter = plugin.Instance as QTPlugin.IFilter;
                     }
                     if (this.plgFilterCore == null)
                     {
                         this.plgFilterCore = plugin.Instance as QTPlugin.IFilterCore;
                     }
                 }
                 else
                 {
                     information.Enabled = false;
                 }
             }
             continue;
         }
         if (information.PluginType == PluginType.BackgroundMultiple)
         {
             if (!this.PluginInstantialized(information.PluginID) && (this.Load(information, pa) == null))
             {
                 information.Enabled = false;
             }
         }
         else if ((fStatic && (information.PluginType == PluginType.Static)) && !dicStaticPluginInstances.ContainsKey(information.PluginID))
         {
             LoadStatics(information, pa, false);
         }
     }
 }
Exemplo n.º 3
0
 private void CreatePluginEntry(PluginAssembly pa, bool fAddedByUser)
 {
     if (!pa.PluginInfosExist || CurrentPlugins.Any(pe => pe.Path == pa.Path))
     {
         return;
     }
     foreach (PluginInformation pi in pa.PluginInformations)
     {
         PluginEntry entry = new PluginEntry(this, pi, pa)
         {
             InstallOnClose = fAddedByUser
         };
         int i = 0;
         while (i < CurrentPlugins.Count && string.Compare(CurrentPlugins[i].Title, entry.Title, true) <= 0)
         {
             ++i;
         }
         CurrentPlugins.Insert(i, entry);
     }
 }
Exemplo n.º 4
0
 private static PluginAssembly LoadAssembly(string path)
 {
     if (path.Length > 0)
     {
         PluginAssembly pa = new PluginAssembly(path);
         if (pa.PluginInfosExist)
         {
             string[] enabled = Config.Plugin.Enabled;
             foreach (PluginInformation info in pa.PluginInformations
                      .Where(info => enabled.Contains(info.PluginID)))
             {
                 info.Enabled = true;
                 pa.Enabled   = true;
             }
             dicPluginAssemblies[pa.Path] = pa;
             return(pa);
         }
     }
     return(null);
 }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
        private void btnPluginRemove_Click(object sender, RoutedEventArgs e)
        {
            PluginEntry    entry          = (PluginEntry)((Button)sender).DataContext;
            PluginAssembly pluginAssembly = entry.PluginAssembly;

            if (pluginAssembly.PluginInformations.Count > 1)
            {
                string plugins = pluginAssembly.PluginInformations.Select(info => info.Name).StringJoin(", ");
                if (MessageBox.Show(
                        QTUtility.TextResourcesDic["Options_Page12_Plugins"][8] +
                        Environment.NewLine + Environment.NewLine + plugins + Environment.NewLine + Environment.NewLine +
                        QTUtility.TextResourcesDic["Options_Page12_Plugins"][9],
                        QTUtility.TextResourcesDic["OptionsDialog"][3],
                        MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
                {
                    return;
                }
            }
            for (int i = 0; i < CurrentPlugins.Count; i++)
            {
                PluginEntry otherEntry = CurrentPlugins[i];
                if (otherEntry.PluginAssembly == entry.PluginAssembly)
                {
                    if (otherEntry.InstallOnClose)
                    {
                        CurrentPlugins.RemoveAt(i);
                        --i;
                    }
                    else
                    {
                        otherEntry.UninstallOnClose = true;
                    }
                }
            }
            if (entry.InstallOnClose)
            {
                entry.PluginAssembly.Dispose();
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        public static void UninstallPluginAssembly(PluginAssembly pa)
        {
            List <string> pids = pa.PluginInformations.Select(pi => pi.PluginID).ToList();

            InstanceManager.LocalTabBroadcast(tabbar => pids.ForEach(pid =>
                                                                     tabbar.pluginServer.UnloadPluginInstance(pid, EndCode.Removed)));

            foreach (PluginInformation info in pa.PluginInformations)
            {
                Plugin plugin;
                if (!dicStaticPluginInstances.TryGetValue(info.PluginID, out plugin))
                {
                    continue;
                }
                if (info.PluginType == PluginType.Static)
                {
                    plugin.Close(EndCode.Removed);
                }
                dicStaticPluginInstances.Remove(info.PluginID);
            }
            dicPluginAssemblies.Remove(pa.Path);
            pa.Uninstall();
            pa.Dispose();
        }
Exemplo n.º 10
0
 public void UninstallPluginAssembly(PluginAssembly pa, bool fStatic)
 {
     foreach (PluginInformation information in pa.PluginInformations)
     {
         this.UnloadPluginInstance(information.PluginID, EndCode.Removed, fStatic);
         if (fStatic)
         {
             Plugin plugin;
             QTUtility.dicPluginShortcutKeys.Remove(information.PluginID);
             if ((information.PluginType == PluginType.Static) && dicStaticPluginInstances.TryGetValue(information.PluginID, out plugin))
             {
                 plugin.Close(EndCode.Removed);
                 dicStaticPluginInstances.Remove(information.PluginID);
             }
         }
     }
     if (fStatic)
     {
         dicPluginAssemblies.Remove(pa.Path);
         List <int> list = new List <int>();
         foreach (int[] numArray in QTUtility.dicPluginShortcutKeys.Values)
         {
             if (numArray != null)
             {
                 for (int i = 0; i < numArray.Length; i++)
                 {
                     list.Add(numArray[i]);
                 }
             }
         }
         QTUtility.PluginShortcutKeysCache = list.ToArray();
         SavePluginShortcutKeys();
         pa.Uninstall();
         pa.Dispose();
     }
 }
Exemplo n.º 11
0
 private void DeletePluginAssembly(PluginAssembly pa) {
     foreach(PluginInformation information in pa.PluginInformations) {
         RemovePluginShortcutKeys(information.PluginID);
     }
     if(lstPluginAssembliesUserAdded.Contains(pa)) {
         pa.Dispose();
         lstPluginAssembliesUserAdded.Remove(pa);
     }
 }
Exemplo n.º 12
0
 private void CreatePluginViewItem(PluginAssembly[] pluginAssemblies, bool fAddedByUser) {
     foreach(PluginAssembly assembly in pluginAssemblies.Where(assembly => assembly.PluginInfosExist
             && pluginView.PluginViewItems.All(item => item.PluginInfo.Path != assembly.Path))) {
         int num = 0;
         foreach(PluginInformation information in assembly.PluginInformations) {
             if(fAddedByUser || information.Enabled) {
                 information.Enabled = assembly.Enabled = true;
             }
             pluginView.AddPluginViewItem(information, assembly);
             num++;
         }
         if((num > 0) && fAddedByUser) {
             lstPluginAssembliesUserAdded.Add(assembly);
         }
     }
 }
Exemplo n.º 13
0
        private void btnBrowsePlugin_Click(object sender, RoutedEventArgs e) {
            using(OpenFileDialog ofd = new OpenFileDialog()) {
                ofd.Filter = QTUtility.TextResourcesDic["FileFilters"][2] + "|*.dll";
                ofd.RestoreDirectory = true;
                ofd.Multiselect = true;

                if(System.Windows.Forms.DialogResult.OK != ofd.ShowDialog()) return;
                bool fFirst = true;
                foreach(string path in ofd.FileNames) {
                    PluginAssembly pa = new PluginAssembly(path);
                    if(!pa.PluginInfosExist) continue;
                    CreatePluginEntry(pa, true);
                    if(!fFirst) continue;
                    fFirst = false;
                    lstPluginView.SelectedItem = CurrentPlugins[CurrentPlugins.Count - 1];
                    lstPluginView.ScrollIntoView(lstPluginView.SelectedItem);
                }
            }
        }
Exemplo n.º 14
0
 public static void Initialize()
 {
     using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Quizo\QTTabBar\Plugins")) {
         if (key != null)
         {
             string[]    strArray = QTUtility2.ReadRegBinary <string>("Buttons_Order", key);
             string[]    array    = QTUtility2.ReadRegBinary <string>("Enabled", key);
             PluginKey[] keyArray = QTUtility2.ReadRegBinary <PluginKey>("ShortcutKeys", key);
             QTUtility.Path_PluginLangFile = (string)key.GetValue("LanguageFile", string.Empty);
             using (RegistryKey key2 = key.CreateSubKey("Paths")) {
                 bool flag = (array != null) && (array.Length > 0);
                 foreach (string str in key2.GetValueNames())
                 {
                     string path = (string)key2.GetValue(str, string.Empty);
                     if (path.Length > 0)
                     {
                         PluginAssembly pa = new PluginAssembly(path);
                         if (pa.PluginInfosExist)
                         {
                             if (flag)
                             {
                                 foreach (PluginInformation information in pa.PluginInformations)
                                 {
                                     if (Array.IndexOf <string>(array, information.PluginID) != -1)
                                     {
                                         information.Enabled = true;
                                         pa.Enabled          = true;
                                         if (information.PluginType == PluginType.Static)
                                         {
                                             LoadStatics(information, pa, false);
                                         }
                                     }
                                 }
                             }
                             dicPluginAssemblies[path] = pa;
                         }
                     }
                 }
             }
             if ((strArray != null) && (strArray.Length > 0))
             {
                 foreach (string str3 in strArray)
                 {
                     foreach (PluginAssembly assembly2 in dicPluginAssemblies.Values)
                     {
                         PluginInformation information2;
                         if (assembly2.TryGetPluginInformation(str3, out information2))
                         {
                             if (information2.Enabled)
                             {
                                 lstPluginButtonsOrder.Add(str3);
                             }
                             break;
                         }
                     }
                 }
             }
             if (keyArray != null)
             {
                 List <int> list = new List <int>();
                 foreach (PluginKey key3 in keyArray)
                 {
                     if (key3.Keys != null)
                     {
                         QTUtility.dicPluginShortcutKeys[key3.PluginID] = key3.Keys;
                         for (int i = 0; i < key3.Keys.Length; i++)
                         {
                             list.Add(key3.Keys[i]);
                         }
                     }
                 }
                 QTUtility.PluginShortcutKeysCache = list.ToArray();
             }
         }
     }
 }
Exemplo n.º 15
0
 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;
     }
 }
Exemplo n.º 16
0
 private static PluginAssembly LoadAssembly(string path)
 {
     if(path.Length > 0) {
         PluginAssembly pa = new PluginAssembly(path);
         if(pa.PluginInfosExist) {
             string[] enabled = Config.Plugin.Enabled;
             foreach(PluginInformation info in pa.PluginInformations
                     .Where(info => enabled.Contains(info.PluginID))) {
                 info.Enabled = true;
                 pa.Enabled = true;
             }
             dicPluginAssemblies[pa.Path] = pa;
             return pa;
         }
     }
     return null;
 }
Exemplo n.º 17
0
        public static void UninstallPluginAssembly(PluginAssembly pa)
        {
            List<string> pids = pa.PluginInformations.Select(pi => pi.PluginID).ToList();
            InstanceManager.LocalTabBroadcast(tabbar => pids.ForEach(pid =>
                    tabbar.pluginServer.UnloadPluginInstance(pid, EndCode.Removed)));

            foreach(PluginInformation info in pa.PluginInformations) {
                Plugin plugin;
                if(!dicStaticPluginInstances.TryGetValue(info.PluginID, out plugin)) continue;
                if(info.PluginType == PluginType.Static) plugin.Close(EndCode.Removed);
                dicStaticPluginInstances.Remove(info.PluginID);
            }
            dicPluginAssemblies.Remove(pa.Path);
            pa.Uninstall();
            pa.Dispose();
        }
Exemplo n.º 18
0
 public static bool GetAssembly(string path, out PluginAssembly asm)
 {
     return dicPluginAssemblies.TryGetValue(path, out asm);
 }
Exemplo n.º 19
0
 private void CreatePluginEntry(PluginAssembly pa, bool fAddedByUser) {
     if(!pa.PluginInfosExist || CurrentPlugins.Any(pe => pe.Path == pa.Path)) {
         return;
     }
     foreach(PluginInformation pi in pa.PluginInformations) {
         PluginEntry entry = new PluginEntry(this, pi, pa) { InstallOnClose = fAddedByUser };
         int i = 0;
         while(i < CurrentPlugins.Count && string.Compare(CurrentPlugins[i].Title, entry.Title, true) <= 0) ++i;
         CurrentPlugins.Insert(i, entry);
     }
 }
Exemplo n.º 20
0
 public static bool GetAssembly(string path, out PluginAssembly asm)
 {
     return(dicPluginAssemblies.TryGetValue(path, out asm));
 }
Exemplo n.º 21
0
 public PluginEntry(Options12_Plugins parent, PluginInformation pluginInfo, PluginAssembly pluginAssembly)
 {
     this.parent    = parent;
     PluginInfo     = pluginInfo;
     PluginAssembly = pluginAssembly;
 }
Exemplo n.º 22
0
 private void pluginView_DragDropEx(object sender, EventArgs e) {
     bool flag = true;
     foreach(string str in this.pluginView.DroppedFiles) {
         if(!string.IsNullOrEmpty(str)) {
             PluginAssembly assembly = new PluginAssembly(str);
             if(assembly.PluginInfosExist) {
                 this.CreatePluginViewItem(new PluginAssembly[] { assembly }, true);
                 if(flag) {
                     flag = false;
                     this.SelectPluginBottom();
                 }
             }
         }
     }
 }
Exemplo n.º 23
0
 private void btnBrowsePlugin_Click(object sender, EventArgs e) {
     using(OpenFileDialog dialog = new OpenFileDialog()) {
         dialog.Filter = "Plugin files (*.dll)|*.dll";
         dialog.RestoreDirectory = true;
         dialog.Multiselect = true;
         if(DialogResult.OK == dialog.ShowDialog()) {
             bool flag = true;
             foreach(string str in dialog.FileNames) {
                 PluginAssembly assembly = new PluginAssembly(str);
                 if(assembly.PluginInfosExist) {
                     this.CreatePluginViewItem(new PluginAssembly[] { assembly }, true);
                     if(flag) {
                         flag = false;
                         this.SelectPluginBottom();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 24
0
 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;
 }
Exemplo n.º 25
0
 private void CreatePluginViewItem(PluginAssembly[] pluginAssemblies, bool fAddedByUser) {
     foreach(PluginAssembly assembly in pluginAssemblies) {
         if(assembly.PluginInfosExist) {
             bool flag = false;
             foreach(PluginViewItem item in this.pluginView.PluginViewItems) {
                 if(assembly.Path == item.PluginInfo.Path) {
                     flag = true;
                     break;
                 }
             }
             if(!flag) {
                 int num = 0;
                 foreach(PluginInformation information in assembly.PluginInformations) {
                     if(fAddedByUser || information.Enabled) {
                         information.Enabled = assembly.Enabled = true;
                     }
                     this.pluginView.AddPluginViewItem(information, assembly);
                     num++;
                 }
                 if((num > 0) && fAddedByUser) {
                     this.lstPluginAssembliesUserAdded.Add(assembly);
                 }
             }
         }
     }
 }
Exemplo n.º 26
0
 public PluginEntry(Options12_Plugins parent, PluginInformation pluginInfo, PluginAssembly pluginAssembly) {
     this.parent = parent;
     PluginInfo = pluginInfo;
     PluginAssembly = pluginAssembly;
 }