Esempio n. 1
0
        private void ShowPluginInfo(object sender, EventArgs eventArgs)
        {
            IPlugin plugin = (IPlugin)((ToolStripMenuItem)sender).Tag;

            PluginInfoDialog pluginInfoDialog = new PluginInfoDialog(plugin);

            pluginInfoDialog.ShowDialog();
        }
        public void GatherPluginInfo(Dictionary <string, string> replacementsDictionary, object[] customParams)
        {
            var destination = replacementsDictionary["$destinationdirectory$"];

            _pluginInfo.Name        = replacementsDictionary["$specifiedsolutionname$"];
            _pluginInfo.Description = "This is my awesome plugin";
            _pluginInfo.Icon        = "ToyBrickPlus";

            var pluginInfoDialog          = new PluginInfoDialog(_pluginInfo);
            var pluginInfoDialogCompleted = pluginInfoDialog.ShowModal();

            if (pluginInfoDialogCompleted == false)
            {
                throw new WizardCancelledException();
            }

            // Paths
            replacementsDictionary["$ArtemisDirectory$"]        = GetRelativePath(_pluginInfo.ArtemisDirectory, destination);
            replacementsDictionary["$ArtemisDirectoryEscaped$"] = GetRelativePath(_pluginInfo.ArtemisDirectory, destination).Replace("\\", "\\\\");

            // Nuget package versions
            replacementsDictionary["$MaterialDesignThemesVersion$"]     = GetNugetFileVersion("MaterialDesignThemes.Wpf.dll");
            replacementsDictionary["$MaterialDesignExtensionsVersion$"] = GetNugetFileVersion("MaterialDesignExtensions.dll");
            replacementsDictionary["$FluentValidationVersion$"]         = GetNugetFileVersion("FluentValidation.dll");
            replacementsDictionary["$SkiaSharpVersion$"] = GetNugetFileVersion("SkiaSharp.dll");
            replacementsDictionary["$StyletVersion$"]    = GetNugetFileVersion("Stylet.dll");

            // Plugin info
            replacementsDictionary["$PluginGuid$"]        = _pluginInfo.Guid.ToString();
            replacementsDictionary["$PluginName$"]        = _pluginInfo.Name;
            replacementsDictionary["$PluginDescription$"] = _pluginInfo.Description;
            replacementsDictionary["$PluginAuthor$"]      = _pluginInfo.Author;
            replacementsDictionary["$PluginWebsite$"]     = _pluginInfo.Website != null ? $"\"{_pluginInfo.Website}\"" : "null";
            replacementsDictionary["$PluginRepository$"]  = _pluginInfo.Repository != null ? $"\"{_pluginInfo.Repository}\"" : "null";
            if (_pluginInfo.Icon != null)
            {
                replacementsDictionary["$PluginIcon$"] = _pluginInfo.Icon;
            }

            // customParams contains the path to the template
            if (customParams.Any(p => p.ToString().Contains("Module")))
            {
                _pluginType = new ModulePluginType(this, replacementsDictionary, customParams, _pluginInfo);
            }
            else if (customParams.Any(p => p.ToString().Contains("Layer Brush")))
            {
                _pluginType = new LayerBrushType(this, replacementsDictionary, customParams, _pluginInfo);
            }
            else if (customParams.Any(p => p.ToString().Contains("Layer Effect")))
            {
                _pluginType = new LayerEffectType(this, replacementsDictionary, customParams, _pluginInfo);
            }
            else if (customParams.Any(p => p.ToString().Contains("Device")))
            {
                _pluginType = new DeviceType(replacementsDictionary);
            }
            else
            {
                throw new Exception("Couldn't detect a plugin type based on the template that was selected.");
            }

            _pluginType.GatherInfo();
        }