IControlPoint GetExternalOutputControlPoint(IControlPoint originalSender, IControlPoint originalTarget) { if (mOutputControlPointMap.ContainsKey(originalTarget) == false) { originalTarget.HasProxy = true; BasicControlPoint proxy = new BasicControlPoint(mOuterGroup); proxy.Virtual = true; proxy.SetDirection(new Point(-250, 0)); //proxy.ChainChild = target; proxy.TargetKey = originalTarget.TargetKey; proxy.TypeKey = originalTarget.TypeKey; //proxy.BackColor = originalSender.BackColor; proxy.ControlPointDescription = originalTarget.ControlPointDescription; proxy.Name = originalTarget.ToString(); proxy.TagObject = this; proxy.ProxyTarget = originalTarget; mControlPoints.Add(proxy); //? GroupOutputHardPointsBar.AddControl(proxy); mOutputControlPointMap[originalTarget] = proxy; proxy.SenderControlPointConnected += new BasicControlPoint.ControlPointEvent(outproxy_ControlPointConnected); proxy.SenderControlPointRemoved += new BasicControlPoint.ControlPointEvent(outproxy_ControlPointRemoved); } return(mOutputControlPointMap[originalTarget]); }
public void DisconnectControlPoint(IControlPoint cpTarget) { if (GetTargets().Contains(cpTarget)) { //Recursive removal of chained control points //if (cpTarget.ChainChild != null) //{ // foreach(IControlPoint subtarget in cpTarget.ChainChild.GetTargets()) // { // //this.DisconnectControlPoint(subtarget); // //cpTarget.ChainChild.DisconnectControlPoint(subtarget); // } //} //IControlPoint chainStart = cpTarget.ChainChild //Remove the actual target GetTargets().Remove(cpTarget); if (ControlPointRemoved != null) { ControlPointRemoved.Invoke(this, cpTarget); } BasicControlPoint target = cpTarget as BasicControlPoint; if (target.SenderControlPointRemoved != null && target != null) { target.SenderControlPointRemoved.Invoke(target, this); } } }
// GroupInputHardPointsBar IControlPoint GetExternalInputControlPoint(IControlPoint originalSender) { if (mInputControlPointMap.ContainsKey(originalSender) == false) { BasicControlPoint proxy = new BasicControlPoint(mOuterGroup); //proxy.mbDontHide = true; proxy.Virtual = true; proxy.SetDirection(new Point(250, 0)); proxy.TargetKey = originalSender.TargetKey; proxy.TypeKey = originalSender.TypeKey; //proxy.BackColor = originalSender.BackColor; proxy.TagObject = this; proxy.ControlPointDescription = proxy.ControlPointDescription; proxy.ProxyTarget = originalSender; mControlPoints.Add(proxy); GroupInputHardPointsBar.AddControl(proxy); mInputControlPointMap[originalSender] = proxy; proxy.ControlPointConnected += new BasicControlPoint.ControlPointEvent(inproxy_ControlPointConnected); proxy.ControlPointRemoved += new BasicControlPoint.ControlPointEvent(inproxy_ControlPointRemoved); } return(mInputControlPointMap[originalSender]); }
//Remove the binding target void output_ControlPointRemoved(BasicControlPoint cp, IControlPoint other) { if (other.Virtual == true) { return; } TriggersTemplateOutputActionBinder outputBinder = mOutputActionCPs[cp]; TriggerBindInfo toremove = null; foreach (TriggerBindInfo b in outputBinder.TargetIDs) { if (b != null && other != null) { if (b.LinkName == other.ToString()) { toremove = b; } } else { CoreGlobals.getErrorManager().LogErrorToNetwork("(b.LinkName == other.ToString())"); } } if (toremove != null) { outputBinder.TargetIDs.Remove(toremove); } }
void outproxy_ControlPointRemoved(BasicControlPoint cp, IControlPoint other) { if (!cp.MarkForDelete && !mbLoading) { other.DisconnectControlPoint(cp.ProxyTarget); } if (!cp.MarkForDelete && !mbLoading) { mHost.UIUpdate(mGroupUI, new BasicArgument(BasicArgument.eArgumentType.Refresh), eUpdateVisibilty.AnyVisiblity); } mHost.SetGroupsDirty(); }
public BasicControlPoint GetInputControlPoint(string name) { Dictionary <BasicControlPoint, TriggersTemplateInputActionBinder> .Enumerator it = mInputActionCPs.GetEnumerator(); while (it.MoveNext()) { BasicControlPoint thisCp = it.Current.Key; if (thisCp.Name == name) { return(thisCp); } } return(null); }
/// <summary> /// Add a new binding target /// </summary> /// <param name="cp">This(starting) control point</param> /// <param name="other">Target control point</param> void output_ControlPointConnected(BasicControlPoint cp, IControlPoint other) { if (other.Virtual == true) { return; } //set target value: TriggerControl t = other.TagObject as TriggerControl; TriggersTemplateOutputActionBinder outputbinder = mOutputActionCPs[cp]; if (t != null) { string name = cp.ToString(); if (mOutputActionCPs.ContainsKey(cp)) { TriggerBindInfo bindInfo = new TriggerBindInfo(); bindInfo.SetTarget(t.Trigger.ID, other.ToString()); outputbinder.TargetIDs.Add(bindInfo); return; } } TemplateControl templateControl = other.TagObject as TemplateControl; if (templateControl != null) { string name = other.ToString(); foreach (TriggersTemplateInputActionBinder inputBinder in templateControl.TriggerTemplateMapping.TriggerInputs) { if (inputBinder.Name == name) { foreach (TriggerBindInfo b in inputBinder.TargetIDs) { if (b.ID == templateControl.TriggerTemplateMapping.ID && b.LinkName == other.ToString()) { CoreGlobals.getErrorManager().OnSimpleWarning("can't bind. template is already bound to trigger. this is a bug"); return; } } TriggerBindInfo bindInfo = new TriggerBindInfo(); bindInfo.SetTarget(templateControl.TriggerTemplateMapping.ID, other.ToString()); outputbinder.TargetIDs.Add(bindInfo); return; } } } }
void inproxy_ControlPointConnected(BasicControlPoint cp, IControlPoint other) { if (!cp.MarkForDelete && !mbLoading) { if (cp.ProxyTarget.CanConnect(other)) { cp.ProxyTarget.ConnectControlPoint(other); } } if (!cp.MarkForDelete && !mbLoading) { mHost.UIUpdate(mGroupUI, new BasicArgument(BasicArgument.eArgumentType.Refresh), eUpdateVisibilty.AnyVisiblity); } mHost.SetGroupsDirty(); }
public void ConnectControlPoint(IControlPoint cpTarget) { if (CanConnect(cpTarget)) { GetTargets().Add(cpTarget); if (ControlPointConnected != null) { ControlPointConnected.Invoke(this, cpTarget); } BasicControlPoint target = cpTarget as BasicControlPoint; if (target.SenderControlPointConnected != null && target != null) { target.SenderControlPointConnected.Invoke(target, this); } } }
void newConnection_Click(object sender, EventArgs e) { NewLinkInitiator = this; //throw new Exception("The method or operation is not implemented."); Cursor.Current = Cursors.Cross; }
void mTriggerOutControlPoint_ControlPointRemoved(BasicControlPoint cp, IControlPoint other) { TriggerControl otherctrl = other.TagObject as TriggerControl; if (otherctrl != null) { bool onfalse = (cp.GetName() == "Effect.False") ? true : false; TriggerEffect toremove = null; if (onfalse == false) { foreach (TriggerEffect effect in Trigger.TriggerEffects.Effects) { if ((effect.Type == TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName()) || (effect.Type == TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName())) { TriggerValue val = ParentTriggerNamespace.GetValues()[effect.Parameter[0].ID]; if (val.Value == otherctrl.Trigger.ID.ToString()) { toremove = effect; } } } } if (onfalse == true) { foreach (TriggerEffect effect in Trigger.TriggerEffectsFalse.Effects) { if ((effect.Type == TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName()) || (effect.Type == TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName())) { TriggerValue val = ParentTriggerNamespace.GetValues()[effect.Parameter[0].ID]; if (val.Value == otherctrl.Trigger.ID.ToString()) { toremove = effect; } } } } if (toremove != null) { ParentTriggerNamespace.DeleteEffect(Trigger, toremove, onfalse); } } TemplateControl templateControl = other.TagObject as TemplateControl; if (templateControl != null) { string name = other.ToString(); BasicControlPoint othercp = other as BasicControlPoint; TriggersTemplateInputActionBinder targetBinder = templateControl.mInputActionCPs[othercp]; TriggerBindInfo toremove = null; string linkName = cp.Name; int linkID = this.Trigger.ID; foreach (TriggerBindInfo b in targetBinder.TargetIDs) { if ((b.LinkName == linkName) && (b.ID == linkID)) { toremove = b; } } if (toremove != null) { targetBinder.TargetIDs.Remove(toremove); } else { CoreGlobals.getErrorManager().LogErrorToNetwork("mTriggerOutControlPoint_ControlPointRemoved: error deleting template link"); } } }
void mTriggerOutControlPoint_ControlPointConnected(BasicControlPoint cp, IControlPoint other) { //set target value: TriggerControl t = other.TagObject as TriggerControl; if (t != null) { string effectName = ""; if (other.GetName() == "Activate") { effectName = TriggerSystemMain.mTriggerDefinitions.GetActivateEffectName(); } if (other.GetName() == "Deactivate") { effectName = TriggerSystemMain.mTriggerDefinitions.GetDeactivateEffectName(); } TriggerEffect effect; Dictionary <int, TriggerValue> values; TriggerSystemMain.mTriggerDefinitions.GetTriggerEffect(effectName, out effect, out values); Dictionary <int, TriggerValue> .Enumerator it = values.GetEnumerator(); while (it.MoveNext()) { it.Current.Value.Value = t.Trigger.ID.ToString(); break; } int newID; bool onfalse = (cp.GetName() == "Effect.False")?true:false; ParentTriggerNamespace.InsertEffect(Trigger.ID, effect, values, onfalse, out newID); return;//Finished } //else.. template object TemplateControl templateControl = other.TagObject as TemplateControl; if (templateControl != null) { string name = other.ToString(); foreach (TriggersTemplateInputActionBinder binder in templateControl.TriggerTemplateMapping.TriggerInputs) { if (binder.Name == name) { foreach (TriggerBindInfo b in binder.TargetIDs) { if (b.ID == templateControl.TriggerTemplateMapping.ID && b.LinkName == other.ToString()) { CoreGlobals.getErrorManager().OnSimpleWarning("can't bind. template is already bound to trigger. this is a bug"); return; } } TriggerBindInfo bindInfo = new TriggerBindInfo(); bindInfo.SetTarget(this.Trigger.ID, cp.ToString()); binder.TargetIDs.Add(bindInfo); return; } } } }
/// <summary> /// This connects the ui elements based off of the data that was loaded. /// Templates hold the connection data when a connection to a template is made in the ActionBinder classes /// Templates always load the connections to the right(output), and load connections to the left if trigger control is left of them /// </summary> public void LoadExistingConnections() { Dictionary <BasicControlPoint, TriggersTemplateInputActionBinder> .Enumerator it = mInputActionCPs.GetEnumerator(); while (it.MoveNext()) { TriggersTemplateInputActionBinder binder = it.Current.Value; BasicControlPoint thisCp = it.Current.Key; foreach (TriggerBindInfo targetinfo in binder.TargetIDs) { if (targetinfo.HasTarget()) { if (targetinfo.LinkName == "Effect.False" || targetinfo.LinkName == "Effect.True") { TriggerControl targetC = mTriggerHost.GetTriggerControl(targetinfo.ID); if (targetC != null) { if (targetinfo.LinkName == "Effect.True") { targetC.GetEffectTruePoint().GetTargets().Add(thisCp); } else { targetC.GetEffectFalsePoint().GetTargets().Add(thisCp); } } } } } } Dictionary <BasicControlPoint, TriggersTemplateOutputActionBinder> .Enumerator it2 = mOutputActionCPs.GetEnumerator(); while (it2.MoveNext()) { TriggersTemplateOutputActionBinder binder = it2.Current.Value; BasicControlPoint thisCp = it2.Current.Key; List <TriggerBindInfo> toRemove = new List <TriggerBindInfo>(); foreach (TriggerBindInfo targetinfo in binder.TargetIDs) { if (targetinfo.HasTarget()) { //bound to trigger if (targetinfo.LinkName == "Activate" || targetinfo.LinkName == "Deactivate") { TriggerControl triggerTarget = mTriggerHost.GetTriggerControl(targetinfo.ID); if (triggerTarget != null) { if (targetinfo.LinkName == "Activate") { thisCp.GetTargets().Add(triggerTarget.GetActivationPoint()); } else if (targetinfo.LinkName == "Deactivate") { thisCp.GetTargets().Add(triggerTarget.GetDeactivationPoint()); } } } else //it is a template { TemplateControl c = mTriggerHost.GetTemplatetControl(targetinfo.ID); if (c != null) { BasicControlPoint cpTarget = c.GetInputControlPoint(targetinfo.LinkName); thisCp.GetTargets().Add(cpTarget); } else { string groupName = this.ParentTriggerNamespace.GetGroupName(TriggerTemplateMapping.GroupID); string errormsg = "Error connecting template " + this.TriggerTemplateMapping.Name + "(" + this.TriggerTemplateMapping.ID + ")" + "." + thisCp.Name + " to missing template input: " + targetinfo.LinkName + ", " + targetinfo.ID + " in group: " + groupName + " Bad Link removed (most likely harmless residue from an old deleted template that this was connected to)"; toRemove.Add(targetinfo); this.BackColor = Color.Red; this.TriggerNameText.Text = Path.GetFileNameWithoutExtension(TriggerTemplateMapping.Name) + "(" + this.TriggerTemplateMapping.ID + ")"; CoreGlobals.getErrorManager().OnSimpleWarning(errormsg); CoreGlobals.ShowMessage(errormsg); CoreGlobals.getErrorManager().LogErrorToNetwork(errormsg); } } } } foreach (TriggerBindInfo badBind in toRemove) { binder.TargetIDs.Remove(badBind); } } }
//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; } }