private void ItemContainerGeneratorOnItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         MixListScrollViewer.ScrollToTop();
     }
 }
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args) {
            ItemsControl itemsOwner;
            switch (args.Action) {
            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
            case NotifyCollectionChangedAction.Move:
                // THE HACK
                RemoveChildRange(args.Position, args.ItemCount, args.ItemUICount);
                return;

            case NotifyCollectionChangedAction.Reset:
                itemsOwner = ItemsControl.GetItemsOwner(this);
                if (itemsOwner == null)
                    return;
                if (PreviousItemCount != itemsOwner.Items.Count) {
                    if (Orientation != Orientation.Horizontal) {
                        SetHorizontalOffset(0.0);
                        break;
                    }
                    SetVerticalOffset(0.0);
                }
                break;

            default:
                return;
            }
            var itemCount = itemsOwner.Items.Count;
            PreviousItemCount = itemCount;
        }
Пример #3
0
 void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         Position item = lstPositions.Items.Last() as Position;
         location = new GeoCoordinate(item.Latitude, item.Longitude);
         mapPositions.Center = location;
         layer = new MapLayer();
         grid = new Grid();
         grid.DataContext = item;
         grid.Hold += grid_Hold;
         textBlock = new TextBlock();
         textBlock.Text = item.Counter.ToString();
         textBlock.VerticalAlignment = VerticalAlignment.Bottom;
         textBlock.HorizontalAlignment = HorizontalAlignment.Center;
         brush = new ImageBrush();
         brush.ImageSource = image;
         ellipse = new Ellipse();
         ellipse.Height = 100;
         ellipse.Width = 100;
         ellipse.Fill = brush;
         grid.Children.Add(ellipse);
         grid.Children.Add(textBlock);
         overlay = new MapOverlay();
         overlay.Content = grid;
         overlay.GeoCoordinate = location;
         layer.Add(overlay);
         mapPositions.Layers.Add(layer);
     }
 }
Пример #4
0
		void OnItemsChangedItemContainerGenerator(object sender, ItemsChangedEventArgs e)
		{
			ItemsControl ic = ItemsControl.ItemsControlFromItemContainer(item);

			if (null == ic)
				return;
			item.SetValue(IsLastOneProperty, ic.ItemContainerGenerator.IndexFromContainer(item) == ic.Items.Count - 1);
		}
Пример #5
0
        private void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
        {
            var action = (CollectionChange)e.Action;

            if (action == CollectionChange.Reset)
            {
                // Reset collection to reload later.
                _hasLoaded = false;
            }
        }
 private void ModifyModelActionOnItemsChanged(object sender, ItemsChangedEventArgs e){
     foreach (var itemChangesType in e.ChangedItemsInfo.Where(pair => pair.Value==ChoiceActionItemChangesType.Add)){
         var choiceActionItem = itemChangesType.Key as ChoiceActionItem;
         if (choiceActionItem != null && choiceActionItem.Id==ModifyModelActionChoiceItemsUpdater.ChangeViewModel) {
             choiceActionItem.Active.BeginUpdate();
             choiceActionItem.Active["ModelNotConfigured"] = ((IModelViewConfigurationView)View.Model).ConfigurationView != null;
             choiceActionItem.Active.EndUpdate();
         }
     }
 }
Пример #7
0
 void OnItemsChanged(object sender, ItemsChangedEventArgs itemsChangedEventArgs) {
     var changedItemsInfo = itemsChangedEventArgs.ChangedItemsInfo;
     foreach (var actionItemChangesType in changedItemsInfo) {
         if (actionItemChangesType.Key is ChoiceActionItem && actionItemChangesType.Value == ChoiceActionItemChangesType.Add) {
             var choiceActionItem = ((ChoiceActionItem)actionItemChangesType.Key);
             var transition = choiceActionItem.Data as ITransition;
             if (transition != null)
                 choiceActionItem.Active["Permission"] = !IsGranted(transition.TargetState);
         }
     }
 }
Пример #8
0
		void OnItemsChangedInternal (object sender, ItemsChangedEventArgs args)
 		{
			InvalidateMeasure ();
			if (args.Action == NotifyCollectionChangedAction.Reset) {
				Children.Clear ();
				ItemContainerGenerator.RemoveAll ();
				OnClearChildren ();
			}

			OnItemsChanged (sender, args);
 		}
Пример #9
0
 /// <summary>
 ///     When items are removed, remove the corresponding UI if necessary
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
 {
     switch (args.Action)
     {
     case NotifyCollectionChangedAction.Remove:
     case NotifyCollectionChangedAction.Replace:
     case NotifyCollectionChangedAction.Move:
         RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
         break;
     }
 }
Пример #10
0
 protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
 {
     switch (args.Action)
     {
         case NotifyCollectionChangedAction.Move:
         case NotifyCollectionChangedAction.Remove:
         case NotifyCollectionChangedAction.Replace:
             RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
             break;
     }
     base.OnItemsChanged(sender, args);
 }
Пример #11
0
 /// <summary>
 ///  Called when the System.Windows.Controls.ItemsControl.Items collection that
 ///  is associated with the System.Windows.Controls.ItemsControl for this System.Windows.Controls.Panel changes.
 /// </summary>
 /// <param name="sender">The System.Object that raised the event.</param>
 /// <param name="args">Provides data for the System.Windows.Controls.ItemContainerGenerator.ItemsChanged event.</param>
 protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
 {
     base.OnItemsChanged(sender, args);
     if (this.columns != null)
     {
         this.columns.Clear();
     }
     if (this.slots != null)
     {
         this.slots.Clear();
     }
 }
Пример #12
0
 private void lvResults_ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     // Refresh our list objects and it's view.
     if (lvFavorites.Items.Count == 0)
     {
         lvFavorites.View = View.SmallIcon;
     }
     else
     {
         lvFavorites.View = View.Details;
     }
 }
Пример #13
0
 private void ItemContainerGeneratorItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Reset)
     {
         // An item was added to the listbox, or listbox was cleared.
         if (_autoScroll && !_userInteracting)
         {
             // If automatic scrolling is turned on, scroll to the bottom to bring new item into view.
             // Do not do this if the user is actively interacting with the listbox.
             _scrollViewer?.ScrollToBottom();
         }
     }
 }
Пример #14
0
 void AddNodeActionOnItemsChanged(object sender, ItemsChangedEventArgs itemsChangedEventArgs) {
     var singleChoiceAction = (sender) as SingleChoiceAction;
     if (singleChoiceAction != null && (singleChoiceAction.Id == "Add" && itemsChangedEventArgs.ChangedItemsInfo.Values.Contains(ChoiceActionItemChangesType.ItemsAdd))) {
         if (CurrentModelNode.ModelNode.GetType().Name == "ModelLogicRules") {
             var modelTreeListNode = CurrentModelNode.Parent;
             for (int i = singleChoiceAction.Items.Count - 1; i > -1; i--) {
                 var value = modelTreeListNode.ModelNode.Id.Replace("Conditional", "");
                 if (!singleChoiceAction.Items[i].Id.StartsWith(value))
                     singleChoiceAction.Items.RemoveAt(i);
             }
         }
     }
 }
 private void ModifyModelActionOnItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     foreach (var itemChangesType in e.ChangedItemsInfo.Where(pair => pair.Value == ChoiceActionItemChangesType.Add))
     {
         var choiceActionItem = itemChangesType.Key as ChoiceActionItem;
         if (choiceActionItem != null && choiceActionItem.Id == ModifyModelActionChoiceItemsUpdater.ChangeViewModel)
         {
             choiceActionItem.Active.BeginUpdate();
             choiceActionItem.Active["ModelNotConfigured"] = ((IModelViewConfigurationView)View.Model).ConfigurationView != null;
             choiceActionItem.Active.EndUpdate();
         }
     }
 }
        private void OnItemsChanged(object sender, ItemsChangedEventArgs e)
        {
            if (!HasEffectiveKeyboardFocus)
            {
                return;
            }

            this.popup.IsOpen = (this.list.Items.Count > 0);
            if (this.list.SelectedIndex == -1)
            {
                this.list.SelectedIndex = 0;
            }
        }
Пример #17
0
        void OnItemsChangedItemContainerGenerator(object sender, ItemsChangedEventArgs e)
        {
            ItemsControl ic = ItemsControl.ItemsControlFromItemContainer(_item);

            if (null != ic)
            {
                int shift = 1, a = ic.ItemContainerGenerator.IndexFromContainer(_item);
                if (a == -1)
                {
                    shift = 2;
                }
                _item.SetValue(IsLastOneProperty, a == ic.Items.Count - shift);
            }
        }
Пример #18
0
 /// <summary>
 /// Event handler for the items changed event
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A <see cref="ItemsChangedEventArgs" /> that contains the event data.</param>
 private static void ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     if (itemsControls.TryGetValue(sender, out var control))
     {
         if (ShouldShowPlaceholder(control))
         {
             ShowPlaceholder(control);
         }
         else
         {
             RemovePlaceholder(control);
         }
     }
 }
        /// <summary>
        /// Event fired when the Items list changes</summary>
        /// <param name="sender">Originator of the event</param>
        /// <param name="args">Event args</param>
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            base.OnItemsChanged(sender, args);

            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Remove:
                Debug.WriteLine("REMOVING ITEM FROM ITEM CONTROL: " + args.Position.Index);
                RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                if (args.Position.Index >= 0)
                {
                    m_abstractPanel?.Remove(args.Position.Index);
                }
                else
                {
                    m_abstractPanel = null;
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                Debug.WriteLine("REPLACING ITEM FROM ITEM CONTROL");
                RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                break;

            case NotifyCollectionChangedAction.Move:
                Debug.WriteLine("MOVING ITEM FROM ITEM CONTROL");
                RemoveInternalChildRange(args.OldPosition.Index, args.ItemUICount);
                break;

            case NotifyCollectionChangedAction.Reset:
                Debug.WriteLine("RESETTING ITEM CONTROL");
                m_abstractPanel = null;
                ResetScrollInfo();
                break;

            case NotifyCollectionChangedAction.Add:
                Debug.WriteLineIf(args.Position.Index != -1, "ADDING ITEM FROM ITEM CONTROL");
                Debug.WriteLineIf(args.Position.Index != -1, "Index: " + args.Position.Index + " Offset: " + args.Position.Offset);
                if (args.Position.Index == -1)
                {
                    m_abstractPanel = null;
                }
                else
                {
                    m_abstractPanel.Insert(args.Position.Index);
                }
                break;
            }
            ScrollOwner?.InvalidateScrollInfo();
        }
Пример #20
0
 void AddNodeActionOnItemsChanged(object sender, ItemsChangedEventArgs itemsChangedEventArgs) {
     var singleChoiceAction = (sender) as SingleChoiceAction;
     if ((singleChoiceAction != null && singleChoiceAction.Id == "Add") && (itemsChangedEventArgs.ChangedItemsInfo.Values.Contains(ChoiceActionItemChangesType.ItemsAdd | ChoiceActionItemChangesType.ItemsRemove))) {
         string name = CurrentModelNode.ModelNode.GetType().Name;
         switch (name) {
             case "ModelLogicRules":
                 FilterModelLogicRules(singleChoiceAction);
                 break;
             case "ModelBOModelClassMembers":
                 EnableBOModelClassMembersAddMenu();
                 break;
         }
     }
 }
Пример #21
0
 /// <summary>
 /// Event handler for the items changed event
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A <see cref="ItemsChangedEventArgs"/> that contains the event data.</param>
 private static void ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     if (ItemsControls.TryGetValue(sender, out var control))
     {
         if (ShouldShowWatermark(control))
         {
             ShowWatermark(control);
         }
         else
         {
             RemoveWatermark(control);
         }
     }
 }
Пример #22
0
 private static void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     if (itemsControls.TryGetValue(sender, out ItemsControl control))
     {
         if (ShouldShowCueBanner(control))
         {
             ShowCueBanner(control);
         }
         else
         {
             RemoveCueBanner(control);
         }
     }
 }
Пример #23
0
 /// <summary>
 /// Event handler for the items changed event
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A <see cref="ItemsChangedEventArgs"/> that contains the event data.</param>
 private static void ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     ItemsControl control;
     if (itemsControls.TryGetValue(sender, out control))
     {
         if (ShouldShowWatermark(control))
         {
             ShowWatermark(control);
         }
         else
         {
             RemoveWatermark(control);
         }
     }
 }
Пример #24
0
        private void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            //if (VerifyBoundState())
            //{
            Debug.Assert(_itemContainerGenerator != null, "Encountered a null _itemContainerGenerator while receiving an ItemsChanged from a generator.");

            bool affectsLayout = OnItemsChangedInternal(sender, args);

            if (affectsLayout)
            {
                // todo
                InvalidateMeasure();
            }
            //}
        }
Пример #25
0
        private static void ItemsChanged(object sender, ItemsChangedEventArgs e)
        {
            ItemsControl control;

            if (itemsControls.TryGetValue(sender, out control))
            {
                if (e.ItemCount > 0)
                {
                    RemoveCueBanner(control);
                }
                else
                {
                    ShowCueBanner(control);
                }
            }
        }
Пример #26
0
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            //Debug.WriteLine("OnItemsChanged: " + args.Action + " - " + args.ItemCount + " - " + args.ItemUICount + " - " + args.OldPosition + " - " + args.Position);
            _abstractPanel = null;


            //TODO: This is sort of copied from the VirtualizingStackPanel code. Assuming the other action cases need to be handled as well
            if (args.Action == NotifyCollectionChangedAction.Remove)
            {
                RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
            }

            base.OnItemsChanged(sender, args);

            ResetScrollInfo();
        }
Пример #27
0
    /// <summary>
    /// Event handler for the items changed event
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">A <see cref="ItemsChangedEventArgs"/> that contains the event data.</param>
    private static void ItemsChanged(object sender, ItemsChangedEventArgs e)
    {
        ItemsControl control;

        if (itemsControls.TryGetValue(sender, out control))
        {
            if (control.Items.Count > 0)
            {
                RemoveWatermark(control);
            }
            else
            {
                ShowWatermark(control);
            }
        }
    }
        /// <summary>
        /// Event handler for the items changed event
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="ItemsChangedEventArgs"/> that contains the event data.</param>
        private static void itemsChanged(object sender, ItemsChangedEventArgs e)
        {
            ItemsControl control;

            if (itemsControls.TryGetValue(sender, out control))
            {
                if (PlaceholderService.shouldShowWatermark(control))
                {
                    PlaceholderService.showWatermark(control);
                }
                else
                {
                    PlaceholderService.removeWatermark(control);
                }
            }
        }
Пример #29
0
 protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
 {
     if (args.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
     {
         int index = args.Position.Index;
         if (args.Position.Offset > 0)
         {
             index++;
         }
         if (index < InternalChildren.Count && args.ItemUICount > 0)
         {
             RemoveInternalChildRange(index, args.ItemUICount);
         }
     }
     base.OnItemsChanged(sender, args);
 }
Пример #30
0
        private static void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            if (!_itemsControls.TryGetValue(sender, out ItemsControl control))
            {
                return;
            }

            if (ShouldShowWatermark(control))
            {
                ShowWatermark(control);
            }
            else
            {
                RemoveWatermark(control);
            }
        }
Пример #31
0
        void OnItemsChanged(object sender, ItemsChangedEventArgs itemsChangedEventArgs)
        {
            var changedItemsInfo = itemsChangedEventArgs.ChangedItemsInfo;

            foreach (var actionItemChangesType in changedItemsInfo)
            {
                if (actionItemChangesType.Key is ChoiceActionItem && actionItemChangesType.Value == ChoiceActionItemChangesType.Add)
                {
                    var choiceActionItem = ((ChoiceActionItem)actionItemChangesType.Key);
                    var transition       = choiceActionItem.Data as ITransition;
                    if (transition != null)
                    {
                        choiceActionItem.Active["Permission"] = !IsGranted(transition.TargetState);
                    }
                }
            }
        }
        public void ItemContainerGeneratorBasicTest()
        {
            TestGeneratorHost      host      = new TestGeneratorHost();
            ItemContainerGenerator generator = new ItemContainerGenerator(host);

            ItemsChangedEventArgs lastChangedArg = null;

            generator.ItemsChanged += (sender, e) => lastChangedArg = e;

            host.View.Add("item1");
            Assert.AreEqual(NotifyCollectionChangedAction.Add, lastChangedArg.Action);
            Assert.AreEqual(0, lastChangedArg.NewStartingIndex);
            Assert.AreEqual(1, lastChangedArg.ItemsCount);
            Assert.AreEqual(0, lastChangedArg.ContainersCount);

            FrameworkElement container1 = generator.Generate(0);

            Assert.IsTrue(host.Containers.ContainsKey("item1"));
            Assert.AreEqual("item1", container1.GetValue(TestGeneratorHost.ItemForItemContainerProperty));

            host.View[0] = "item2";
            Assert.IsFalse(host.Containers.ContainsKey("item1"));
            Assert.IsTrue(host.Containers.ContainsKey("item2"));
            Assert.IsNull(container1.GetValue(TestGeneratorHost.ItemForItemContainerProperty));

            FrameworkElement container2 = generator.Generate(0);

            Assert.IsTrue(host.Containers.ContainsKey("item2"));
            Assert.AreEqual("item2", container2.GetValue(TestGeneratorHost.ItemForItemContainerProperty));

            host.View.Remove("item2");
            Assert.IsFalse(host.Containers.ContainsKey("item2"));
            Assert.IsNull(container2.GetValue(TestGeneratorHost.ItemForItemContainerProperty));

            host.View.Add("item3");
            Assert.IsFalse(host.Containers.ContainsKey("item3"));

            FrameworkElement container3 = generator.Generate(0);

            Assert.IsTrue(host.Containers.ContainsKey("item3"));
            Assert.AreEqual("item3", container3.GetValue(TestGeneratorHost.ItemForItemContainerProperty));

            generator.Dispose();
            Assert.IsFalse(host.Containers.ContainsKey("item3"));
            Assert.IsNull(container3.GetValue(TestGeneratorHost.ItemForItemContainerProperty));
        }
Пример #33
0
        /// <summary>
        /// When items are removed, remove the corresponding UI if necessary
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
            case NotifyCollectionChangedAction.Move:
                RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                break;

            case NotifyCollectionChangedAction.Reset:
                SetVerticalOffset(0);     //TODO: Is this enough?
                itemsTopPosition = new List <double>();
                itemsHeight      = new List <double>();
                totalHeight      = 0;
                break;
            }
        }
Пример #34
0
        /// <summary>
        /// Event fired when the Items list changes</summary>
        /// <param name="sender">Originator of the event</param>
        /// <param name="args">Event args</param>
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            base.OnItemsChanged(sender, args);
            m_abstractPanel = null;
            ResetScrollInfo();

            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
                RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                break;

            case NotifyCollectionChangedAction.Move:
                RemoveInternalChildRange(args.OldPosition.Index, args.ItemUICount);
                break;
            }
        }
        /// <summary>
        /// Called when the Items collection associated with the containing ItemsControl changes.
        /// </summary>
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            switch (args.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                Owner.ClearCards();
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                throw new NotImplementedException(string.Format("Implement Remove. Count:{0} OldPos:{1} Pos:{2}", args.ItemCount, args.OldPosition, args.Position));

            case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                throw new NotImplementedException("Implement Replace");

            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                throw new NotImplementedException("Implement Add");
            }
        }
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            base.OnItemsChanged(sender, args);

            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Add:
                if (Generator != null)
                {
                    using (Generator.StartAt(args.Position, GeneratorDirection.Forward, true))
                    {
                        UIElement childToAdd = Generator.GenerateNext() as UIElement;
                        Generator.PrepareItemContainer(childToAdd);
                        int indexToInsertAt = Generator.IndexFromGeneratorPosition(args.Position);
                        GeneratedChildren.Insert(indexToInsertAt, childToAdd);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                RemoveItem(args.Position.Index);
                break;

            case NotifyCollectionChangedAction.Reset:
                RemoveInternalChildRange(0, InternalChildren.Count);
                if (QAT != null &&
                    QAT.OverflowPanel != null)
                {
                    QAT.OverflowPanel.Children.Clear();
                }

                RepopulateGeneratedChildren();
                break;

            case NotifyCollectionChangedAction.Move:
                UIElement childToMove = GeneratedChildren[args.OldPosition.Index];
                RemoveItem(args.OldPosition.Index);
                GeneratedChildren.Insert(args.Position.Index, childToMove);
                break;

            case NotifyCollectionChangedAction.Replace:
                break;
            }
        }
Пример #37
0
        /// <summary>
        /// When items are removed, remove the corresponding UI if necessary
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
                RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                break;

            case NotifyCollectionChangedAction.Move:
                RemoveInternalChildRange(args.OldPosition.Index, args.ItemUICount);
                break;

            case NotifyCollectionChangedAction.Reset:
                _lineSizeDictionary.Clear();
                break;
            }
            base.OnItemsChanged(sender, args);
        }
Пример #38
0
        /// <summary>
        /// When items are removed, remove the corresponding UI if necessary
        /// </summary>
        /// <param name="sender">System.Object repersenting the source of the event.</param>
        /// <param name="args">The arguments for the event.</param>
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
            case NotifyCollectionChangedAction.Reset:
                //Peform layout refreshment.
                if (_owner != null)
                {
                    _owner.ScrollToTop();
                }
                break;

            case NotifyCollectionChangedAction.Move:
                RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                break;
            }
        }
Пример #39
0
        private async Task ChangeNotificationThreadMain()
        {
            while (!this.changeNotificationCancellationTokenSource.IsCancellationRequested)
            {
                TrackedChange changes = null;
                try
                {
                    changes = await this.GetChangesAsync().ConfigureAwait(false);
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, "Failed to pull changes from OneDrive");
                }

                if (changes != null &&
                    changes.Changes.Any() &&
                    !string.Equals(changes.State, this.Config.LatestDeltaToken, StringComparison.Ordinal))
                {
                    ItemsChangedEventArgs eventArgs = new ItemsChangedEventArgs();

                    foreach (IChangeTrackedAdapterItem change in changes.Changes)
                    {
                        eventArgs.Changes.Add(
                            new ItemChange(
                                change.FullName,
                                ItemChangeType.None));
                    }

                    this.ItemChanged?.Invoke(this, eventArgs);
                }

                Logger.Debug("OneDriveAdapter.ChangeNotificationThreadMain delay for " + OneDriveChangeNotificationPollingInterval);

                this.nextNotificationPollTime = DateTime.Now.Add(
                    OneDriveChangeNotificationPollingInterval);

                await Task.Delay(
                    OneDriveChangeNotificationPollingInterval,
                    this.changeNotificationCancellationTokenSource.Token)
                .ConfigureAwait(false);
            }
        }
Пример #40
0
        void OnItemsChangedItemContainerGenerator(object sender, ItemsChangedEventArgs e)
        {
            ItemsControl ic = ItemsControl.ItemsControlFromItemContainer(_item);

            if (null != ic)
            {
                _item.SetValue(IsLastOneProperty,
                               ic.ItemContainerGenerator.IndexFromContainer(_item) == ic.Items.Count - 1);
            }

            if (_item is SyncTreeViewItem)
            {
                SyncTreeViewItem item = _item as SyncTreeViewItem;
                _item.SetValue(IsToggleButtonVisibleProperty, (!item.IsSynced || item.HasItems));
            }
            else if (_item != null)
            {
                _item.SetValue(IsToggleButtonVisibleProperty, _item.HasItems);
            }
        }
Пример #41
0
        void AddNodeActionOnItemsChanged(object sender, ItemsChangedEventArgs itemsChangedEventArgs)
        {
            var singleChoiceAction = (sender) as SingleChoiceAction;

            if (singleChoiceAction != null && (singleChoiceAction.Id == "Add" && itemsChangedEventArgs.ChangedItemsInfo.Values.Contains(ChoiceActionItemChangesType.ItemsAdd)))
            {
                if (CurrentModelNode.ModelNode.GetType().Name == "ModelLogicRules")
                {
                    var modelTreeListNode = CurrentModelNode.Parent;
                    for (int i = singleChoiceAction.Items.Count - 1; i > -1; i--)
                    {
                        var value = modelTreeListNode.ModelNode.Id.Replace("Conditional", "");
                        if (!singleChoiceAction.Items[i].Id.StartsWith(value))
                        {
                            singleChoiceAction.Items.RemoveAt(i);
                        }
                    }
                }
            }
        }
Пример #42
0
 public bool ShouldItemsChangeAffectLayout(bool areItemChangesLocal, ItemsChangedEventArgs args)
 {
     return ShouldItemsChangeAffectLayoutCore(areItemChangesLocal, args);
 }
Пример #43
0
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            CalculateItemSizes();

            base.OnItemsChanged(sender, args);
        }
 private void singleChoiceAction_ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     if ((
         from a in e.ChangedItemsInfo.Values
         where a == ChoiceActionItemChangesType.Items
         select a).Count<ChoiceActionItemChangesType>() > 0)
     {
         this.ItemChanged(this, ChoiceActionItemChangesType.Items);
     }
 }
Пример #45
0
 private void ItemContainerGeneratorOnItemsChanged(object sender, ItemsChangedEventArgs itemsChangedEventArgs)
 {
     //throw new NotImplementedException();
 }
Пример #46
0
 protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
 {
     base.OnItemsChanged(sender, args);
 }
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            base.OnItemsChanged(sender, args);

            switch (args.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    if (Generator != null)
                    {
                        using (Generator.StartAt(args.Position, GeneratorDirection.Forward, true))
                        {
                            UIElement childToAdd = Generator.GenerateNext() as UIElement;
                            Generator.PrepareItemContainer(childToAdd);
                            int indexToInsertAt = Generator.IndexFromGeneratorPosition(args.Position);
                            GeneratedChildren.Insert(indexToInsertAt, childToAdd);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                    RemoveItem(args.Position.Index);
                    break;
                case NotifyCollectionChangedAction.Reset:
                    RemoveInternalChildRange(0, InternalChildren.Count);
                    if (QAT != null &&
                        QAT.OverflowPanel != null)
                    {
                        QAT.OverflowPanel.Children.Clear();
                    }

                    RepopulateGeneratedChildren();
                    break;
                case NotifyCollectionChangedAction.Move:
                    UIElement childToMove = GeneratedChildren[args.OldPosition.Index];
                    RemoveItem(args.OldPosition.Index);
                    GeneratedChildren.Insert(args.Position.Index, childToMove);
                    break;
                case NotifyCollectionChangedAction.Replace:
                    break;
            }
        }
Пример #48
0
            private void OnItemsChanged(object sender, ItemsChangedEventArgs e)
            {
                CollectionViewGroup group = (CollectionViewGroup)GetValue(ItemContainerGenerator.ItemForItemContainerProperty);

                // if the group becomes non-empty, un-hide the UI
                if (group.ItemCount > 0)
                {
                    ItemContainerGenerator generator = Generator;
                    generator.ItemsChanged -= new ItemsChangedEventHandler(OnItemsChanged);
                    generator.Parent.OnSubgroupBecameNonEmpty(this, group);
                }
            }
Пример #49
0
		internal void OnOwnerItemsItemsChanged (object sender, NotifyCollectionChangedEventArgs e)
		{
			int itemCount;
			int itemUICount;
			GeneratorPosition oldPosition = new GeneratorPosition(-1, 0);
			GeneratorPosition position;
			
			switch (e.Action) {
			case NotifyCollectionChangedAction.Add:
				if ((e.NewStartingIndex + 1) != Owner.Items.Count)
					MoveExistingItems (e.NewStartingIndex, 1);
				itemCount = 1;
				itemUICount = 0;
				position = GeneratorPositionFromIndex (e.NewStartingIndex);
				// Yes, this looks like a Silverlight Bug.
				position.Offset = 1;
				break;
			case NotifyCollectionChangedAction.Remove:
				itemCount = 1;
				itemUICount = RealizedElements.Contains (e.OldStartingIndex) ? 1 : 0;
				position = GeneratorPositionFromIndex (e.OldStartingIndex);
				if (itemUICount == 1)
					Remove (position, 1);
				MoveExistingItems (e.OldStartingIndex, -1);
				break;
			case NotifyCollectionChangedAction.Replace:
				if (!RealizedElements.Contains (e.NewStartingIndex))
					return;

				itemCount = 1;
				itemUICount = 1;
				position = GeneratorPositionFromIndex (e.NewStartingIndex);
				Remove (position, 1);

				bool fresh;
				var newPos = GeneratorPositionFromIndex (e.NewStartingIndex);
				using (StartAt (newPos, GeneratorDirection.Forward, true))
					PrepareItemContainer (GenerateNext (out fresh));
				break;
			case NotifyCollectionChangedAction.Reset:
				itemCount = e.OldItems == null ? 0 : e.OldItems.Count;
				itemUICount = RealizedElements.Count;
				position = new GeneratorPosition (-1, 0);
				RemoveAll ();
				break;
			default:
				Console.WriteLine ("*** Critical error in ItemContainerGenerator.OnOwnerItemsItemsChanged. NotifyCollectionChangedAction.{0} is not supported", e.Action);
				return;
			}
			
			ItemsChangedEventArgs args = new ItemsChangedEventArgs {
				Action = e.Action,
				ItemCount = itemCount,
				ItemUICount = itemUICount,
				OldPosition = oldPosition,
				Position = position
			};
			var h = ItemsChanged;
			if (h != null)
				h (this, args);
		}
		protected override void OnItemsChanged (object sender, ItemsChangedEventArgs args)
		{
			if (OnItemsChangedAction != null)
				OnItemsChangedAction ();
			base.OnItemsChanged (sender, args);
		}
Пример #51
0
 /// <summary>
 ///     Returns whether an Items collection change affects layout for this panel.
 /// </summary>
 /// <param name="args">Event arguments</param>
 /// <param name="areItemChangesLocal">Says if this notification represents a direct change to this Panel's collection</param>
 protected virtual bool ShouldItemsChangeAffectLayoutCore(bool areItemChangesLocal, ItemsChangedEventArgs args)
 {
     return true;
 }
Пример #52
0
 static void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
 {
     RefreshWidth(sender as ItemsControl);
 }
Пример #53
0
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            base.OnItemsChanged(sender, args);

            InvalidateMeasure();
        }
Пример #54
0
        /// <summary>
        ///     Called when the Items collection associated with the containing ItemsControl changes.
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="args">Event arguments</param>
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            base.OnItemsChanged(sender, args);

            switch (args.Action)
            {
                case NotifyCollectionChangedAction.Remove:
                    OnItemsRemove(args);
                    break;

                case NotifyCollectionChangedAction.Replace:
                    OnItemsReplace(args);
                    break;

                case NotifyCollectionChangedAction.Move:
                    OnItemsMove(args);
                    break;

                case NotifyCollectionChangedAction.Reset:
                    break;
            }
        }
        private void ListView_ItemsChanged(ListView listView, ItemsChangedEventArgs e)
        {
            DebugHelper.AssertUIThread();

            if ((listView != null) && (e != null))
            {
                switch (e.Action)
                {
                    case NotifyCollectionChangedAction.Add:
                        if (MetadataViewContent.lastFocused == this)
                        {
                            int newIndex = listView.Items.Count - 1;
                            listView.SelectedIndex = newIndex;
                            listView.ScrollIntoView(listView.Items[newIndex]);
                            this.setNextMetadatFocus = listView;
                        }
                        break;

                    default:
                        this.setNextMetadatFocus = null;
                        break;
                }
            }
        }
Пример #56
0
 private void OnItemsMove(ItemsChangedEventArgs args)
 {
     RemoveChildRange(args.OldPosition, args.ItemCount, args.ItemUICount);
 }
        /// <summary>
        /// OnItemsChanged override
        /// </summary>
        protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            try
            {
            ItemsControl ic = ItemsControl.GetItemsOwner(this);
            if (ic == null) return;

            _actualChildCount = ic.Items.Count;

            switch (args.Action)
            {
                case NotifyCollectionChangedAction.Remove:
                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Move:
                    RemoveInternalChildRange(args.Position.Index, args.ItemUICount);

                    // if we've removed the last tabitem, we need to scroll to the left
                    while (FirstVisibleIndex > 0 && LastVisibleIndex > ic.Items.Count - 1)
                        FirstVisibleIndex--;
                    break;
            }
        }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "OnItemsChanged()", "Controls\\VMuktiGrid\\Page\\VirtualizingTabPanel.cs");
                }
        }
Пример #58
0
 		protected override void OnItemsChanged (object sender, ItemsChangedEventArgs args)
 		{
			base.OnItemsChanged (sender, args);
			IItemContainerGenerator generator = ItemContainerGenerator;
			ItemsControl owner = ItemsControl.GetItemsOwner (this);
			int index, offset, viewable, delta;
			
			switch (args.Action) {
			case NotifyCollectionChangedAction.Add:
				// The following logic is meant to keep the current viewable items in view
				// after adjusting for added items.
				index = generator.IndexFromGeneratorPosition (args.Position);
				if (Orientation == Orientation.Horizontal)
					offset = (int) HorizontalOffset;
				else
					offset = (int) VerticalOffset;
				
				if (index <= offset) {
					// items have been added earlier in the list than what is viewable
					offset += args.ItemCount;
				}
				
				if (Orientation == Orientation.Horizontal)
					SetHorizontalOffset (offset);
				else
					SetVerticalOffset (offset);
				break;
			case NotifyCollectionChangedAction.Remove:
				// The following logic is meant to keep the current viewable items in view
				// after adjusting for removed items.
				index = generator.IndexFromGeneratorPosition (args.Position);
				if (Orientation == Orientation.Horizontal) {
					offset = (int) HorizontalOffset;
					viewable = (int) ViewportWidth;
				} else {
					viewable = (int) ViewportHeight;
					offset = (int) VerticalOffset;
				}
				
				if (index < offset) {
					// items earlier in the list than what is viewable have been removed
					offset = Math.Max (offset - args.ItemCount, 0);
				}
				
				// adjust for items removed in the current view and/or beyond the current view
				offset = Math.Min (offset, owner.Items.Count - viewable);
				offset = Math.Max (offset, 0);
				
				if (Orientation == Orientation.Horizontal)
					SetHorizontalOffset (offset);
				else
					SetVerticalOffset (offset);
				
				RemoveInternalChildRange (args.Position.Index, args.ItemUICount);
				break;
			case NotifyCollectionChangedAction.Replace:
				RemoveInternalChildRange (args.Position.Index, args.ItemUICount);
				break;
			case NotifyCollectionChangedAction.Reset:
				// DO NOTHING
				break;
			}
			
			InvalidateMeasure ();
			
			if (ScrollOwner != null)
				ScrollOwner.InvalidateScrollInfo ();
 		}
Пример #59
0
        // This method returns a bool to indicate if or not the panel layout is affected by this collection change
        internal override bool OnItemsChangedInternal(object sender, ItemsChangedEventArgs args)
        {
            switch (args.Action)
            {
                case NotifyCollectionChangedAction.Add:
                case NotifyCollectionChangedAction.Remove:
                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Move:
                    // Don't allow Panel's code to run for add/remove/replace/move
                    break;

                default:
                    base.OnItemsChangedInternal(sender, args);
                    break;
            }

            OnItemsChanged(sender, args);

            return ShouldItemsChangeAffectLayout(true /*areItemChangesLocal*/, args);
        }
Пример #60
0
 void test_ItemsChanged(object sender, ItemsChangedEventArgs<object> e)
 {
     ItemsChangedEventArgs = e;
 }