Exemplo n.º 1
0
        public override bool PrepareRun()
        {
            base.PrepareRun();
            if (Values.Count > 0)
            {
                if (_scriptContent != Values[0])
                {
                    //cannot cleanup, waste of resources, I know...
                    _scriptedImplementation = null;
                }
                if (_scriptedImplementation == null)
                {
                    _scriptContent = Values[0];
                    //build script
                    System.IO.File.WriteAllText(_scriptFile.Path, _scriptContent);
                    _compiledAssembly = CSScript.Load(_scriptFile.Path);
                    //create object
                    Type[] types = _compiledAssembly.GetTypes();
                    foreach (Type t in types)
                    {
                        if (t.IsClass && (t.BaseType == typeof(ActionImplementationCondition)))
                        {
                            ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) });
                            object[] parameters = new object[] { Core };
                            _scriptedImplementation = (ActionImplementationCondition)constructor.Invoke(parameters);

                            break;
                        }
                    }
                    _scriptedImplementation.PrepareRun();
                }
            }
            return true;
        }
Exemplo n.º 2
0
        public ActionBuilderForm(Framework.Interfaces.IPlugin owner, Framework.Interfaces.ICore core)
            : base(owner, core)
        {
            InitializeComponent();

            ActionBuilderFormInstance = this;

            var p = PluginSettings.Instance.WindowPos;

            if (p != null && !p.IsEmpty)
            {
                this.Bounds        = p;
                this.StartPosition = FormStartPosition.Manual;
            }

            actionBuilderEditor1.ShowConnectionLabels(PluginSettings.Instance.ShowConnectionLabel);

            loadFlowsFile();

            splitContainer1.SplitterDistance = PluginSettings.Instance.LeftPanelWidth;
            if (splitContainer2.Width > PluginSettings.Instance.RightPanelWidth)
            {
                splitContainer2.SplitterDistance = splitContainer2.Width - PluginSettings.Instance.RightPanelWidth;
            }

            _sizeInitializing = false;

            try
            {
                Assembly asm   = Assembly.GetExecutingAssembly();
                Type[]   types = asm.GetTypes();
                foreach (Type t in types)
                {
                    if (t.IsClass && (t.BaseType == typeof(ActionImplementationCondition)))
                    {
                        ConstructorInfo constructor       = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) });
                        object[]        parameters        = new object[] { core };
                        ActionImplementationCondition obj = (ActionImplementationCondition)constructor.Invoke(parameters);

                        //exception for the start
                        if (obj is ActionStart)
                        {
                            //skip. auto
                        }
                        else
                        {
                            Button b = new Button();
                            b.Dock       = DockStyle.Top;
                            b.Tag        = obj;
                            b.Height     = 25;
                            b.Click     += new EventHandler(b_Click);
                            b.MouseDown += new MouseEventHandler(b_MouseDown);
                            b.MouseMove += new MouseEventHandler(b_MouseMove);
                            panel3.Controls.Add(b);

                            core.LanguageItems.Add(new Framework.Data.LanguageItem(obj.Name));
                        }
                    }
                }
                foreach (Type t in types)
                {
                    if (t.IsClass && (t.BaseType == typeof(ActionImplementationExecuteOnce)))
                    {
                        ConstructorInfo constructor         = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) });
                        object[]        parameters          = new object[] { core };
                        ActionImplementationExecuteOnce obj = (ActionImplementationExecuteOnce)constructor.Invoke(parameters);

                        Button b = new Button();
                        b.Dock       = DockStyle.Top;
                        b.Tag        = obj;
                        b.Height     = 25;
                        b.Click     += new EventHandler(b_Click);
                        b.MouseDown += new MouseEventHandler(b_MouseDown);
                        b.MouseMove += new MouseEventHandler(b_MouseMove);
                        panel5.Controls.Add(b);

                        core.LanguageItems.Add(new Framework.Data.LanguageItem(obj.Name));
                    }
                }
                Label la = new Label();
                la.AutoSize  = false;
                la.TextAlign = ContentAlignment.MiddleCenter;
                la.Dock      = DockStyle.Top;
                la.Text      = Utils.LanguageSupport.Instance.GetTranslation(STR_EXECUTEONCE);
                panel5.Controls.Add(la);
                _executeOnceLabel = la;
                foreach (Type t in types)
                {
                    if (t.IsClass && (t.BaseType == typeof(ActionImplementationAction)))
                    {
                        ConstructorInfo            constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) });
                        object[]                   parameters  = new object[] { core };
                        ActionImplementationAction obj         = (ActionImplementationAction)constructor.Invoke(parameters);

                        //exception for the start
                        Button b = new Button();
                        b.Dock       = DockStyle.Top;
                        b.Tag        = obj;
                        b.Height     = 25;
                        b.Click     += new EventHandler(b_Click);
                        b.MouseDown += new MouseEventHandler(b_MouseDown);
                        b.MouseMove += new MouseEventHandler(b_MouseMove);
                        panel5.Controls.Add(b);

                        core.LanguageItems.Add(new Framework.Data.LanguageItem(obj.Name));
                    }
                }
            }
            catch
            {
            }

            SelectedLanguageChanged(this, EventArgs.Empty);
        }