Пример #1
0
    /// <summary>
    /// Create a selection frame. The method set is used during the creation.
    /// </summary>
    public SelectionFrame CreateSelectionFrame(Transform _parent, Vector3 _pos, Vector3 _size, Material _material = null)
    {
        GameObject     go             = Instantiate(prefabs["SelectionFrame"] as GameObject, _parent);
        SelectionFrame selectionFrame = go.GetComponent <SelectionFrame>();

        selectionFrame.Set(_pos, _size, _material);

        popUpList.Add(go);

        return(selectionFrame);
    }
Пример #2
0
 protected override void OnStopped()
 {
     if (adornerPanel != null)
     {
         designPanel.Adorners.Remove(adornerPanel);
         adornerPanel = null;
     }
     GrayOutDesignerExceptActiveArea.Stop(ref grayOut);
     selectionFrame = null;
     base.OnStopped();
 }
Пример #3
0
        protected override void OnDragStarted(MouseEventArgs e)
        {
            adornerPanel = new AdornerPanel();
            adornerPanel.SetAdornedElement(container.View, container);

            selectionFrame = new SelectionFrame();
            adornerPanel.Children.Add(selectionFrame);

            designPanel.Adorners.Add(adornerPanel);

            GrayOutDesignerExceptActiveArea.Start(ref grayOut, services, container.View);
        }
Пример #4
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            var mouse = MouseZoom(e.Location);

            if (draggedShape != null)
            {
                DragShape(e);

                if (dragStarted)
                {
                    view.Model.ReRouteTask(draggedShape.Task);
                }

                Invalidate();
                draggedShape = null;
            }
            if (draggedSegment != null)
            {
                draggedSegment.Connector.Normalise();
                draggedSegment = null;
            }
            if (rubberBand != null)
            {
                rubberBand.MouseUp(mouse);
                rubberBand = null;
                Invalidate();
            }
            if (panning)
            {
                Cursor  = Cursors.Default;
                panning = false;
                Invalidate();
            }
            if (selectionFrame != null)
            {
                var frame   = selectionFrame.Frame;
                var topLeft = PointToClient(frame.Location);
                var rect    = new Rectangle(
                    (int)Math.Floor(topLeft.X / zoom),
                    (int)Math.Floor(topLeft.Y / zoom),
                    (int)Math.Ceiling(frame.Width / zoom),
                    (int)Math.Ceiling(frame.Height / zoom));
                View.Selection.SelectInRectangle(rect);
                selectionFrame = null;
                Invalidate();
            }
            UpdateSize();
        }
Пример #5
0
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                Keys number = (Keys)Marshal.ReadInt32(lParam);
                //MessageBox.Show(number.ToString());
                if (number == Keys.PrintScreen)
                {
                    Debug.WriteLine(wParam.ToString());
                    if (pressed && wParam == (IntPtr)261 && Keys.Alt == Control.ModifierKeys && number == Keys.PrintScreen)
                    {
                        var res = Scr.Capture(ScreenCapturer.CaptureMode.Window, Properties.Settings.Default.cutborder);
                        WinForm.OnGrabScreen(res, false, 1);
                        pressed = false;
                    }
                    else if (pressed && wParam == (IntPtr)257 && Keys.Shift == Control.ModifierKeys && number == Keys.PrintScreen)
                    {
                        if (!WinForm.Selection)
                        {
                            var res  = Scr.Capture(ScreenCapturer.CaptureMode.Screen);
                            var form = new SelectionFrame(WinForm, res);
                            form.ShowDialog();
                        }
                        pressed = false;
                    }
                    else if (pressed && wParam == (IntPtr)257 && number == Keys.PrintScreen)
                    {
                        var res = Scr.Capture(ScreenCapturer.CaptureMode.Screen);
                        WinForm.OnGrabScreen(res);
                        pressed = false;
                    }
                    else if (wParam == (IntPtr)256 || wParam == (IntPtr)260)
                    {
                        pressed = true; // fix for win xp double press
                    }
                }
            }

            return(CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
        }
Пример #6
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            var mouse = MouseZoom(e.Location);
            var obj   = view.HitTest(mouse);

            if (obj is Shape)
            {
                if (ModifierKeys == Keys.Control)
                {
                    Debug.WriteLine("toggling object");
                    View.Selection.Toggle(obj);
                    Invalidate();
                }
                else if (ModifierKeys == Keys.None)
                {
                    View.Selection.Select(obj);
                    if (!ReadOnly)
                    {
                        StartShapeDrag((Shape)obj, mouse);
                    }
                    Invalidate();
                }
            }
            else if (obj is Pin && !ReadOnly && ModifierKeys == Keys.None)
            {
                rubberBand = new RubberBand(this, view, obj as Pin);
            }
            else if (obj is Segment && !ReadOnly)
            {
                var connector = (obj as Segment).Connector;
                if (ModifierKeys == Keys.Control)
                {
                    View.Selection.Toggle(connector);
                    Invalidate();
                }
                else if (ModifierKeys == Keys.None)
                {
                    View.Selection.Select(connector);
                    StartSegmentDrag(mouse, (obj as Segment));
                    Invalidate();
                }
            }
            else
            {
                // User clicked on background
                if (ModifierKeys == Keys.Control)
                {
                    selectionFrame = new SelectionFrame(PointToScreen(e.Location), BackColor);
                }
                else if (ModifierKeys == Keys.None)
                {
                    if (View.Selection.Count != 0)
                    {
                        Invalidate();
                        View.Selection.Clear();
                    }
                    panning  = true;
                    panClick = mouse;
                    minLeft  = Math.Min(0, Parent.Width - Width);
                    minTop   = Math.Min(0, Parent.Height - Height);
                }
            }
        }