Exemple #1
0
        private static void UnregisterToolTip(UIElement owner)
        {
            Debug.Assert(owner != null, "owner element is required");

            if (owner.GetValue(AssignedToolTipProperty) == null)
            {
                return;
            }

            owner.MouseEnter          -= new MouseEventHandler(OnOwnerMouseEnter);
            owner.MouseLeave          -= new MouseEventHandler(OnOwnerMouseLeave);
            owner.MouseLeftButtonDown -= new MouseButtonEventHandler(OnOwnerMouseLeftButtonDown);
            owner.KeyDown             -= new KeyEventHandler(OnOwnerKeyDown);

            ToolTip toolTip = (ToolTip)owner.GetValue(AssignedToolTipProperty);

            toolTip.TooltipParent = null;
            if (toolTip.IsOpen)
            {
                if (toolTip == ToolTipService._currentToolTip)
                {
                    // unregistering a currently open automatic toltip
                    // thus need to stop the timer
                    ToolTipService._closeTimer.Stop();
                    ToolTipService._currentToolTip  = null;
                    ToolTipService._owner           = null;
                    ToolTipService._lastEnterSource = null;
                }

                toolTip.IsOpen = false;
            }

            owner.ClearValue(AssignedToolTipProperty);
        }
Exemple #2
0
        private static void OnTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Label label = (Label)d;

            UIElement oldElement = (UIElement)e.OldValue;
            UIElement newElement = (UIElement)e.NewValue;

            // If the Target property has changed, set the LabeledByProperty on
            // the new Target and clear the LabeledByProperty on the old Target.
            if (oldElement != null)
            {
                object oldValueLabeledBy = oldElement.GetValue(LabeledByProperty);

                // If this Label was actually labelling the oldValue
                // then clear the LabeledByProperty
                if (oldValueLabeledBy == label)
                {
                    oldElement.ClearValue(LabeledByProperty);
                }
            }

            if (newElement != null)
            {
                newElement.SetValue(LabeledByProperty, label);
            }
        }
Exemple #3
0
        private static void ShowValidationAdornerHelper(DependencyObject targetElement, DependencyObject adornerSite, bool show, bool tryAgain)
        {
            UIElement siteUIElement = adornerSite as UIElement;

            if (siteUIElement != null)
            {
                AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(siteUIElement);

                if (adornerLayer == null)
                {
                    if (tryAgain)
                    {
                        // try again later, perhaps giving layout a chance to create the adorner layer
                        adornerSite.Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
                                                           new DispatcherOperationCallback(ShowValidationAdornerOperation),
                                                           new object[] { targetElement, adornerSite, show });
                    }
                    return;
                }

                TemplatedAdorner validationAdorner = siteUIElement.ReadLocalValue(ValidationAdornerProperty) as TemplatedAdorner;

                if (show && validationAdorner == null)
                {
                    // get the template from the site, or from the target element
                    ControlTemplate validationTemplate = GetErrorTemplate(siteUIElement);
                    if (validationTemplate == null)
                    {
                        validationTemplate = GetErrorTemplate(targetElement);
                    }

                    if (validationTemplate != null)
                    {
                        validationAdorner = new TemplatedAdorner(siteUIElement, validationTemplate);
                        adornerLayer.Add(validationAdorner);

                        siteUIElement.SetValue(ValidationAdornerProperty, validationAdorner);
                    }
                }
                else if (!show && validationAdorner != null)
                {
                    validationAdorner.ClearChild();
                    adornerLayer.Remove(validationAdorner);
                    siteUIElement.ClearValue(ValidationAdornerProperty);
                }
            }
        }
        // Token: 0x0600597E RID: 22910 RVA: 0x0018B1FC File Offset: 0x001893FC
        private static void ShowValidationAdornerHelper(DependencyObject targetElement, DependencyObject adornerSite, bool show, bool tryAgain)
        {
            UIElement uielement = adornerSite as UIElement;

            if (uielement != null)
            {
                AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(uielement);
                if (adornerLayer == null)
                {
                    if (tryAgain)
                    {
                        adornerSite.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(Validation.ShowValidationAdornerOperation), new object[]
                        {
                            targetElement,
                            adornerSite,
                            show
                        });
                    }
                    return;
                }
                TemplatedAdorner templatedAdorner = uielement.ReadLocalValue(Validation.ValidationAdornerProperty) as TemplatedAdorner;
                if (show && templatedAdorner == null)
                {
                    ControlTemplate errorTemplate = Validation.GetErrorTemplate(uielement);
                    if (errorTemplate == null)
                    {
                        errorTemplate = Validation.GetErrorTemplate(targetElement);
                    }
                    if (errorTemplate != null)
                    {
                        templatedAdorner = new TemplatedAdorner(uielement, errorTemplate);
                        adornerLayer.Add(templatedAdorner);
                        uielement.SetValue(Validation.ValidationAdornerProperty, templatedAdorner);
                        return;
                    }
                }
                else if (!show && templatedAdorner != null)
                {
                    templatedAdorner.ClearChild();
                    adornerLayer.Remove(templatedAdorner);
                    uielement.ClearValue(Validation.ValidationAdornerProperty);
                }
            }
        }
Exemple #5
0
        // Token: 0x06005119 RID: 20761 RVA: 0x0016BE2C File Offset: 0x0016A02C
        private static void OnTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Label     label      = (Label)d;
            UIElement uielement  = (UIElement)e.OldValue;
            UIElement uielement2 = (UIElement)e.NewValue;

            if (uielement != null)
            {
                object value = uielement.GetValue(Label.LabeledByProperty);
                if (value == label)
                {
                    uielement.ClearValue(Label.LabeledByProperty);
                }
            }
            if (uielement2 != null)
            {
                uielement2.SetValue(Label.LabeledByProperty, label);
            }
        }
Exemple #6
0
        private static void UnregisterToolTip(UIElement owner)
        {
            Debug.Assert(owner != null, "owner element is required"); 
 
            if (owner.GetValue (AssignedToolTipProperty) == null)
            { 
                return;
            }
 
            owner.MouseEnter -= new MouseEventHandler(OnOwnerMouseEnter);
            owner.MouseLeave -= new MouseEventHandler(OnOwnerMouseLeave);
            owner.MouseLeftButtonDown -= new MouseButtonEventHandler(OnOwnerMouseLeftButtonDown); 
            owner.KeyDown -= new KeyEventHandler(OnOwnerKeyDown); 

            ToolTip toolTip = (ToolTip) owner.GetValue (AssignedToolTipProperty);
            if (toolTip.IsOpen)
            {
                if (toolTip == ToolTipService._currentToolTip) 
                {
                    // unregistering a currently open automatic toltip
                    // thus need to stop the timer 
                    ToolTipService._closeTimer.Stop(); 
                    ToolTipService._currentToolTip = null;
                    ToolTipService._owner = null; 
                    ToolTipService._lastEnterSource = null;
                }
 
                toolTip.IsOpen = false;
            }
 
            owner.ClearValue (AssignedToolTipProperty);
        }
Exemple #7
0
        protected sealed override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            ItemCollection itemCollection        = ItemsOwner?.Items;
            NotifyCollectionChangedAction action = args.Action;

            if (action == NotifyCollectionChangedAction.Reset)
            {
                OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action));
            }
            else if (itemCollection != null)
            {
                IItemContainerGenerator itemContainerGenerator = sender as IItemContainerGenerator;
                if (itemContainerGenerator != null)
                {
                    switch (action)
                    {
                    case NotifyCollectionChangedAction.Add:
                    {
                        int num4 = itemContainerGenerator.IndexFromGeneratorPosition(args.Position);
                        if (args.Position.Offset == 1)
                        {
                            num4 = itemCollection.Count - 1;
                        }
                        VirtualItemsList changedItems2 = new VirtualItemsList(itemCollection, num4, args.ItemCount);
                        if (!IsVirtualizing)
                        {
                            for (int k = num4; k < num4 + args.ItemCount; k++)
                            {
                                RealizeItem(k);
                            }
                        }
                        OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action, changedItems2, num4));
                        break;
                    }

                    case NotifyCollectionChangedAction.Remove:
                    {
                        int       num5      = itemContainerGenerator.IndexFromGeneratorPosition(args.Position);
                        ArrayList arrayList = new ArrayList(args.ItemCount);
                        for (int l = 0; l < args.ItemUICount; l++)
                        {
                            UIElement uIElement = base.InternalChildren[args.Position.Index + l];
                            arrayList.Add(ItemFromContainer(uIElement));
                            if (num5 == -1)
                            {
                                num5 = (int)uIElement.ReadLocalValue(IndexForItemContainerProperty);
                            }
                            uIElement.ClearValue(IndexForItemContainerProperty);
                        }
                        if (args.ItemUICount > 0)
                        {
                            RemoveInternalChildRange(args.Position.Index, args.ItemUICount);
                        }
                        OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action, arrayList, num5));
                        break;
                    }

                    case NotifyCollectionChangedAction.Move:
                    {
                        int num2 = -1;
                        int num3 = itemContainerGenerator.IndexFromGeneratorPosition(args.Position);
                        VirtualItemsList changedItems = new VirtualItemsList(itemCollection, num3, args.ItemCount);
                        int itemUICount = args.ItemUICount;
                        if (itemUICount > 0)
                        {
                            UIElement[] array = new UIElement[itemUICount];
                            for (int i = 0; i < itemUICount; i++)
                            {
                                array[i] = base.InternalChildren[args.OldPosition.Index + i];
                                if (num2 == -1)
                                {
                                    num2 = (int)array[i].ReadLocalValue(IndexForItemContainerProperty);
                                }
                            }
                            RemoveInternalChildRange(args.OldPosition.Index + Math.Min(args.OldPosition.Offset, 1), itemUICount);
                            for (int j = 0; j < itemUICount; j++)
                            {
                                InsertInternalChild(args.Position.Index + j, array[j]);
                            }
                        }
                        OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action, changedItems, num3, num2));
                        break;
                    }

                    case NotifyCollectionChangedAction.Replace:
                    {
                        int num = itemContainerGenerator.IndexFromGeneratorPosition(args.Position);
                        VirtualItemsList newItems = new VirtualItemsList(itemCollection, num, args.ItemCount);
                        VirtualItemsList oldItems = new VirtualItemsList(null, num, args.ItemCount);
                        OnItemsChanged(itemCollection, new NotifyCollectionChangedEventArgs(action, newItems, oldItems, num));
                        break;
                    }
                    }
                }
            }
            base.OnItemsChanged(sender, args);
            InvalidateReality();
        }