예제 #1
0
        public LogicalViewModel(ISolutionBuilderViewModel sourceViewModel, InnerPanelViewModel innerView)
        {
            this.Title = innerView.Title;
            this.WireSolutionBuilderViewModel(sourceViewModel, true);
            this.LogicalViewNodes = new ObservableCollection <LogicalViewModelNode>();
            IProductElementViewModel root        = null;
            IEnumerable <string>     menuFilters = null;
            InnerPanelItem           rootItem    = null;
            ObservableCollection <IProductElementViewModel> children = new ObservableCollection <IProductElementViewModel>();

            foreach (InnerPanelItem item in innerView.Items)
            {
                if (item is InnerPanelTitle)
                {
                    if (root != null)
                    {
                        var rootNode = new LogicalViewModelNode(this, root, children)
                        {
                            CustomIconPath = rootItem.IconPath
                        };
                        if (menuFilters != null)
                        {
                            rootNode.FilterMenuItems(menuFilters.ToArray());
                        }
                        this.LogicalViewNodes.Add(rootNode);
                    }
                    rootItem    = item;
                    root        = this.GetProductNode(item);
                    menuFilters = (item as InnerPanelTitle).MenuFilters;
                    children    = new ObservableCollection <IProductElementViewModel>();
                }
                else
                {
                    children.Add(this.GetProductNode(item));
                }
            }
            if (root != null)
            {
                var rootNode = new LogicalViewModelNode(this, root, children)
                {
                    CustomIconPath = rootItem.IconPath
                };
                if (menuFilters != null)
                {
                    rootNode.FilterMenuItems(menuFilters.ToArray());
                }
                this.LogicalViewNodes.Add(rootNode);
            }
        }
예제 #2
0
        private IProductElementViewModel GetProductNode(InnerPanelItem item)
        {
            IProductElement          target = item.Product;
            string                   label  = item.Text;
            IProductElementViewModel model  = this.SearchInNodes(this.SourceViewModel.TopLevelNodes, target);

            if (model == null)
            {
                var element = this.SourceViewModel.TopLevelNodes[0].Data.As <IApplication>().Design.DummyCollection.As <IAbstractElement>();
                var ctx     = this.SourceViewModel.TopLevelNodes[0].Context;
                LabelElementViewModel model2 = new LabelElementViewModel(element, ctx)
                {
                    Label = label
                };
                model = model2;
            }
            else if (item is InnerPanelTitle && (item as InnerPanelTitle).ForceText)
            {
                var ctx = this.SourceViewModel.TopLevelNodes[0].Context;
                if (model.Data is IAbstractElement)
                {
                    LabelElementViewModel model2 = new LabelElementViewModel(model.Data.As <IAbstractElement>(), ctx)
                    {
                        Label = item.Text
                    };
                    model = model2;
                }
                //else
                //{
                //    LabelProductElementViewModel model2 = new LabelProductElementViewModel(model.Data.As<IProduct>(), ctx)
                //    {
                //        Label = item.Text
                //    };
                //    model = model2;
                //}
            }
            return(model);
        }
예제 #3
0
 private IProductElementViewModel GetProductNode(InnerPanelItem item)
 {
     IProductElement target = item.Product;
     string label = item.Text;
     IProductElementViewModel model = this.SearchInNodes(this.SourceViewModel.TopLevelNodes, target);
     if (model == null)
     {
         var element = this.SourceViewModel.TopLevelNodes[0].Data.As<IApplication>().Design.DummyCollection.As<IAbstractElement>();
         var ctx = this.SourceViewModel.TopLevelNodes[0].Context;
         LabelElementViewModel model2 = new LabelElementViewModel(element, ctx)
         {
             Label = label
         };
         model = model2;
     }
     else if (item is InnerPanelTitle && (item as InnerPanelTitle).ForceText)
     {
         var ctx = this.SourceViewModel.TopLevelNodes[0].Context;
         if (model.Data is IAbstractElement)
         {
             LabelElementViewModel model2 = new LabelElementViewModel(model.Data.As<IAbstractElement>(), ctx)
             {
                 Label = item.Text
             };
             model = model2;
         }
         //else
         //{
         //    LabelProductElementViewModel model2 = new LabelProductElementViewModel(model.Data.As<IProduct>(), ctx)
         //    {
         //        Label = item.Text
         //    };
         //    model = model2;
         //}
     }
     return model;
 }