Exemple #1
0
        internal static EndpointCollection Create(PortCollection portCollection, TinyXdto.XdtoFactory factory)
        {
            var ports = new List <Endpoint> ();

            foreach (var mPort in portCollection)
            {
                var port = mPort as Port;
                ports.Add(new Endpoint(port, factory));
            }
            return(new EndpointCollection(ports));
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Node"/> class.
 /// </summary>
 public Node()
 {
     _ports                    = new PortCollection(this);
     _zIndex                   = Constants.NODE_ZINDEX;
     _location                 = new GraphPoint();
     _lastLocation             = new GraphPoint();
     _ports.CollectionChanged += _ports_CollectionChanged;
     _ports.PortChanged       += _ports_PortChanged;
     _ports.PortConnected     += _ports_PortConnected;
     _ports.PortDisconnected  += _ports_PortDisconnected;
 }
Exemple #3
0
 public ActionResult Save(Bam.Net.Analytics.Port[] values)
 {
     try
     {
         PortCollection saver = new PortCollection();
         saver.AddRange(values);
         saver.Save();
         return(Json(new { Success = true, Message = "", Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
        private static void UpdateGrid(Grid grid, PortCollection portCollection)
        {
            if (portCollection == null)
            {
                return;
            }

            grid.RowDefinitions.Clear();

            for (int i = 0; i < portCollection.RowCount; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(0, GridUnitType.Auto)
                });
            }

            //grid.RowDefinitions.Clear();

            //if (grid.RowDefinitions.Count == 0 && portCollection.Count > 0)
            //{
            //    var toCreate = portCollection.RowCount;

            //    for (int i = 0; i < toCreate; i++)
            //    {
            //        grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(0, GridUnitType.Auto) });
            //    }
            //}
            //else if (portCollection.RowCount > grid.RowDefinitions.Count)
            //{
            //    var toCreate = portCollection.RowCount - grid.RowDefinitions.Count;

            //    for (int i = 0; i < toCreate; i++)
            //    {
            //        grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(0, GridUnitType.Auto) });
            //    }
            //}
            //else if (portCollection.RowCount < grid.RowDefinitions.Count)
            //{
            //    var toDelete = portCollection.RowCount - grid.RowDefinitions.Count;

            //    for (int i = toDelete; i < 0; i++)
            //    {
            //        grid.RowDefinitions.RemoveAt(i);
            //    }
            //}

            //portCollection.RaiseRowIndexChanged();
            //grid.UpdateLayout();
        }
        public PortCreateVM()
        {
            var vm = ResourcesBase.GetMainWindowViewModel();

            Collection     = vm.PortCollection;
            CityCollection = vm.CityCollection;
            PortTypes      = ResourcesBase.GetEnumCollection <ModelsShared.Models.PortType>();

            Save = new CommandHandler {
                CanExecuteAction = x => SaveValidation(), ExecuteAction = x => SaveAction()
            };
            Cancel = new CommandHandler {
                CanExecuteAction = x => true, ExecuteAction = c => CancelAction()
            };
        }
Exemple #6
0
        static void OnOptionLoaded()
        {
            PortOption option = Center.Option.Get <PortOption>();

            foreach (var item in option.PortPairs)
            {
                OutPortValue   op = GetOutputPort(item.Target.AsmName, item.Target.PortName);
                InPortValue    ip = GetInputPort(item.Input.AsmName, item.Input.PortName);
                PortCollection collection;
                if (!mOutIns.TryGetValue(op.port, out collection))
                {
                    collection = new PortCollection();
                    mOutIns.Add(op.port, collection);
                }
                collection.Add(ip.port);
            }
        }
Exemple #7
0
        public static void ChangePortTarget(string asmout, string outputport, string asmin, string inputport)
        {
            OutPortValue op = GetOutputPort(asmout, outputport);
            InPortValue  ip = GetInputPort(asmin, inputport);

            foreach (var outin in mOutIns)
            {
                outin.Value.RemoveAll(i => i == ip.port);
            }

            PortCollection coellection;

            if (!mOutIns.TryGetValue(op.port, out coellection))
            {
                coellection = new PortCollection();
                mOutIns.Add(op.port, coellection);
            }
            coellection.Add(ip.port);
        }
        public virtual PortCollection GetAllPorts()
        {
            PortCollection     pc   = new PortCollection();
            List <EventPortIn> list = DestinationPorts;

            if (list != null)
            {
                foreach (LinkLineNodeInPort p in list)
                {
                    pc.Add(p);
                }
            }
            if (_events != null)
            {
                if (IsRootClass)
                {
                    foreach (EventIcon ei in _events)
                    {
                        if (ei.CustomEvent != null)
                        {
                            List <EventPortIn> ports = ei.DestinationPorts;
                            if (ports != null && ports.Count > 0)
                            {
                                pc.AddRange(ports.ToArray());
                            }
                        }
                    }
                }
            }
            List <EventPortOut> l2 = SourcePorts;

            if (l2 != null)
            {
                foreach (LinkLineNodeOutPort p in l2)
                {
                    pc.Add(p);
                }
            }
            return(pc);
        }
        private void setupPorts(bool isNewAction)
        {
            if (isNewAction)
            {
                _act.InitializePorts(this);
            }
            PortCollection pc = _act.GetAllPorts();

            if (!isNewAction)
            {
                foreach (LinkLineNodePort p in pc)
                {
                    p.Owner = this;
                }
            }
            List <Control> ctrls = pc.GetAllControls(false);

            Control[] a = new Control[ctrls.Count];
            ctrls.CopyTo(a);
            Parent.Controls.AddRange(a);

            if (isNewAction)
            {
                OnInitNewPorts();
                Parent.Refresh();
            }
            else
            {
                for (int i = 0; i < a.Length; i++)
                {
                    ActiveDrawing ad = a[i] as ActiveDrawing;
                    if (ad != null)
                    {
                        ad.RestoreLocation();
                    }
                }
                OnInitExistingPorts();
            }
        }
Exemple #10
0
        public void PortCollectionSerialization()
        {
            var ports = new PortCollection
            {
                Ports = { new Port {
                              Id = Guid.NewGuid()
                          } },
                PortsLinks = { new Link("next", "http://api.com/next") }
            };

            string json = JsonConvert.SerializeObject(ports, Formatting.None);

            Assert.Contains("\"ports\"", json);
            Assert.DoesNotContain("\"port\"", json);

            var result = JsonConvert.DeserializeObject <PortCollection>(json);

            Assert.NotNull(result);
            Assert.Equal(1, result.Count());
            Assert.Equal(1, result.Ports.Count());
            Assert.Equal(1, result.PortsLinks.Count());
        }
Exemple #11
0
 public static void SetDynamicEventHandlerLineColor(PortCollection pc)
 {
     foreach (LinkLineNodePort p in pc)
     {
         LinkLineNodeInPort ip = p as LinkLineNodeInPort;
         if (ip != null)
         {
             ComponentIconEventhandle ieh = ip.PortOwner as ComponentIconEventhandle;
             if (ieh != null)
             {
                 EventHandlerMethod ehm = ieh.Method as EventHandlerMethod;
                 if (ehm != null)
                 {
                     UInt32 actId = ehm.GetDynamicActionId();
                     if (actId != 0)
                     {
                         ip.SetLineColor(Color.Yellow);
                     }
                 }
             }
         }
         else
         {
             EventPortOutExecuteMethod op = p as EventPortOutExecuteMethod;
             if (op != null)
             {
                 EventHandlerMethod ehm = op.Method as EventHandlerMethod;
                 if (ehm != null)
                 {
                     UInt32 actId = ehm.GetDynamicActionId();
                     if (actId != 0)
                     {
                         op.SetLineColor(Color.Yellow);
                     }
                 }
             }
         }
     }
 }
        public ManifestOutGoingCreateVM()
        {
            this.PortTypes       = ResourcesBase.GetEnumCollection <ModelsShared.Models.PortType>();
            this.PortCollection  = ResourcesBase.GetMainWindowViewModel().PortCollection;
            this.OriginView      = (CollectionView)CollectionViewSource.GetDefaultView(this.PortCollection.Source);
            DestinationSource    = new ObservableCollection <ModelsShared.Models.Port>();
            this.DestinationView = (CollectionView)CollectionViewSource.GetDefaultView(DestinationSource);


            this.AgentCollection  = ResourcesBase.GetMainWindowViewModel().AgentCollection;
            BrowseManifestCommand = new CommandHandler {
                CanExecuteAction = x => BrowseManifestCommandValidate(), ExecuteAction = x => BrowseManifestCommandAction()
            };

            this.PenjualanTemporaty     = new List <Models.PenjualanView>();
            this.PenjualanTemporaryView = (CollectionView)CollectionViewSource.GetDefaultView(this.PenjualanTemporaty);
            DeleteSTTFromList           = new CommandHandler {
                CanExecuteAction = x => (STTSelectedItem != null), ExecuteAction = x => DeleteSTTFromListAction()
            };
            Save = new CommandHandler {
                CanExecuteAction = x => SaveValidation(), ExecuteAction = x => SaveAction()
            };
            Preview = new CommandHandler {
                ExecuteAction = x => PreviewAction(), CanExecuteAction = x => PreviewValidation()
            };
            Cancel = new CommandHandler {
                ExecuteAction = CancelAction, CanExecuteAction = x => true
            };
            PortCollection.RefreshCompleted += PortCollection_RefreshCompleted;


            if (PortCollection.Source.Count <= 0)
            {
                PortCollection.Refresh();
            }
            this.OriginView.Filter = PortFilter;
            DestinationView.Filter = PortFilter;
        }
Exemple #13
0
        public virtual PortCollection GetAllPorts()
        {
            PortCollection ports = new PortCollection();

            if (_newInport == null)
            {
                _newInport = new ProgramNewInPort(this);
            }
            if (_newOutport == null)
            {
                _newOutport = new ProgramNewOutPort(this);
            }
            ports.Add(_newInport);
            ports.Add(_newOutport);
            if (_inports != null)
            {
                ports.AddRange(_inports);
            }
            if (_outports != null)
            {
                ports.AddRange(_outports);
            }
            return(ports);
        }
        private void SetupReferenceData()
        {
            var countries = new Country { CountryId = "1", Name = "USA", Code = "USA" };

            var states = new State { StateId = "2", CountryId = "1", Name = "Florida" };

            var ports = new Port { PortId = "1", City = "Florida", Name = "Miami", State = "Florida", StateId = "2", CountryId = "1" };

            var brands = new Brand { BrandId = "1", Name = "Carnival" };

            var personTypes = new PersonTypeEntity { PersonTypeId = "1001", Name = "Daniel" };

            var loyaltyLevelTypes = new LoyaltyLevelType { LoyaltyLevelTypeId = "1001", Name = "abc", BrandId = "1", NoOfCruiseNights = 3, LogoImageAddress = "abc" };

            var documentType = new DocumentType { CountryId = "232", Code = "USA", DocumentTypeId = "1", Name = "Passport" };

            var brand = new BrandCollection();

            var country = new CountryCollection();
            country.Add(countries);

            var state = new StateCollection();
            state.Add(states);

            var documentTypes = new DocumentTypeCollection();
            documentTypes.Add(documentType);

            var port = new PortCollection();
            port.Add(ports);

            var personTypeEntity = new PersonTypeEntityCollection();
            personTypeEntity.Add(personTypes);

            var loyaltyLevelType = new LoyaltyLevelTypeCollection();
            loyaltyLevelType.Add(loyaltyLevelTypes);

            this.referenceData.AssignBrands(brand);
            this.referenceData.AssignCountries(country);
            this.referenceData.AssignStates(state);
            this.referenceData.AssignDocumentTypes(documentTypes);
            this.referenceData.AssignLoyaltyLevelTypes(loyaltyLevelType);
            this.referenceData.AssignPersonTypes(personTypeEntity);
            this.referenceData.AssignPorts(port);
        }
Exemple #15
0
        /// <summary>
        /// remove invalid icons
        /// add missing icons
        /// make links
        /// </summary>
        /// <param name="eventPath"></param>
        public void OnLoadData(EventPath eventPath)
        {
            _owner = eventPath;
            //all icons saved in XML
            List <ComponentIconEvent> iconList = ComponentIconList;
            //all components, each corresponding to one icon
            ClassPointer  root    = _owner.Loader.GetRootId();
            List <IClass> objList = root.GetClassList();
            //all custom methods, each corresponding to one icon
            Dictionary <string, MethodClass> methods = root.CustomMethods;
            //all event handlers, each HandlerMathodID object corresponds to one icon
            List <EventAction> handlers = root.EventHandlers;
            //all custom properties
            Dictionary <string, PropertyClass> props = root.CustomProperties;
            //all used html elements
            IList <HtmlElement_BodyBase> htmlElements = null;

            if (root.IsWebPage)
            {
                htmlElements = root.UsedHtmlElements;
            }
            //
            //remove invalid icons
            List <ComponentIconEvent> iconInvalid = new List <ComponentIconEvent>();

            foreach (ComponentIconEvent ic in iconList)
            {
                if (!ic.OnDeserialize(root, _owner.Loader))
                {
                    iconInvalid.Add(ic);
                }
            }
            foreach (ComponentIconEvent ic in iconInvalid)
            {
                iconList.Remove(ic);
            }
            //remove invalid events. unknown reason causing invalid events
            foreach (ComponentIconEvent ic in iconList)
            {
                if (ic.MemberId != 0 && ic.GetType().Equals(typeof(ComponentIconEvent)))
                {
                    MemberComponentId mid0 = ic.ClassPointer as MemberComponentId;
                    if (mid0 != null)
                    {
                        List <EventIcon> eis = ic.EventIcons;
                        if (eis != null && eis.Count > 0)
                        {
                            List <EventIcon> invalidEis = new List <EventIcon>();
                            foreach (EventIcon ei in eis)
                            {
                                if (ei.Event != null)
                                {
                                    MemberComponentId mid = ei.Event.Owner as MemberComponentId;
                                    if (mid != null && mid.MemberId != 0)
                                    {
                                        if (mid.MemberId != ic.MemberId)
                                        {
                                            invalidEis.Add(ei);
                                        }
                                    }
                                }
                            }
                            foreach (EventIcon ei in invalidEis)
                            {
                                eis.Remove(ei);
                            }
                        }
                    }
                }
            }
            //
            //add new icons
            int x0 = 20;
            int y0 = 20;
            int x  = x0;
            int y  = y0;
            int dx = 30;
            int dy = 30;

            //add missing component icon
            foreach (IClass c in objList)
            {
                bool bFound = false;
                foreach (ComponentIconEvent ic in iconList)
                {
                    if (ic.IsForComponent)
                    {
                        if (ic.MemberId == c.MemberId)
                        {
                            ic.Designer = _owner.Loader;
                            bFound      = true;
                            break;
                        }
                    }
                }
                if (!bFound)
                {
                    ComponentIconEvent cip;
                    if (c is HtmlElement_Base)
                    {
                        cip = new ComponentIconHtmlElement();
                    }
                    else
                    {
                        cip = new ComponentIconEvent();
                    }
                    cip.Init(_owner.Loader, c);
                    cip.Location = new Point(x, y);
                    x           += dx;
                    x           += cip.Width;
                    if (x > _owner.Width)
                    {
                        x  = x0;
                        y += dy;
                        y += cip.Height;
                    }
                    iconList.Add(cip);
                }
            }
            ComponentIconEvent rootIcon = null;

            foreach (ComponentIconEvent ci in iconList)
            {
                if (ci.IsForComponent)
                {
                    if (ci.IsRootClass)
                    {
                        rootIcon = ci;
                        break;
                    }
                }
            }
            if (rootIcon == null)
            {
                throw new DesignerException("Root component icon not found for class {0}", root.ClassId);
            }
#if USEHTMLEDITOR
            //add missing html element
            if (htmlElements != null)
            {
                foreach (HtmlElement_Base he in htmlElements)
                {
                    bool bFound = false;
                    foreach (ComponentIconEvent ic in iconList)
                    {
                        ComponentIconHtmlElement cihe = ic as ComponentIconHtmlElement;
                        if (cihe != null)
                        {
                            if (ic.MemberId == cihe.MemberId)
                            {
                                ic.Designer = _owner.Loader;
                                bFound      = true;
                                break;
                            }
                        }
                    }
                    if (!bFound)
                    {
                        ComponentIconHtmlElement cip = new ComponentIconHtmlElement();
                        cip.Init(_owner.Loader, he);
                        cip.Location = new Point(x, y);
                        x           += dx;
                        x           += cip.Width;
                        if (x > _owner.Width)
                        {
                            x  = x0;
                            y += dy;
                            y += cip.Height;
                        }
                        iconList.Add(cip);
                    }
                }
            }
            //add missing current html element
            if (root.IsWebPage)
            {
                bool bFound = false;
                foreach (ComponentIconEvent ic in iconList)
                {
                    ComponentIconHtmlElementCurrent cic = ic as ComponentIconHtmlElementCurrent;
                    if (cic != null)
                    {
                        bFound = true;
                        break;
                    }
                }
                if (!bFound)
                {
                    HtmlElement_body heb = new HtmlElement_body(root);
                    ComponentIconHtmlElementCurrent cip = new ComponentIconHtmlElementCurrent();
                    cip.ClassPointer = heb;
                    cip.Init(_owner.Loader, heb);
                    cip.Location = new Point(x, y);
                    x           += dx;
                    x           += cip.Width;
                    if (x > _owner.Width)
                    {
                        x  = x0;
                        y += dy;
                        y += cip.Height;
                    }
                    iconList.Add(cip);
                }
            }
#endif
            //add missing FireEventMethod, ComponentIconClass and ComponentIconClassType
            Dictionary <UInt32, IAction> actions = root.GetActions();
            foreach (IAction act in actions.Values)
            {
                if (act != null)
                {
                    FireEventMethod fe = act.ActionMethod as FireEventMethod;
                    if (fe != null)
                    {
                        ComponentIconFireEvent cife = null;
                        foreach (ComponentIconEvent ic in iconList)
                        {
                            if (!ic.IsForComponent)
                            {
                                ComponentIconFireEvent cie = ic as ComponentIconFireEvent;
                                if (cie != null)
                                {
                                    if (fe.MemberId == cie.FirerId && fe.EventId == cie.EventId)
                                    {
                                        cie.Firer   = fe;
                                        ic.Designer = _owner.Loader;
                                        cife        = cie;
                                        break;
                                    }
                                }
                            }
                        }
                        if (cife == null)
                        {
                            cife       = new ComponentIconFireEvent();
                            cife.Firer = fe;
                            cife.Init(_owner.Loader, root);
                            cife.Location = new Point(x, y);
                            //cip.FirerPort
                            x += dx;
                            x += cife.Width;
                            if (x > _owner.Width)
                            {
                                x  = x0;
                                y += dy;
                                y += cife.Height;
                            }
                            iconList.Add(cife);
                        }
                        //make port link
                        EventPortInFireEvent epife = null;
                        EventIcon            ei    = rootIcon.GetEventIcon(fe.Event);
                        if (ei == null)
                        {
                            ei       = new EventIcon(rootIcon);
                            ei.Event = fe.Event;
                            ComponentIconEvent.SetInitialPosition(100, ei);
                            rootIcon.EventIcons.Add(ei);
                        }
                        List <EventPortIn> ports = ei.DestinationPorts;
                        foreach (EventPortIn epi in ports)
                        {
                            EventPortInFireEvent epife0 = epi as EventPortInFireEvent;
                            if (epife0 != null)
                            {
                                if (epife0.FireEventMethodId == fe.MemberId)
                                {
                                    epife0.FireEventMethod = fe;
                                    epife = epife0;
                                    break;
                                }
                            }
                        }
                        if (epife == null)
                        {
                            epife = new EventPortInFireEvent(ei);
                            epife.FireEventMethod = fe;
                            ei.DestinationPorts.Add(epife);
                        }
                        epife.LinkedPortID                  = cife.FirerPort.PortID;
                        epife.LinkedPortInstanceID          = cife.FirerPort.PortInstanceID;
                        cife.FirerPort.LinkedPortID         = epife.PortID;
                        cife.FirerPort.LinkedPortInstanceID = epife.PortInstanceID;
                        //
                        epife.RestoreLocation();
                        epife.SetLoaded();
                        //
                        cife.FirerPort.RestoreLocation();
                        cife.FirerPort.SetLoaded();
                    }
                    else if (act.ActionMethod != null)
                    {
                        ClassPointer cp = root.GetExternalExecuterClass(act);
                        if (cp != null)
                        {
                            ComponentIconClass cic = null;
                            foreach (ComponentIconEvent ic in iconList)
                            {
                                ComponentIconClass cic0 = ic as ComponentIconClass;
                                if (cic0 != null)
                                {
                                    if (cic0.ClassId == act.ExecuterClassId)
                                    {
                                        cic          = cic0;
                                        cic.Designer = _owner.Loader;
                                        break;
                                    }
                                }
                            }
                            if (cic == null)
                            {
                                cic = new ComponentIconClass();
                                cic.Init(_owner.Loader, cp);
                                cic.Location = new Point(x, y);
                                x           += dx;
                                x           += cic.Width;
                                if (x > _owner.Width)
                                {
                                    x  = x0;
                                    y += dy;
                                    y += cic.Height;
                                }
                                iconList.Add(cic);
                            }
                        }
                        else
                        {
                            DataTypePointer tp = act.ActionMethod.Owner as DataTypePointer;
                            if (tp != null)
                            {
                                ComponentIconClassType cict = null;
                                foreach (ComponentIconEvent ic in iconList)
                                {
                                    ComponentIconClassType cict0 = ic as ComponentIconClassType;
                                    if (cict0 != null)
                                    {
                                        if (cict0.ClassType.Equals(tp.BaseClassType))
                                        {
                                            cict          = cict0;
                                            cict.Designer = _owner.Loader;
                                            break;
                                        }
                                    }
                                }
                                if (cict == null)
                                {
                                    cict = new ComponentIconClassType();
                                    cict.Init(_owner.Loader, tp);
                                    cict.Location = new Point(x, y);
                                    x            += dx;
                                    x            += cict.Width;
                                    if (x > _owner.Width)
                                    {
                                        x  = x0;
                                        y += dy;
                                        y += cict.Height;
                                    }
                                    iconList.Add(cict);
                                }
                            }
                        }
                    }
                    else
                    {
                        ActionAttachEvent aae = act as ActionAttachEvent;
                        if (aae != null)
                        {
                            IObjectPointer eventOwner = aae.EventOwner;
                            if (eventOwner != null)
                            {
                            }
                        }
                    }
                }
            }
            //add missing method icon
            foreach (MethodClass mc in methods.Values)
            {
                bool bFound = false;
                foreach (ComponentIconEvent ic in iconList)
                {
                    if (!ic.IsForComponent)
                    {
                        ComponentIconMethod cie = ic as ComponentIconMethod;
                        if (cie != null)
                        {
                            if (mc.MethodID == cie.MethodId)
                            {
                                ic.Designer = _owner.Loader;
                                bFound      = true;
                                break;
                            }
                        }
                    }
                }
                if (!bFound)
                {
                    ComponentIconMethod cip = new ComponentIconMethod();
                    cip.Init(_owner.Loader, mc.RootPointer);
                    cip.Method   = mc;
                    cip.MethodId = mc.MethodID;
                    cip.Location = new Point(x, y);
                    x           += dx;
                    x           += cip.Width;
                    if (x > _owner.Width)
                    {
                        x  = x0;
                        y += dy;
                        y += cip.Height;
                    }
                    iconList.Add(cip);
                }
            }
            //add missing handler icon
            foreach (EventAction ea in handlers)
            {
                if (ea.TaskIDList != null && ea.TaskIDList.Count > 0)
                {
                    foreach (TaskID tid in ea.TaskIDList)
                    {
                        HandlerMethodID hid = tid as HandlerMethodID;
                        if (hid != null)
                        {
                            bool bFound = false;
                            foreach (ComponentIconEvent ic in iconList)
                            {
                                ComponentIconEventhandle cie = ic as ComponentIconEventhandle;
                                if (cie != null)
                                {
                                    if (ic.MemberId == cie.MemberId && cie.MethodId == hid.ActionId)
                                    {
                                        ic.Designer = _owner.Loader;
                                        bFound      = true;
                                        break;
                                    }
                                }
                            }
                            if (!bFound)
                            {
                                ComponentIconEventhandle cip = new ComponentIconEventhandle();
                                cip.Init(_owner.Loader, root);
                                cip.Method   = hid.HandlerMethod;
                                cip.MethodId = hid.ActionId;
                                cip.Location = new Point(x, y);
                                x           += dx;
                                x           += cip.Width;
                                if (x > _owner.Width)
                                {
                                    x  = x0;
                                    y += dy;
                                    y += cip.Height;
                                }
                                iconList.Add(cip);
                            }
                        }
                    }
                }
            }
            //add missing property icon
            foreach (PropertyClass p in props.Values)
            {
                bool bFound = false;
                foreach (ComponentIconEvent ic in iconList)
                {
                    if (!ic.IsForComponent)
                    {
                        ComponentIconProperty cie = ic as ComponentIconProperty;
                        if (cie != null)
                        {
                            if (p.MemberId == cie.PropertyId)
                            {
                                ic.Designer = _owner.Loader;
                                bFound      = true;
                                break;
                            }
                        }
                    }
                }
                if (!bFound)
                {
                    ComponentIconProperty cip = new ComponentIconProperty();
                    cip.Init(_owner.Loader, root);
                    cip.Property   = p;
                    cip.PropertyId = p.MemberId;
                    cip.Location   = new Point(x, y);
                    x += dx;
                    x += cip.Width;
                    if (x > _owner.Width)
                    {
                        x  = x0;
                        y += dy;
                        y += cip.Height;
                    }
                    iconList.Add(cip);
                }
            }

            //add icons to the parent
            _owner.Controls.AddRange(iconList.ToArray());
            //collect all ports
            PortCollection pc = new PortCollection();
            foreach (ComponentIconEvent ic in iconList)
            {
                if (ic.Left < 0)
                {
                    ic.Left = 2;
                }
                if (ic.Top < 0)
                {
                    ic.Top = 2;
                }
                ic.Visible = true;
                ic.BringToFront();
                ic.RefreshLabelPosition();
                //
                if (ic.IsPortOwner)
                {
                    //validate the input/output ports of the icon.
                    //it will also add EventIcon controls to the parent
                    ic.Initialize(this);
                    //collect ports from the icon
                    pc.AddRange(ic.GetAllPorts());
                }
            }
            //add all ports to the parent
            List <Control> cs = pc.GetAllControls(false);
            _owner.Controls.AddRange(cs.ToArray());
            //apply port locations
            foreach (ComponentIconEvent ic in iconList)
            {
                //output ports
                List <EventIcon> eis = ic.EventIcons;
                if (eis != null && eis.Count > 0)
                {
                    foreach (EventIcon ei in eis)
                    {
                        List <EventPortOut> pos = ei.SourcePorts;
                        if (pos != null)
                        {
                            foreach (EventPortOut po in pos)
                            {
                                po.RestoreLocation();
                                po.SetLoaded();
                            }
                        }
                    }
                }
                //input ports
                List <EventPortIn> epis = ic.DestinationPorts;
                if (epis != null && epis.Count > 0)
                {
                    foreach (EventPortIn pi in epis)
                    {
                        pi.RestoreLocation();
                        pi.SetLoaded();
                    }
                }
            }
            pc.ValidatePortLinks();
            //link ports
            MakePortLinks(pc);
            //link lines
            pc.MakeLinks(TraceLogClass.MainForm);
            //set line color
            SetDynamicEventHandlerLineColor(pc);
            //
            pc.CreateLinkLines();
            //
            //remove unlinked inports
            foreach (ComponentIconEvent cieSource in iconList)
            {
                List <EventPortIn> epis = cieSource.DestinationPorts;
                if (epis != null && epis.Count > 0)
                {
                    List <EventPortIn> unlinked = new List <EventPortIn>();
                    foreach (EventPortIn ei in epis)
                    {
                        if (ei.LinkedOutPort == null)
                        {
                            unlinked.Add(ei);
                        }
                    }
                    if (unlinked.Count > 0)
                    {
                        foreach (EventPortIn ei in unlinked)
                        {
                            epis.Remove(ei);
                            if (ei.Parent != null)
                            {
                                ei.Parent.Controls.Remove(ei);
                            }
                        }
                    }
                }
            }
            //monitor and notify link line changes
            eventPath.SetupLineNodeMonitor();
            //
            //remedy for unsolved bug: remove duplicated ComponentIconEvent
            Dictionary <UInt64, List <ComponentIconEvent> > cieList = new Dictionary <UInt64, List <ComponentIconEvent> >();
            foreach (ComponentIconEvent cieSource in iconList)
            {
                if (typeof(ComponentIconEvent).Equals(cieSource.GetType()))
                {
                    UInt64 id = cieSource.WholeId;
                    List <ComponentIconEvent> list;
                    if (!cieList.TryGetValue(id, out list))
                    {
                        list = new List <ComponentIconEvent>();
                        cieList.Add(id, list);
                    }
                    list.Add(cieSource);
                }
            }
            foreach (KeyValuePair <UInt64, List <ComponentIconEvent> > kv in cieList)
            {
                if (kv.Value.Count > 1)
                {
                    //duplicate icons. Find those can be removed
                    List <ComponentIconEvent> deleting = new List <ComponentIconEvent>();
                    foreach (ComponentIconEvent cie in kv.Value)
                    {
                        if (cie.DestinationPorts.Count == 0)
                        {
                            if (cie.EventIcons.Count == 0)
                            {
                                deleting.Add(cie);
                            }
                        }
                    }
                    if (deleting.Count == kv.Value.Count)
                    {
                        deleting.RemoveAt(0);
                    }
                    foreach (ComponentIconEvent cie in deleting)
                    {
                        cie.Parent.Controls.Remove(cie.Label);
                        cie.Parent.Controls.Remove(cie);
                        _componentIconList.Remove(cie);
                        if (cie.DataXmlNode != null)
                        {
                            XmlNode xmp = cie.DataXmlNode.ParentNode;
                            xmp.RemoveChild(cie.DataXmlNode);
                        }
                    }
                }
            }
            eventPath.EnlargeForChildren();
        }
Exemple #16
0
    public static void Main()
    {
        ServiceDescription myServiceDescription = new ServiceDescription();

        myServiceDescription.Name            = "StockQuote";
        myServiceDescription.TargetNamespace = "http://www.contoso.com/stockquote.wsdl";

        // Generate the 'Types' element.
        XmlSchema myXmlSchema = new XmlSchema();

        myXmlSchema.AttributeFormDefault = XmlSchemaForm.Qualified;
        myXmlSchema.ElementFormDefault   = XmlSchemaForm.Qualified;
        myXmlSchema.TargetNamespace      = "http://www.contoso.com/stockquote.wsdl";

        //XmlSchemaElement myXmlSchemaElement;
        XmlSchemaComplexType myXmlSchemaComplexType = new XmlSchemaComplexType();

        myXmlSchemaComplexType.Name = "GetTradePriceInputType";
        XmlSchemaSequence myXmlSchemaSequence = new XmlSchemaSequence();

        myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "tickerSymbol", true, new XmlQualifiedName("s:string")));
        myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "time", true, new XmlQualifiedName("s:string")));
        myXmlSchemaComplexType.Particle = myXmlSchemaSequence;
        myXmlSchema.Items.Add(myXmlSchemaComplexType);

        myXmlSchemaComplexType      = new XmlSchemaComplexType();
        myXmlSchemaComplexType.Name = "GetTradePriceOutputType";
        myXmlSchemaSequence         = new XmlSchemaSequence();
        myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "result", true, new XmlQualifiedName("s:string")));
        myXmlSchemaComplexType.Particle = myXmlSchemaSequence;
        myXmlSchema.Items.Add(myXmlSchemaComplexType);

        myXmlSchemaComplexType      = new XmlSchemaComplexType();
        myXmlSchemaComplexType.Name = "GetTradePriceStringFaultType";
        myXmlSchemaSequence         = new XmlSchemaSequence();
        myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "error", true, new XmlQualifiedName("s:string")));
        myXmlSchemaComplexType.Particle = myXmlSchemaSequence;
        myXmlSchema.Items.Add(myXmlSchemaComplexType);

        myXmlSchemaComplexType      = new XmlSchemaComplexType();
        myXmlSchemaComplexType.Name = "GetTradePriceStringIntType";
        myXmlSchemaSequence         = new XmlSchemaSequence();
        myXmlSchemaSequence.Items.Add(CreateComplexTypeXmlElement("1", "1", "error", true, new XmlQualifiedName("s:int")));
        myXmlSchemaComplexType.Particle = myXmlSchemaSequence;
        myXmlSchema.Items.Add(myXmlSchemaComplexType);

        myXmlSchema.Items.Add(CreateOtherXmlElement("GetTradePriceSoapIn", new XmlQualifiedName("s0:GetTradePriceInputType")));
        myXmlSchema.Items.Add(CreateOtherXmlElement("GetTradePriceSoapOut", new XmlQualifiedName("s0:GetTradePriceOutputType")));
        myXmlSchema.Items.Add(CreateOtherXmlElement("GetTradePriceSoapStringFault", new XmlQualifiedName("s0:GetTradePriceStringFaultType")));
        myXmlSchema.Items.Add(CreateOtherXmlElement("GetTradePriceSoapIntFault", new XmlQualifiedName("s0:GetTradePriceIntFaultType")));

        myServiceDescription.Types.Schemas.Add(myXmlSchema);

        // Generate the 'Message' element.
        MessageCollection myMessageCollection = myServiceDescription.Messages;

        myMessageCollection.Add(CreateMessage("GetTradePriceInput", "parameters", "GetTradePriceSoapIn", myServiceDescription.TargetNamespace));
        myMessageCollection.Add(CreateMessage("GetTradePriceOutput", "parameters", "GetTradePriceSoapOut", myServiceDescription.TargetNamespace));
        myMessageCollection.Add(CreateMessage("GetTradePriceStringFault", "parameters", "GetTradePriceStringSoapFault", myServiceDescription.TargetNamespace));
        myMessageCollection.Add(CreateMessage("GetTradePriceIntFault", "parameters", "GetTradePriceIntSoapFault", myServiceDescription.TargetNamespace));

        // Generate the 'Port Type' element.
        PortTypeCollection myPortTypeCollection = myServiceDescription.PortTypes;
        PortType           myPortType           = new PortType();

        myPortType.Name = "StockQuotePortType";
        OperationCollection myOperationCollection = myPortType.Operations;
        Operation           myOperation           = new Operation();

        myOperation.Name = "GetTradePrice";
        OperationMessage           myOperationMessage;
        OperationMessageCollection myOperationMessageCollection = myOperation.Messages;

        myOperationMessage         = (OperationMessage) new OperationInput();
        myOperationMessage.Message = new XmlQualifiedName("s0:GetTradePriceInput");
        myOperationMessageCollection.Add(myOperationMessage);
        myOperationMessage         = (OperationMessage) new OperationOutput();
        myOperationMessage.Message = new XmlQualifiedName("s0:GetTradePriceOutput");
        myOperationMessageCollection.Add(myOperationMessage);
        OperationFault myOperationFault = new OperationFault();

        myOperationFault.Name    = "ErrorString";
        myOperationFault.Message = new XmlQualifiedName("s0:GetTradePriceStringFault");
        myOperation.Faults.Add(myOperationFault);
        myOperationFault         = new OperationFault();
        myOperationFault.Name    = "ErrorInt";
        myOperationFault.Message = new XmlQualifiedName("s0:GetTradePriceIntFault");
        myOperation.Faults.Add(myOperationFault);
        myOperationCollection.Add(myOperation);
        myPortTypeCollection.Add(myPortType);

        // Generate the 'Binding' element.
        ServiceDescriptionFormatExtensionCollection myExtensions;
        BindingCollection myBindingCollection = myServiceDescription.Bindings;
        Binding           myBinding           = new Binding();

        myBinding.Name = "StockQuoteSoapBinding";
        myBinding.Type = new XmlQualifiedName("s0:StockQuotePortType");
        myExtensions   = myBinding.Extensions;
        SoapBinding mySoapBinding = new SoapBinding();

        mySoapBinding.Style     = SoapBindingStyle.Document;
        mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http";
        myExtensions.Add(mySoapBinding);
        OperationBindingCollection myOperationBindingCollection = myBinding.Operations;
        OperationBinding           myOperationBinding           = new OperationBinding();

        myExtensions = myOperationBinding.Extensions;
        SoapOperationBinding mySoapBindingOperation = new SoapOperationBinding();

        mySoapBindingOperation.SoapAction = "http://www.contoso.com/GetTradePrice";
        myExtensions.Add(mySoapBindingOperation);
        myOperationBinding.Name  = "GetTradePrice";
        myOperationBinding.Input = new InputBinding();
        myExtensions             = myOperationBinding.Input.Extensions;
        SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();

        mySoapBodyBinding.Use       = SoapBindingUse.Literal;
        mySoapBodyBinding.Namespace = "http://www.contoso.com/stockquote";
        myExtensions.Add(mySoapBodyBinding);
        myOperationBinding.Output = new OutputBinding();
        myExtensions                = myOperationBinding.Output.Extensions;
        mySoapBodyBinding           = new SoapBodyBinding();
        mySoapBodyBinding.Use       = SoapBindingUse.Literal;
        mySoapBodyBinding.Namespace = "http://www.contoso.com/stockquote";
        myExtensions.Add(mySoapBodyBinding);
// <Snippet1>
// <Snippet2>
// <Snippet3>
        FaultBindingCollection myFaultBindingCollection = myOperationBinding.Faults;
        FaultBinding           myFaultBinding           = new FaultBinding();

        myFaultBinding.Name = "ErrorString";
        // Associate SOAP fault binding to the fault binding of the operation.
        myExtensions = myFaultBinding.Extensions;
        SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding();

        mySoapFaultBinding.Use       = SoapBindingUse.Literal;
        mySoapFaultBinding.Namespace = "http://www.contoso.com/stockquote";
        myExtensions.Add(mySoapFaultBinding);
        myFaultBindingCollection.Add(myFaultBinding);
// </Snippet3>
// </Snippet2>
// </Snippet1>
        myFaultBinding      = new FaultBinding();
        myFaultBinding.Name = "ErrorInt";
        // Associate SOAP fault binding to the fault binding of the operation.
        myExtensions                 = myFaultBinding.Extensions;
        mySoapFaultBinding           = new SoapFaultBinding();
        mySoapFaultBinding.Use       = SoapBindingUse.Literal;
        mySoapFaultBinding.Namespace = "http://www.contoso.com/stockquote";
        myExtensions.Add(mySoapFaultBinding);
        myFaultBindingCollection.Add(myFaultBinding);
        myOperationBindingCollection.Add(myOperationBinding);
        myBindingCollection.Add(myBinding);

        // Generate the 'Service' element.
        ServiceCollection myServiceCollection = myServiceDescription.Services;
// <Snippet4>
        Service myService = new Service();

        // Add a simple documentation for the service to ease the readability of the generated WSDL file.
        myService.Documentation = "A Simple Stock Quote Service";
        myService.Name          = "StockQuoteService";
        PortCollection myPortCollection = myService.Ports;
        Port           myPort           = new Port();

        myPort.Name    = "StockQuotePort";
        myPort.Binding = new XmlQualifiedName("s0:StockQuoteSoapBinding");
        myExtensions   = myPort.Extensions;
        SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();

        mySoapAddressBinding.Location = "http://www.contoso.com/stockquote";
        myExtensions.Add(mySoapAddressBinding);
        myPortCollection.Add(myPort);
// </Snippet4>
        myServiceCollection.Add(myService);

        // Display the WSDL generated to the console.
        myServiceDescription.Write(Console.Out);
    }
Exemple #17
0
        public void pipeWalk()
        {
            // 4.1 Declare a variable as a PlantProject. Instantiate it using
            // the CurrentProject of PlantApplication
            PlantProject mainPrj = PlantApplication.CurrentProject;

            // 4.2 Declare a Project and instantiate it using
            // ProjectParts[] of the PlantProject from step 4.1
            // use "Piping" for the name. This will get the Piping project
            Project prj = mainPrj.ProjectParts["Piping"];

            // 4.3 Declare a variable as a DataLinksManager. Instantiate it using
            // the DataLinksManager property of the Project from 4.2.
            DataLinksManager dlm = prj.DataLinksManager;

            //  PipingProject pipingPrj = (PipingProject) mainPrj.ProjectParts["Piping"];
            //  DataLinksManager dlm = pipingPrj.DataLinksManager;


            // Get the TransactionManager
            TransactionManager tm =
                AcadApp.DocumentManager.MdiActiveDocument.Database.TransactionManager;

            // Get the AutoCAD editor
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            // Prompt the user to select a pipe entity
            PromptEntityOptions pmtEntOpts = new PromptEntityOptions("Select a Pipe : ");
            PromptEntityResult  pmtEntRes  = ed.GetEntity(pmtEntOpts);

            if (pmtEntRes.Status == PromptStatus.OK)
            {
                // Get the ObjectId of the selected entity
                ObjectId entId = pmtEntRes.ObjectId;

                // Use the using statement and start a transaction
                // Use the transactionManager created above (tm)
                using (Transaction tr = tm.StartTransaction())
                {
                    try
                    {
                        // 4.4 Declare a variable as a Part. Instantiate it using
                        // the GetObject Method of the Transaction created above (tr)
                        // for the ObjectId argument use the ObjectId from above (entId)
                        // Open it for read. (need to cast it to Part)
                        Part pPart = (Part)tr.GetObject(entId, OpenMode.ForRead);

                        // 4.5 Declare a variable as a PortCollection. Instantiate it
                        // using the GetPorts method of the Part from step 4.4.
                        // use PortType.All for the PortType.
                        PortCollection portCol = pPart.GetPorts(PortType.All); // (PortType.Both);

                        // 4.6 Use the WriteMessage function of the Editor created above (ed)
                        // print the Count property of the PortCollection from step 4.5.
                        // use a string similar to this: "\n port collection count = "
                        ed.WriteMessage("\n port collection count = " + portCol.Count);

                        // 4.7 Declare a ConnectionManager variable.
                        // (Autodesk.ProcessPower.PnP3dObjects.ConnectionManager)
                        // Instantiate the ConnectionManager variable by making it
                        // equal to a new Autodesk.ProcessPower.PnP3dObjects.ConnectionManager();
                        ConnectionManager conMgr = new Autodesk.ProcessPower.PnP3dObjects.ConnectionManager();

                        // 4.8 Declare a bool variable named bPartIsConnected and make it false
                        bool bPartIsConnected = false;


                        // 4.9 Use a foreach loop and iterate through all of the Port in
                        // the PortCollection from step 4.5.
                        // Note: Put the closing curly brace below step 4.18
                        foreach (Port pPort in portCol)
                        {
                            // 4.10 Use the WriteMessage function of the Editor created above (ed)
                            // print the Name property of the Port (looping through the ports)
                            // use a string similar to this: "\nName of this Port = " +
                            ed.WriteMessage("\nName of this Port = " + pPort.Name);

                            // 4.11 Use the WriteMessage function of the Editor created above (ed)
                            // print the X property of the Position from the Port
                            // use a string similar to this: "\nX of this Port = " +
                            ed.WriteMessage("\nX of this Port = " + pPort.Position.X.ToString());

                            // 4.12 Declare a variable as a Pair and make it equal to a
                            // new Pair().
                            Pair pair1 = new Pair();

                            // 4.13 Make the ObjectId property of the Pair created in step 4.10
                            // equal to the ObjectId of the selected Part (entId)
                            pair1.ObjectId = entId;

                            // 4.14 Make the Port property of the Pair created in step 4.10
                            // equal to the port from the foreach cycle (step 4.7)
                            pair1.Port = pPort;


                            // 4.15 Use an if else and the IsConnected method of the ConnectionManager
                            // from step 4.7. Pass in the Pair from step 4.12
                            // Note: Put the else statement below step 4.17 and the closing curly
                            // brace for the else below step 4.18
                            if (conMgr.IsConnected(pair1))
                            {
                                // 4.16 Use the WriteMessage function of the Editor (ed)
                                // and put this on the command line:
                                // "\n Pair is connected "
                                ed.WriteMessage("\n Pair is connected ");

                                // 4.17 Make the bool from step 4.8 equal to true.
                                // This is used in an if statement in step 4.19.
                                bPartIsConnected = true;
                            }
                            else
                            {
                                // 4.18 Use the WriteMessage function of the Editor (ed)
                                // and put this on the command line:
                                // "\n Pair is NOT connected "
                                ed.WriteMessage("\n Pair is NOT connected ");
                            }
                        }


                        // 4.19 Use an If statement and the bool from step 4.8. This will be
                        // true if one of the pairs tested in loop above loop was connected.
                        // Note: Put the closing curly brace after step 4.26
                        if (bPartIsConnected)
                        {
                            // 4.20 Declare an ObjectId named curObjID make it
                            // equal to ObjectId.Null
                            ObjectId curObjId = ObjectId.Null;


                            // 4.21 Declare an int name it rowId
                            int rowId;

                            // 4.22 Declare a variable as a  ConnectionIterator instantiate it
                            // using the NewIterator method of ConnectionIterator (Autodesk.ProcessPower.PnP3dObjects.)
                            // Use the ObjectId property of the Part from step 4.4
                            ConnectionIterator connectIter = ConnectionIterator.NewIterator(pPart.ObjectId);                       //need PnP3dObjectsMgd.dll

                            // You could Also use this, need to ensure that pPort is connected
                            // Use the ConnectionManager and a Pair as in the example above.
                            // conIter = ConnectionIterator.NewIterator(pPart.ObjectId, pPort);

                            // 4.23 Use a for loop and loop through the connections in the
                            // ConnectionIterator from step 4.22. The initializer can be empty.
                            // Use !.Done for the condition. use .Next for the iterator.
                            // Note: Put the closing curly brace after step 4.26
                            for (; !connectIter.Done(); connectIter.Next())
                            {
                                // 4.24 Make the ObjectId from step 4.20 equal to the ObjectId
                                // property of the ConnectionIterator
                                curObjId = connectIter.ObjectId;

                                // 4.25 Make the integer from step 4.21 equal to the return from
                                // FindAcPpRowId method of the DataLinksManager from step 4.3.
                                // pass in the ObjectId from step 4.24
                                rowId = dlm.FindAcPpRowId(curObjId);

                                //4.26 Use the WriteMessage function of the Editor (ed)
                                // and pring the integer from step 4.25. Use a string similar to this
                                // this on the command line:
                                // "\n PnId = " +
                                ed.WriteMessage("\n PnId = " + rowId);
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        ed.WriteMessage(ex.ToString());
                    }
                }
            }
        }
        /// <summary>
        /// Maps the ports.
        /// </summary>
        /// <param name="dataReader">The data reader.</param>
        /// <returns>port collection.</returns>
        private static async Task<PortCollection> MapPorts(SqlDataReader dataReader)
        {
            var portCollection = new PortCollection();
            if (dataReader != null)
            {
                while (await dataReader.ReadAsync())
                {
                    var port = new Port
                    {
                        PortId = dataReader.Int32Field(PortId).ToString(),
                        CountryId = dataReader.Int32Field(CountryId).ToString(),
                        Code = dataReader.StringField(Code),
                        City = dataReader.StringField(City),
                        State = dataReader.StringField(State),
                        StateId = dataReader.Int32NullableField(StateId).ToString(),
                        Description = dataReader.StringField(Description),
                        Name = dataReader.StringField(Name)
                    };

                    portCollection.Add(port);
                }
            }

            return portCollection;
        }
        public DrawingTool()
        {
            InitializeComponent();
            if (Device.RuntimePlatform == Device.Android)
            {
                Xamarin.Forms.DependencyService.Get <IText>().GenerateFactor();
            }
            diagram.IsReadOnly = true;
            Node n1 = DrawNode(145, 110, 100, 55, ShapeType.Rectangle, "Node1");

            if (Device.RuntimePlatform == Device.UWP)
            {
                n1.ShapeType = ShapeType.Rectangle;
            }
            n1.Style.Brush       = new SolidBrush(Color.FromRgb(49, 162, 255));
            n1.Style.StrokeBrush = new SolidBrush(Color.FromRgb(23, 132, 206));
            PortCollection node1ports = new PortCollection();
            Port           port1      = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 0, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port2 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port3 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 1, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port4 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 1, ShapeType = ShapeType.Circle, IsVisible = true
            };

            node1ports.Add(port1);
            node1ports.Add(port2);
            node1ports.Add(port3);
            node1ports.Add(port4);
            n1.Ports = node1ports;
            Node n2 = DrawNode(30, 260, 100, 55, ShapeType.Rectangle, "Node2");

            if (Device.RuntimePlatform == Device.UWP)
            {
                n2.ShapeType = ShapeType.Rectangle;
            }
            n2.Style.Brush       = new SolidBrush(Color.FromRgb(239, 75, 93));
            n2.Style.StrokeBrush = new SolidBrush(Color.FromRgb(201, 32, 61));
            PortCollection node2ports = new PortCollection();
            Port           port5      = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 0, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port6 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port7 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 1, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port8 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 1, ShapeType = ShapeType.Circle, IsVisible = true
            };

            node2ports.Add(port5);
            node2ports.Add(port6);
            node2ports.Add(port7);
            node2ports.Add(port8);
            n2.Ports = node2ports;
            Node n3 = DrawNode(260, 260, 100, 55, ShapeType.Rectangle, "Node3");

            if (Device.RuntimePlatform == Device.UWP)
            {
                n3.ShapeType = ShapeType.Rectangle;
            }
            n3.Style.Brush       = new SolidBrush(Color.FromRgb(0, 194, 192));
            n3.Style.StrokeBrush = new SolidBrush(Color.FromRgb(14, 142, 135));
            PortCollection node3ports = new PortCollection();
            Port           port9      = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 0, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port10 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port11 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 1, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true
            };
            Port port12 = new Port()
            {
                Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 1, ShapeType = ShapeType.Circle, IsVisible = true
            };

            node3ports.Add(port9);
            node3ports.Add(port10);
            node3ports.Add(port11);
            node3ports.Add(port12);
            n3.Ports = node3ports;
            Connector con1 = new Connector()
            {
                SourcePort = port4, TargetPort = port5, SegmentType = SegmentType.StraightSegment, TargetDecoratorType = DecoratorType.None
            };
            Connector con2 = new Connector()
            {
                SourcePort = port4, TargetPort = port9, SegmentType = SegmentType.StraightSegment, TargetDecoratorType = DecoratorType.None
            };
            Connector con3 = new Connector()
            {
                SourcePort = port7, TargetPort = port10, SegmentType = SegmentType.StraightSegment, TargetDecoratorType = DecoratorType.None
            };

            diagram.AddNode(n1);
            diagram.AddNode(n2);
            diagram.AddNode(n3);
            diagram.AddConnector(con1);
            diagram.AddConnector(con2);
            diagram.AddConnector(con3);
        }
        public void PortCollectionSerialization()
        {
            var ports = new PortCollection
            {
                Ports = {new Port {Id = Guid.NewGuid()}},
                PortsLinks = {new Link("next", "http://api.com/next")}
            };

            string json = JsonConvert.SerializeObject(ports, Formatting.None);
            Assert.Contains("\"ports\"", json);
            Assert.DoesNotContain("\"port\"", json);

            var result = JsonConvert.DeserializeObject<PortCollection>(json);
            Assert.NotNull(result);
            Assert.Equal(1, result.Count());
            Assert.Equal(1, result.Ports.Count());
            Assert.Equal(1, result.PortsLinks.Count());
        }
Exemple #21
0
 public static void MakePortLinks(PortCollection ports)
 {
     foreach (LinkLineNodePort p in ports)
     {
         EventPortIn epi = p as EventPortIn;
         if (epi != null)
         {
             EventPortInFireEvent epife = epi as EventPortInFireEvent;
             //
             bool bLinked = false;
             foreach (LinkLineNodePort p2 in ports)
             {
                 bool bMatch = false;
                 if (epife != null)
                 {
                     EventPortOutFirer epof = p2 as EventPortOutFirer;
                     if (epof != null)
                     {
                         //it is a fire-event action
                         ComponentIconFireEvent cife = epof.PortOwner as ComponentIconFireEvent;
                         if (cife != null)
                         {
                             FireEventMethod fe1 = epife.FireEventMethod;
                             FireEventMethod fe2 = cife.Firer;
                             if (fe1 != null && fe2 != null && fe1.EventId == fe2.EventId && fe2.MemberId == fe2.MemberId)
                             {
                                 bMatch = true;
                             }
                         }
                     }
                 }
                 else
                 {
                     EventPortOut epo = p2 as EventPortOut;
                     if (epo != null)
                     {
                         if (epi.Event.IsSameObjectRef(epo.Event))
                         {
                             ComponentIconEvent cieDest = (ComponentIconEvent)(epi.PortOwner);
                             if (epo.IsActionExecuter(cieDest))
                             {
                                 bMatch = true;
                             }
                         }
                     }
                 }
                 if (bMatch)
                 {
                     if (p2.LinkedPortID == epi.PortID && p2.LinkedPortInstanceID == epi.PortInstanceID &&
                         epi.LinkedPortID == p2.PortID && epi.LinkedPortInstanceID == p2.PortInstanceID)
                     {
                         bLinked = true;
                         break;
                     }
                     else
                     {
                         //try to fix it
                         if (p2.LinkedPortID == 0 && epi.LinkedPortID == 0)
                         {
                             p2.LinkedPortID          = epi.PortID;
                             p2.LinkedPortInstanceID  = epi.PortInstanceID;
                             epi.LinkedPortID         = p2.PortID;
                             epi.LinkedPortInstanceID = p2.PortInstanceID;
                             bLinked = true;
                             break;
                         }
                         else
                         {
                             LinkLineNodePort lp;
                             lp = ports.GetPortByID(epi.LinkedPortID, epi.LinkedPortInstanceID);
                             if (lp == null)
                             {
                                 if (p2.LinkedPortID == 0)
                                 {
                                     p2.LinkedPortID          = epi.PortID;
                                     p2.LinkedPortInstanceID  = epi.PortInstanceID;
                                     epi.LinkedPortID         = p2.PortID;
                                     epi.LinkedPortInstanceID = p2.PortInstanceID;
                                     bLinked = true;
                                     break;
                                 }
                                 else
                                 {
                                     lp = ports.GetPortByID(p2.LinkedPortID, p2.LinkedPortInstanceID);
                                     if (lp == null)
                                     {
                                         p2.LinkedPortID          = epi.PortID;
                                         p2.LinkedPortInstanceID  = epi.PortInstanceID;
                                         epi.LinkedPortID         = p2.PortID;
                                         epi.LinkedPortInstanceID = p2.PortInstanceID;
                                         bLinked = true;
                                         break;
                                     }
                                 }
                             }
                             else
                             {
                                 if (lp.LinkedPortID == epi.PortID && lp.LinkedPortInstanceID == epi.PortInstanceID)
                                 {
                                     bLinked = true;
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             if (!bLinked)
             {
                 if (epi.LinkedPortID != 0)
                 {
                     LinkLineNodePort lp;
                     lp = ports.GetPortByID(epi.LinkedPortID, epi.LinkedPortInstanceID);
                     if (lp == null || lp != epi)
                     {
                         epi.LinkedPortInstanceID = 0;
                         epi.LinkedPortID         = 0;
                     }
                 }
                 if (epi.LinkedPortID == 0)
                 {
                 }
             }
         }
     }
     foreach (LinkLineNodePort p in ports)
     {
         EventPortOut epo = p as EventPortOut;
         if (epo != null)
         {
             if (epo.LinkedPortID != 0)
             {
                 if (ports.GetPortByID(epo.LinkedPortID, epo.LinkedPortInstanceID) == null)
                 {
                     epo.LinkedPortInstanceID = 0;
                     epo.LinkedPortID         = 0;
                 }
             }
         }
     }
 }
Exemple #22
0
        public override PortCollection GetAllPorts()
        {
            PortCollection pc = new PortCollection();

            return(pc);
        }
Exemple #23
0
        public void ShowLinks()
        {
            List <ComponentIconEvent> iconList = ComponentIconList;
            //collect all ports
            PortCollection pc = new PortCollection();

            foreach (ComponentIconEvent ic in iconList)
            {
                if (ic.Left < 0)
                {
                    ic.Left = 2;
                }
                if (ic.Top < 0)
                {
                    ic.Top = 2;
                }
                ic.Visible = true;
                ic.BringToFront();
                ic.RefreshLabelPosition();
                //
                if (ic.IsPortOwner)
                {
                    //validate the input/output ports of the icon.
                    //it will also add EventIcon controls to the parent
                    ic.Initialize(this);
                    //collect ports from the icon
                    pc.AddRange(ic.GetAllPorts());
                }
            }
            //add all ports to the parent
            List <Control> cs = pc.GetAllControls(false);

            _owner.Controls.AddRange(cs.ToArray());
            //apply port locations
            foreach (ComponentIconEvent ic in iconList)
            {
                //output ports
                List <EventIcon> eis = ic.EventIcons;
                if (eis != null && eis.Count > 0)
                {
                    foreach (EventIcon ei in eis)
                    {
                        List <EventPortOut> pos = ei.SourcePorts;
                        if (pos != null)
                        {
                            foreach (EventPortOut po in pos)
                            {
                                po.RestoreLocation();
                                po.SetLoaded();
                            }
                        }
                    }
                }
                //input ports
                List <EventPortIn> epis = ic.DestinationPorts;
                if (epis != null && epis.Count > 0)
                {
                    foreach (EventPortIn pi in epis)
                    {
                        pi.RestoreLocation();
                        pi.SetLoaded();
                    }
                }
            }
            pc.ValidatePortLinks();
            //link ports
            MakePortLinks(pc);
            //link lines
            pc.MakeLinks(TraceLogClass.MainForm);
            //set line color
            SetDynamicEventHandlerLineColor(pc);
            //
            pc.CreateLinkLines();
        }