예제 #1
0
 public void Bid_SubScopeConnectionLinking()
 {
     foreach (TECController controller in bid.Controllers)
     {
         foreach (IControllerConnection connection in controller.ChildrenConnections)
         {
             var subScopeConnection = connection as TECHardwiredConnection;
             if (subScopeConnection != null)
             {
                 Assert.IsTrue(bid.GetAll <TECSubScope>().Contains(subScopeConnection.Child as TECSubScope));
             }
         }
     }
     foreach (TECTypical typical in bid.Systems)
     {
         foreach (TECController controller in typical.Controllers)
         {
             foreach (IControllerConnection connection in controller.ChildrenConnections)
             {
                 var subScopeConnection = connection as TECHardwiredConnection;
                 if (subScopeConnection != null)
                 {
                     Assert.IsTrue(bid.GetAll <TECSubScope>().Contains(subScopeConnection.Child as TECSubScope));
                 }
             }
         }
         foreach (TECSystem instance in typical.Instances)
         {
             foreach (TECController controller in instance.Controllers)
             {
                 foreach (IControllerConnection connection in controller.ChildrenConnections)
                 {
                     var subScopeConnection = connection as TECHardwiredConnection;
                     if (subScopeConnection != null)
                     {
                         Assert.IsTrue(bid.GetAll <TECSubScope>().Contains(subScopeConnection.Child as TECSubScope));
                     }
                 }
             }
         }
     }
 }
예제 #2
0
        public QuotesVM(TECBid bid, ChangeWatcher watcher)
        {
            watcher.Changed  += bidChanged;
            NeedQuoteHardware = new ObservableCollection <TECHardware>(bid
                                                                       .GetAll <TECSubScope>()
                                                                       .SelectMany(ss => ss.Devices
                                                                                   .Where(x => x is TECHardware ware && ware.RequireQuote && ware.QuotedPrice == -1))
                                                                       .Distinct()
                                                                       .OfType <TECHardware>());
            QuotedHardware = new ObservableCollection <TECHardware>(bid.Catalogs.GetAll <TECHardware>().Where(x => x.QuotedPrice != -1).Distinct());
            QuotedHardware.CollectionChanged += quotedHardware_CollectionChanged;
            var dropHandler = new EmptyDropTarget();

            dropHandler.DragOverAction = info =>
            {
                DragDropHelpers.DragOver(info, (item, sourceType, targetType) =>
                {
                    var hardware = item as TECHardware;
                    return(hardware != null && hardware.QuotedPrice == -1);
                });
            };
            dropHandler.DropAction = info =>
            {
                DragDropHelpers.Drop(info, item =>
                {
                    var hardware         = item as TECHardware;
                    hardware.QuotedPrice = hardware.Cost;
                    return(hardware);
                });
            };
            QuoteDropHandler = dropHandler;
            CollectionsVM    = new ScopeCollectionsTabVM(bid);
            CollectionsVM.OmitCollections(new List <AllSearchableObjects>()
            {
                AllSearchableObjects.System,
                AllSearchableObjects.Equipment,
                AllSearchableObjects.SubScope,
                AllSearchableObjects.Controllers,
                AllSearchableObjects.Panels,
                AllSearchableObjects.MiscCosts,
                AllSearchableObjects.MiscWiring,
                AllSearchableObjects.Tags,
                AllSearchableObjects.AssociatedCosts,
                AllSearchableObjects.Wires,
                AllSearchableObjects.Conduits,
                AllSearchableObjects.Protocols
            });
        }
예제 #3
0
        public static bool LinkLoadedBid(TECBid bid, Dictionary <Guid, List <Guid> > guidDictionary)
        {
            bool needsSave = false;

            foreach (TECController controller in bid.GetAll <TECController>())
            {
                if (controller is TECProvidedController provided)
                {
                    bool controllerNeedsSave = ModelCleanser.addRequiredIOModules(provided);
                    if (controllerNeedsSave)
                    {
                        needsSave = true;
                    }
                }
            }

            foreach (TECTypical typical in bid.Systems)
            {
                createScopeDictionary(typical, guidDictionary);
                typical.RefreshRegistration();
            }
            return(needsSave);
        }