Esempio n. 1
0
 private void OnRootAdded(object sender, ModelAddedEventArgs<Root> e)
 {
     var newRootVm = new RootVM(e.NewModel, Access, RootDataService);
     Items.AddNewItem(newRootVm);
     Items.CommitNew();
     CurrentContent = newRootVm;
     CurrentContent.IsSelected = true;
 }
Esempio n. 2
0
        public RootFishbonesVM(RootVM root, ProductDefectionVM productDefection, AccessType access) : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentRoot = root;
            RootDataService = new RootDataService(UnitOfWork);
            RootDataService.FishboneAdded += OnFishboneNodeAdded;
            RootDataService.FishboneRemoved += OnFishboneNodeRemoved;
            ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork);
            ProductDataService = new ProductDataService(UnitOfWork);
            DefectionDataService = new DefectionDataService(UnitOfWork);
            SwitchItemsCommand = new Command(SetProductDefections);
            ViewProductDefectionsCommand = new Command(ViewProductDefections);
            InitializeFishboneCommand = new Command(InitializeFishbone);
            FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork);

            RootNode = new FishboneNodeVM(Access, FishboneNodeDataService) { Title = string.Empty, Id = -1, ParentId = -2 };

            var selectedVms = new ObservableCollection<FishboneNodeVM>();
            foreach (var rootFishboneNode in RootDataService.GetFishboneNodes(root.Id))
            {
                selectedVms.Add(new FishboneNodeVM(rootFishboneNode, Access, FishboneNodeDataService));
            }

            SetProductDefections();

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeTreeCommand = new Command(ExcludeTree, CanExcludeTree);


            foreach (FishboneNodeVM item in selectedVms)
            {
                if (item.ParentId == RootNode.Id)
                {
                    RootNode.ChildNodes.Add(item);
                    break;
                }
            }

            CurrentNode = RootNode;

            if (productDefection != null)
            {
                foreach (IInfoViewModel item in DefectionList)
                {
                    if (item.Id == productDefection.DefectionId)
                    {
                        CurrentDefection = item;
                        ViewProductDefections(null);
                        break;
                    }
                }
				if(AllItems!=null)
                foreach (ProductDefectionVM item in AllItems)
                {
                    if (item.Id == productDefection.Id)
                    {
                        CurrentProductDefection = item;
                        IsEnabled = false;
                        break;
                    }
                }
            }

        }