コード例 #1
0
 private void PointsPropertyChanged()
 {
     if (Points == null || !Points.Any())
     {
         if (_children.Count > 4)
         {
             _children.RemoveRange(_children.Count - 4, 4);
         }
         else if (_children.Count > 1)
         {
             _children.RemoveRange(1, _children.Count - 1);
         }
     }
 }
コード例 #2
0
        // ------------------------------------------------------------------
        // Syncs a floating element para list with a visual collection
        // ------------------------------------------------------------------
        internal static void UpdateFloatingElementVisuals(ContainerVisual visual, List <BaseParaClient> floatingElementList)
        {
            VisualCollection visualChildren = visual.Children;
            int visualIndex = 0;

            if (floatingElementList == null || floatingElementList.Count == 0)
            {
                visualChildren.Clear();
            }
            else
            {
                for (int index = 0; index < floatingElementList.Count; index++)
                {
                    Visual paraVisual = floatingElementList[index].Visual;

                    while (visualIndex < visualChildren.Count && visualChildren[visualIndex] != paraVisual)
                    {
                        visualChildren.RemoveAt(visualIndex);
                    }

                    if (visualIndex == visualChildren.Count)
                    {
                        visualChildren.Add(paraVisual);
                    }

                    visualIndex++;
                }


                if (visualChildren.Count > floatingElementList.Count)
                {
                    visualChildren.RemoveRange(floatingElementList.Count, visualChildren.Count - floatingElementList.Count);
                }
            }
        }
コード例 #3
0
        // Token: 0x0600692C RID: 26924 RVA: 0x001DC364 File Offset: 0x001DA564
        internal static void UpdateFloatingElementVisuals(ContainerVisual visual, List <BaseParaClient> floatingElementList)
        {
            VisualCollection children = visual.Children;
            int num = 0;

            if (floatingElementList == null || floatingElementList.Count == 0)
            {
                children.Clear();
                return;
            }
            for (int i = 0; i < floatingElementList.Count; i++)
            {
                Visual visual2 = floatingElementList[i].Visual;
                while (num < children.Count && children[num] != visual2)
                {
                    children.RemoveAt(num);
                }
                if (num == children.Count)
                {
                    children.Add(visual2);
                }
                num++;
            }
            if (children.Count > floatingElementList.Count)
            {
                children.RemoveRange(floatingElementList.Count, children.Count - floatingElementList.Count);
            }
        }
コード例 #4
0
        public override void RemoveRange(int index, int count)
        {
            int actualCount = visualChildren.Count;

            if (count > (actualCount - index))
            {
                count = actualCount - index;
            }

            if (count > 0)
            {
                Visual[] visualArray = new Visual[count];
                int      copyIndex   = index;
                for (int i = 0; i < count; i++)
                {
                    visualArray[i] = visualChildren[copyIndex];
                    copyIndex++;
                }

                visualChildren.RemoveRange(index, count);

                for (int i = 0; i < count; i++)
                {
                    UIElement element = visualArray[i] as UIElement;
                    if (element != null)
                    {
                        ClearLogicalParent(element);
                    }
                }
            }
        }
コード例 #5
0
 public void Reset()
 {
     if (_children.Count > 1)
     {
         _children.RemoveRange(1, _children.Count - 1);
     }
 }
コード例 #6
0
        // Token: 0x06005950 RID: 22864 RVA: 0x0018ABA4 File Offset: 0x00188DA4
        internal void RemoveRangeInternal(int index, int count)
        {
            VisualCollection visualChildren = this._visualChildren;
            int count2 = visualChildren.Count;

            if (count > count2 - index)
            {
                count = count2 - index;
            }
            if (count > 0)
            {
                Visual[] array = new Visual[count];
                int      i     = index;
                for (int j = 0; j < count; j++)
                {
                    array[j] = visualChildren[i];
                    i++;
                }
                visualChildren.RemoveRange(index, count);
                for (i = 0; i < count; i++)
                {
                    UIElement uielement = array[i] as UIElement;
                    if (uielement != null)
                    {
                        this.ClearLogicalParent(uielement);
                    }
                }
                this._visualParent.InvalidateMeasure();
            }
        }
コード例 #7
0
        // ------------------------------------------------------------------
        // Update visuals for list of paragraphs.
        // ------------------------------------------------------------------
        internal static void UpdateParaListVisuals(
            PtsContext ptsContext,
            VisualCollection visualCollection,
            PTS.FSKUPDATE fskupdInherited,
            PTS.FSPARADESCRIPTION [] arrayParaDesc)
        {
            // For each paragraph, do following:
            // (1) Retrieve ParaClient object
            // (3) Update visual, if necessary
            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                // (1) Retrieve ParaClient object
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                // (2) Update visual, if necessary
                PTS.FSKUPDATE fskupd = arrayParaDesc[index].fsupdinf.fskupd;
                if (fskupd == PTS.FSKUPDATE.fskupdInherited)
                {
                    fskupd = fskupdInherited;
                }
                if (fskupd == PTS.FSKUPDATE.fskupdNew)
                {
                    // Disconnect visual from its old parent, if necessary.
                    Visual currentParent = VisualTreeHelper.GetParent(paraClient.Visual) as Visual;
                    if (currentParent != null)
                    {
                        ContainerVisual parent = currentParent as ContainerVisual;
                        Invariant.Assert(parent != null, "parent should always derives from ContainerVisual");
                        parent.Children.Remove(paraClient.Visual);
                    }

                    // New paragraph - insert new visual node
                    visualCollection.Insert(index, paraClient.Visual);

                    paraClient.ValidateVisual(fskupd);
                }
                else
                {
                    // Remove visuals for non-existing paragraphs
                    while (visualCollection[index] != paraClient.Visual)
                    {
                        visualCollection.RemoveAt(index);
                        Invariant.Assert(index < visualCollection.Count);
                    }

                    if (fskupd == PTS.FSKUPDATE.fskupdChangeInside || fskupd == PTS.FSKUPDATE.fskupdShifted)
                    {
                        paraClient.ValidateVisual(fskupd);
                    }
                }
            }
            // Remove obsolete visuals
            if (arrayParaDesc.Length < visualCollection.Count)
            {
                visualCollection.RemoveRange(arrayParaDesc.Length, visualCollection.Count - arrayParaDesc.Length);
            }
        }
コード例 #8
0
 // Token: 0x06006930 RID: 26928 RVA: 0x001DC5E0 File Offset: 0x001DA7E0
 internal static void UpdateParaListVisuals(PtsContext ptsContext, VisualCollection visualCollection, PTS.FSKUPDATE fskupdInherited, PTS.FSPARADESCRIPTION[] arrayParaDesc)
 {
     for (int i = 0; i < arrayParaDesc.Length; i++)
     {
         BaseParaClient baseParaClient = ptsContext.HandleToObject(arrayParaDesc[i].pfsparaclient) as BaseParaClient;
         PTS.ValidateHandle(baseParaClient);
         PTS.FSKUPDATE fskupdate = arrayParaDesc[i].fsupdinf.fskupd;
         if (fskupdate == PTS.FSKUPDATE.fskupdInherited)
         {
             fskupdate = fskupdInherited;
         }
         if (fskupdate == PTS.FSKUPDATE.fskupdNew)
         {
             Visual visual = VisualTreeHelper.GetParent(baseParaClient.Visual) as Visual;
             if (visual != null)
             {
                 ContainerVisual containerVisual = visual as ContainerVisual;
                 Invariant.Assert(containerVisual != null, "parent should always derives from ContainerVisual");
                 containerVisual.Children.Remove(baseParaClient.Visual);
             }
             visualCollection.Insert(i, baseParaClient.Visual);
             baseParaClient.ValidateVisual(fskupdate);
         }
         else
         {
             while (visualCollection[i] != baseParaClient.Visual)
             {
                 visualCollection.RemoveAt(i);
                 Invariant.Assert(i < visualCollection.Count);
             }
             if (fskupdate == PTS.FSKUPDATE.fskupdChangeInside || fskupdate == PTS.FSKUPDATE.fskupdShifted)
             {
                 baseParaClient.ValidateVisual(fskupdate);
             }
         }
     }
     if (arrayParaDesc.Length < visualCollection.Count)
     {
         visualCollection.RemoveRange(arrayParaDesc.Length, visualCollection.Count - arrayParaDesc.Length);
     }
 }
コード例 #9
0
        public void Update()
        {
            const int NUM_DOTS = 100;

            // Add a dot in a random color/location.
            Canvas c   = Parent as Canvas;
            Color  clr = Color.FromRgb((byte)_rand.Next(0, 255), (byte)_rand.Next(0, 255), (byte)_rand.Next(0, 255));
            int    x   = _rand.Next(0, (int)c.ActualWidth);
            int    y   = _rand.Next(0, (int)c.ActualHeight);

            // Draw it.
            DrawingVisual  vis     = new DrawingVisual();
            DrawingContext context = vis.RenderOpen();

            context.DrawEllipse(new SolidColorBrush(clr), null, new Point(x, y), 5.0, 5.0);
            // Close the DrawingContext to persist changes to the DrawingVisual.
            context.Close();

            _children.Add(vis);
            if (_children.Count > NUM_DOTS)
            {
                _children.RemoveRange(0, NUM_DOTS / 20);
            }
        }
コード例 #10
0
ファイル: UIElementCollection.cs プロジェクト: beda2280/wpf-1
        // Warning: this method is very dangerous because it does not prevent adding children
        // into collection populated by generator. This may cause crashes if used incorrectly.
        // Don't call this unless you are deriving a panel that is populating the collection
        // in cooperation with the generator
        internal void RemoveRangeInternal(int index, int count)
        {
            VisualCollection vc = _visualChildren;
            int cnt             = vc.Count;

            if (count > (cnt - index))
            {
                count = cnt - index;
            }

            if (count > 0)
            {
                // copy children in VisualCollection so that we can clear the visual link first,
                // followed by the logical link
                Visual[] visuals = new Visual[count];
                int      i       = index;
                for (int loop = 0; loop < count; i++, loop++)
                {
                    visuals[loop] = vc[i];
                }

                vc.RemoveRange(index, count);

                //disconnect from logical tree
                for (i = 0; i < count; i++)
                {
                    UIElement e = visuals[i] as UIElement;
                    if (e != null)
                    {
                        ClearLogicalParent(e);
                    }
                }

                _visualParent.InvalidateMeasure();
            }
        }
コード例 #11
0
 public void Clear()
 {
     children.RemoveRange(2, children.Count - 2);
     this.Objects.Clear();
 }
コード例 #12
0
 public void Clear()
 {
     children.RemoveRange(0, children.Count);
     Map.Clear();
     hexagonCenters.Clear();
 }