Exemplo n.º 1
0
        private void UpdateMonitor(RoutedEventArgs routedPropertyChangedEventArgs)
        {
            if (PositionMonitor == null)
            {
                return;
            }

            var dragablzItem = (DragablzItem)routedPropertyChangedEventArgs.OriginalSource;

            if (!Equals(ItemsControlFromItemContainer(dragablzItem), this))
            {
                return;
            }

            PositionMonitor.OnLocationChanged(new LocationChangedEventArgs(dragablzItem.Content, new Point(dragablzItem.X, dragablzItem.Y)));

            if (!(PositionMonitor is StackPositionMonitor linearPositionMonitor))
            {
                return;
            }

            var sortedItems = linearPositionMonitor.Sort(this.Containers <DragablzItem> ( )).Select(di => di.Content).ToArray( );

            if (_previousSortQueryResult?.SequenceEqual(sortedItems) != true)
            {
                linearPositionMonitor.OnOrderChanged(new OrderChangedEventArgs(_previousSortQueryResult, sortedItems));
            }

            _previousSortQueryResult = sortedItems;
        }
Exemplo n.º 2
0
        public BasicExampleMainModel()
        {
            _basicColourMonitor = new PositionMonitor();
            _basicColourMonitor.LocationChanged += (sender, args) => BasicColourMonitorText = args.Location.ToString();
            _peopleMonitor = new VerticalPositionMonitor();
            _peopleMonitor.OrderChanged += PeopleMonitorOnOrderChanged;

            _people.Add(new Person {FirstName = "Albert", LastName = "Einstein"});
            _people.Add(new Person { FirstName = "Neil", LastName = "Tyson" });
            _people.Add(new Person { FirstName = "James", LastName = "Willock" }); //i move in esteemed circles ;)

            _viewModels.Add(new SimpleViewModel { Name = "Alpha", SimpleContent = "This is the alpha content"});
            _viewModels.Add(new SimpleViewModel { Name = "Beta", SimpleContent = "Beta content", IsSelected = true });
            _viewModels.Add(new SimpleViewModel { Name = "Gamma", SimpleContent = "And here is the gamma content" });

            SelectedViewModel = _viewModels[1];

            _interTabClient = new BasicExampleInterTabClient();

            _addNewPerson = new AnotherCommandImplementation(
                x =>
                {
                    _newPersonCount++;
                    _people.Add(new Person
                    {
                        FirstName = "Hello_" + _newPersonCount,
                        LastName = "World_" + _newPersonCount
                    });
                });

            _addNewViewModel = new AnotherCommandImplementation(
                x =>
                {
                    _newViewModelCount++;
                    _viewModels.Add(new SimpleViewModel()
                    {
                        Name = "New Tab " + _newViewModelCount,
                        SimpleContent = "New Tab Content " + _newViewModelCount
                    });
                    SelectedViewModel = _viewModels.Last();
                });
        }