Пример #1
0
 private void CheckLayerExist(LayerController layer)
 {
     if (!layers.Exists(x => x == layer))
     {
         throw new ArgumentException("This slice doesn't contain given layer.");
     }
 }
Пример #2
0
        private void AddLayer(LayerController layer, int id = 0)
        {
            layers.Insert(id, layer);

            for (int i = LayerCount - 1; i >= id; i -= 1)
            {
                layers[i].SetId(i);
            }
        }
Пример #3
0
        private void RemoveLayer(LayerController layer)
        {
            int layerId = layer.GetId();

            layers.RemoveAt(layerId);

            for (int i = layerId; i < LayerCount; i += 1)
            {
                layers[i].SetId(i);
            }
        }
Пример #4
0
        internal void SwapLayers(int id1, int id2)
        {
            layers[id1].SetId(id2);
            layers[id2].SetId(id1);

            LayerController layer1 = layers[id1];

            layers[id1] = layers[id2];
            layers[id2] = layer1;

            UpdateUI();
        }
Пример #5
0
        internal void TransferLayer(LayerController layer, SliceController slice, int id = 0)
        {
            if (slice == this)
            {
                throw new ArgumentException("New slice can't be this slice.");
            }
            CheckLayerExist(layer);

            int slicesStart, slicesEnd;

            if (this.id < slice.id)
            {
                slicesStart = this.id;
                slicesEnd   = slice.id;
            }
            else
            {
                slicesStart = slice.id;
                slicesEnd   = this.id;
            }
            List <SliceController> slices = timeline.GetSlices(slicesStart, slicesEnd - slicesStart + 1);

            RemoveLayer(layer);
            slice.AddLayer(layer, id);

            foreach (SliceController timelineSlice in slices)
            {
                timelineSlice.UpdateCache();
            }

            if (Disowning != null)
            {
                Disowning.Invoke(this, new DisownEventArgs(layer, slice));
            }

            foreach (SliceController timelineSlice in slices)
            {
                timelineSlice.UpdateUI();
                timelineSlice.InvokeLocationChanged(new LocationChangeEventArgs(false, true));
            }

            InvokeSizeChanged();
            slice.InvokeSizeChanged();
        }
Пример #6
0
        internal LayerController CreateLayer(int id)
        {
            LayerController layer = new LayerController(this, id);

            AddLayer(layer, id);

            UpdateCache();

            List <SliceController> slices = timeline.GetSlices(this.id, timeline.SliceCount - this.id);

            UpdateSlicesCache(slices);
            UpdateSlicesUI(slices);

            UpdateUI();

            InvokeLocationChanged(new LocationChangeEventArgs(false, true));
            InvokeSizeChanged();

            return(layer);
        }
Пример #7
0
        internal void TransferItem(ItemController item, LayerController layer)
        {
            if (layer == this)
            {
                throw new ArgumentException("Layer can't be this layer.");
            }
            if (!items.Exists(x => x == item))
            {
                throw new ArgumentException("This layer doesn't contain given item.");
            }

            RectangleProvider.InvalidateContentContainerRectangle(item.Rectangle);

            items.Remove(item);
            layer.items.Add(item);
            if (Disowning != null)
            {
                Disowning.Invoke(this, new DisownEventArgs(item, layer));
            }

            RectangleProvider.InvalidateContentContainerRectangle(item.Rectangle);
        }
Пример #8
0
        /// <summary>
        /// Removes the layer from slice and deletes it. To move layer to another slice use TransferLayer() instead.
        /// </summary>
        internal void DeleteLayer(LayerController layer)
        {
            CheckLayerExist(layer);
            RemoveLayer(layer);
            layer.Delete();

            if (layers.Count == 0)
            {
                AddLayer(new LayerController(this));
            }

            if (id < timeline.SliceCount)
            {
                List <SliceController> slices = timeline.GetSlices(id, timeline.SliceCount - id);
                UpdateSlicesCache(slices);
                UpdateSlicesUI(slices);
            }

            InvokeLocationChanged(new LocationChangeEventArgs(false, true));
            InvokeSizeChanged();

            rectangleProvider.Invalidate();
        }
Пример #9
0
 internal void SwapLayers(LayerController layer1, LayerController layer2)
 {
     SwapLayers(layer1.GetId(), layer2.GetId());
 }
Пример #10
0
 internal int GetLayerId(LayerController layer)
 {
     return(layers.IndexOf(layer));
 }