Пример #1
0
        // To handle the dragging of panels
        private static void PanelDrag(object sender, MouseEventArgs e)
        {
            foreach (Panel p in panels)
            {
                if (p.centered)
                {
                    p.Center();
                }

                if (!ResizeGrip.IsResizing() && p.dragging && !p.centered)
                {
                    // if predrag returns true, move the panel
                    if (p.PreDrag(e.X - p.dragOffsetX, e.Y - p.dragOffsetY))
                    {
                        p.SetPos(e.X - p.dragOffsetX, e.Y - p.dragOffsetY, !VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_TAB));
                        p.PostDrag();
                        RefreshProperties();

                        if (!VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_CONTROL))
                        {
                            continue;
                        }

                        List <Panel> panelsOver = GetPanelsMouseIsOver();
                        foreach (Panel pan in panelsOver)
                        {
                            if (pan != p && pan.canBeParent == true && p.parent != pan && p.canBeChild == true && (!p.parent || p.parent.z < pan.z))
                            {
                                if (p.hasParent && p.parent)
                                {
                                    if (p.parent.z < pan.z && pan.parent != p)
                                    {
                                        pan.highlighted = true;
                                        break;
                                    }
                                }
                                else
                                {
                                    pan.highlighted = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (Derma.GetSelected() == null)
            {
                return;
            }

            if (e.KeyValue == (int)Keys.Delete)
            {
                Derma.GetSelected().Remove();
                Derma.prop.propertyGrid.SelectedObject = null;
                return;
            }

            int dist;

            if ((e.Modifiers & Keys.Shift) == Keys.Shift)
            {
                dist = 10;
            }
            else
            {
                dist = 1;
            }

            switch (e.KeyValue)
            {
            case (int)Keys.Up:
                if (GUI.Grid.DrawGrid && !VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_TAB))
                {
                    dist = Derma.GetSelected().y % GUI.Grid.GridSize;
                    if (dist == 0)
                    {
                        dist = GUI.Grid.GridSize;
                    }
                    if (VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_SHIFT))
                    {
                        dist += GUI.Grid.GridSize;
                    }
                }
                Derma.GetSelected().ModifyPos(0, -dist);
                break;

            case (int)Keys.Left:
                if (GUI.Grid.DrawGrid && !VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_TAB))
                {
                    dist = Derma.GetSelected().x % GUI.Grid.GridSize;
                    if (dist == 0)
                    {
                        dist = GUI.Grid.GridSize;
                    }
                    if (VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_SHIFT))
                    {
                        dist += GUI.Grid.GridSize;
                    }
                }
                Derma.GetSelected().ModifyPos(-dist, 0);
                break;

            case (int)Keys.Right:
                if (GUI.Grid.DrawGrid && !VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_TAB))
                {
                    dist = Derma.GetSelected().x % GUI.Grid.GridSize;
                    if (dist == 0)
                    {
                        dist = GUI.Grid.GridSize;
                    }
                    if (VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_SHIFT))
                    {
                        dist += GUI.Grid.GridSize;
                    }
                }
                Derma.GetSelected().ModifyPos(dist, 0);
                break;

            case (int)Keys.Down:
                if (GUI.Grid.DrawGrid && !VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_TAB))
                {
                    dist = Derma.GetSelected().y % GUI.Grid.GridSize;
                    if (dist == 0)
                    {
                        dist = GUI.Grid.GridSize;
                    }
                    if (VirtualKeys.IsKeyPressed(VirtualKeyStates.VK_SHIFT))
                    {
                        dist += GUI.Grid.GridSize;
                    }
                }
                Derma.GetSelected().ModifyPos(0, dist);
                break;
            }

            Derma.RefreshProperties();
        }