コード例 #1
0
        /// <summary>
        /// Remove a layer from this collection.
        /// </summary>
        /// <param name="layer"></param>
        /// <remarks>
        /// If the layer is owned by this collection's container, this method
        /// calls <see cref="M:Northwoods.Go.GoLayer.Clear" /> on <paramref name="layer" />.
        /// The <see cref="M:Northwoods.Go.IGoLayerCollectionContainer.RaiseChanged(System.Int32,System.Int32,System.Object,System.Int32,System.Object,System.Drawing.RectangleF,System.Int32,System.Object,System.Drawing.RectangleF)" />
        /// call gets a <see cref="F:Northwoods.Go.GoLayerCollection.RemovedLayer" /> hint.
        /// </remarks>
        public bool Remove(GoLayer layer)
        {
            if (layer == null)
            {
                return(false);
            }
            int num = IndexOf(layer);

            if (num < 0)
            {
                return(false);
            }
            bool flag = layer.LayerCollectionContainer == LayerCollectionContainer;

            if (flag)
            {
                layer.Clear();
            }
            GoLayer goLayer = null;

            foreach (GoLayer myLayer in myLayers)
            {
                if (myLayer != layer && myLayer.LayerCollectionContainer == LayerCollectionContainer)
                {
                    goLayer = myLayer;
                    break;
                }
            }
            if (goLayer == null)
            {
                return(false);
            }
            GoLayer oldVal = null;

            checked
            {
                if (num + 1 < myLayers.Count)
                {
                    oldVal = myLayers[num + 1];
                }
                if (flag)
                {
                    layer.LayerCollectionIndex = -1;
                }
                myLayers.RemoveAt(num);
                UpdateLayerIndices();
                try
                {
                    LayerCollectionContainer.RaiseChanged(802, 0, layer, 0, oldVal, NullRect, 0, null, NullRect);
                }
                finally
                {
                    if (layer == Default)
                    {
                        Default = goLayer;
                    }
                }
                return(true);
            }
        }
コード例 #2
0
 internal void moveInCollection(int newidx, GoLayer moving, int oldidx, bool undoing)
 {
     if (oldidx >= 0 && oldidx < myLayers.Count && newidx >= 0 && newidx < myLayers.Count)
     {
         myLayers.RemoveAt(oldidx);
         myLayers.Insert(newidx, moving);
         UpdateLayerIndices();
     }
     LayerCollectionContainer.RaiseChanged(803, 0, this, oldidx, moving, NullRect, newidx, moving, NullRect);
 }
コード例 #3
0
        internal void InsertBefore(GoLayer dest, GoLayer newlayer)
        {
            if (dest == null)
            {
                dest = Bottom;
            }
            int num = IndexOf(dest);

            if (num >= 0)
            {
                myLayers.Insert(num, newlayer);
                UpdateLayerIndices();
                LayerCollectionContainer.RaiseChanged(801, 0, newlayer, num, dest, NullRect, num, newlayer, NullRect);
            }
        }
コード例 #4
0
        internal void InsertAfter(GoLayer dest, GoLayer newlayer)
        {
            if (dest == null)
            {
                dest = Top;
            }
            int num = IndexOf(dest);

            checked
            {
                if (num >= 0)
                {
                    myLayers.Insert(num + 1, newlayer);
                    UpdateLayerIndices();
                    LayerCollectionContainer.RaiseChanged(801, 1, newlayer, num, dest, NullRect, num + 1, newlayer, NullRect);
                }
            }
        }