Ejemplo n.º 1
0
        /// <summary>Shows a context menu to change the order of the layers</summary>
        /// <param name="pos">The position to show the context menu</param>
        private void showContextMenu(Point pos)
        {
            // If the context menu hasn't been created, create one
            ContextMenu ctxMenu = new ContextMenu();
            ctxMenu.MenuItems.Add(new MenuItem("Plaats naar bovenste niveau",
                (object o, EventArgs ea) => { schetscontrol.ChangeLayerOrder(ctxActiveLayer, SchetsControl.ReorderActions.SendToTop); }));
            ctxMenu.MenuItems.Add(new MenuItem("Plaats één niveau naar boven",
                (object o, EventArgs ea) => { schetscontrol.ChangeLayerOrder(ctxActiveLayer, SchetsControl.ReorderActions.OneUp); })); ;
            ctxMenu.MenuItems.Add(new MenuItem("Plaats één niveau naar onder",
                (object o, EventArgs ea) => { schetscontrol.ChangeLayerOrder(ctxActiveLayer, SchetsControl.ReorderActions.OneDown); }));
            ctxMenu.MenuItems.Add(new MenuItem("Plaats naar onderste niveau",
                (object o, EventArgs ea) => { schetscontrol.ChangeLayerOrder(ctxActiveLayer, SchetsControl.ReorderActions.SendToBottom); }));

            // Determine if a layer was clicked
            // To do so, we loop through the layers from top to bottom
            ctxActiveLayer = null;
            int layerIndex = schetscontrol.Schets.Layers.Count;
            for(; layerIndex != 0; --layerIndex)
            {
                // Check if we found a layer at the given position
                if(schetscontrol.Schets.Layers[layerIndex - 1].IsClicked(pos))
                {
                    ctxActiveLayer = schetscontrol.Schets.Layers[layerIndex - 1];
                    break;
                }
            }
            --layerIndex;

            // If a layer was clicked, we show the context menu
            if(ctxActiveLayer != null)
            {
                ctxMenu.MenuItems[0].Enabled = layerIndex != schetscontrol.Schets.Layers.Count - 1;
                ctxMenu.MenuItems[1].Enabled = layerIndex != schetscontrol.Schets.Layers.Count - 1;
                ctxMenu.MenuItems[2].Enabled = layerIndex != 0;
                ctxMenu.MenuItems[3].Enabled = layerIndex != 0;
                ctxMenu.Show(this, pos);
            }
        }
Ejemplo n.º 2
0
 public virtual void MuisVast(SchetsControl s, Point p)
 {
     color = s.PenKleur;
     penWidth = s.PenWidth;
     startpunt = p;
     edittingLayer = null;
 }
Ejemplo n.º 3
0
        /// <summary>Change the order of the layers by changing the z-index of the given layer</summary>
        /// <param name="layer">The layer whose z-index is to be changed</param>
        /// <param name="action">How the z-index of the layer should be changed</param>
        public void ChangeLayerOrder(Layer layer, ReorderActions action)
        {
            // If no layer is given, stop here
            if(layer == null) return;

            // Find the current index of the layer and determine it's new index
            int currIndex = Schets.Layers.IndexOf(layer);
            int newIndex = currIndex;
            switch(action)
            {
                case ReorderActions.SendToTop:
                    if(newIndex == Schets.Layers.Count - 1) return;
                    newIndex = Schets.Layers.Count - 1;
                    break;

                case ReorderActions.OneUp:
                    if(newIndex == Schets.Layers.Count - 1) return;
                    ++newIndex;
                    break;

                case ReorderActions.OneDown:
                    if(newIndex == 0) return;
                    --newIndex;
                    break;

                case ReorderActions.SendToBottom:
                    if(newIndex == 0) return;
                    newIndex = 0;
                    break;
            }

            // Change the z-index of the layer
            Schets.Layers.RemoveAt(currIndex);
            Schets.Layers.Insert(newIndex, layer);

            // Commit the action
            CommitAction(new SchetsActionReorder(currIndex, newIndex));

            // Redraw
            Invalidate();
        }
Ejemplo n.º 4
0
 // Commit the move action when the tool changes
 public virtual void ToolChange(SchetsControl s)
 {
     if(selectedLayer != null)
     {
         s.CommitAction(new SchetsActionMove(selectedLayer, selectedLayer.Location.X - oldLayerPos.X, selectedLayer.Location.Y - oldLayerPos.Y));
         s.Invalidate();
         selectedLayer = null;
     }
 }
Ejemplo n.º 5
0
 public virtual void MuisVast(SchetsControl s, Point p)
 {
     // Loop through the layers from top to bottom to determine whether a layer is selected
     for(int i = s.Schets.Layers.Count; i != 0; --i)
     {
         // Check if we found a layer at the given position
         if(s.Schets.Layers[i - 1].IsClicked(p))
         {
             selectedLayer = s.Schets.Layers[i - 1];
             oldLayerPos = selectedLayer.Location;
             lastPoint = p;
             break;
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>Construct the action</summary>
 /// <param name="layer">The layer that is added to the SchetsControl</param>
 public SchetsActionAddLayer(Layer layer)
 {
     addedLayer = layer;
 }
Ejemplo n.º 7
0
 /// <summary>Construct the action</summary>
 /// <param name="layer">The layer that was removed from the SchetsControl</param>
 /// <param name="i">The index of the layer</param>
 public SchetsActionRemoveLayer(Layer layer, int i)
 {
     removedLayer = layer;
     index = i;
 }
Ejemplo n.º 8
0
 /// <summary>Constructor</summary>
 /// <param name="l">The layer that was moved</param>
 /// <param name="deltaX">The horizontal movement</param>
 /// <param name="deltaY">The vertical movement</param>
 public SchetsActionMove(Layer l, int deltaX, int deltaY)
 {
     layer = l;
     dx = deltaX;
     dy = deltaY;
 }