Esempio n. 1
0
        /// <summary>
        /// Shows the progress overlay
        /// </summary>
        /// <param name="message">Message to display in the progress</param>
        public void Show(string message)
        {
            if (!isShowing)
            {
                if (progressOverlay == null)
                {
                    progressOverlay =
                        XamlReader.Load(progressOverlayTemplate) as Coding4Fun.Toolkit.Controls.ProgressOverlay;
                }

                Grid newParent = Mowbly.ActivePhoneApplicationPage.GetContentPanel();
                // Remove the progress overlay from the current parent if available
                // and if the new parent and the old parent is not same
                if (parent != null && !newParent.Equals(parent))
                {
                    UIElementCollection children = parent.Children;
                    if (children.Contains(progressOverlay))
                    {
                        children.Remove(progressOverlay);
                    }
                }

                // Add it the the new parent
                parent = newParent;
                parent.Children.Add(progressOverlay);
                progressOverlay.Show();
                isShowing = true;
                // Set progressbar indeterminate to true
                ((ProgressBar)((StackPanel)progressOverlay.Content).Children[1]).IsIndeterminate = true;
            }

            // Set the message
            ((TextBlock)((StackPanel)progressOverlay.Content).Children[0]).Text = message;
        }
        private void AddChild(UIElement element)
        {
            if (element == null)
            {
                return;
            }

            if (!_children.Contains(element))
            {
                _children.Add(element);

                OnVisualChildrenChanged(element, null);

                InvalidateMeasure();
                InvalidateArrange();
            }
        }
Esempio n. 3
0
 private void btnBack_Click(object sender, RoutedEventArgs e)
 {
     if (this.Parent != null)
     {
         UIElementCollection children = ((Panel)this.Parent).Children;
         if (children.Contains(this))
         {
             children.Remove(this);
         }
     }
 }
Esempio n. 4
0
        public bool HasMoveable(Moveable moveable, string bagName)
        {
            if (moveable == null)
            {
                throw new ArgumentNullException("moveable");
            }

            UIElementCollection moveables = GetMoveables(bagName);

            return(moveables.Contains(moveable));
        }
Esempio n. 5
0
        private void KinectTileButton_Click(object sender, RoutedEventArgs e)
        {
            if (homePage == null)
            {
                homePage = new HomePage((SystemStatusCollection)this.DataContext);
            }

            UIElementCollection children = ((Panel)this.Parent).Children;

            if (!children.Contains(homePage))
            {
                children.Add(homePage);
            }
        }
Esempio n. 6
0
        private void btnLearn_Click(object sender, RoutedEventArgs e)
        {
            if (signBrowserPage == null)
            {
                signBrowserPage = new SignBrowserPage((SystemStatusCollection)this.DataContext);
            }

            UIElementCollection children = ((Panel)this.Parent).Children;

            if (!children.Contains(signBrowserPage))
            {
                children.Add(signBrowserPage);
            }
        }
Esempio n. 7
0
        public void AddSameName()
        {
            UIElementCollection uiec = GetUIElementCollection();

            Assert.AreEqual(0, uiec.Count, "Count-0");

            Slider s1 = new Slider();

            s1.Name = "MySlider";
            uiec.Add(s1);
            Assert.AreEqual(1, uiec.Count, "Count-1");

            Slider s2 = new Slider();

            s2.Name = "MySlider";
            Assert.IsTrue(uiec.Contains(s1), "Contains(s1)-1");
            Assert.IsFalse(uiec.Contains(s2), "Contains(s2)-1");

            uiec.Add(s2);
            Assert.AreEqual(2, uiec.Count, "Count-2");

            Assert.IsTrue(uiec.Contains(s1), "Contains(s1)-2");
            Assert.IsTrue(uiec.Contains(s2), "Contains(s2)-2");
        }
Esempio n. 8
0
        internal virtual void ManageChildrenChanged(UIElementCollection oldChildren, UIElementCollection newChildren)
        {
            if (oldChildren != null)
            {
                // Detach old children only if they are not in the "newChildren" collection:
                foreach (UIElement child in oldChildren) //note: there is no setter for Children so the user cannot change the order of the elements in one step --> we cannot have the same children in another order (which would keep the former order with the way it is handled now) --> no problem here
                {
#if PERFSTAT
                    var t2 = Performance.now();
#endif
                    if (newChildren == null || !newChildren.Contains(child))
                    {
#if PERFSTAT
                        Performance.Counter("Panel.ManageChildrenChanged 'Contains'", t2);
#endif
                        INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(child, this);
                    }
                    else
                    {
#if PERFSTAT
                        Performance.Counter("Panel.ManageChildrenChanged 'Contains'", t2);
#endif
                    }
                }
            }
            if (newChildren != null)
            {
                // Note: we attach all the children (regardless of whether they are in the oldChildren collection or not) to make it work when the item is first added to the Visual Tree (at that moment, all the properties are refreshed by calling their "Changed" method).

                if (this.EnableProgressiveRendering)
                {
                    this.ProgressivelyAttachChildren(newChildren);
                }
                else
                {
                    foreach (UIElement child in newChildren)
                    {
#if REWORKLOADED
                        this.AddVisualChild(child);
#else
                        INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(child, this);
#endif
                    }
                }
            }
        }
Esempio n. 9
0
        public void ArgumentChecks()
        {
            Canvas canvas         = new Canvas();
            UIElementCollection c = canvas.Children;

            Assert.Throws <ArgumentNullException> (() => c.Add(null), "Add");
            Assert.Throws <ArgumentNullException> (() => c.Insert(0, null), "Insert null");
            Assert.Throws <ArgumentOutOfRangeException> (() => c.Insert(-1, new Rectangle()), "Insert negative");
            Assert.Throws <ArgumentOutOfRangeException> (() => c.RemoveAt(-1), "RemoveAt negative");
            Assert.Throws <ArgumentOutOfRangeException> (() => Console.WriteLine(c [-1] == null), "this getter");
            Assert.Throws <ArgumentOutOfRangeException> (() => c [-1] = new Rectangle(), "this setter");

            Assert.IsFalse(c.Contains(null), "Contains");
            Assert.IsFalse(c.Remove(null), "Remove");

            Assert.AreEqual(-1, c.IndexOf(null), "IndexOf");
        }
Esempio n. 10
0
        private void btnSignWord_Click(object sender, RoutedEventArgs e)
        {
            KinectTileButton button = (KinectTileButton)sender;

            if (signWordPage == null)
            {
                signWordPage = new SignWordPage((SystemStatusCollection)this.DataContext);
            }
            ((SystemStatusCollection)this.DataContext).CurrentSignWord = ((SignWord)button.DataContext);

            UIElementCollection children = ((Panel)this.Parent).Children;

            if (!children.Contains(signWordPage))
            {
                children.Add(signWordPage);
            }
        }
Esempio n. 11
0
        /// <summary>
        ///  Hides the progress overlay
        ///  Raises OnHide event which can be listened by any page and UI changes done
        /// </summary>
        public void Hide()
        {
            if (progressOverlay != null)
            {
                // Hide and set indeterminate false on progressbar to save battery
                progressOverlay.Hide();
                ((ProgressBar)((StackPanel)progressOverlay.Content).Children[1]).IsIndeterminate = false;

                // Remove from parent
                if (parent != null)
                {
                    UIElementCollection children = parent.Children;
                    if (children.Contains(progressOverlay))
                    {
                        children.Remove(progressOverlay);
                    }
                }
            }
            isShowing = false;
        }
Esempio n. 12
0
        public override bool Merge(CommandItem newitem)
        {
            ElementAddOrRem newitemx = newitem as ElementAddOrRem;

            if (newitemx == null ||
                newitemx._editingMode != _editingMode ||
                newitemx._editingOperationCount != _editingOperationCount)
            {
                return(false);
            }

            // We only implement merging for repeated point-erase operations.
            if (_editingMode != InkCanvasEditingMode.EraseByPoint)
            {
                return(false);
            }
            if (newitemx._editingMode != InkCanvasEditingMode.EraseByPoint)
            {
                return(false);
            }

            // Note: possible for point-erase to have hit intersection of >1 strokes!
            // For each newly hit stroke, merge results into this command item.
            foreach (UIElement doomed in newitemx._removed)
            {
                if (_added.Contains(doomed))
                {
                    _added.Remove(doomed);
                }
                else
                {
                    _removed.Add(doomed);
                }
            }
            for (int i = 0; i < newitemx._added.Count; i++)
            {
                _added.Add(newitemx._added[i]);
            }
            return(true);
        }
Esempio n. 13
0
 /// <inheritdoc />
 public bool Contains(Inline item) => _collection.Contains(item);
Esempio n. 14
0
        static void ManageChildrenChanged(DependencyObject d, UIElementCollection oldChildren, UIElementCollection newChildren)
        {
#if PERFSTAT
            var t1 = Performance.now();
#endif

            Panel parent = (Panel)d;
            if (parent is DockPanel)
            {
                ((DockPanel)parent).ManageChildrenChanged(oldChildren, newChildren);
            }
            else
            {
                bool isCSSGrid = Grid_InternalHelpers.isCSSGridSupported();
                if (!isCSSGrid && parent is Grid)
                {
                    ((Grid)parent).ManageChildrenChanged(oldChildren, newChildren);
                }
                else
                {
                    if (oldChildren != null)
                    {
                        //// Put the list in a HashSet for performant lookup:
                        //HashSet<UIElement> newChidrenHashSet = new HashSet<UIElement>();
                        //if (newChildren != null)
                        //{
                        //    foreach (UIElement child in newChildren)
                        //        newChidrenHashSet.Add(child);
                        //}
                        //// Detach old children only if they are not in the "newChildren" collection:
                        //foreach (UIElement child in oldChildren)
                        //{
                        //    if (newChildren == null || !newChidrenHashSet.Contains(child)) //todo: verify that in the produced JavaScript, "newChidrenHashSet.Contains" has still a O(1) complexity.
                        //    {
                        //        INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(child, parent);
                        //    }
                        //}

                        //todo: use HashSet version.

                        // Detach old children only if they are not in the "newChildren" collection:
                        foreach (UIElement child in oldChildren) //note: there is no setter for Children so the user cannot change the order of the elements in one step --> we cannot have the same children in another order (which would keep the former order with the way it is handled now) --> no problem here
                        {
#if PERFSTAT
                            var t2 = Performance.now();
#endif
                            if (newChildren == null || !newChildren.Contains(child))
                            {
#if PERFSTAT
                                Performance.Counter("Panel.ManageChildrenChanged 'Contains'", t2);
#endif
                                INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(child, parent);
                            }
                            else
                            {
#if PERFSTAT
                                Performance.Counter("Panel.ManageChildrenChanged 'Contains'", t2);
#endif
                            }
                        }
                    }
                    if (newChildren != null)
                    {
                        foreach (UIElement child in newChildren)
                        {
                            // Note: we do this for all items (regardless of whether they are in the oldChildren collection or not) to make it work when the item is first added to the Visual Tree (at that moment, all the properties are refreshed by calling their "Changed" method).
                            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(child, parent);
                        }
                    }

                    if (parent is Grid)
                    {
                        ((Grid)parent).LocallyManageChildrenChanged();
                    }
                }
            }
        }
        protected override Size MeasureOverride(Size availableSize)
        {
            Size desiredSize = new Size();
            UIElementCollection     children  = InternalChildren;
            IItemContainerGenerator generator = ItemContainerGenerator;

            int itemsCount = 0;

            if (generator != null)
            {
                int StartItemIndex = navigationPane.GetFirstItemIndex(DisplayType);
                if (StartItemIndex > -1)
                {
                    int maxItems = DisplayType == NavigationPaneItemDisplayType.Large ? navigationPane.LargeItems : int.MaxValue;
                    GeneratorPosition startPos = new GeneratorPosition(-1, StartItemIndex + 1);

                    using (generator.StartAt(startPos, GeneratorDirection.Forward, true))
                    {
                        bool sizeExceeded = false;

                        bool      newlyRealized;
                        UIElement child = null;

                        // temp fix for {Disconnected Item}
                        // needs more inspecting and documentation to fix it correctly !!
                        // but this for now seems to work... strange items present ??
                        // remove them, NOW !!!!!
                        //for (int j = children.Count - 1; j > -1; j--)
                        //{
                        //UIElement item = children[j];
                        //object o = navigationPane.ItemContainerGenerator.ItemFromContainer(item);
                        //if (o == DependencyProperty.UnsetValue)
                        // RemoveInternalChild(item);
                        //}

                        while (!sizeExceeded && (itemsCount < maxItems) && (child = generator.GenerateNext(out newlyRealized) as UIElement) != null)
                        {
                            bool isExcluded = NavigationPane.GetIsItemExcluded(child);
                            if (!isExcluded)
                            {
                                if (newlyRealized || !children.Contains(child))
                                {
                                    int absoluteIndex = StartItemIndex + itemsCount;
                                    int index         = GetInsertIndex(absoluteIndex);

                                    if (absoluteIndex < 9 && navigationPane.ItemsKeyAuto)
                                    {
                                        NavigationPaneItem f = child as NavigationPaneItem;
                                        {
                                            Window w = Window.GetWindow(child);
                                            if (w != null)
                                            {
                                                KeyBinding binding = f.keyBinding;
                                                if (binding != null)
                                                {
                                                    w.InputBindings.Remove(binding);
                                                }

                                                f.keyBinding = new KeyBinding(NavigationPane.SelectItemCommand, Key.D1 + absoluteIndex, navigationPane.ItemsKeyModifiers);
                                                f.keyBinding.CommandParameter = child;
                                                f.keyBinding.CommandTarget    = navigationPane;
                                                w.InputBindings.Add(f.keyBinding);

                                                if (f != null)
                                                {
                                                    f.Gesture = (f.keyBinding.Gesture as KeyGesture).GetDisplayStringForCulture(CultureInfo.CurrentCulture);
                                                }
                                            }
                                        }
                                    }
                                    SetActivePanel(child, this);
                                    SetAbosluteIndex(child, absoluteIndex);
                                    SetItemDisplayType(child, DisplayType);

                                    if (newlyRealized)
                                    {
                                        generator.PrepareItemContainer(child);
                                    }

                                    InsertInternalChild(index, child);
                                }

                                #region measurament algoritm
                                Size childSize = new Size();
                                if (Orientation == Orientation.Vertical)
                                {
                                    childSize = new Size(availableSize.Width, double.PositiveInfinity);
                                }
                                else
                                {
                                    childSize = new Size(double.PositiveInfinity, availableSize.Height);
                                }

                                child.Measure(childSize);

                                if (Orientation == Orientation.Vertical)
                                {
                                    sizeExceeded = desiredSize.Height + child.DesiredSize.Height > availableSize.Height;
                                    if (!sizeExceeded)
                                    {
                                        desiredSize.Width   = Math.Max(desiredSize.Width, child.DesiredSize.Width);
                                        desiredSize.Height += child.DesiredSize.Height;
                                    }
                                }
                                else
                                {
                                    sizeExceeded = desiredSize.Width + child.DesiredSize.Width > availableSize.Width;
                                    if (!sizeExceeded)
                                    {
                                        desiredSize.Width += child.DesiredSize.Width;
                                        desiredSize.Height = Math.Max(desiredSize.Height, child.DesiredSize.Height);
                                    }
                                }
                                #endregion

                                if (!sizeExceeded)
                                {
                                    itemsCount++;
                                }
                            }
                            else
                            {
                                RemoveInternalChild(child);
                            }
                        }
                    }
                    CleanUpItems(StartItemIndex, itemsCount);
                }
            }

            if (DisplayType == NavigationPaneItemDisplayType.Small)
            {
                navigationPane.SmallItems = itemsCount;
            }
            return(desiredSize);
        }
 public bool Contains(ListBoxItem item)
 {
     return(_items.Contains(item));
 }
Esempio n. 17
0
 public bool Contains(IContent value)
 {
     return(_children.Contains((UIElement)value.Control));
 }