Exemplo n.º 1
0
 private void NavigateBack()
 {
     OnNavigateBack?.Invoke(this, EventArgs.Empty);
     CurrentStep = Steps[Steps.IndexOf(CurrentStep) - 1];
 }
Exemplo n.º 2
0
        /// <inheritdoc />
        public override bool OnKeyDown(Keys key)
        {
            // Navigate backward
            if (key == Keys.Backspace)
            {
                OnNavigateBack?.Invoke();
                return(true);
            }

            // Select all
            if (key == Keys.A && ParentWindow.GetKey(Keys.Control))
            {
                SelectAll();
                return(true);
            }

            // Check if sth is selected
            if (HasSelection)
            {
                // Delete selection
                if (key == Keys.Delete)
                {
                    OnDelete?.Invoke(_selection);
                    return(true);
                }

                // Open
                if (key == Keys.Return && _selection.Count == 1)
                {
                    OnOpen?.Invoke(_selection[0]);
                    return(true);
                }

                // Duplicate
                if (key == Keys.D && ParentWindow.GetKey(Keys.Control))
                {
                    DuplicateSelection();
                    return(true);
                }

                // Movement with arrows
                {
                    var         root   = _selection[0];
                    Vector2     size   = root.Size;
                    Vector2     offset = Vector2.Minimum;
                    ContentItem item   = null;
                    if (key == Keys.ArrowUp)
                    {
                        offset = new Vector2(0, -size.Y);
                    }
                    else if (key == Keys.ArrowDown)
                    {
                        offset = new Vector2(0, size.Y);
                    }
                    else if (key == Keys.ArrowRight)
                    {
                        offset = new Vector2(size.X, 0);
                    }
                    else if (key == Keys.ArrowLeft)
                    {
                        offset = new Vector2(-size.X, 0);
                    }
                    if (offset != Vector2.Minimum)
                    {
                        item = GetChildAt(root.Location + size / 2 + offset) as ContentItem;
                    }
                    if (item != null)
                    {
                        OnItemClick(item);
                        return(true);
                    }
                }
            }

            return(base.OnKeyDown(key));
        }