コード例 #1
0
        public void DragOver(IDropInfo dropInfo)
        {
            if (SelectedController == null)
            {
                return;
            }
            List <IConnectable> connectables = new List <IConnectable>();

            if (dropInfo.Data is FilteredConnectablesGroup group)
            {
                if (group.Scope == SelectedController)
                {
                    return;
                }
                connectables = ConnectionHelper.GetConnectables(group.Scope, filterPredicate);
            }
            else if (dropInfo.Data is IEnumerable dropList && dropList.GetItemType() == typeof(FilteredConnectablesGroup))
            {
                foreach (FilteredConnectablesGroup item in dropList)
                {
                    connectables.AddRange(ConnectionHelper.GetConnectables(item.Scope, filterPredicate));
                }
            }
            if (ConnectionHelper.CanConnectToController(connectables, SelectedController))
            {
                DragDropHelpers.SetDragAdorners(dropInfo);
            }
        }
コード例 #2
0
        private List <TECController> getCompatibleControllers(IEnumerable <TECController> controllers)
        {
            List <TECController> result = new List <TECController>();

            foreach (TECController controller in controllers)
            {
                if (ConnectionHelper.CanConnectToController(toConnect, controller))
                {
                    result.Add(controller);
                }
            }
            return(result);
        }
コード例 #3
0
        public void CanConnectToControllerTest1()
        {
            TECProtocol protocol      = new TECProtocol(new List <TECConnectionType>());
            TECProtocol otherProtocol = new TECProtocol(new List <TECConnectionType>());

            TECDevice protDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                protocol
            }, new TECManufacturer());
            TECDevice otherProtDevice = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>()
            {
                otherProtocol
            }, new TECManufacturer());

            List <IConnectable> connectables = new List <IConnectable>();

            TECSubScope item1 = new TECSubScope();

            item1.Devices.Add(otherProtDevice);
            connectables.Add(item1);
            TECSubScope item2 = new TECSubScope();

            item2.Devices.Add(protDevice);
            connectables.Add(item2);
            TECSubScope item3 = new TECSubScope();

            item3.Devices.Add(protDevice);
            connectables.Add(item3);
            TECSubScope item4 = new TECSubScope();

            item4.Devices.Add(protDevice);
            connectables.Add(item4);
            TECSubScope item5 = new TECSubScope();

            item5.Devices.Add(protDevice);
            connectables.Add(item5);
            TECSubScope item6 = new TECSubScope();

            item6.Devices.Add(protDevice);
            connectables.Add(item6);


            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(protocol));
            TECProvidedController controller = new TECProvidedController(type);

            Assert.IsFalse(ConnectionHelper.CanConnectToController(connectables, controller));
        }
コード例 #4
0
        public void CanConnectToControllerTest3()
        {
            TECConnectionType connectionType = new TECConnectionType();
            TECDevice         device         = new TECDevice(new List <TECConnectionType> {
                connectionType
            }, new List <TECProtocol>(), new TECManufacturer());

            List <IConnectable> connectables = new List <IConnectable>();

            TECSubScope item1 = new TECSubScope();

            item1.Devices.Add(device);
            TECPoint aiPoint = new TECPoint();

            aiPoint.Type = IOType.AI;
            item1.AddPoint(aiPoint);
            connectables.Add(item1);
            TECSubScope item2 = new TECSubScope();

            item2.Devices.Add(device);
            TECPoint diPoint = new TECPoint();

            diPoint.Type = IOType.DI;
            item2.AddPoint(diPoint);
            connectables.Add(item2);
            TECSubScope item3 = new TECSubScope();

            item3.Devices.Add(device);
            TECPoint doPoint = new TECPoint();

            doPoint.Type = IOType.DO;
            item3.AddPoint(doPoint);
            connectables.Add(item3);
            TECSubScope item4 = new TECSubScope();

            item4.Devices.Add(device);
            TECPoint aoPoint = new TECPoint();

            aoPoint.Type = IOType.AO;
            item4.AddPoint(aoPoint);
            connectables.Add(item4);
            TECSubScope item5 = new TECSubScope();

            item5.Devices.Add(device);
            TECPoint otherAoPoint = new TECPoint();

            otherAoPoint.Type = IOType.AO;
            item5.AddPoint(otherAoPoint);
            connectables.Add(item5);


            TECControllerType type = new TECControllerType(new TECManufacturer());

            type.IO.Add(new TECIO(IOType.UI));
            type.IO.Add(new TECIO(IOType.UI));
            type.IO.Add(new TECIO(IOType.UO));
            type.IO.Add(new TECIO(IOType.UO));
            type.IO.Add(new TECIO(IOType.UI));

            TECProvidedController controller = new TECProvidedController(type);

            Assert.IsFalse(ConnectionHelper.CanConnectToController(connectables, controller));
        }