Ejemplo n.º 1
0
 public IEnumerable <ElementsGroup> GetSettings(PluginAction argAction, IDictionary <string, object> argCurrentValues)
 {
     return(new ElementsGroup[]
     {
         new ElementsGroup("group1", "Options 1", new BoolItem("bool-item", "Bool item", false)),
     });
 }
Ejemplo n.º 2
0
        public string Run(PluginInfo info, PluginAction action)
        {
            if (info.PluginType == PluginType.RESOURCE)
            {
                return(new PluginJsonResult(true).ToString());
            }

            try
            {
                switch (action)
                {
                case PluginAction.INSTALL:
                case PluginAction.REMOTEINSTALL:
                case PluginAction.UPDATE:
                case PluginAction.REMOTEUPDATE:
                    info.IsInstalled = true;
                    break;

                case PluginAction.UNSTALL:
                    info.IsInstalled = false;
                    break;
                }
                info.Save();
            }
            catch (Exception ex)
            {
                return(new PluginJsonResult(false, ex.Message).ToString());
            }
            return(new PluginJsonResult(true).ToString());
        }
Ejemplo n.º 3
0
        public override string Run(PluginInfo info, PluginAction action)
        {
            try
            {
                string widgetDownloadPath = Path.Combine(Constants.We7WidgetsFileFolder, "商城下载类");
                if (!Directory.Exists(widgetDownloadPath))
                {
                    Directory.CreateDirectory(widgetDownloadPath);
                }

                BaseControlHelper baseControlHelper = new BaseControlHelper();
                string            srcWidgetPath     = Path.Combine(info.PluginClientPath, "Widget");
                if (Directory.Exists(srcWidgetPath))
                {
                    CopyDirectory(info, action, srcWidgetPath, widgetDownloadPath);
                    baseControlHelper.CreateWidegetsIndex();                    //创建部件索引
                }

                string srcPath = Path.Combine(info.PluginClientPath, "Control");
                if (Directory.Exists(srcPath))
                {
                    CopyDirectory(info, action, srcPath, "We7Controls");
                    baseControlHelper.CreateIntegrationIndexConfig();                    //创建控件索引
                }
            }
            catch (Exception ex)
            {
                return(new PluginJsonResult(false, ex.Message).ToString());
            }
            return(new PluginJsonResult(true).ToString());
        }
Ejemplo n.º 4
0
 public PluginActionData(PluginAction action, Guid pluginGuid, byte[] integrityHash, byte[] pluginData)
 {
     Action = action;
     PluginGuid = pluginGuid;
     IntegrityHash = integrityHash;
     PluginData = pluginData;
 }
Ejemplo n.º 5
0
        public string Run(PluginInfo info, PluginAction action)
        {
            if (info.PluginType == PluginType.RESOURCE)
            {
                return(new PluginJsonResult(true).ToString());
            }

            info.LoadXml();
            if (String.IsNullOrEmpty(info.Version) || String.Compare(info.Version, Version, true) < 0)
            {
                if (action == PluginAction.INSTALL || action == PluginAction.REMOTEINSTALL)
                {
                    try
                    {
                        Directory.Delete(info.PluginClientPath, true);
                    }
                    catch (Exception ex)
                    {
                        Logger.Warn(info.PluginClientPath + "不能删除:\r\n" + ex.Message);
                    }
                }
                return(new PluginJsonResult(false, "当前插件版本低于" + Version + "。不能进行安装!").ToString());
            }
            return(new PluginJsonResult(true).ToString());
        }
Ejemplo n.º 6
0
        public string Run(PluginInfo info, PluginAction action)
        {
            if (info.PluginType == PluginType.RESOURCE)
            {
                return(new PluginJsonResult(true).ToString());
            }

            try
            {
                string dataDir = Path.Combine(info.PluginClientPath, "Data");
                switch (action)
                {
                case PluginAction.INSTALL:
                case PluginAction.REMOTEINSTALL:
                    CheckFileExits(info.Deployment.Install, dataDir);
                    CheckFileExits(info.Deployment.Update, dataDir);
                    break;

                case PluginAction.UPDATE:
                case PluginAction.REMOTEUPDATE:
                    CheckFileExits(info.Deployment.Update, dataDir);
                    break;

                case PluginAction.UNSTALL:
                    CheckFileExits(info.Deployment.Update, dataDir);
                    break;
                }
            }
            catch (Exception ex)
            {
                return(new PluginJsonResult(false, ex.Message).ToString());
            }
            return(new PluginJsonResult(true).ToString());
        }
Ejemplo n.º 7
0
        public void PluginAction_GetHashCode_Not_Equal_To_Zero()
        {
            const string expectedMethod = "testMethod";

            var mockServiceInput = new Mock <IServiceInput>();

            mockServiceInput.Setup(serviceInput => serviceInput.Name).Returns("testName");
            mockServiceInput.Setup(serviceInput => serviceInput.Value).Returns("1");

            var mockServiceInputOther = new Mock <IServiceInput>();

            mockServiceInputOther.Setup(serviceInput => serviceInput.Name).Returns("testNewName");
            mockServiceInputOther.Setup(serviceInput => serviceInput.Value).Returns("2");

            var expectedInputs = new List <IServiceInput>
            {
                mockServiceInput.Object,
                mockServiceInputOther.Object
            };

            var pluginAction = new PluginAction
            {
                Method = expectedMethod,
                Inputs = expectedInputs
            };

            var hashCode = pluginAction.GetHashCode();

            Assert.AreNotEqual(0, hashCode);
        }
 public PluginActionData(PluginAction action, Guid pluginGuid, byte[] integrityHash, byte[] pluginData)
 {
     Action        = action;
     PluginGuid    = pluginGuid;
     IntegrityHash = integrityHash;
     PluginData    = pluginData;
 }
Ejemplo n.º 9
0
 public IDictionary <string, object> GetProcessingSettingsForAction(PluginAction argAction)
 {
     return(new Dictionary <string, object>
     {
         // Supported file formats
         [ProcessSettings.COSupportedFileFormatsKey] = new[]
         {
             ProcessSettings.COProcessFileFormat.COProcessFileFormatTIFF,
             ProcessSettings.COProcessFileFormat.COProcessFileFormatJPEG
         },
         // The default export formats
         [ProcessSettings.COProcessFileFormatKey] = ProcessSettings.COProcessFileFormat.COProcessFileFormatJPEG,
         // Include annotations
         [ProcessSettings.COProcessIncludeAnnotationsKey] = true,
         // Include keywords
         [ProcessSettings.COProcessIncludeKeywordsMetadataKey] = ProcessSettings.COProcessMetadataIncludeKeywords.COProcessMetadataIncludeKeywordsIncludeAll,
         // Scale to 100px on the long edge
         [ProcessSettings.COProcessScaleMethodKey] = ProcessSettings.COProcessScaleMethod.COProcessScaleMethodLongEdge,
         [ProcessSettings.COProcessLongEdgeScaleKey] = new Dictionary <string, object>
         {
             [ProcessSettings.COProcessScaleLengthKey] = 100,
             [ProcessSettings.COProcessScaleUnitKey] = ProcessSettings.COProcessSizeUnit.COProcessSizeUnitPixel
         }
     });
 }
Ejemplo n.º 10
0
        public IEnumerable <FileHandlingPluginTask> GetTasks(PluginAction argPluginAction, IEnumerable <string> argFiles)
        {
            // one task for all files
            if (argPluginAction.Identifier == _openConfiguratorAction.Identifier)
            {
                var firstFile = argFiles.FirstOrDefault(f => f != null && (f.EndsWith("jpeg") || f.EndsWith(".jpg")));

                if (firstFile != null)
                {
                    return(new[]
                    {
                        new FileHandlingPluginTask(Guid.NewGuid(), argPluginAction, new [] { firstFile }),
                    });
                }
            }
            else if (argPluginAction.Identifier == _runProcessAction.Identifier)
            {
                var files = argFiles.Where(f => f != null && (f.EndsWith("jpeg") || f.EndsWith(".jpg")));

                if (files.Any())
                {
                    return(new[]
                    {
                        new FileHandlingPluginTask(Guid.NewGuid(), argPluginAction, files.ToArray()),
                    });
                }
            }

            var tasks = argFiles.Select(f => new FileHandlingPluginTask(Guid.NewGuid(), argPluginAction, new[] { f }));

            return(tasks);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 拷贝安装文件到指定目录或删除指定目录下的文件
        /// </summary>
        /// <param name="info">控件信息</param>
        /// <param name="action">当前动作</param>
        /// <param name="source">源文件</param>
        /// <param name="target">目标文件</param>
        protected void CopyFile(PluginInfo info, PluginAction action, string source, string target)
        {
            string        srcPath   = Path.Combine(info.PluginClientPath, source);
            DirectoryInfo sourceDir = new DirectoryInfo(srcPath);

            if (!sourceDir.Exists)
            {
                return;
            }
            //throw new Exception("安装文件缺失,请检查安装文件");

            string        targetPath = Path.Combine(info.BaseDircotry, target);
            DirectoryInfo targetDir  = new DirectoryInfo(targetPath);

            if (!targetDir.Exists)
            {
                targetDir.Create();
            }

            switch (action)
            {
            case PluginAction.INSTALL:
            case PluginAction.UPDATE:
            case PluginAction.REMOTEINSTALL:
            case PluginAction.REMOTEUPDATE:
                foreach (FileInfo file in sourceDir.GetFiles())
                {
                    file.CopyTo(Path.Combine(targetPath, Path.GetFileName(file.FullName)), true);
                }
                break;

            case PluginAction.UNSTALL:
                foreach (FileInfo file in sourceDir.GetFiles())
                {
                    string filePath = Path.Combine(targetPath, Path.GetFileName(file.FullName));
                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }
                }
                foreach (DirectoryInfo di in sourceDir.GetDirectories())
                {
                    if (di.Name.Contains(".svn"))
                    {
                        continue;
                    }
                    string dipath = Path.Combine(targetPath, di.Name);
                    if (Directory.Exists(dipath))
                    {
                        Directory.Delete(dipath);
                    }
                }
                if (0 == targetDir.GetFileSystemInfos().Length)
                {
                    targetDir.Delete();
                }
                ;
                break;
            }
        }
Ejemplo n.º 12
0
        public void ComActionRegion_ChangeActionSomethingChanged_RegionsNotRestored_Invalid()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfComDllActivity {
                SourceId = id
            };
            var src       = new Mock <IComPluginServiceModel>();
            var dotNetsrc = new ComPluginSourceDefinition()
            {
                Id = id
            };
            var action = new PluginAction {
                FullName = "bravo"
            };

            var s2 = new ComPluginSourceDefinition {
                Id = Guid.NewGuid()
            };
            var action1 = new PluginAction {
                FullName = "bravo1"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IComPluginSource>()
            {
                dotNetsrc, s2
            });

            ComSourceRegion sourceRegion = new ComSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfComDllActivity()));

            var namespaceItem = new NamespaceItem {
                FullName = "johnny"
            };
            ComNamespaceRegion comNamespaceRegion = new ComNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            comNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Execute Test---------------------------
            ComActionRegion dotNetActionRegion = new ComActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, comNamespaceRegion);

            var clone1 = new Mock <IToolRegion>();
            var clone2 = new Mock <IToolRegion>();
            var dep1   = new Mock <IToolRegion>();

            dep1.Setup(a => a.CloneRegion()).Returns(clone1.Object);

            var dep2 = new Mock <IToolRegion>();

            dep2.Setup(a => a.CloneRegion()).Returns(clone2.Object);
            dotNetActionRegion.Dependants = new List <IToolRegion> {
                dep1.Object, dep2.Object
            };
            dotNetActionRegion.SelectedAction = action;
            dotNetActionRegion.SelectedAction = action1;

            //------------Assert Results-------------------------
            dep1.Verify(a => a.RestoreRegion(clone1.Object), Times.Never);
            dep2.Verify(a => a.RestoreRegion(clone2.Object), Times.Never);
        }
Ejemplo n.º 13
0
        public void PluginAction_GetHashCode_Expect_Zero()
        {
            var pluginAction = new PluginAction();

            var hashCode = pluginAction.GetHashCode();

            Assert.AreEqual(0, hashCode);
        }
 public void TraversePlugins(PluginAction action)
 {
     _extensions.ForEach(ext => {
         if (ext is IBioLinkPlugin)
         {
             action(ext as IBioLinkPlugin);
         }
     });
 }
Ejemplo n.º 15
0
        public void PluginAction_Equals_Object_Null_Expected_False()
        {
            var pluginAction = new PluginAction();

            const object pluginActionObj = null;

            var isEqual = pluginAction.Equals(pluginActionObj);

            Assert.IsFalse(isEqual);
        }
Ejemplo n.º 16
0
        public void PluginAction_Equals_PluginAction_Null_Expected_False()
        {
            var pluginAction = new PluginAction();

            const PluginAction nullPluginAction = null;

            var isEqual = pluginAction.Equals(nullPluginAction);

            Assert.IsFalse(isEqual);
        }
Ejemplo n.º 17
0
        public virtual void RemoveAction(Framework.Interfaces.IPlugin plugin, string action, string subAction)
        {
            PluginAction pa = (from p in _pluginActionList where p.plugin == plugin && p.action == action && p.subaction == subAction select p).FirstOrDefault();

            if (pa != null)
            {
                RemovePluginAction(pa);
                _pluginActionList.Remove(pa);
            }
        }
Ejemplo n.º 18
0
        public virtual void AddAction(Framework.Interfaces.IPlugin plugin, string action)
        {
            PluginAction pa = new PluginAction();

            pa.plugin = plugin;
            pa.action = action;
            pa.Tag    = null;
            _pluginActionList.Add(pa);

            plugin.Closing += new Framework.EventArguments.PluginEventHandler(plugin_Closing);
            AddPluginAction(pa);
        }
Ejemplo n.º 19
0
        public void PluginAction_ReferenceEquals_PluginAction_Expected_True()
        {
            const string expectedMethod = "testMethod";

            var pluginAction = new PluginAction
            {
                Method = expectedMethod
            };

            var isEqual = pluginAction.Equals(pluginAction);

            Assert.IsTrue(isEqual);
        }
Ejemplo n.º 20
0
        public AccPlugin() : base()
        {
            // You read the name of the PluginActions from a file or even hard code them here because from the analysis phase, the features of this system are already specified
            // It makes a PluginAction and adds it to the list of pluginActions derived from the parent
            PluginAction showVoucherFormAction = new PluginAction("صدور سند",
                                                                  () =>
            {
                Form1 frm = new Form1(); frm.Show();
            } //  A Method could be written and called here instead of what I did
                                                                  );

            this.PluginActions.Add(showVoucherFormAction); // We had defined it as a protected property indicating the PluginActions must be set in a child
        }
Ejemplo n.º 21
0
 public override string Run(PluginInfo info, PluginAction action)
 {
     try
     {
         string srcPath = Path.Combine(info.PluginClientPath, "Skin");
         CopyDirectory(info, action, srcPath, "_Skins");
     }
     catch (Exception ex)
     {
         return(new PluginJsonResult(false, ex.Message).ToString());
     }
     return(new PluginJsonResult(true).ToString());
 }
Ejemplo n.º 22
0
 public ValidationResult ValidateSettings(PluginAction argAction, IDictionary <string, object> argSettings)
 {
     if (argSettings.TryGetValue("bool-item", out var value))
     {
         if (!(bool)value)
         {
             return(new ValidationResult(new Dictionary <string, string> {
                 { "bool-item", "It has to be checked" }
             }));
         }
         return(new ValidationResult()); // validation OK
     }
     throw new PluginException("Unable to validate - internal error");
 }
Ejemplo n.º 23
0
 public override string Run(PluginInfo info, PluginAction action)
 {
     try
     {
         string srcPath = Path.Combine(info.PluginClientPath, "Model");
         CopyDirectory(info, action, srcPath, "Models");
         ModelHelper.ReCreateModelIndex();
     }
     catch (Exception ex)
     {
         return(new PluginJsonResult(false, ex.Message).ToString());
     }
     return(new PluginJsonResult(true).ToString());
 }
Ejemplo n.º 24
0
        public void PluginAction_Equals_Object_Expected_True()
        {
            const string expectedMethod = "testMethod";

            var pluginAction = new PluginAction
            {
                Method = expectedMethod
            };

            object pluginActionObj = pluginAction;

            var isEqual = pluginAction.Equals(pluginActionObj);

            Assert.IsTrue(isEqual);
        }
Ejemplo n.º 25
0
        public void PluginAction_Equals_Object_GetType_Expected_False()
        {
            const string expectedMethod = "testMethod";

            var pluginAction = new PluginAction
            {
                Method = expectedMethod
            };

            var pluginActionObj = new object();

            var isEqual = pluginAction.Equals(pluginActionObj);

            Assert.IsFalse(isEqual);
        }
        public void LoadPlugins(PluginAction pluginAction)
        {
            var path1 = string.Format("{0}|^BioLink[.].*[.]dll$", AppDomain.CurrentDomain.BaseDirectory);
            var path2 = string.Format("{0}/plugins", AppDomain.CurrentDomain.BaseDirectory);

            LoadPlugins(pluginAction, path1, path2);

            NotifyProgress("Loading html...", 99, ProgressEventType.Update);

            var service = new SupportService(User);
            var links   = service.GetMultimediaItems(TraitCategoryType.Biolink.ToString(), SupportService.BIOLINK_HTML_INTRA_CAT_ID);

            if (links.Count > 0)
            {
                var directory = new DirectoryInfo(Path.Combine(SystemUtils.GetUserDataPath(), ".BioLink"));
                if (directory.Exists)
                {
                    directory.Delete(true);
                }

                directory.Create();


                string htmlfile = "";
                foreach (MultimediaLink link in links)
                {
                    var filename = Path.Combine(directory.FullName, link.Name + "." + link.Extension);
                    var bytes    = service.GetMultimediaBytes(link.MultimediaID);
                    File.WriteAllBytes(filename, bytes);

                    if (link.Extension.StartsWith("html", StringComparison.CurrentCultureIgnoreCase))
                    {
                        htmlfile = filename;
                    }
                }

                if (!string.IsNullOrWhiteSpace(htmlfile))
                {
                    BioLinkCorePlugin core = GetExtensionsOfType <BioLinkCorePlugin>()[0];
                    var browser            = new WebBrowser();
                    AddDocumentContent(core, browser, new DockableContentOptions {
                        Title = "Welcome"
                    });
                    browser.Navigate(string.Format("file:///{0}", htmlfile));
                }
            }
        }
Ejemplo n.º 27
0
        public void ComActionRegion_ChangeActionSomethingChanged_RestoreRegion_ExpectedRestore()
        {
            //------------Setup for test--------------------------
            var id  = Guid.NewGuid();
            var act = new DsfComDllActivity {
                SourceId = id
            };
            var src       = new Mock <IComPluginServiceModel>();
            var dotNetsrc = new ComPluginSourceDefinition {
                Id = id
            };
            var s2 = new ComPluginSourceDefinition {
                Id = Guid.NewGuid()
            };
            var action = new PluginAction {
                FullName = "bravo"
            };

            src.Setup(a => a.RetrieveSources()).Returns(new ObservableCollection <IComPluginSource>()
            {
                dotNetsrc, s2
            });

            ComSourceRegion sourceRegion = new ComSourceRegion(src.Object, ModelItemUtils.CreateModelItem(new DsfComDllActivity()));

            var namespaceItem = new NamespaceItem {
                FullName = "johnny"
            };
            ComNamespaceRegion comNamespaceRegion = new ComNamespaceRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion);

            comNamespaceRegion.SelectedNamespace = namespaceItem;

            //------------Execute Test---------------------------
            ComActionRegion dotNetActionRegion = new ComActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, comNamespaceRegion);
            // ReSharper disable once UseObjectOrCollectionInitializer
            ComActionRegion dotNetActionRegionToRestore = new ComActionRegion(src.Object, ModelItemUtils.CreateModelItem(act), sourceRegion, comNamespaceRegion);

            dotNetActionRegionToRestore.IsEnabled      = false;
            dotNetActionRegionToRestore.SelectedAction = action;

            dotNetActionRegion.RestoreRegion(dotNetActionRegionToRestore);

            //------------Assert Results-------------------------
            Assert.AreEqual(dotNetActionRegion.SelectedAction, action);
            Assert.IsFalse(dotNetActionRegion.IsEnabled);
        }
Ejemplo n.º 28
0
        public override string Run(PluginInfo info, PluginAction action)
        {
            if (info.PluginType == PluginType.RESOURCE)
            {
                return(new PluginJsonResult(true).ToString());
            }

            try
            {
                CopyFile(info, action, "Bin", "Bin");
            }
            catch (Exception ex)
            {
                return(new PluginJsonResult(false, ex.Message).ToString());
            }
            return(new PluginJsonResult(true).ToString());
        }
Ejemplo n.º 29
0
 public IEnumerable <FileHandlingPluginTask> GetTasks(PluginAction argPluginAction, IEnumerable <string> argFiles)
 {
     // one task for all files
     if (argPluginAction.Identifier == publishAction.Identifier)
     {
         return(new[]
         {
             new FileHandlingPluginTask(Guid.NewGuid(), argPluginAction, argFiles),
         });
     }
     // create a task for each file
     else
     {
         var tasks = argFiles.Select(f => new FileHandlingPluginTask(Guid.NewGuid(), argPluginAction, new[] { f }));
         return(tasks);
     }
 }
Ejemplo n.º 30
0
        public override string Run(PluginInfo info, PluginAction action)
        {
            if (info.PluginType == PluginType.RESOURCE)
            {
                return(new PluginJsonResult(true).ToString());
            }

            try
            {
                CopyFile(info, action, "Data/Relation", "App_Data/XML");
                //CopyFile(info, action, "Data", "Install/SQL/plugin_" + info.Directory);
            }
            catch (Exception ex)
            {
                return(new PluginJsonResult(false, ex.Message).ToString());
            }
            return(new PluginJsonResult(true).ToString());
        }
Ejemplo n.º 31
0
        public DemoPlugin()
        {
            publishActionImage = getImage(Environment.CurrentDirectory + "/actionIcon.png");
            publishAction      = new PluginAction(
                "publish to dummy service - all files in one task",
                "publishActionAllFilesId")
            {
                Image = publishActionImage
            };
            publishActionEachFileSeparately = new PluginAction(
                "publish to dummy service - each file as a separate task",
                "publishActionSeparatelyId")
            {
                Image = publishActionImage
            };

            randomSleepTime = new Random();
        }
Ejemplo n.º 32
0
 public override void RemovePluginAction(PluginAction pa)
 {
     if (pa != null)
     {
         if (toolStripComboBoxScript.Items.Contains(pa))
         {
             toolStripComboBoxScript.Items.Remove(pa);
         }
         if (pa.plugin.PluginType == Framework.PluginType.Action && pa.action == "Action builder")
         {
             for (int i = 0; i < toolStripComboBoxBuilderFlows.Items.Count; i++)
             {
                 ActionBuilderPluginAction bpa = toolStripComboBoxBuilderFlows.Items[i] as ActionBuilderPluginAction;
                 if (bpa != null)
                 {
                     if (bpa.subaction == pa.subaction)
                     {
                         toolStripComboBoxBuilderFlows.Items.Remove(bpa);
                         break;
                     }
                 }
             }
         }
         else if (pa.plugin.PluginType == Framework.PluginType.Action && pa.action == "Action sequence")
         {
             for (int i = 0; i < toolStripComboBoxActionSequence.Items.Count; i++)
             {
                 ActionSequencePluginAction bpa = toolStripComboBoxActionSequence.Items[i] as ActionSequencePluginAction;
                 if (bpa != null)
                 {
                     if (bpa.subaction == pa.subaction)
                     {
                         toolStripComboBoxActionSequence.Items.Remove(bpa);
                         break;
                     }
                 }
             }
         }
         ToolStripMenuItem mi = pa.Tag as ToolStripMenuItem;
         if (mi != null)
         {
             mi.Dispose();
             pa.Tag = null;
         }
     }
 }
Ejemplo n.º 33
0
 private async Task startPluginAction(PluginAction pa)
 {
     if (pa != null)
     {
         PrepareCommandExecution(); ;
         try
         {
             if (string.IsNullOrEmpty(pa.subaction))
             {
                 await pa.plugin.ActionAsync(pa.action);
             }
             else
             {
                 await pa.plugin.ActionAsync(string.Format("{0}{1}{2}", pa.action, Utils.BasePlugin.Plugin.SubActionSep, pa.subaction));
             }
         }
         catch(Exception e)
         {
             System.Windows.Forms.MessageBox.Show(e.Message, Utils.LanguageSupport.Instance.GetTranslation("Error"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
         }
         CommandExecutionFinished();
     }
 }
Ejemplo n.º 34
0
        public override void AddPluginAction(PluginAction pa)
        {
            AddPluginActionForToolbar(pa);

            ToolStripItem mi = new ToolStripMenuItem();
            mi.Text = Utils.LanguageSupport.Instance.GetTranslation(pa.action);
            mi.Tag = pa;
            pa.Tag = mi;
            mi.Click += new EventHandler(mi_Click);

            var p = (from s in Core.ShortcutInfo where s.PluginType == pa.plugin.GetType().ToString() && s.PluginAction == pa.action && (s.PluginSubAction ?? "") == (pa.subaction ?? "") select s).FirstOrDefault();
            if (p != null)
            {
                (mi as ToolStripMenuItem).ShortcutKeyDisplayString = p.ShortcutKeyString;
                (mi as ToolStripMenuItem).ShortcutKeys = p.ShortcutKeys;
            }
            var tsp = (from t in _toolbarActionProperties where t.PluginType == pa.plugin.PluginType && t.Action == (pa.action ?? "") && t.SubAction == (pa.subaction ?? "") select t).FirstOrDefault();
            if (tsp != null)
            {
                (mi as ToolStripMenuItem).Image = tsp.ButtonImage;
                (mi as ToolStripMenuItem).ImageScaling = ToolStripItemImageScaling.None;
            }

            ToolStripMenuItem misub = null;
            if (!string.IsNullOrEmpty(pa.subaction))
            {
                mi.Text = Utils.LanguageSupport.Instance.GetTranslation(pa.subaction);

                misub = (from m in _pluginActionList
                         where m.action == pa.action && m.plugin == pa.plugin && string.IsNullOrEmpty(m.subaction)
                         select m.Tag as ToolStripMenuItem).FirstOrDefault();

                if (misub == null)
                {
                    //ok, parent does not exist, create
                    PluginAction parentPa = new PluginAction();
                    parentPa.action = pa.action;
                    parentPa.subaction = null;
                    parentPa.plugin = pa.plugin;
                    _pluginActionList.Add(parentPa);

                    misub = new ToolStripMenuItem();
                    misub.Text = Utils.LanguageSupport.Instance.GetTranslation(pa.action);
                    misub.Tag = pa;
                    parentPa.Tag = misub;
                    misub.DropDownItems.Add(mi);

                    mi = misub;
                }
                else
                {
                    if (mi.Text == "-")
                    {
                        misub.DropDownItems.Add(new ToolStripSeparator());
                        mi.Dispose();
                    }
                    else
                    {
                        misub.DropDownItems.Add(mi);
                    }
                    return;
                }
            }

            if (mi.Text == "-")
            {
                mi.Dispose();
                mi = new ToolStripSeparator();
            }
            switch (pa.plugin.PluginType)
            {
                case Framework.PluginType.InternalStorage:
                    fileToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.LanguageSupport:
                    languageToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.ImportData:
                    importToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.ExportData:
                    exportToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.UIChildWindow:
                    windowToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.GeocacheSelectFilter:
                    searchToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.Action:
                    actionToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.Script:
                    scriptsToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.PluginManager:
                    pluginsToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.Debug:
                    windowToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.LiveAPI:
                    liveAPIToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.OKAPI:
                    oKAPIToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.ImageResource:
                    actionToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.GenericWindow:
                    windowToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.Map:
                    mapToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.Account:
                    fileToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                case Framework.PluginType.GeocacheCollection:
                    windowToolStripMenuItem.DropDownItems.Add(mi);
                    break;
                default:
                    pluginsToolStripMenuItem.DropDownItems.Add(mi);
                    break;
            }
        }
Ejemplo n.º 35
0
        public void AddPluginActionForToolbar(PluginAction pa)
        {
            var tsp = (from t in _toolbarActionProperties where t.PluginType == pa.plugin.PluginType && t.Action == (pa.action ?? "") && t.SubAction == (pa.subaction ?? "") select t).FirstOrDefault();
            if (tsp != null)
            {
                ToolStripButton tb = new ToolStripButton(tsp.ButtonImage);
                if (!string.IsNullOrEmpty(pa.subaction))
                {
                    tb.Text = string.Format("{0} - {1}", Utils.LanguageSupport.Instance.GetTranslation(pa.action), Utils.LanguageSupport.Instance.GetTranslation(pa.subaction));
                }
                else
                {
                    tb.Text = string.Format("{0}", Utils.LanguageSupport.Instance.GetTranslation(pa.action));
                }
                tb.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
                tb.ImageTransparentColor = System.Drawing.Color.Magenta;
                tb.Click += new EventHandler(mi_Click);
                tb.Tag = pa;
                tsp.DefaultToolStrip.Items.Add(tb);
                if (_sizeInitialized && (
                    (tsp.DefaultToolStrip == toolStripFile && PluginSettings.Instance.ToolbarFile) ||
                    (tsp.DefaultToolStrip == toolStripSearch && PluginSettings.Instance.ToolbarSearch) ||
                    (tsp.DefaultToolStrip == toolStripScripts && PluginSettings.Instance.ToolbarScripts) ||
                    (tsp.DefaultToolStrip == toolStripWindows && PluginSettings.Instance.ToolbarWindows) ||
                    (tsp.DefaultToolStrip == toolStripMaps && PluginSettings.Instance.ToolbarMaps) ||
                    (tsp.DefaultToolStrip == toolStripActions && PluginSettings.Instance.ToolbarActions) ||
                    (tsp.DefaultToolStrip == toolStripLiveAPI && PluginSettings.Instance.ToolbarLiveAPI)
                    ))
                {
                    tsp.DefaultToolStrip.Visible = true;
                }
                _toolbarItems.Add(tb);

                //custom toolbar?
                if (CustomToolbarSettingForm.GetToolbarPropertySelected(tsp))
                {
                    tb = new ToolStripButton(tsp.ButtonImage);
                    if (!string.IsNullOrEmpty(pa.subaction))
                    {
                        tb.Text = string.Format("{0} - {1}", Utils.LanguageSupport.Instance.GetTranslation(pa.action), Utils.LanguageSupport.Instance.GetTranslation(pa.subaction));
                    }
                    else
                    {
                        tb.Text = string.Format("{0}", Utils.LanguageSupport.Instance.GetTranslation(pa.action));
                    }
                    tb.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
                    tb.ImageTransparentColor = System.Drawing.Color.Magenta;
                    tb.Click += new EventHandler(mi_Click);
                    tb.Tag = pa;
                    toolStripCustom.Items.Add(tb);
                    _toolbarItems.Add(tb);
                }
            }
            if (pa.plugin.PluginType == Framework.PluginType.Script)
            {
                if (pa.action != "Select Folder" && pa.action != "Refresh" && pa.action != "-")
                {
                    toolStripComboBoxScript.Items.Add(pa);
                }
            }
            else if (pa.plugin.PluginType == Framework.PluginType.Action)
            {
                if (pa.action == "Action builder")
                {
                    if (pa.subaction != "Editor" && pa.subaction != "-")
                    {
                        ActionBuilderPluginAction bpa = new ActionBuilderPluginAction();
                        bpa.action = pa.action;
                        bpa.plugin = pa.plugin;
                        bpa.subaction = pa.subaction;
                        bpa.Tag = pa.Tag;
                        toolStripComboBoxBuilderFlows.Items.Add(bpa);
                    }
                }
                else if (pa.action == "Action sequence")
                {
                    if (pa.subaction != "Edit" && pa.subaction != "-")
                    {
                        ActionSequencePluginAction bpa = new ActionSequencePluginAction();
                        bpa.action = pa.action;
                        bpa.plugin = pa.plugin;
                        bpa.subaction = pa.subaction;
                        bpa.Tag = pa.Tag;
                        toolStripComboBoxActionSequence.Items.Add(bpa);
                    }
                }
            }
        }
Ejemplo n.º 36
0
 public virtual void RemovePluginAction(PluginAction pa)
 {
 }
Ejemplo n.º 37
0
 public virtual void AddPluginAction(PluginAction pa)
 {
 }
Ejemplo n.º 38
0
        public virtual void AddAction(Framework.Interfaces.IPlugin plugin, string action, string subaction)
        {
            PluginAction pa = new PluginAction();
            pa.plugin = plugin;
            pa.action = action;
            pa.subaction = subaction;
            pa.Tag = null;
            _pluginActionList.Add(pa);

            plugin.Closing += new Framework.EventArguments.PluginEventHandler(plugin_Closing);
            AddPluginAction(pa);
        }