예제 #1
0
        //初期処理を行います
        public bool Initialize(PluginCreateParam param)
        {
            //プロパティファイルを読み込みます
            var property = new PluginProperty();

            property.Load(param.PropertyPath);

            //プロパティから値を取得します
            var text      = property[PluginProperty.NO_SECTION, "text"];
            var className = property[PluginProperty.NO_SECTION, "create_plugin_class_name"];
            var method    = property[PluginProperty.NO_SECTION, "method"];

            //メニューを作成します
            this.Text = text;
            //this.ShortcutKeys = Keys.F3; //TODO プロパティで指定できるようにする
            this.Click += (sender, e) => {
                var targetPlugin = PluginManager.GetInstance().ActivePlugin;
                if (targetPlugin == null)
                {
                    return;
                }

                //リフレクションで指定されたメソッドを取得します
                var methodInfo = targetPlugin.GetType().GetMethod(method);

                //メソッドが取得できない場合は、処理を中止します
                if (methodInfo == null)
                {
                    return;                     //TODO ログ出力
                }
                //メソッドを実行します
                methodInfo.Invoke(targetPlugin, null);
            };
            return(true);
        }
예제 #2
0
        //初期処理を行います
        public bool Initialize(PluginCreateParam param)
        {
            //プラグインマネージャーを保持します
            _pluginManager = PluginManager.GetInstance();

            //プロパティファイルを読み込みます
            _property = new PluginProperty();
            _property.Load(param.PropertyPath);

            //プロパティから色を取得して保持します
            _foreColor = Color.FromArgb((int)((long)0xff000000 + _property.ToInt("color", "fore_color", 0xffffff)));
            _backColor = Color.FromArgb((int)((long)0xff000000 + _property.ToInt("color", "back_color", 0x000000)));

            //カラーデータを生成して、共通データとして設定します
            var colorData = new ColorData {
                ForeColor = Color.White, BackColor = Color.Black
            };

            _pluginManager.CommonData[CommonDataKeys.ColorData] = colorData;

            //イベントハンドラーを登録します
            _pluginManager.GetEventManager().AddEventHandler(PluginCreatedEventParam.Name, this);
            _pluginManager.GetEventManager().AddEventHandler(AllPluginCreatedEventParam.Name, this);
            return(true);
        }
예제 #3
0
        public Property(PluginProperty pluginProperty)
        {
            this.pluginProperty = pluginProperty;

            ClearValueCommand = new DelegateCommand(parameter => HasOwnValue, parameter => Value = null);
            callback = new DataListener(this);
            DisplayFileChooserCommand = new DelegateCommand(null, parameter =>
            {
                DialogService.ShowFileChooserDialog((result, pathName) =>
                {
                    if (result == true)
                    {
                        string fileName = System.IO.Path.GetFileName(pathName);

                        if (!Workspace.Instance.Project.HasAssetWithFileName(fileName))
                        {
                            Notify(new AssetUsed(pathName));
                            Value = new Value("\"" + fileName + "\"");
                        }
                        else
                        {
                            Workspace.Instance.DialogService.Warn("Asset Already Exists", "This project already contains an asset named " + fileName + ".", System.Windows.MessageBoxButton.OK);
                        }
                    }
                }, this.PluginProperty.FileFilter, this.PluginProperty.FileChooserTitle);
            });
        }
예제 #4
0
        //初期処理を行います
        public bool Initialize(PluginCreateParam param)
        {
            //プラグインマネージャーを保持します
            _pluginManager = PluginManager.GetInstance();

            //プロパティファイルを読み込みます
            _property = new PluginProperty();
            _property.Load(param.PropertyPath);

            var text      = _property[PluginProperty.NO_SECTION, "text"];
            var toolTip   = _property[PluginProperty.NO_SECTION, "tool_tip_text"];
            var className = _property[PluginProperty.NO_SECTION, "create_plugin_class_name"];
            var imgPath   = _property[PluginProperty.NO_SECTION, "img_path"]; //img/calendar.png

            //ツールの画像を設定します
            if (StringUtils.IsNotEmpty(imgPath))
            {
                this.Image = System.Drawing.Image.FromFile(FileUtils.AppendPath(param.DataPath, imgPath));
            }

            //メニューを作成します
            this.Text        = text;
            this.ToolTipText = toolTip;
            this.Click      += (sender, e) => {
                //プラグインを生成します
                var type   = _pluginManager.GetPluginType(className);
                var plugin = (IPlugin)_pluginManager.CreatePluginInstance(type, new PluginCreateParam(), this);
            };

            return(true);
        }
예제 #5
0
 public HTMLToImagePlugin()
 {
     _HTMLPath = new PluginPropertyString("HTMLPath", this, false);
     _DestinationPath = new PluginPropertyFilePath("DestinationPath", this);
     _ShouldOwerwriteExistingFile = new PluginPropertyValueType<bool>("ShouldOwerwriteExistingFile", this, false);
     _Width = new PluginProperty<int>("Width", this);
     _Height = new PluginProperty<int>("Height", this);
     _Delay = new PluginProperty<int>("Delay", this, 0);
     _ShouldWaitForJavascript = new PluginProperty<bool>("ShouldWaitForJavascript", this, false);
 }
예제 #6
0
        }                                                       //プラグインが終了できるかどうか

        /// <summary>
        /// プラグインの終了処理
        /// </summary>
        public void ClosePlugin()
        {
            //入力値を保存します
            _property["input", "not_ignore_case"] = _control.NotIgnoreCase.ToString();
            _property["input", "include_sub_dir"] = _control.IncludeSubDir.ToString();
            _property["input", "use_reg_exp"]     = _control.UseRegExp.ToString();
            _property["input", "extension"]       = _control.Extension;

            //defineのプロパティに保存します
            PluginProperty.SaveToDefine(this, _property);

            //コントロールを削除します
            _control.Parent = null;
            _control.Dispose();
        }
예제 #7
0
        //初期処理を行います
        public bool Initialize(PluginCreateParam param)
        {
            //プロパティファイルを読み込みます
            var property = new PluginProperty();

            property.Load(param.PropertyPath);

            var text = property[PluginProperty.NO_SECTION, "text"];

            //メニューを作成します
            this.Text = text;
            //this.ShortcutKeys = Keys.F3; //TODO プロパティで指定できるようにする

            return(true);
        }
예제 #8
0
        //初期処理を行います
        public bool Initialize(PluginCreateParam param)
        {
            //プラグインマネージャーを保持します
            _pluginManager = PluginManager.GetInstance();

            //プロパティファイルを読み込みます
            var property = new PluginProperty();

            property.Load(param.PropertyPath);

            var text      = property[PluginProperty.NO_SECTION, "text"];
            var toolTip   = property[PluginProperty.NO_SECTION, "tool_tip_text"];
            var className = property[PluginProperty.NO_SECTION, "create_plugin_class_name"];
            var imgPath   = property[PluginProperty.NO_SECTION, "img_path"]; //img/calendar.png
            var method    = property[PluginProperty.NO_SECTION, "method"];

            //ツールの画像を設定します
            if (StringUtils.IsNotEmpty(imgPath))
            {
                this.Image = System.Drawing.Image.FromFile(FileUtils.AppendPath(param.DataPath, imgPath));
            }

            //メニューを作成します
            this.Text        = text;
            this.ToolTipText = toolTip;
            this.Click      += (sender, e) => {
                var targetPlugin = _pluginManager.ActivePlugin;
                if (targetPlugin == null)
                {
                    return;
                }

                //リフレクションで指定されたメソッドを取得します
                var methodInfo = targetPlugin.GetType().GetMethod(method);

                //メソッドが取得できない場合は、処理を中止します
                if (methodInfo == null)
                {
                    return;                     //TODO ログ出力
                }
                //メソッドを実行します
                methodInfo.Invoke(targetPlugin, null);
            };

            return(true);
        }
예제 #9
0
        //初期処理を行います
        public bool Initialize(PluginCreateParam param)
        {
            //プラグインマネージャーを保持します
            _pluginManager = PluginManager.GetInstance();

            //プロパティファイルを読み込みます
            _property = new PluginProperty();
            _property.Load(param.PropertyPath);

            var text      = _property[PluginProperty.NO_SECTION, "text"];
            var className = _property[PluginProperty.NO_SECTION, "create_plugin_class_name"];

            //メニューを作成します
            this.Text   = text;
            this.Click += (sender, e) => {
                //プラグイン生成パラメーター
                var pluginCreateParam = new PluginCreateParam();

                //親プラグインがパスを保持している場合は、
                //パスをプラグイン生成パラメーターに設定します
                if (this.ParentPlugin is IPathPlugin parentPlugin)
                {
                    var path = parentPlugin.GetPath();
                    if (string.IsNullOrEmpty(path))
                    {
                        return;                             //TODO 要検討。パスが取得できない場合に、プラグインを生成するか?
                    }
                    //プラグイン生成パラメーターを設定します
                    pluginCreateParam["path"] = path; //選択されたパス
                }

                //プラグインを生成します
                var type   = _pluginManager.GetPluginType(className);
                var plugin = (IPlugin)_pluginManager.CreatePluginInstance(type, pluginCreateParam, this);
            };

            return(true);
        }
예제 #10
0
        //初期処理を行います
        public bool Initialize(PluginCreateParam param)
        {
            //プラグインマネージャーを保持します
            _pluginManager = PluginManager.GetInstance();

            //プロパティファイルを読み込みます
            _property = new PluginProperty();
            _property.Load(param.PropertyPath);

            bool notIgnoreCase = _property.ToBool("input", "not_ignore_case");
            bool includeSubDir = _property.ToBool("input", "include_sub_dir");
            bool useRegExp     = _property.ToBool("input", "use_reg_exp");
            var  extension     = _property.ToString("input", "extension");
            var  fontName      = _property.ToString("font", "name");
            var  fontSize      = _property.ToDouble("font", "size");

            //プラグイン生成時のパスを取得します
            var path = param.ToString("path");

            //Grepコントロールを生成します
            _control = new GrepControl(this, _pluginManager, path, notIgnoreCase, includeSubDir, useRegExp, extension, fontName, (float)fontSize);
            return(true);
        }
예제 #11
0
 public BoolPropertyViewModel(PluginProperty pluginProperty) : base(pluginProperty)
 {
 }
예제 #12
0
 set => SetValue(PluginProperty, value);
예제 #13
0
 public PluginPropertyViewModel(PluginProperty pluginProperty)
 {
     this.pluginProperty = pluginProperty;
     Value = GetPropertyValueViewModel();
 }
        private PluginProperty[] GetPluginProperties(object plugin)
        {
            List <PluginProperty> pluginProperties = new List <PluginProperty>();

            if (plugin == null)
            {
                return(pluginProperties.ToArray());
            }

            Type pluginObjectType = plugin.GetType();

            foreach (System.Reflection.PropertyInfo objectProperty in pluginObjectType.GetProperties())
            {
                PluginProperty pluginProperty = new PluginProperty();
                bool           exclude        = false;
                bool           dataMember     = false;

                if (!objectProperty.CanWrite)
                {
                    continue;
                }

                pluginProperty.Name = objectProperty.Name;

                pluginProperty.Value = objectProperty.GetValue(plugin, null);

                Type propertyType = objectProperty.PropertyType;
                if (propertyType == typeof(string))
                {
                    pluginProperty.Type = "text";
                }
                else if (propertyType == typeof(int))
                {
                    pluginProperty.Type = "number";
                }
                else if (propertyType == typeof(bool))
                {
                    pluginProperty.Type = "boolean";
                }
                else if (propertyType == typeof(List <Core.Light>))
                {
                    pluginProperty.Type = "lights";

                    string[] colourClasses  = new string[] { "btn-primary", "btn-success", "btn-info", "btn-warning", "btn-danger" };
                    int      colourPosition = 0;

                    List <Core.Light> lights     = pluginProperty.Value as List <Core.Light>;
                    LightSetup        lightSetup = new LightSetup();

                    if (lights != null && lights.Any())
                    {
                        //convert back to 2d array for setup
                        lightSetup.LightRows = new List <LightRow>();

                        int numberOfRows    = lights.Max(l => l.Top);
                        int numberOfColumns = lights.Max(l => l.Left);

                        for (int row = 0; row <= numberOfRows; row++)
                        {
                            LightRow lightRow = new LightRow();
                            lightRow.RowIndex     = row;
                            lightRow.LightColumns = new List <LightColumn>();
                            for (int column = 0; column <= numberOfColumns; column++)
                            {
                                LightColumn lightColumn = new LightColumn();
                                lightColumn.ColumnIndex = column;
                                if (column == 0 || column == numberOfColumns ||
                                    row == 0 || row == numberOfRows)
                                {
                                    Light light = (from l in lights
                                                   where l.Top == row &&
                                                   l.Left == column
                                                   select l).FirstOrDefault();
                                    if (light != null)
                                    {
                                        lightColumn.Id    = light.Id.ToString();
                                        lightColumn.Index = light.Index.ToString();

                                        lightColumn.ColourClass = colourClasses[colourPosition++];

                                        lightColumn.Enabled = !string.IsNullOrEmpty(lightColumn.Id);

                                        if (lightColumn.Id == "1")
                                        {
                                            lightSetup.FirstColumnIndex = column;
                                            lightSetup.FirstRowIndex    = row;
                                        }
                                    }
                                    else
                                    {
                                        lightColumn.ColourClass = colourClasses[colourPosition++];
                                    }
                                }
                                else
                                {
                                    lightColumn.ColourClass = "disabled";
                                    lightColumn.Enabled     = false;
                                }
                                if (colourPosition >= colourClasses.Length)
                                {
                                    colourPosition = 0;
                                }
                                lightRow.LightColumns.Add(lightColumn);
                            }
                            lightSetup.LightRows.Add(lightRow);
                        }
                    }
                    pluginProperty.Value = lightSetup;
                }

                foreach (System.Attribute attr in objectProperty.GetCustomAttributes(true))
                {
                    if ((attr as DisplayAttribute) != null)
                    {
                        DisplayAttribute displayName = (DisplayAttribute)attr;
                        pluginProperty.DisplayName = displayName.Name;
                        pluginProperty.Description = displayName.Description;
                    }
                    else if ((attr as RangeAttribute) != null)
                    {
                        RangeAttribute range = (RangeAttribute)attr;
                        pluginProperty.MinValue = range.Minimum as int?;
                        pluginProperty.MaxValue = range.Maximum as int?;
                    }
                    else if ((attr as RequiredAttribute) != null)
                    {
                        RequiredAttribute required = (RequiredAttribute)attr;
                        pluginProperty.Required = required.AllowEmptyStrings;
                    }
                    else if ((attr as DataMemberAttribute) != null)
                    {
                        dataMember = true;
                    }
                    else if ((attr as KeyAttribute) != null)
                    {
                        exclude = true;
                        break;
                    }
                    else if ((attr as ConfigLookupAttribute) != null)
                    {
                        ConfigLookupAttribute lookup = (ConfigLookupAttribute)attr;
                        pluginProperty.Type = "lookup";

                        PropertyInfo optionsProperty = pluginObjectType.GetProperty(lookup.RetrieveValuesFrom);

                        IEnumerable <object> options       = optionsProperty.GetValue(plugin, null) as IEnumerable <object>;
                        List <SelectOption>  parsedOptions = new List <SelectOption>();
                        if (options.Any())
                        {
                            foreach (object option in options)
                            {
                                LookupItem       lookupItem       = option as LookupItem;
                                LookupItemString lookupItemString = option as LookupItemString;
                                SelectOption     pluginOption     = new SelectOption();

                                if (lookupItem != null)
                                {
                                    pluginOption.Id   = lookupItem.Id;
                                    pluginOption.Name = lookupItem.Name;
                                }
                                else if (lookupItemString != null)
                                {
                                    pluginOption.Id   = lookupItemString.Id;
                                    pluginOption.Name = lookupItemString.Name;
                                }
                                else
                                {
                                    pluginOption.Id   = option;
                                    pluginOption.Name = option.ToString();
                                }
                                parsedOptions.Add(pluginOption);
                            }
                        }
                        pluginProperty.Options = parsedOptions;
                    }
                }

                if (dataMember && !exclude)
                {
                    if (pluginProperty.Type == "lookup" && pluginProperty.Value != null)
                    {
                        var currentValue = (from o in pluginProperty.Options
                                            where o.Id.ToString() == pluginProperty.Value.ToString()
                                            select o).FirstOrDefault();
                        if (currentValue == null)
                        {
                            List <SelectOption> options = pluginProperty.Options as List <SelectOption>;
                            options.Add(new SelectOption()
                            {
                                Id   = pluginProperty.Value,
                                Name = "Invalid! " + pluginProperty.Value.ToString()
                            });
                            pluginProperty.Options = options;
                        }
                    }
                    pluginProperties.Add(pluginProperty);
                }
            }

            return(pluginProperties.ToArray());
        }
예제 #15
0
 public PluginObjectConfig(Guid plgid, PluginProperty plgp)
 {
     PluginClassID  = plgid;
     PluginProperty = plgp;
 }
예제 #16
0
 public ChoicesPropertyViewModel(PluginProperty pluginProperty) : base(pluginProperty)
 {
     Choices        = pluginProperty.ConcreteChoices;
     SelectedChoice = pluginProperty.SelectedChoice;
 }
예제 #17
0
 public bool HasInheritedProperty(PluginProperty property)
 {
     return false;
 }
예제 #18
0
 public Value GetInheritedValue(PluginProperty property)
 {
     return property.DefaultValue;
 }
예제 #19
0
 public static bool CanEdit(PluginProperty pluginProperty, bool defaultCheck)
 {
     return(!defaultCheck && pluginProperty.ConcreteChoices.Any());
 }
예제 #20
0
 public bool HasInheritedNonDefaultValue(PluginProperty property)
 {
     return false;
 }
예제 #21
0
 public TextPropertyViewModel(PluginProperty pluginProperty)
     : base(pluginProperty)
 {
     Text = pluginProperty.Value.ToString();
 }
예제 #22
0
 public static bool CanEdit(PluginProperty pluginProperty, bool defaultCheck)
 {
     return(!defaultCheck && pluginProperty.DefaultValue is bool);
 }
 public EffectiveValueChanged(Plugin plugin, PluginProperty property)
     : base(NotificationMode.Parent)
 {
     Plugin = plugin;
     PluginProperty = property;
 }
예제 #24
0
 public static bool CanEdit(PluginProperty pluginProperty, bool defaultCheck)
 {
     return(defaultCheck);
 }
 protected APluginExtendedFileOperation()
 {
     _SourceFilePath = new PluginPropertyFilePath("SourceFilePath", this);
     _DestinationFilePath = new PluginPropertyFilePath("DestinationFilePath", this);
     _ShouldOwerwriteExistingFile = new PluginProperty<bool>("ShouldOwerwriteExistingFile", this, false);
 }
예제 #26
0
 public PluginPropertyViewModel(PluginProperty pluginProperty)
 {
     PluginProperty = pluginProperty;
 }
예제 #27
0
 protected ValueViewModel(PluginProperty pluginProperty)
 {
     this.pluginProperty = pluginProperty;
 }