Example #1
0
        /// <summary>
        /// Invoked when the effective property value of the Source property changes.
        /// </summary>
        /// <param name="dependencyObject">The DependencyObject on which the property has changed value.</param>
        /// <param name="dependencyPropertyChangedEventArgs">Event data that is issued by any event that tracks changes to the effective value of this property.
        /// </param>
        private static void OnSourcePropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            // This will disable the navigation when the source URI is changed retroactively to the page navigation.  That is, when the journal, forward button,
            // backward button change the current page, the source URI is set after the fact in order to reflect the location of the selected page.  Conversly,
            // when a breadcrumb control or tree view changes the source URI, that should be taken as an instruction to navigate to the selected page.
            ViewPage viewPage  = dependencyObject as ViewPage;
            Uri      newSource = dependencyPropertyChangedEventArgs.NewValue as Uri;

            // When the source URI has changed we need a new data context for the new source URI.  This effectively chooses the items that appear in any one of the
            // views provided by this class by selecting the IExplorerItem as the data context for the page.
            if (newSource != null)
            {
                IExplorerItem rootItem      = viewPage.DataContext as IExplorerItem;
                IExplorerItem iExplorerItem = ExplorerHelper.FindExplorerItem(rootItem, newSource);
                if (iExplorerItem != null)
                {
                    IExplorerItem       parentItem         = iExplorerItem;
                    CompositeCollection compositCollection = new CompositeCollection();
                    compositCollection.Add(new CollectionContainer()
                    {
                        Collection = parentItem as IEnumerable
                    });
                    compositCollection.Add(new CollectionContainer()
                    {
                        Collection = parentItem.Leaves
                    });
                    viewPage.listBoxView.ItemsSource = compositCollection;
                }
            }
        }
        public GameViewModel(Core.Game game, IDialogService dialogService, bool isPlayingAutomatically)
        {
            _game                      = game;
            _dialogService             = dialogService;
            UndoCommand                = new ActionCommand(DoUndo, CanUndo);
            RedoCommand                = new ActionCommand(DoRedo, CanRedo);
            CurrentHistoryPosition     = 0;
            RobotThinkingTime          = 5;
            _isPlayingAutomatically    = isPlayingAutomatically;
            _emptyCellsPlayerViewModel = new EmptyCellsPlayerViewModel(_game.EmptyCellsAsPlayer);
            _playerOne                 = new HumanPlayerViewModel(_game.MainPlayer, _emptyCellsPlayerViewModel.PlayerPositions.ToList());
            _playerTwo                 = new RobotPlayerViewModel(_game.RobotPlayer, _emptyCellsPlayerViewModel.PlayerPositions.ToList());

            var playerOneCollectionContainer = new CollectionContainer {
                Collection = _playerOne.PlayerPositions
            };
            var playerTwoCollectionContainer = new CollectionContainer {
                Collection = _playerTwo.PlayerPositions
            };
            var emptyCollectionContainer = new CollectionContainer {
                Collection = _emptyCellsPlayerViewModel.PlayerPositions
            };

            _positions.Add(playerOneCollectionContainer);
            _positions.Add(playerTwoCollectionContainer);
            _positions.Add(emptyCollectionContainer);

            WaitMove();
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the DetailBar class.
        /// </summary>
        public DetailBar()
        {
            // The data context drives the information that is presented in this control.
            this.DataContextChanged += new DependencyPropertyChangedEventHandler(OnDataContextChanged);

            // When the size of the frame changes we need to adjust the settings on the grid to make sure that everything important stays visible.
            this.SizeChanged += new SizeChangedEventHandler(this.OnSizeChanged);

            // This is the collection of items that appear in the metadata area.
            this.items = new ViewableCollection();

            // The actual detail area is composed of two collections.  One is basically a 'system' area where metadata common to all objects is displayed, such as
            // the name of the element and the element's type.  The second part is filled in with data provided by the consumer of the DetailBar.  In most
            // scenarios, this is the ExplorerFrame window which, in turn is fed metadata by an embedded page.  However, the DetailBar doesn't want to make a
            // distinction between the two lists when presenting the information in the WrapPanel: both collections are aggregated and treated as a single list.
            CompositeCollection compositCollection = new CompositeCollection();

            compositCollection.Add(new CollectionContainer()
            {
                Collection = this.commonMetadata
            });
            compositCollection.Add(new CollectionContainer()
            {
                Collection = this.items
            });
            base.ItemsSource = compositCollection;
        }
        private void PopulateComboboxBarang()
        {
            _itemRepo = new ItemServices();
            var Data = AutoMapper.Mapper.Map <List <MasterItemDto> >(_itemRepo.GetAll().Where(x => x.STATUS == Status.Aktif));

            _dataBarang = CollectionViewSource.GetDefaultView(Data);

            _dataBarang.Filter = new Predicate <object>(FilterCandidates);

            var TransportCompositeCollection = new CompositeCollection();

            TransportCompositeCollection.Add(new ComboBoxItem()
            {
                Content = "Please Select"
            });
            TransportCompositeCollection.Add(new CollectionContainer()
            {
                Collection = _dataBarang
            });

            NamaBarang.ItemsSource = TransportCompositeCollection;

            filters.Clear();
            if (_dataBarang != null)
            {
                AddFilterAndRefresh("JENIS_BARANG", candidate => (JenisBarang.SelectedItem.GetType() == typeof(ItemType) && candidate.JENIS_BARANG == (ItemType)JenisBarang.SelectedItem));
            }
            //NamaBarang.SelectedValuePath = "ID";
            //NamaBarang.DisplayMemberPath = "NAMA_BARANG";
            NamaBarang.SelectedIndex = 0;
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            CompositeCollection collection = new CompositeCollection();

            foreach (var item in values)
            {
                if (item == null)
                {
                    continue;
                }

                if (item is IEnumerable)
                {
                    collection.Add(new CollectionContainer()
                    {
                        Collection = item as IEnumerable
                    });
                }
                else
                {
                    collection.Add(item);
                }
            }

            return(collection);
        }
Example #6
0
        /// <summary>
        /// Конструктор MainWindowVM
        /// </summary>
        public MainWindowVM()
        {
            RectangulationCommand = new RectangulationCommand();
            ClearCommand          = new ClearCommand();
            LeftClickCommand      = new LeftClickCommand();
            RightClickCommand     = new RightClickCommand();

            Shapes     = new CompositeCollection();
            Polygons   = new ObservableCollection <PolygonVM>();
            Rectangles = new ObservableCollection <RectangleVM>();

            var polygonContainer = new CollectionContainer {
                Collection = Polygons
            };

            Shapes.Add(polygonContainer);

            var rectangleContainer = new CollectionContainer {
                Collection = Rectangles
            };

            Shapes.Add(rectangleContainer);

            CurrentPolygon      = null;
            RectWidth           = 20;
            RectHeight          = 20;
            SelectedRectangleVM = null;
        }
        /// <summary>
        /// 文件列表上下文菜单
        /// </summary>
        /// <param name="fileDataGridItem"></param>
        void FileDataContextMenu(FileDataGridItem fileDataGridItem)
        {
            ContextMenu         contextMenu         = new ContextMenu();
            CompositeCollection contextMenuBase     = new CompositeCollection();
            CompositeCollection compositeCollection = new CompositeCollection();
            CollectionContainer collectionContainer = new CollectionContainer();

            MenuItem cmOpen = new MenuItem();

            cmOpen.Header = "打开";
            cmOpen.Click += (sender, e) => CMOpen_Click(fileDataGridItem);
            if ((string)fileDataGridItem.panFile["isdir"] != "1")
            {
                cmOpen.IsEnabled = false;
            }

            MenuItem cmDownload = new MenuItem();

            cmDownload.Header = "下载";
            cmDownload.Click += (misender, mie) => CMDownload_Click(fileDataGridItem);

            contextMenuBase.Add(cmOpen);
            contextMenuBase.Add(cmDownload);
            //contextMenuBase.Add(new Separator());
            collectionContainer.Collection = contextMenuBase;
            compositeCollection.Add(collectionContainer);
            contextMenu.ItemsSource = compositeCollection;
            contextMenu.IsOpen      = true;
        }
Example #8
0
        public static CompositeCollection Construct(IEnumerable <MenuElement> input)
        {
            var result = new CompositeCollection();

            foreach (var i in input)
            {
                if (i is MenuCommand menuCommand)
                {
                    result.Add(Construct(menuCommand));
                }

                if (i is MenuEnum menuEnum)
                {
                    foreach (Enum field in menuEnum.Type.GetEnumValues())
                    {
                        result.Add(Construct(new MenuEnumField($"{field}")));
                    }
                }

                if (i is MenuLine menuSeparator)
                {
                    var separator = new Separator();
                    SeparatorExtensions.SetHeader(separator, menuSeparator.Name);
                    result.Add(separator);
                }
            }
            return(result);
        }
 private void AddTransaction(CompositeCollection cc, string filterText)
 {
     try
     {
         using (var ctx = new RMSModel())
         {
             // right now any prescriptions
             foreach (
                 var trns in
                 ctx.TransactionBase.OfType <Prescription>()
                 .Where(x => x.TransactionNumber.Contains(filterText))
                 .OrderBy(t => t.Time)
                 .Take(100))
             {
                 cc.Add(trns);
             }
         }
         using (var ctx = new RMSModel())
         {
             foreach (
                 var trns in
                 ctx.TransactionBase.OfType <QuickPrescription>()
                 .Where(x => x.TransactionNumber.Contains(filterText))
                 .OrderBy(t => t.Time)
                 .Take(100))
             {
                 cc.Add(trns);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #10
0
        private void AddInventory(CompositeCollection cc)
        {
            switch (ApplicationMode)
            {
            case ApplicationMode.Ticket:
                foreach (var itm in rms.Item.OfType <TicketItem>())
                {
                    cc.Add(itm);
                }
                break;

            case ApplicationMode.Pharmacy:
                foreach (var itm in rms.Item.OfType <Medicine>())
                {
                    cc.Add(itm);
                }

                foreach (var itm in rms.Item.OfType <StockItem>())
                {
                    cc.Add(itm);
                }
                break;

            case ApplicationMode.POS:
                foreach (var itm in rms.Item.OfType <StockItem>())
                {
                    cc.Add(itm);
                }
                break;

            default:
                break;
            }
        }
Example #11
0
        public ParallaxBackgroundViewModel(
            ChildCOViewModel parentVm,
            MainViewModel mainVm,
            ParallaxBackgroundPropertiesViewModel pbpvm)
        {
            _parentCompoundObjectVm = parentVm;
            _mainVm             = mainVm;
            _parentBackgroundVm = pbpvm;

            _shapes = new CompositeCollection()
            {
                new CollectionContainer {
                    Collection = new ObservableCollection <LfSpriteBoxViewModel>()
                },
                new CollectionContainer {
                    Collection = new ObservableCollection <LfSpritePolygonViewModel>()
                },
            };

            foreach (Object o in parentVm.ShapeCollection.Shapes)
            {
                if (o is LfSpriteBoxViewModel)
                {
                    LfSpriteBoxViewModel svm = o as LfSpriteBoxViewModel;
                    _shapes.Add(svm);
                }
                else if (o is LfSpritePolygonViewModel)
                {
                    LfSpritePolygonViewModel svm = o as LfSpritePolygonViewModel;
                    _shapes.Add(svm);
                }
            }
        }
Example #12
0
				protected void Adapt()
				{
					if (CollectionView != null)
					{
						CollectionView.CurrentChanged -= CollectionView_CurrentChanged;
						CollectionView = null;
					}
					if (ComboBox != null && ItemsSource != null)
					{
						CompositeCollection comp = new CompositeCollection();
						//If AllowNull == true, add a "NullItem" as the first item in the ComboBox.
						if (AllowNull)
						{
							comp.Add(NullItem);
						}
						//Now Add the ItemsSource.
						comp.Add(new CollectionContainer{Collection = ItemsSource});
						//Lastly, If Selected item is not null and does not already exist in the ItemsSource,
						//Add it as the last item in the ComboBox
						if (SelectedItem != null)
						{
							List<object> items = ItemsSource.Cast<object>().ToList();
							if (!items.Contains(SelectedItem))
							{
								comp.Add(SelectedItem);
							}
						}
						CollectionView = CollectionViewSource.GetDefaultView(comp);
						if (CollectionView != null)
						{
							CollectionView.CurrentChanged += CollectionView_CurrentChanged;
						}
						ComboBox.ItemsSource = comp
					}
				}
        private CompositeCollection AddSearchItems()
        {
            CompositeCollection cc = new CompositeCollection();
            //SearchItem b = new SearchItem();
            //b.SearchObject = new RMSDataAccessLayer.Transactionlist();
            //b.SearchCriteria = "Transaction History";
            //b.DisplayName = "Transaction History";
            //cc.Add(b);

            SearchItem p = new SearchItem();

            p.SearchObject   = null;
            p.SearchCriteria = "Add Patient";
            p.DisplayName    = "Add Patient";
            cc.Add(p);

            SearchItem d = new SearchItem();

            d.SearchObject   = null;
            d.SearchCriteria = "Add Doctor";
            d.DisplayName    = "Add Doctor";
            cc.Add(d);


            return(cc);
        }
    public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        MyControl mc = value as MyControl;

        if (mc != null)
        {
            CompositeCollection cc = new CompositeCollection();

            CollectionContainer container1 = new CollectionContainer();
            BindingOperations.SetBinding(container1, CollectionContainer.CollectionProperty,
                                         new Binding()
            {
                Source = mc,
                Path   = new PropertyPath("InstanceItems")
            });
            cc.Add(container1);

            CollectionContainer container2 = new CollectionContainer()
            {
                Collection = mc.FindResource("Static_CloudItems") as Array
            };

            cc.Add(container2);

            return(cc);
        }
        return(null);
    }
        /// <summary>
        /// This constructor supports the configuration design-time and is not intended to be used directly from your code.
        /// </summary>
        public ElementLookup(ConfigurationSourceDependency sourceModelDependency)
        {
            this.sourceModelDependency          = sourceModelDependency;
            this.sourceModelDependency.Cleared += new EventHandler(sourceModelDependency_Refresh);

            innerCollection = new CompositeCollection();
            innerCollection.Add(new CollectionContainer {
                Collection = sections
            });
            innerCollection.Add(new CollectionContainer {
                Collection = customElementViewModels
            });

            var view = ((ICollectionViewFactory)innerCollection).CreateView();

            innerCollectionChanged = view;

            allElements = view.OfType <ElementViewModel>();

            innerCollectionChanged.CollectionChanged += (sender, args) =>
            {
                if (!refreshing)
                {
                    if (args.Action == NotifyCollectionChangedAction.Reset)
                    {
                        return;
                    }
                    OnCollectionChanged(args);
                }
            };
        }
Example #16
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var sourceClass = value as TagClass;

            if (sourceClass == null)
            {
                return(null);
            }

            //hax 2 tha max
            var nullTag = new TagEntry(null, null, "(null)");

            var tagList = new CompositeCollection();

            tagList.Add(nullTag);

            var mainTagListContainer = new CollectionContainer();

            mainTagListContainer.Collection = sourceClass.Children;

            tagList.Add(mainTagListContainer);


            return(tagList);
        }
Example #17
0
        private void AddCustomers(CompositeCollection cc)
        {
            switch (ApplicationMode)
            {
            case ApplicationMode.Ticket:
                break;

            case ApplicationMode.Pharmacy:
                foreach (var cus in rms.Persons.OfType <Patient>())
                {
                    cc.Add(cus);
                }

                foreach (var cus in rms.Persons.OfType <Doctor>())
                {
                    cc.Add(cus);
                }
                break;

            case ApplicationMode.POS:
                foreach (var cus in rms.Persons.OfType <Customers>())
                {
                    cc.Add(cus);
                }
                break;

            default:
                break;
            }
        }
Example #18
0
        public RoutineBuilder(Routine routine)
        {
            //View initialization
            InitializeComponent();
            LivePreview = false;
            //Initialize Routine
            _routine = routine;
            _routine.RoutineBuilder = this;
            tbxRoutineName.Text     = _routine.Name;
            this.Title = _routine.Name;
            //Build Canvas toolbar - drawing shapes icons
            toolbarButtons = new List <ToggleButton>();
            toolbarButtons.Add(btnToolbarMove);
            toolbarButtons.Add(btnToolbarArc);
            toolbarButtons.Add(btnToolbarCircle);
            toolbarButtons.Add(btnToolbarDot);
            toolbarButtons.Add(btnToolbarLine);
            toolbarButtons.Add(btnToolbarPolyline);
            toolbarButtons.Add(btnToolbarRectangle);
            toolbarButtons.Add(btnToolbarReferencePoint);
            toolbarButtons.Add(btnToolbarAttrPoint);
            _activeTool           = null;
            _drawing              = false;
            _movingShape          = false;
            _movingReferencePoint = false;
            _movingAttributePoint = false;
            _makingPath           = false;
            _makingPathStep2      = false;
            attributePointPopup   = new AttributePointPopup();
            //Build "Add Fixture" popup
            addFixturePop = new AddFixturePopup();
            addFixturePop.AddSelectedClick += new RoutedEventHandler(SubroutineBuilder_AddSelectedClick);

            //Initialize Timeline
            CollectionContainer items = new CollectionContainer();

            items.Collection = _routine.RoutineFixtures;
            CollectionContainer  newFixtureLineCollection = new CollectionContainer();
            BindingList <string> newFixtureLine           = new BindingList <string>();

            newFixtureLine.Add("Click here to add a fixture...");
            newFixtureLineCollection.Collection = newFixtureLine;

            CompositeCollection cmpc = new CompositeCollection();

            cmpc.Add(items);
            cmpc.Add(newFixtureLineCollection);

            lbxTimeline.ItemsSource = cmpc;
            //lbxTimeline.ItemsSource = _routine.RoutineFixtures;
            _lastSelectedFixture = null;

            //Step items list. necessary?
            lbxSteps.ItemsSource = null;

            //Reference Point list.
            lbxReferencePoints.ItemsSource = null;
        }
Example #19
0
        public WorkspaceViewModel(WorkspaceModel model, DynamoViewModel dynamoViewModel)
        {
            this.DynamoViewModel = dynamoViewModel;
            Model = model;
            stateMachine = new StateMachine(this);

            var nodesColl = new CollectionContainer { Collection = Nodes };
            _workspaceElements.Add(nodesColl);

            var connColl = new CollectionContainer { Collection = Connectors };
            _workspaceElements.Add(connColl);

            var notesColl = new CollectionContainer { Collection = Notes };
            _workspaceElements.Add(notesColl);

            var errorsColl = new CollectionContainer { Collection = Errors };
            _workspaceElements.Add(errorsColl);

            var annotationsColl = new CollectionContainer {Collection = Annotations};
            _workspaceElements.Add(annotationsColl);

            //respond to collection changes on the model by creating new view models
            //currently, view models are added for notes and nodes
            //connector view models are added during connection

            Model.NodeAdded += Model_NodeAdded;
            Model.NodeRemoved += Model_NodeRemoved;
            Model.NodesCleared += Model_NodesCleared;

            Model.NoteAdded += Model_NoteAdded;
            Model.NoteRemoved += Model_NoteRemoved;
            Model.NotesCleared += Model_NotesCleared;

            Model.AnnotationAdded += Model_AnnotationAdded;
            Model.AnnotationRemoved += Model_AnnotationRemoved;
            Model.AnnotationsCleared += Model_AnnotationsCleared;

            Model.ConnectorAdded += Connectors_ConnectorAdded;
            Model.ConnectorDeleted += Connectors_ConnectorDeleted;
            Model.PropertyChanged += ModelPropertyChanged;
            Model.PopulateJSONWorkspace += Model_PopulateJSONWorkspace;
            
            DynamoSelection.Instance.Selection.CollectionChanged += RefreshViewOnSelectionChange;

            DynamoViewModel.CopyCommand.CanExecuteChanged += CopyPasteChanged;
            DynamoViewModel.PasteCommand.CanExecuteChanged += CopyPasteChanged;

            // sync collections

            foreach (NodeModel node in Model.Nodes) Model_NodeAdded(node);
            foreach (NoteModel note in Model.Notes) Model_NoteAdded(note);
            foreach (AnnotationModel annotation in Model.Annotations) Model_AnnotationAdded(annotation);
            foreach (ConnectorModel connector in Model.Connectors) Connectors_ConnectorAdded(connector);

            InCanvasSearchViewModel = new SearchViewModel(DynamoViewModel);
            InCanvasSearchViewModel.Visible = true;
        }
Example #20
0
 public HeaderFooterWrapPanel()
 {
     InitializeComponent();
     _container.Collection = ItemsSource;
     _composedCollection.Add(Header);
     _composedCollection.Add(_container);
     _composedCollection.Add(Footer);
     wrapPanel1.ItemsSource = _composedCollection;
 }
Example #21
0
        public void TestCompositeCollectionEmptyConstructor()
        {
            CompositeCollection <int> comp = new CompositeCollection <int>();

            comp.Add(1);
            comp.Add(2);
            Assert.Equal(comp.Count, 2);
            comp.AddAll(Enumerable.Range(3, 5).ToList());
            Assert.Equal(comp.Count, 7);
        }
Example #22
0
        public WorkspaceViewModel(WorkspaceModel model, DynamoViewModel dynamoViewModel)
        {
            this.DynamoViewModel = dynamoViewModel;

            Model        = model;
            stateMachine = new StateMachine(this);

            var nodesColl = new CollectionContainer {
                Collection = Nodes
            };

            _workspaceElements.Add(nodesColl);

            var connColl = new CollectionContainer {
                Collection = Connectors
            };

            _workspaceElements.Add(connColl);

            var notesColl = new CollectionContainer {
                Collection = Notes
            };

            _workspaceElements.Add(notesColl);

            var errorsColl = new CollectionContainer {
                Collection = Errors
            };

            _workspaceElements.Add(errorsColl);

            // Add EndlessGrid
            var endlessGrid = new EndlessGridViewModel(this);

            _workspaceElements.Add(endlessGrid);

            //respond to collection changes on the model by creating new view models
            //currently, view models are added for notes and nodes
            //connector view models are added during connection
            Model.Nodes.CollectionChanged += Nodes_CollectionChanged;
            Model.Notes.CollectionChanged += Notes_CollectionChanged;
            Model.ConnectorAdded          += Connectors_ConnectorAdded;
            Model.ConnectorDeleted        += Connectors_ConnectorDeleted;
            Model.PropertyChanged         += ModelPropertyChanged;

            DynamoSelection.Instance.Selection.CollectionChanged += this.AlignSelectionCanExecuteChanged;

            // sync collections
            Nodes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Model.Nodes));
            Notes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Model.Notes));
            foreach (var c in Model.Connectors)
            {
                Connectors_ConnectorAdded(c);
            }
        }
Example #23
0
 public AssemblyTypeData(string name, BaseDataContainer dir) : base(name, dir)
 {
     nestedTypes = new List <AssemblyTypeData>();
     methods     = new List <AssemblyMethodData>();
     children    = new CompositeCollection();
     children.Add(new CollectionContainer {
         Collection = nestedTypes
     });
     children.Add(new CollectionContainer {
         Collection = methods
     });
 }
 // Constructor
 public MainViewModel(ObservableCollection <Id> ids)
 {
     ViewIds = new CompositeCollection();
     ViewIds.Add(new CollectionContainer {
         Collection = Empty
     });
     ViewIds.Add(new CollectionContainer {
         Collection = Ids = ids
     });
     // Whenever something changes in Ids, Update the collections
     CollectionChangedEventManager.AddHandler(Ids, delegate { UpdateEmptyCollection(); });
     UpdateEmptyCollection();     // First time
 }
        /// <summary>
        /// </summary>
        /// <param name="values"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            /*  List<object> items = new List<object>();
             *
             * for (int i = 0; i < values.Length; i++)
             * {
             *  if (values[i].GetType() == typeof (ObservableCollection<ViewModels.ExportGroupVm>) ||
             *      values[i].GetType() == typeof(ObservableCollection<ViewModels.ExportVm>))
             *  {
             *      IEnumerable childs = values[i] as IEnumerable ?? new List<object> { values[i] };
             *
             *      foreach (var child in childs)
             *          { items.Add(child); }
             *  }
             * }
             *
             *
             * // CompositeCollection compositeCollection = new CompositeCollection();
             *
             *
             *
             * return items;*/

            var result = new CompositeCollection();

            for (var i = 0; i < values.Length; i++)
            {
                if (values[i].GetType() == typeof(ViewModelVirtualizingIoCObservableCollection <ExportGroupVm, ExportGroup>))
                {
                    var nc = new ExportsCollectionContainer
                    {
                        Collection = (ViewModelVirtualizingIoCObservableCollection <ExportGroupVm, ExportGroup>)values[i],
                        IsGroup    = true
                    };
                    result.Add(nc);
                }
                else if (values[i].GetType() == typeof(ViewModelVirtualizingIoCObservableCollection <ExportVm, SnooperExportBase>))
                {
                    var nc = new ExportsCollectionContainer
                    {
                        Collection = (ViewModelVirtualizingIoCObservableCollection <ExportVm, SnooperExportBase>)values[i],
                        IsResult   = true
                    };
                    result.Add(nc);
                }
            }


            return(result);
        }
Example #26
0
        public WorkspaceViewModel(WorkspaceModel model, DynamoViewModel vm)
        {
            _model       = model;
            stateMachine = new StateMachine(this);

            //setup the composite collection
            var previewsColl = new CollectionContainer {
                Collection = Previews
            };

            _workspaceElements.Add(previewsColl);

            var nodesColl = new CollectionContainer {
                Collection = Nodes
            };

            _workspaceElements.Add(nodesColl);

            var connColl = new CollectionContainer {
                Collection = Connectors
            };

            _workspaceElements.Add(connColl);

            var notesColl = new CollectionContainer {
                Collection = Notes
            };

            _workspaceElements.Add(notesColl);

            var errorsColl = new CollectionContainer {
                Collection = Errors
            };

            _workspaceElements.Add(errorsColl);

            //respond to collection changes on the model by creating new view models
            //currently, view models are added for notes and nodes
            //connector view models are added during connection
            _model.Nodes.CollectionChanged      += Nodes_CollectionChanged;
            _model.Notes.CollectionChanged      += Notes_CollectionChanged;
            _model.Connectors.CollectionChanged += Connectors_CollectionChanged;
            _model.PropertyChanged += ModelPropertyChanged;

            // sync collections
            Nodes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _model.Nodes));
            Connectors_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _model.Connectors));
            Notes_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _model.Notes));
            Dispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
        }
Example #27
0
        /// <summary>
        /// This method is called when the dependency graph service created the dependency graph.
        /// </summary>
        /// <param name="ar">The async result.</param>
        private void OnGetDependencyGraphCompleted(IAsyncResult ar)
        {
            var dispatcher = Application.Current.Dispatcher;

            if (!dispatcher.CheckAccess())
            {
                dispatcher.BeginInvoke(new Action <IAsyncResult>(OnGetDependencyGraphCompleted), ar);
                return;
            }

            bool onLoad = (bool)ar.AsyncState;

            try
            {
                Graph = DependencyGraphService.EndGetDependencyGraph(ar);

                if (Graph == null)
                {
                    RefreshHint = onLoad ? "Effective dependencies and identified anomalies are not resolved (Graph could not be created)" : "Effective dependencies and identified anomalies are not resolved (Graph could not be refreshed)";
                    return;
                }
            }
            catch (InvalidComponentException)
            {
                RefreshHint = onLoad ? "Effective dependencies and identified anomalies are not resolved (Graph could not be created)" : "Effective dependencies and identified anomalies are not resolved (Graph could not be refreshed)";
                return;
            }
            catch (DependencyServiceException)
            {
                RefreshHint = onLoad ? "Effective dependencies and identified anomalies are not resolved (Graph could not be created)" : "Effective dependencies and identified anomalies are not resolved (Graph could not be refreshed)";
                return;
            }

            var anomalies = new CompositeCollection();

            if (Graph.CircularDependencies.Any())
            {
                var collectionContainer = new CollectionContainer();
                collectionContainer.Collection = Graph.CircularDependencies;
                anomalies.Add(collectionContainer);
            }
            if (Graph.SideBySideDependencies.Any())
            {
                var collectionContainer = new CollectionContainer();
                collectionContainer.Collection = Graph.SideBySideDependencies;
                anomalies.Add(collectionContainer);
            }
            Anomalies = anomalies;
        }
Example #28
0
        private void NotifyIconList_OnLoaded(object sender, RoutedEventArgs e)
        {
            if (!_isLoaded && NotificationArea != null)
            {
                CompositeCollection allNotifyIcons = new CompositeCollection();
                allNotifyIcons.Add(new CollectionContainer {
                    Collection = NotificationArea.UnpinnedIcons
                });
                allNotifyIcons.Add(new CollectionContainer {
                    Collection = NotificationArea.PinnedIcons
                });
                allNotifyIconsSource = new CollectionViewSource {
                    Source = allNotifyIcons
                };

                CompositeCollection pinnedNotifyIcons = new CompositeCollection();
                pinnedNotifyIcons.Add(new CollectionContainer {
                    Collection = promotedIcons
                });
                pinnedNotifyIcons.Add(new CollectionContainer {
                    Collection = NotificationArea.PinnedIcons
                });
                pinnedNotifyIconsSource = new CollectionViewSource {
                    Source = pinnedNotifyIcons
                };

                NotificationArea.UnpinnedIcons.CollectionChanged += UnpinnedIcons_CollectionChanged;
                NotificationArea.NotificationBalloonShown        += NotificationArea_NotificationBalloonShown;

                Settings.Instance.PropertyChanged += Settings_PropertyChanged;

                if (Settings.Instance.CollapseNotifyIcons)
                {
                    NotifyIcons.ItemsSource = pinnedNotifyIconsSource.View;
                    SetToggleVisibility();

                    if (NotifyIconToggleButton.IsChecked == true)
                    {
                        NotifyIconToggleButton.IsChecked = false;
                    }
                }
                else
                {
                    NotifyIcons.ItemsSource = allNotifyIconsSource.View;
                }

                _isLoaded = true;
            }
        }
Example #29
0
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        var input = value as Milestone;
        CompositeCollection collection = new CompositeCollection();

        collection.Add(new CollectionContainer()
        {
            Collection = input.SubMilestones
        });
        collection.Add(new CollectionContainer()
        {
            Collection = input.Activities
        });
        return(collection);
    }
Example #30
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            TreeFolderInfo      input      = value as TreeFolderInfo;
            CompositeCollection collection = new CompositeCollection();

            collection.Add(new CollectionContainer()
            {
                Collection = input.Folders
            });
            collection.Add(new CollectionContainer()
            {
                Collection = input.Files
            });
            return(collection);
        }