Пример #1
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
            });
        }
Пример #2
0
        //Initializer
        public ScopeEditorVM(TECBid bid, ChangeWatcher watcher)
        {
            Bid = bid;

            ScopeCollection              = new ScopeCollectionsTabVM(Bid);
            ScopeCollection.DragHandler += DragOver;
            ScopeCollection.DropHandler += Drop;

            setupControllersPanelsTab();
            setupMiscVM();
            TypicalEditVM           = new SystemHierarchyVM(bid, true);
            TypicalEditVM.Selected += item =>
            {
                Selected = item;
            };
            InstanceEditVM           = new TypicalHierarchyVM(bid, watcher);
            InstanceEditVM.Selected += item => {
                Selected = item;
            };
            PropertiesVM  = new PropertiesVM(bid.Catalogs, bid);
            WorkBoxVM     = new WorkBoxVM(bid);
            ConnectionsVM = new ConnectionsVM(bid, watcher, bid.Catalogs, locations: bid.Locations, filterPredicate: filterPredicate);

            bool filterPredicate(ITECObject obj)
            {
                if (obj is ITypicalable typable)
                {
                    return(typable is TECTypical || !typable.IsTypical);
                }
                else if (obj is TECScopeTemplates || obj is TECCatalogs)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            ConnectionsVM.Selected += item =>
            {
                Selected = item;
            };
            DGTabIndex          = GridIndex.Systems;
            TemplatesVisibility = Visibility.Visible;
        }