public NewActionHandler SetSourceEvent(VDEventBase evt)
            {
                if (evt != null)
                {
                    VDWidget source = evt.Widget;
                    SetSource(source);
                }
                else
                {
                    SetSource(null);
                }

                m_cmbEvent.Enabled = false;
                return(this);
            }
Пример #2
0
 private static bool CanAcceptVDEventBaseAsSource(VDEventBase candidate)
 {
     return true;
 }
Пример #3
0
 private static bool CanAcceptVDEventBaseAndVDViewComponentAsSourceAndTarget(VDEventBase sourceEvent, VDViewComponent targetComponent)
 {
     return true;
 }
Пример #4
0
        private static ElementLink ConnectSourceToTarget(ModelElement source, ModelElement target)
        {
            if (source is VDEventBase && target is VDActionBase)
            {
                VDEventBase  evt = source as VDEventBase;
                VDActionBase act = target as VDActionBase;
                evt.TargetComponents.Add(act);
                return(R_Event2Component.GetLink(evt, act));
            }
            else if (source is VDActionJoint && target is VDViewComponent)
            {
                VDActionJoint   joint = source as VDActionJoint;
                VDViewComponent tgt   = target as VDViewComponent;
                joint.TargetComponents.Add(tgt);
                return(R_ActionJoint2Component.GetLink(joint, tgt));
            }
            else if (source is VDViewComponent && target is VDActionBase)
            {
                VDViewComponent        srcComponent = source as VDViewComponent;
                VDActionBase           targetAction = target as VDActionBase;
                Component2ActionDialog dlg          = new Component2ActionDialog();
                dlg.SetComponentAndAction(srcComponent, targetAction);
                dlg.ShowDialog();

                if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    IEventInfo  evtInfo  = dlg.SelectedEvent;
                    VDEventBase newEvent = evtInfo.CreateEvent(srcComponent);
                    newEvent.Widget = srcComponent;
                    newEvent.TargetComponents.Add(targetAction);
                    return(R_Event2Component.GetLink(newEvent, targetAction));
                }
            }
            else if (source is VDEventBase && target is VDViewComponent) // create new action
            {
                VDEventBase               sourceEvent     = source as VDEventBase;
                VDViewComponent           targetComponent = target as VDViewComponent;
                Component2ComponentDialog dlg             = new Component2ComponentDialog(false);
                dlg.NewAction.SetSourceEvent(sourceEvent).SetTarget(targetComponent);
                dlg.ShowDialog();

                if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    IActionInfo  actInfo = dlg.NewAction.SelectedAction;
                    VDActionBase newAct  = actInfo.CreateAction(sourceEvent.Partition);
                    VDWidget.GetCommonParent(sourceEvent.Widget, targetComponent).Children.Add(newAct);
                    //sourceEvent.Widget.Parent.Children.Add(newAct);
                    sourceEvent.TargetComponents.Add(newAct);

                    IActionJointInfo jointInfo = dlg.NewAction.SelectedJoint;
                    VDActionJoint    newJoint  = jointInfo.CreateActionJoint(newAct, targetComponent);
                    newJoint.Widget = newAct;
                    newJoint.TargetComponents.Add(targetComponent);
                    return(R_ActionJoint2Component.GetLink(newJoint, targetComponent));
                }
            }
            else if (source is VDViewComponent && target is VDViewComponent) // create new action or target
            {
                VDViewComponent           srcComponent = source as VDViewComponent;
                VDViewComponent           tgtComponent = target as VDViewComponent;
                Component2ComponentDialog dlg          = new Component2ComponentDialog();
                dlg.NewAction.SetSource(srcComponent).SetTarget(tgtComponent);
                dlg.NewTarget.SetSource(srcComponent).SetTarget(tgtComponent);
                dlg.ShowDialog();

                if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    if (dlg.IfCreateNewAction)
                    {
                        IEventInfo  evtInfo  = dlg.NewAction.SelectedEvent;
                        VDEventBase newEvent = evtInfo.CreateEvent(srcComponent);
                        newEvent.Widget = srcComponent;

                        IActionInfo  actInfo = dlg.NewAction.SelectedAction;
                        VDActionBase newAct  = actInfo.CreateAction(srcComponent.Partition);
                        VDWidget.GetCommonParent(srcComponent, tgtComponent).Children.Add(newAct);
                        //srcComponent.Parent.Children.Add(newAct);
                        newEvent.TargetComponents.Add(newAct);

                        IActionJointInfo jointInfo = dlg.NewAction.SelectedJoint;
                        VDActionJoint    newJoint  = jointInfo.CreateActionJoint(newAct, tgtComponent);
                        newJoint.Widget = newAct;
                        newJoint.TargetComponents.Add(tgtComponent);
                        return(R_ActionJoint2Component.GetLink(newJoint, tgtComponent));
                    }
                    else
                    {
                        IActionJointInfo jointInfo = dlg.NewTarget.SelectedJoint;
                        VDActionJoint    joint     = jointInfo.CreateActionJoint(srcComponent, tgtComponent);
                        joint.Widget = srcComponent;
                        joint.TargetComponents.Add(tgtComponent);
                        return(R_ActionJoint2Component.GetLink(joint, tgtComponent));
                    }
                }
            }

            return(null);
        }
Пример #5
0
 private static bool CanAcceptVDEventBaseAndVDViewComponentAsSourceAndTarget(VDEventBase sourceEvent, VDViewComponent targetComponent)
 {
     return(true);
 }
Пример #6
0
 private static bool CanAcceptVDEventBaseAsSource(VDEventBase candidate)
 {
     return(true);
 }
            public NewActionHandler SetSourceEvent(VDEventBase evt)
            {
                if (evt != null)
                {
                    VDWidget source = evt.Widget;
                    SetSource(source);
                }
                else
                {
                    SetSource(null);
                }

                m_cmbEvent.Enabled = false;
                return this;
            }