/// <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; }
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); }
public CollectionContainer <T> SetUpTestFor <T>() where T : IList, new() { var container = new CollectionContainer <T>(); container.Id = 1; container.Collection = new T(); container.Collection.Add(new Person { Id = 1, Name = "Person 1" }); container.Collection.Add(new Person { Id = 2, Name = "Person 2" }); container.Collection.Add(new Person { Id = 3, Name = "Person 3" }); _cache.Add(container, TimeSpan.FromMinutes(10)); _person4 = new Person { Id = 4, Name = "Person 4" }; container.Collection.Add(_person4); _cache.Remove <Person>(p => p.Id == 3); _newPerson3 = new Person { Id = 3, Name = "Person 3.1" }; _cache.Add(_newPerson3, TimeSpan.FromMinutes(10)); return(container); }
public override void Perform() { ICollectionView collectionView = null; if (ItemsControl.ItemsSource is CompositeCollection) { CompositeCollection compositeCollection = ItemsControl.ItemsSource as CompositeCollection; if (compositeCollection != null && compositeCollection.Count > 0) { Index %= compositeCollection.Count; CollectionContainer container = (CollectionContainer)compositeCollection[Index]; if (container != null && container.Collection != null) { collectionView = CollectionViewSource.GetDefaultView(container.Collection); } } } else { collectionView = ItemsControl.Items; } if (collectionView != null) { Index %= BindingInfo.GroupDescriptionArray.Length; PropertyGroupDescription propertyGroupDescription = BindingInfo.GroupDescriptionArray[Index]; using (collectionView.DeferRefresh()) { collectionView.GroupDescriptions.Clear(); collectionView.GroupDescriptions.Add(propertyGroupDescription); } } }
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(); }
/// <summary> /// Replaces the element at the specified index. /// </summary> /// <param name="index">The zero-based index of the element to replace.</param> /// <param name="item">The new value for the element at the specified index.</param> protected override void SetItem(int index, CollectionContainer <T> item) { var items = Items[index].Collection.ToList(); base.SetItem(index, item); OnViewChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, item.Collection.ToList(), items, Items[index].Offset)); }
// Method reads in the 'container' object from the file and extracts current list data private static void InitializeCollections() { CollectionContainer c; BinaryFormatter binFormat = new BinaryFormatter(); Stream fStream = File.Open(FileName, FileMode.OpenOrCreate); try { c = (CollectionContainer)binFormat.Deserialize(fStream); } catch (Exception ex) { // If file fails to load or did not exist, create a new, empty container object Console.WriteLine("File did not exist. Will create new one: {0}", ex.Message); c = new CollectionContainer(); } finally { if (fStream != null) { fStream.Close(); } } // Extract collection data for use. If data file didn't exist collections // should be empty People = c.peopleHidden; SquadronJobs = c.jobsHidden; SquadronFlights = c.flightsHidden; //Console.WriteLine("exiting init collections method"); }
/// <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; }
private ParameterStructure.Parameter.Parameter FindParameterToSelect(string _pname) { if (string.IsNullOrEmpty(_pname)) { return(null); } if (this.parameters_for_size_transfer == null) { return(null); } foreach (object container in this.parameters_for_size_transfer) { CollectionContainer col_container = container as CollectionContainer; if (col_container != null && col_container.Collection != null) { foreach (object item in col_container.Collection) { ParameterStructure.Parameter.Parameter p = item as ParameterStructure.Parameter.Parameter; if (p == null) { continue; } if (p.Name == _pname) { return(p); } } } } return(null); }
public BlockViewModel(IWindowManager windowManager) { _windowManager = windowManager; LoadDomainBlacklist(); LoadAddressBlacklist(); var localDomainRules = new CollectionContainer { Collection = DomainBlacklist.LocalRules }; var remoteDomainRules = new CollectionContainer { Collection = DomainBlacklist.RemoteRules }; var addressRules = new CollectionContainer { Collection = AddressBlacklist.Rules }; DomainRuleCollection.Add(localDomainRules); DomainRuleCollection.Add(remoteDomainRules); AddressRuleCollection.Add(addressRules); _isWorking = false; SetPlugins(MainViewModel.Instance.Plugins); if (File.Exists(_domainBlacklistPath)) { UpdateDomainBlacklistPathInfoString(); } if (File.Exists(_addressBlacklistPath)) { UpdateAddressBlacklistPathInfoString(); } }
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); }
/// <summary> /// Replaces the element at the specified index. /// </summary> /// <param name="index">The zero-based index of the element to replace.</param> /// <param name="item">The new value for the element at the specified index.</param> /// <exception cref="System.ArgumentException">The container belongs to another collection</exception> protected override void SetItem(int index, CollectionContainer <T> item) { var oldItem = Items[index]; base.SetItem(index, item); _viewItems.ReplaceItems(oldItem.Collection, item.Collection, item.Offset); }
public static void ShouldBeABleToTellIfACollectionContainerIsAValidCollectionContainerModel() { //Arrange var collectionContainer = new CollectionContainer(new Collection(new Uri("http://example.org/friends"))); //Act //Assert Assert.IsAssignableFrom<CollectionContainer<Collection,Link,Item,Query,Template,Error,DataElement>>(collectionContainer); }
public static void ShouldBeAbleToCheckTheEqualityBetweenTheSameCollectionContainer() { //Arrange var collectionContainer = new CollectionContainer(new Collection(new Uri("http://example.org/friends"))); //Act //Assert Assert.Equal(collectionContainer, collectionContainer); }
public static void ShouldBeAbleToCreateACollectionContainerWithDefaultProperties() { //Arrange var collectionContainer = new CollectionContainer(new Collection(new Uri("http://example.org/friends"))); //Act //Assert Assert.NotNull(collectionContainer.Collection); }
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; }
public void OperationListWithTransformingTest() { var croocs = new CompositeReadOnlyObservableListSource <int>(); var viewCroocs = croocs.View; viewCroocs.CollectionChanged += ViewCroocs_CollectionChanged1; TransformingReadOnlyObservableList <int, int> trool = new TransformingReadOnlyObservableList <int, int>(viewCroocs, Selector); var observableCollection1 = new ObservableCollection <int>(new List <int>() { 0, 1, 2, 3 }); var rool1 = new ReadOnlyObservableList <int>(observableCollection1); var cc1 = new CollectionContainer <int>(rool1); croocs.Add(cc1); var observableCollection2 = new ObservableCollection <int>(new List <int>() { 4, 5, 6 }); var rool2 = new ReadOnlyObservableList <int>(observableCollection2); var cc2 = new CollectionContainer <int>(rool2); croocs.Add(cc2); var observableCollection3 = new ObservableCollection <int>(new List <int>() { 7, 8, 9 }); var rool3 = new ReadOnlyObservableList <int>(observableCollection3); var cc3 = new CollectionContainer <int>(rool3); var observableCollection4 = new ObservableCollection <int>(new List <int>() { 10, 11, 12 }); var rool4 = new ReadOnlyObservableList <int>(observableCollection4); var cc4 = new CollectionContainer <int>(rool4); croocs.RemoveAt(1); croocs.Insert(0, cc3); croocs.Add(cc4); croocs.Move(0, 2); Assert.AreEqual(trool.Count, 10); Assert.AreEqual(trool[0], 0); Assert.AreEqual(trool[1], 1); Assert.AreEqual(trool[2], 2); Assert.AreEqual(trool[3], 3); Assert.AreEqual(trool[4], 10); Assert.AreEqual(trool[5], 11); Assert.AreEqual(trool[6], 12); Assert.AreEqual(trool[7], 7); Assert.AreEqual(trool[8], 8); Assert.AreEqual(trool[9], 9); }
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); // 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.Connectors.CollectionChanged += Connectors_CollectionChanged; _model.PropertyChanged += ModelPropertyChanged; DynamoSelection.Instance.Selection.CollectionChanged += this.AlignSelectionCanExecuteChanged; // 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 = Dispatcher.CurrentDispatcher; }
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; }
public static void ShouldBeAbleToTellTwoDifferentCollectionContainers() { //Arrange var collectionContainer1 = new CollectionContainer(new Collection(new Uri("http://example.org/friends"))); var collectionContainer2 = new CollectionContainer(new Collection(new Uri("http://example.org"))); //Act //Assert Assert.NotEqual(collectionContainer1, collectionContainer2); }
public void AddItemsTest() { List <CollectionContainer <int> > cc = new List <CollectionContainer <int> >(); var observableCollection1 = new ObservableCollection <int>(new List <int>() { 1, 2, 3 }); var rool1 = new ReadOnlyObservableList <int>(observableCollection1); var cc1 = new CollectionContainer <int>(rool1); cc.Add(cc1); var observableCollection2 = new ObservableCollection <int>(new List <int>() { 7, 8, 9 }); var rool2 = new ReadOnlyObservableList <int>(observableCollection2); var cc2 = new CollectionContainer <int>(rool2); cc.Add(cc2); CompositeReadOnlyObservableCollectionSource <int> croocs = new CompositeReadOnlyObservableCollectionSource <int>(cc); observableCollection1.Add(4); observableCollection1.Add(5); observableCollection1.Add(6); var observableCollection3 = new ObservableCollection <int>(new List <int>() { 10, 11, 12 }); var rool3 = new ReadOnlyObservableList <int>(observableCollection3); var cc3 = new CollectionContainer <int>(rool3); croocs.Add(cc3); var observableCollection4 = new ObservableCollection <int>(new List <int>() { 13, 14, 15 }); var rool4 = new ReadOnlyObservableList <int>(observableCollection4); var cc4 = new CollectionContainer <int>(rool4); croocs.Add(cc4); var iterator = croocs.View; int i = 1; foreach (var v in iterator) { Assert.AreEqual(v, i); i++; } Assert.AreEqual(i, 16); }
public static void ShouldBeAbleToCheckTheEqualityBetweenTwoCollectionContainersWithTheSameValues() { //Arrange var collectionContainer1 = new CollectionContainer(new Collection(new Uri("http://example.org/friends"))); var collectionContainer2 = new CollectionContainer(new Collection(new Uri("http://example.org/friends"))); //Act //Assert Assert.Equal(collectionContainer1, collectionContainer2); }
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); } }
/// <summary> /// Inserts an item into the collection at the specified index. /// </summary> /// <param name="index">The zero-based index at which <paramref name="item" /> should be inserted.</param> /// <param name="item">The object to insert.</param> /// <exception cref="System.ArgumentException">The container belongs to another collection</exception> protected override void InsertItem(int index, CollectionContainer <T> item) { base.InsertItem(index, item); var viewIndex = item.Offset; foreach (var viewItem in item.Collection) { _viewItems.Insert(viewIndex++, viewItem); } }
/// <summary> /// Inserts an item into the collection at the specified index. /// </summary> /// <param name="index">The zero-based index at which <paramref name="item" /> should be inserted.</param> /// <param name="item">The object to insert.</param> protected override void InsertItem(int index, CollectionContainer <T> item) { if (item.Offset >= 0 || item.Index >= 0) { throw new ArgumentException("The container belongs to another collection", nameof(item)); } base.InsertItem(index, item); UpdateRange(index, Count); item.CollectionChanged += ItemOnCollectionChanged; }
static void Main() { // Block of test objects ============================================= int[] arr = { 1, 2, 3, 4 }; NameId nameId = new NameId { Id = 0, Name = "Test1" }; NameId nameId2 = new NameId { Id = 1, Name = "Test2" }; List <NameId> nameIds = new List <NameId> { nameId, nameId2 }; var container = new Container { ContainerId = 0, ContainerName = "Name", NameId = nameId }; var collectionContainer = new CollectionContainer { ContainerId = 0, ContainerName = "Name", NameId = nameId, NameIds = nameIds }; var nameNumbers = new NameIdWithNumber { Id = 1, Name = "Test2", Array = arr }; DateTime date = DateTime.Now; // currently broken, fix later DateName dateName = new DateName { Id = 0, Name = "Test1", Date = date }; // =================================================================== LeSerializer serializer = new LeSerializer(collectionContainer); Console.Write(serializer.Serialize()); Console.ReadKey(); }
private void OnAddPerson(object obj) { CollectionContainer ccItems = _oc[1] as CollectionContainer; if (ccItems != null) { ObservableCollection <Person> items = ccItems.Collection as ObservableCollection <Person>; if (items != null) { Person p = new Person("AAAA", "BBBB"); items.Add(p); } } }
/// <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; }
public MainViewModel() { AddPerson = new DelegateCommand <object>(OnAddPerson, CanAddPerson); CollectionContainer customers = new CollectionContainer(); customers.Collection = Customer.GetSampleCustomerList(); CollectionContainer persons = new CollectionContainer(); persons.Collection = Person.GetSamplePersonList(); _oc.Add(customers); _oc.Add(persons); }
public void Add(IEnumerable <ValidationResult> collection) { if (validationErrorsCollectionContainers.ContainsKey(collection)) { return; } var container = new CollectionContainer() { Collection = collection }; validationErrorsCollectionContainers.Add(collection, container); validationErrorCompositeCollection.Add(container); }
public void OperationsTest() { List <CollectionContainer <int> > cc = new List <CollectionContainer <int> >(); var observableCollection1 = new ObservableCollection <int>(new List <int>() { 1, 2, 3 }); var rool1 = new ReadOnlyObservableList <int>(observableCollection1); var cc1 = new CollectionContainer <int>(rool1); cc.Add(cc1); var observableCollection2 = new ObservableCollection <int>(new List <int>() { 5, 7, 8 }); var rool2 = new ReadOnlyObservableList <int>(observableCollection2); var cc2 = new CollectionContainer <int>(rool2); cc.Add(cc2); var croocs = new CompositeReadOnlyObservableListSource <int>(cc); //[1 2 3 5 7 8] observableCollection1.Add(4); //[1 2 3 4 5 7 8] observableCollection1.Add(8); //[1 2 3 8 4 5 7 8] observableCollection2.Insert(1, 6); //[1 2 3 8 4 5 6 7 8] observableCollection1.Remove(8); //[1 2 3 4 5 6 7 8] observableCollection1.Move(1, 3); //[1 3 4 2 5 6 7 8] var iterator = croocs.View; Assert.AreEqual(iterator.Count, 8); Assert.AreEqual(iterator[0], 1); Assert.AreEqual(iterator[1], 3); Assert.AreEqual(iterator[2], 4); Assert.AreEqual(iterator[3], 2); Assert.AreEqual(iterator[4], 5); Assert.AreEqual(iterator[5], 6); Assert.AreEqual(iterator[6], 7); Assert.AreEqual(iterator[7], 8); }
public dynWorkspaceViewModel(dynWorkspaceModel model, DynamoViewModel vm) { _model = model; 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); //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; HideCommand = new DelegateCommand <object>(Hide, CanHide); CrossSelectCommand = new DelegateCommand <object>(CrossingSelect, CanCrossSelect); ContainSelectCommand = new DelegateCommand <object>(ContainSelect, CanContainSelect); SetCurrentOffsetCommand = new DelegateCommand <object>(SetCurrentOffset, CanSetCurrentOffset); NodeFromSelectionCommand = new DelegateCommand(CreateNodeFromSelection, CanCreateNodeFromSelection); SetZoomCommand = new DelegateCommand <object>(SetZoom, CanSetZoom); FindByIdCommand = new DelegateCommand <object>(FindById, CanFindById); AlignSelectedCommand = new DelegateCommand <string>(AlignSelected, CanAlignSelected); SelectAllCommand = new DelegateCommand(SelectAll, CanSelectAll); FindNodesFromSelectionCommand = new DelegateCommand(FindNodesFromSelection, CanFindNodesFromSelection); DynamoSelection.Instance.Selection.CollectionChanged += NodeFromSelectionCanExecuteChanged; // 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)); }
public InjectionPageViewModel() { Command1 = new Command <Injection>(ExecuteCommand1); Command2 = new Command(ExecuteCommand2); CollectionContainer injectionsCollection = new CollectionContainer() { Collection = InjectionsManager.injections }; CompositeCollection.Add(injectionsCollection); CompositeCollection.Add(new AddNewButton()); CompositeCollection.Add(new Legend()); CompositeCollection.Add(new PETMRBorder()); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var node = value as Node; CompositeCollection collection = new CompositeCollection(); CollectionContainer container = new CollectionContainer(); container.Collection = node.Child; collection.Add(container); container = new CollectionContainer(); container.Collection = node.Attributes; collection.Add(container); return(collection); }
public MainWindowViewModel() { _profileManager.ChangedProfilesEvent += UpdateDisplaySettings; _appUpdater.UserRequestsInstallEvent += NumberOfRunningCopies; _settingsViewModel.PropertyChanged += SettingsHaveChanged; _profileManagerViewModel = new ProfileManagerViewModel(_profileManager); foreach (Profile p in _profileManager.Profiles) { FolderManagerViewModel var = new FolderManagerViewModel(p); FolderManagerViewModels.Add(var); CollectionContainer cc = new CollectionContainer(); cc.Collection = var.Assigned; this.Assigned.Add(cc); } }
public void SetProperty_CollectionProperty_UpdatesModel( string propertyName, Func<object, object> propertyAccessor, object collection) { // Arrange var model = new CollectionContainer(); var type = model.GetType(); var bindingContext = CreateContext(GetMetadataForType(type), model); var modelState = bindingContext.ModelState; var metadataProvider = bindingContext.OperationBindingContext.MetadataProvider; var modelExplorer = metadataProvider.GetModelExplorerForType(type, model); var propertyMetadata = bindingContext.ModelMetadata.Properties[propertyName]; var result = new ModelBindingResult(model: collection, isModelSet: true, key: propertyName); var testableBinder = new TestableMutableObjectModelBinder(); // Act testableBinder.SetProperty(bindingContext, modelExplorer, propertyMetadata, result); // Assert Assert.Equal(collection, propertyAccessor(model)); Assert.True(modelState.IsValid); Assert.Empty(modelState); }
public static void ShouldBeAbleToSerializeACompleteCollectionContainerObject() { //Arrange var collectionContainer = new CollectionContainer(new Collection(new Uri("http://localhost:8080/api"))); var expectedAnswer = "{\"collection\":{\"version\":\"1.0\",\"href\":\"http://localhost:8080/api\"}}"; //Act var realAnswer = JsonConvert.SerializeObject(collectionContainer); //Assert Assert.Equal(expectedAnswer, realAnswer); }
public void SetProperty_ReadOnlyProperty_IsNoOp() { // Arrange var model = new CollectionContainer(); var originalCollection = model.ReadOnlyList; var modelMetadata = GetMetadataForType(model.GetType()); var propertyMetadata = GetMetadataForProperty(model.GetType(), nameof(CollectionContainer.ReadOnlyList)); var bindingContext = CreateContext(modelMetadata, model); var result = ModelBindingResult.Success(new List<string>() { "hi" }); var binder = CreateBinder(bindingContext.ModelMetadata); // Act binder.SetPropertyPublic(bindingContext, propertyMetadata.PropertyName, propertyMetadata, result); // Assert Assert.Same(originalCollection, model.ReadOnlyList); Assert.Empty(model.ReadOnlyList); }