Exemple #1
0
        // Adds a new layer above the current one
        public UserLayer AddNewLayer(string name)
        {
            UserLayer layer;

            if (string.IsNullOrEmpty(name))
            {
                layer = CreateLayer();
            }
            else
            {
                layer = CreateLayer(name);
            }

            UserLayers.Insert(current_layer + 1, layer);

            if (UserLayers.Count == 1)
            {
                current_layer = 0;
            }

            layer.PropertyChanged += RaiseLayerPropertyChangedEvent;

            PintaCore.Layers.OnLayerAdded();
            return(layer);
        }
Exemple #2
0
        // Adds a new layer above the current one
        public void Insert(UserLayer layer, int index)
        {
            UserLayers.Insert(index, layer);

            if (UserLayers.Count == 1)
            {
                current_layer = 0;
            }

            layer.PropertyChanged += RaiseLayerPropertyChangedEvent;

            PintaCore.Layers.OnLayerAdded();
        }
Exemple #3
0
        // Move current layer up
        public void MoveCurrentLayerUp()
        {
            if (current_layer == UserLayers.Count)
            {
                throw new InvalidOperationException("Cannot move layer up because current layer is the top layer.");
            }

            UserLayer layer = CurrentUserLayer;

            UserLayers.RemoveAt(current_layer);
            UserLayers.Insert(++current_layer, layer);

            PintaCore.Layers.OnSelectedLayerChanged();

            Workspace.Invalidate();
        }
Exemple #4
0
        // Move current layer down
        public void MoveCurrentLayerDown()
        {
            if (current_layer == 0)
            {
                throw new InvalidOperationException("Cannot move layer down because current layer is the bottom layer.");
            }

            UserLayer layer = CurrentUserLayer;

            UserLayers.RemoveAt(current_layer);
            UserLayers.Insert(--current_layer, layer);

            PintaCore.Layers.OnSelectedLayerChanged();

            Workspace.Invalidate();
        }
Exemple #5
0
        // Duplicate current layer
        public UserLayer DuplicateCurrentLayer()
        {
            UserLayer source = CurrentUserLayer;
            UserLayer layer  = CreateLayer(string.Format("{0} {1}", source.Name, Catalog.GetString("copy")));

            using (Cairo.Context g = new Cairo.Context(layer.Surface)) {
                g.SetSource(source.Surface);
                g.Paint();
            }

            layer.Hidden  = source.Hidden;
            layer.Opacity = source.Opacity;
            layer.Tiled   = source.Tiled;

            UserLayers.Insert(++current_layer, layer);

            layer.PropertyChanged += RaiseLayerPropertyChangedEvent;

            PintaCore.Layers.OnLayerAdded();

            return(layer);
        }