Beispiel #1
0
        public void InitPlugin(string[] args)
        {
            // start ..
            Log.Info("InitPlugin() called with args = {0}", (args == null) ? "" : string.Join(", ", args));

            // .. with built-in options
            options = AdvancedTextEditOptions.CreateDefault();

            // try load defaults options from assy directory
            try
            {
                var newOpt =
                    AasxPluginOptionsBase.LoadDefaultOptionsFromAssemblyDir <AdvancedTextEditOptions>(
                        this.GetPluginName(), Assembly.GetExecutingAssembly());
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Exception when reading default options {1}");
            }
        }
Beispiel #2
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt = Newtonsoft.Json.JsonConvert.DeserializeObject <AdvancedTextEditOptions>(
                    (args[0] as string));
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                    this.options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense = "The AvalonEdit component, is licensed under the MIT license (MIT).";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && this.eventStack != null)
            {
                // try access
                return(this.eventStack.PopEvent());
            }

            if (action == "get-textedit-control" && args != null && args.Length >= 1 && args[0] is string)
            {
                // args
                var initialContent = args[0] as string;

                // build visual
                this.theEditControl      = new UserControlAdvancedTextEditor();
                this.theEditControl.Text = initialContent;

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = this.theEditControl;
                return(res);
            }

            if (action == "set-content" && args != null && args.Length >= 2 &&
                args[0] is string && args[1] is string &&
                this.theEditControl != null)
            {
                // args
                var mimeType = args[0] as string;
                var content  = args[1] as string;

                // apply
                this.theEditControl.MimeType = mimeType;
                this.theEditControl.Text     = content;
            }

            if (action == "get-content" && this.theEditControl != null)
            {
                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = this.theEditControl.Text;
                return(res);
            }

            // default
            return(null);
        }