Beispiel #1
0
        private void MainCanvas_KeyDown(object sender, KeyEventArgs e)
        {
            if (EditMode == EditMode.Normal)
            {
                if (currentShape != null)
                {
                    Shape shape = currentShape;
                    var args = new ShapeKeyEventArgs
                               {SnapToGrid = SnapToGrid, Sender = this, GridSize = GridSize, Key = e.KeyCode};

                    shape.OnKeyPress(args);

                    if (args.Redraw)
                        Refresh();
                }
            }
        }
Beispiel #2
0
 public virtual void OnKeyPress(ShapeKeyEventArgs args)
 {
 }
        public override void OnKeyPress(ShapeKeyEventArgs args)
        {
            if (SelectedObject == null && args.Key == Keys.Enter)
            {
                BeginRenameType(args.Sender);
            }

            if (SelectedObject != null && args.Key == Keys.Enter)
            {
                if (SelectedObject is UmlTypeMember)
                {
                    BeginRenameProperty(args.Sender, (UmlTypeMember) SelectedObject);
                }
            }

            if (SelectedObject == null && args.Key == Keys.Delete)
            {
                args.Sender.Diagram.Shapes.Remove(this);
                args.Redraw = true;
            }

            if (SelectedObject != null && args.Key == Keys.Delete)
            {
                if (SelectedObject is UmlTypeMember)
                {
                    DeleteSelectedMember();
                    args.Redraw = true;
                }
            }
        }