public NewTargetHandler SetSource(VDViewComponent source)
            {
                if (source is VDActionBase)
                {
                    SetSourceAction((VDActionBase)source);
                }
                else if (source is VDViewComponent)
                {
                    List <VDActionBase> actionList = new List <VDActionBase>();
                    findSourceActionList(source, actionList);
                    List <IActionJointInfo> joints = getCommonActionJoint(actionList);

                    m_lstAction.Items.Clear();
                    m_cmbJoint.Items.Clear();
                    m_cmbJoint.Items.Add(DefaultActionJontInfo.Instance);
                    actionList.ForEach(act => { if (act.ActionInfo != null)
                                                {
                                                    m_lstAction.Items.Add(act.ActionInfo);
                                                }
                                       });
                    m_cmbJoint.Items.AddRange(joints.ToArray());
                    if (m_cmbJoint.Items.Count > 0)
                    {
                        m_cmbJoint.SelectedIndex = 0;
                    }
                }

                return(this);
            }
            public NewActionHandler SetTarget(VDViewComponent target)
            {
                m_txtTarget.Text = string.Empty;
                m_cmbClientAction.Items.Clear();

                if (target != null)
                {
                    m_txtTarget.Text = string.Format("{0} [{1}]", target.WidgetName, target.WidgetType.ToString());
                    if (target.SupportedActions != null)
                    {
                        m_cmbClientAction.Items.AddRange(target.SupportedActions.ToArray());
                        if (m_cmbClientAction.Items.Count > 0)
                        {
                            m_cmbClientAction.SelectedIndex = 0;
                        }
                    }
                }

                m_chkServer.Checked = false;
                m_chkServer.Enabled = target.CanBeTargetOfServerAction;

                VDModelStore ms = target.GetModelStore();

                if (ms != null)
                {
                    m_serverActionJoints = ms.GetSupportedServerActionJoints();
                }
                else
                {
                    m_serverActionJoints = null;
                }

                return(this);
            }
Пример #3
0
        public void SetComponentAndAction(VDViewComponent srcComponent, VDActionBase targetAction)
        {
            // set source component
            cmbEvent.Items.Clear();
            if (srcComponent != null)
            {
                txtSource.Text = string.Format("[{1}] {0}", srcComponent.WidgetName, srcComponent.WidgetType.ToString());
                if (srcComponent.SupportedEvents != null)
                {
                    cmbEvent.Items.AddRange(srcComponent.SupportedEvents.ToArray());
                    if (cmbEvent.Items.Count > 0)
                    {
                        cmbEvent.SelectedIndex = 0;
                    }
                }
            }
            else
            {
                txtSource.Text = string.Empty;
            }

            // set target action
            if (targetAction != null)
            {
                txtAction.Text    = targetAction.Name;
                chkServer.Checked = targetAction is VDServerAction;
            }
            else
            {
                txtAction.Text    = string.Empty;
                chkServer.Checked = false;
            }
        }
Пример #4
0
        public VDEventBase CreateEvent(VDViewComponent widget)
        {
            VDEvent evt = new VDEvent(widget.Partition);

            evt.EventInfo = this;
            return(evt);
        }
Пример #5
0
 private static bool CanAcceptVDActionJointAndVDViewComponentAsSourceAndTarget(VDActionJoint sourceActionJoint, VDViewComponent targetComponent)
 {
     if (sourceActionJoint.GetActions().Find(act => act is VDServerAction) != null && !targetComponent.CanBeTargetOfServerAction)
         return false;
     else
         return true;
 }
Пример #6
0
        public VDActionJoint CreateActionJoint(VDViewComponent widget, VDViewComponent target)
        {
            var joint = new VDActionJoint(widget.Partition);

            joint.JointInfo = this;
            return(joint);
        }
        public void SetComponentAndAction(VDViewComponent srcComponent, VDActionBase targetAction)
        {
            // set source component
            cmbEvent.Items.Clear();
            if (srcComponent != null)
            {
                txtSource.Text = string.Format("[{1}] {0}", srcComponent.WidgetName, srcComponent.WidgetType.ToString());
                if (srcComponent.SupportedEvents != null)
                {
                    cmbEvent.Items.AddRange(srcComponent.SupportedEvents.ToArray());
                    if (cmbEvent.Items.Count > 0) cmbEvent.SelectedIndex = 0;
                }
            }
            else
            {
                txtSource.Text = string.Empty;
            }

            // set target action
            if (targetAction != null)
            {
                txtAction.Text = targetAction.Name;
                chkServer.Checked = targetAction is VDServerAction;
            }
            else
            {
                txtAction.Text = string.Empty;
                chkServer.Checked = false;
            }
        }
Пример #8
0
 private static bool CanAcceptVDViewComponentAndVDViewComponentAsSourceAndTarget(VDViewComponent sourceComponent, VDViewComponent targetComponent)
 {
     if (sourceComponent is VDServerAction && !targetComponent.CanBeTargetOfServerAction)
         return false;
     else
         return true;
 }
 public NewTargetHandler SetTarget(VDViewComponent target)
 {
     if (target != null)
     {
         m_txtTarget.Text = string.Format("{0} [{1}]", target.WidgetName, target.WidgetType.ToString());
     }
     else
     {
         m_txtTarget.Text = string.Empty;
     }
     return(this);
 }
 private static void findSourceActionList(VDViewComponent target, List <VDActionBase> actionList)
 {
     foreach (VDActionJoint joint in target.SourceActionJoints)
     {
         if (joint.Widget is VDActionBase)
         {
             actionList.Add((VDActionBase)joint.Widget);
         }
         else
         {
             findSourceActionList(joint.Widget, actionList);
         }
     }
 }
Пример #11
0
 private static bool CanAcceptVDEventBaseAndVDViewComponentAsSourceAndTarget(VDEventBase sourceEvent, VDViewComponent targetComponent)
 {
     return true;
 }
Пример #12
0
 public VDEventBase CreateEvent(VDViewComponent widget)
 {
     VDEvent evt = new VDEvent(widget.Partition);
     evt.EventInfo = this;
     return evt;
 }
Пример #13
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);
        }
Пример #14
0
 public VDActionJoint CreateActionJoint(VDViewComponent widget, VDViewComponent target)
 {
     var joint = new VDActionJoint(widget.Partition);
     joint.JointInfo = this;
     return joint;
 }
Пример #15
0
 private static bool CanAcceptVDViewComponentAsTarget(VDViewComponent candidate)
 {
     return(true);
 }
 private static void findSourceActionList(VDViewComponent target, List<VDActionBase> actionList)
 {
     foreach(VDActionJoint joint in target.SourceActionJoints)
     {
         if (joint.Widget is VDActionBase)
         {
             actionList.Add((VDActionBase)joint.Widget);
         }
         else
         {
             findSourceActionList(joint.Widget, actionList);
         }
     }
 }
 public NewTargetHandler SetTarget(VDViewComponent target)
 {
     if (target != null)
     {
         m_txtTarget.Text = string.Format("{0} [{1}]", target.WidgetName, target.WidgetType.ToString());
     }
     else
     {
         m_txtTarget.Text = string.Empty;
     }
     return this;
 }
            public NewTargetHandler SetSource(VDViewComponent source)
            {
                if (source is VDActionBase)
                {
                    SetSourceAction((VDActionBase)source);
                }
                else if (source is VDViewComponent)
                {
                    List<VDActionBase> actionList = new List<VDActionBase>();
                    findSourceActionList(source, actionList);
                    List<IActionJointInfo> joints = getCommonActionJoint(actionList);

                    m_lstAction.Items.Clear();
                    m_cmbJoint.Items.Clear();
                    m_cmbJoint.Items.Add(DefaultActionJontInfo.Instance);
                    actionList.ForEach(act => { if (act.ActionInfo != null) m_lstAction.Items.Add(act.ActionInfo); });
                    m_cmbJoint.Items.AddRange(joints.ToArray());
                    if (m_cmbJoint.Items.Count > 0) m_cmbJoint.SelectedIndex = 0;
                }

                return this;
            }
            public NewActionHandler SetTarget(VDViewComponent target)
            {
                m_txtTarget.Text = string.Empty;
                m_cmbClientAction.Items.Clear();

                if (target != null)
                {
                    m_txtTarget.Text = string.Format("{0} [{1}]", target.WidgetName, target.WidgetType.ToString());
                    if (target.SupportedActions != null)
                    {
                        m_cmbClientAction.Items.AddRange(target.SupportedActions.ToArray());
                        if (m_cmbClientAction.Items.Count > 0) m_cmbClientAction.SelectedIndex = 0;
                    }
                }

                m_chkServer.Checked = false;
                m_chkServer.Enabled = target.CanBeTargetOfServerAction;

                VDModelStore ms = target.GetModelStore();
                if (ms != null)
                    m_serverActionJoints = ms.GetSupportedServerActionJoints();
                else
                    m_serverActionJoints = null;

                return this;
            }
Пример #20
0
 private static bool CanAcceptVDViewComponentAsTarget(VDViewComponent candidate)
 {
     return true;
 }
Пример #21
0
 private static bool CanAcceptVDEventBaseAndVDViewComponentAsSourceAndTarget(VDEventBase sourceEvent, VDViewComponent targetComponent)
 {
     return(true);
 }
Пример #22
0
 private static bool CanAcceptVDViewComponentAndVDViewComponentAsSourceAndTarget(VDViewComponent sourceComponent, VDViewComponent targetComponent)
 {
     if (sourceComponent is VDServerAction && !targetComponent.CanBeTargetOfServerAction)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Пример #23
0
 private static bool CanAcceptVDActionJointAndVDViewComponentAsSourceAndTarget(VDActionJoint sourceActionJoint, VDViewComponent targetComponent)
 {
     if (sourceActionJoint.GetActions().Find(act => act is VDServerAction) != null && !targetComponent.CanBeTargetOfServerAction)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }