예제 #1
0
        public void Init(TriggerParameterControl parent, TriggerVariable var, TriggerValue val, HighLevelProperty HLProp)
        {
            this.Text = var.Name + " : " + val.Type;

            mVariable = var;
            mValue    = val;
            mParent   = parent;
            mHLProp   = HLProp;

            UpdateControl();

            //save teh mouseclicks.
            if (mValue.Name.Contains((mVariable.Name + TriggerNamespace.GetDefaultVarSuffix())))
            {
                if (TriggerSystemMain.mTriggerDefinitions.IsListType(mValue.Type))
                {
                    mValue.IsNull = false;
                    ////mParent.ParameterMode = TriggerParameterControl.eParameterMode.
                    UpdateControl();
                    InitVarMode();
                }
                else if (parent.ParentTriggerNamespace.IsSharedValueVar(mValue.ID))
                {
                    //SetValueMode();
                }
                else
                {
                    //InitValueMode();
                    SetValueMode();
                }
            }
        }
예제 #2
0
        void l_DragDrop(object sender, DragEventArgs e)
        {
            Label  l    = sender as Label;
            object data = e.Data.GetData(typeof(TriggerParameterControl));
            TriggerParameterControl otherButton = data as TriggerParameterControl;

            if (otherButton != null)
            {
                TriggerVariable ctrlMove = otherButton.GetVariable();// as TriggerVariable;

                if (e.Effect == DragDropEffects.Move)
                {
                    if (otherButton.ParameterMode == TriggerParameterControl.eParameterMode.Const)
                    {
                        PresentationValue = ctrlMove.ID;
                        l.Text            = mTriggerNamespace.GetValues()[ctrlMove.ID].Value;
                    }
                    else
                    {
                        PresentationValue = ctrlMove.ID;
                        l.Text            = ctrlMove.Name;
                        l.Refresh();
                    }
                    //UpdateControl();
                }
            }
        }
예제 #3
0
        private void TextLabel_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.None;
            if (e.Data.GetDataPresent(typeof(TriggerParameterControl)))
            {
                object data = e.Data.GetData(typeof(TriggerParameterControl));
                TriggerParameterControl otherButton = data as TriggerParameterControl;
                if (otherButton != null)
                {
                    TriggerValue ctrlMove   = otherButton.mValue as TriggerValue;
                    TriggerValue ctrlTarget = this.mValue as TriggerValue;

                    if (ctrlMove.Type == ctrlTarget.Type)
                    {
                        e.Effect = DragDropEffects.Move;
                    }

                    if ((otherButton.ParameterMode == eParameterMode.Const) &&
                        (TriggerSystemMain.mTriggerDefinitions.CanConvertConst(ctrlMove.Type, ctrlTarget.Type)))
                    {
                        e.Effect = DragDropEffects.Link;
                    }
                }
            }
        }
예제 #4
0
        private void TextLabel_DragDrop(object sender, DragEventArgs e)
        {
            object data = e.Data.GetData(typeof(TriggerParameterControl));
            TriggerParameterControl otherButton = data as TriggerParameterControl;

            if (otherButton != null)
            {
                TriggerVariable ctrlMove   = otherButton.mVariable as TriggerVariable;
                TriggerVariable ctrlTarget = this.mVariable as TriggerVariable;

                if (e.Effect == DragDropEffects.Move)
                {
                    //if (TriggerSystemMain.mTriggerDefinitions.IsListType(otherButton.mValue.Type) && otherButton.ParameterMode == eParameterMode.Const)
                    //{
                    //   SetVarMode(ctrlMove.ID);

                    //}
                    /*else*/ if (otherButton.ParameterMode == eParameterMode.Const)
                    {
                        SetValueMode();
                        mValue.Value = otherButton.mValue.Value;
                    }
                    else
                    {
                        SetVarMode(ctrlMove.ID);
                        //ctrlTarget.ID = ctrlMove.ID;
                        //mValue = otherButton.mValue;

                        //mBinder.UpdateValue(mValue);
                        //ParentTriggerNamespace.ProcessVarMapping();
                        if ((mHost == null) && (mUIUpdateRoot == null))
                        {
                            UpdateParent();
                        }
                        if (mUIUpdateRoot != null)
                        {
                            mUIUpdateRoot.UIUpdate(mValue, new BasicArgument(BasicArgument.eArgumentType.Refresh), eUpdateVisibilty.AnyVisiblity);
                        }
                        if (mHost != null)
                        {
                            mHost.UIUpdate(mValue, new BasicArgument(BasicArgument.eArgumentType.Refresh), eUpdateVisibilty.AnyVisiblity);
                        }
                    }
                    UpdateControl();
                }
                if (e.Effect == DragDropEffects.Link)
                {
                    if (otherButton.ParameterMode == eParameterMode.Const)
                    {
                        SetValueMode();
                        mValue.Value = TriggerSystemMain.mTriggerDefinitions.ConvertConst(otherButton.mValue.Value, otherButton.mValue.Type, this.mValue.Type).ToString();
                        UpdateControl();
                    }
                }
            }
        }
예제 #5
0
        void c_HotSelect(object sender, EventArgs e)
        {
            TriggerParameterControl c = sender as TriggerParameterControl;
            //ToolTip t = mToolTipGroup.GetToolTip(c.Parent.GetHashCode());
            ToolTip t       = mToolTipGroup.GetToolTip(c.GetHashCode());
            string  message = c.GetValue().Type + ": \"" + c.GetVariable().Name + "\"";

            t.UseAnimation = false;
            t.UseFading    = false;
            //t.Show(message, c, -120, 0, 3000);
            t.Show(message, c, 130, 0, 3000);
        }
예제 #6
0
        protected string UpdateHelpText(FunctorEditor f, TriggerComponentDefinition def)
        {
            string newHelpText;

            try
            {
                //List<object> paramsString = new List<object>();
                //paramsString.Add("REPORT_THIS_ERROR_PLZ!");  //don't use index 0
                //foreach (Control c in f.GetComponents())
                //{
                //   TriggerParameterControl param = c as TriggerParameterControl;
                //   if (param != null)
                //   {
                //      paramsString.Add(param.TextValue);
                //   }
                //}
                List <object>            paramsString = new List <object>();
                Dictionary <int, string> paramNames   = new Dictionary <int, string>();

                foreach (Control c in f.GetComponents())
                {
                    TriggerParameterControl param = c as TriggerParameterControl;
                    if (param != null)
                    {
                        paramNames[param.GetVariable().SigID] = param.TextValue;
                    }
                }

                for (int i = 0; i < TriggerSystemDefinitions.cMaxParameters; i++)
                {
                    if (paramNames.ContainsKey(i) == false)
                    {
                        paramsString.Add("##ERRORPARAM=" + i.ToString());
                    }
                    else
                    {
                        paramsString.Add(paramNames[i]);
                    }
                }



                newHelpText = string.Format(def.HelpText, paramsString.ToArray());
            }
            catch (System.Exception ex)
            {
                newHelpText = "Please Report Help text error";
                ex.ToString();
            }
            return(newHelpText);
        }
예제 #7
0
        public Control BuildUIFromParameterVariable(TriggerComponent comp, TriggerVariable var, TriggerValue val, bool watchForChange)
        {
            TriggerParameterControl c = new TriggerParameterControl();

            c.Init(comp, var, val, ParentTriggerNamespace);//, Trigger);
            c.HotSelect    += new EventHandler(c_HotSelect);
            c.HotSelectEnd += new EventHandler(c_HotSelectEnd);

            if (watchForChange)
            {
                c.LabelChanged += new EventHandler(c_LabelChanged);
            }
            return(c);
        }
예제 #8
0
        void l_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.None;
            if (e.Data.GetDataPresent(typeof(TriggerParameterControl)))
            {
                object data = e.Data.GetData(typeof(TriggerParameterControl));
                TriggerParameterControl otherButton = data as TriggerParameterControl;
                if (otherButton != null)
                {
                    //TriggerValue ctrlMove = otherButton.mValue as TriggerValue;
                    //TriggerValue ctrlTarget = this.mValue as TriggerValue;

                    //if (ctrlMove.Type == ctrlTarget.Type)
                    e.Effect = DragDropEffects.Move;
                }
            }
        }
예제 #9
0
        void c_LabelChanged(object sender, EventArgs e)
        {
            TriggerParameterControl p = sender as TriggerParameterControl;

            if (p != null)
            {
                if (TriggerSystemMain.mTriggerDefinitions.IsSchemaType(p.GetValue().Type))
                {
                    Dictionary <int, TriggerValue> values;
                    TriggerComponent comp = p.GetComponent();
                    if (TriggerSystemMain.mTriggerDefinitions.UpdateComponentUserDataVars(comp, p.GetValue().Value, mParentTriggerNamespace, out values))
                    {
                        mParentTriggerNamespace.InsertVariableList(this.Trigger.ID, comp.Parameter, values);
                        ReloadUI();
                        InvokeNeedsResize();
                    }
                }
            }
        }
예제 #10
0
 void c_HotSelect(object sender, EventArgs e)
 {
     try
     {
         //return;
         TriggerParameterControl c = sender as TriggerParameterControl;
         //ToolTip t = mToolTipGroup.GetToolTip(c.Parent.GetHashCode());//new ToolTip();
         ToolTip t = mToolTipGroup.GetToolTip(c.GetHashCode());//new ToolTip();
         Point   p = c.PointToScreen(new Point(0, 0));
         p = this.PointToClient(p);
         string message = c.GetValue().Type + ": \"" + c.GetVariable().Name + "\"";
         t.UseAnimation = false;
         t.UseFading    = false;
         t.Show(message, this, 140, p.Y - 2, 3000);
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("Emergency save to crap1.triggerscript");
         System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(TriggerRoot), new Type[] { });
         System.IO.Stream st = System.IO.File.Open(System.IO.Path.Combine(CoreGlobals.getWorkPaths().mScriptTriggerDirectory, "crap1.triggerscript"), System.IO.FileMode.Create);
         s.Serialize(st, mParentTriggerNamespace.TriggerData);
         st.Close();
     }
 }
예제 #11
0
        public bool Setup(TriggerNamespace triggerNamespace, TriggerComponent component)
        {
            mParentTriggerNamespace = triggerNamespace;
            mTriggerComponent       = component;

            if (TriggerSystemMain.mTriggerDefinitions.TryGetDefinition(component.DBID, component.Version, out mDefinition) == false)
            {
                return(false);
            }

            this.ComponentNameLabel.Text = mDefinition.Type;



            int column1X = 0;
            int column2X = 100;
            int column3X = 200;
            int row1Y    = 50;

            int rowN   = row1Y;
            int deltaY = 20;

            Dictionary <int, TriggerValue> values = mParentTriggerNamespace.GetValues();

            foreach (TriggerVariable v in component.Parameter)
            {
                Label ioLabel = new Label();
                if (v is TriggersInputVariable)
                {
                    ioLabel.Text = "Input";
                }
                else if (v is TriggersOutputVariable)
                {
                    ioLabel.Text = "Output";
                }
                ioLabel.Height -= 5;

                Label nameLabel = new Label();
                nameLabel.Text    = v.Name;
                nameLabel.Height -= 5;

                Label typeLabel = new Label();
                typeLabel.Text    = values[v.ID].Type;
                typeLabel.Height -= 5;


                TriggerParameterControl c = new TriggerParameterControl();
                c.Init(component, v, values[v.ID], mParentTriggerNamespace);
                c.LabelChanged += new EventHandler(c_LabelChanged);

                AddControl(InputPanel, ioLabel, column1X, rowN);
                AddControl(TypesPanel, typeLabel, column1X, rowN);
                AddControl(NamePanel, nameLabel, column1X, rowN);
                AddControl(ParameterPanel, c, column1X, rowN);


                nameLabel.Width = nameLabel.Parent.Width;
                c.Width         = c.Parent.Width;



                mParamcontrols.Add(c);

                rowN += deltaY;
            }

            //smart help text

            string helptext = mDefinition.HelpText;

            //string newHelpText;
            //int startOffset  = helptext.IndexOf("{",startOffset);
            //int lastSpot = 0;
            //while(startOffset != -1)
            //{
            //   newHelpText += helptext.Substring(lastSpot, startOffset - lastSpot);
            //   newHelpText +=

            //   startOffset = helptext.IndexOf("{", startOffset);
            //}

            UpdateHelpText();

            return(true);
        }
예제 #12
0
        //Loads ui.  Creates values for the mappings if they do not exist
        private void LoadMappingUI(TriggerTemplateMapping mapping)
        {
            TriggerNameText.Text = Path.GetFileNameWithoutExtension(mapping.Name);

            foreach (TriggersTemplateInputVariable v in mapping.InputMappings)
            {
                TriggerParameterControl c   = new TriggerParameterControl();
                TriggerValue            val = new TriggerValue();

                if (mbDemoMode || (ParentTriggerNamespace.GetValues().ContainsKey(v.ID) == false) || (v.ID == -1))
                {
                    val.Name = v.Name;
                    val.Type = v.Type;
                    int newID = -1;
                    ParentTriggerNamespace.InsertValue(val, out newID);
                    v.ID = newID;

                    //this line set optional parmas to default off for newly placed templates
                    if (v.Optional == true)
                    {
                        val.IsNull = true;
                    }
                }
                else
                {
                    val = ParentTriggerNamespace.GetValues()[v.ID];
                }


                c.Init(null, v, val, ParentTriggerNamespace);

                VarInHardPointsBar.AddControl(c);
            }
            foreach (TriggersTemplateOutputVariable v in mapping.OutputMappings)
            {
                TriggerParameterControl c   = new TriggerParameterControl();
                TriggerValue            val = new TriggerValue();
                if (ParentTriggerNamespace.GetValues().ContainsKey(v.ID) == false)
                {
                    val.Name = v.Name;
                    val.Type = v.Type;
                    int newID = -1;
                    ParentTriggerNamespace.InsertValue(val, out newID);
                    v.ID = newID;
                }
                else
                {
                    val = ParentTriggerNamespace.GetValues()[v.ID];
                }
                c.Init(null, v, val, ParentTriggerNamespace);

                VarOutHardPointsBar.AddControl(c);
            }
            foreach (TriggersTemplateInputActionBinder b in mapping.TriggerInputs)
            {
                BasicControlPoint cp = new BasicControlPoint(mHost);

                INHardPointsBar.AddControl(cp);
                cp.TargetKey = "none";//"Trigger.Link.Back";
                cp.TypeKey   = "Trigger.Link.Forward";
                cp.BackColor = b.GetColor();
                cp.SetToolTipText(b.Name);
                cp.Name = b.Name;
                cp.SetDirection(new Point(-250, 0));
                cp.Tag        = this;
                cp.TagObject  = this;
                cp.RenderText = cp.Name;
                cp.ControlPointDescription = this.mTriggerTemplateMapping.Name + "." + b.Name;

                mControlPoints.Add(cp);

                mInputActionCPs[cp] = b;
            }
            //flowLayoutPanel1.Controls.Add(MakeLabel("OutputTriggers:"));
            foreach (TriggersTemplateOutputActionBinder b in mapping.TriggerOutputs)
            {
                BasicControlPoint cp = new BasicControlPoint(mHost);
                OutHardPointsBar.AddControl(cp);
                cp.TargetKey = "Trigger.Link.Forward";
                cp.TypeKey   = "none";//"Trigger.Link.Back";
                cp.BackColor = b.GetColor();
                cp.SetToolTipText(b.Name);
                cp.Name = b.Name;
                cp.SetDirection(new Point(250, 0));
                cp.Tag                     = this;
                cp.TagObject               = this;
                cp.RenderText              = b.Name;
                cp.ControlPointConnected  += new BasicControlPoint.ControlPointEvent(output_ControlPointConnected);
                cp.ControlPointRemoved    += new BasicControlPoint.ControlPointEvent(output_ControlPointRemoved);
                cp.ControlPointDescription = this.mTriggerTemplateMapping.Name + "." + b.Name;

                mControlPoints.Add(cp);

                mOutputActionCPs[cp] = b;
            }
        }