Esempio n. 1
0
        /// <summary>
        /// Handles the MouseDown event when the object pointer tool is selected
        /// </summary>
        /// <param name="position">Mouse position.</param>
        /// <param name="e">The mouse event args</param>
        /// <remarks>
        /// The strategy to handle the mousedown event is as following:
        ///
        /// Have we clicked on already selected objects?
        ///   if yes (we have clicked on already selected objects) and the shift or control key was pressed -> deselect the object and repaint
        ///   if yes (we have clicked on already selected objects) and none shift nor control key was pressed-> activate the object moving  mode
        ///   if no (we have not clicked on already selected objects) and shift or control key was pressed -> search for the object and add it to the selected objects, then aktivate moving mode
        ///   if no (we have not clicked on already selected objects) and no shift or control key pressed -> if a object was found add it to the selected objects and activate moving mode
        ///                                                                                                  if no object was found clear the selection list, deactivate moving mode
        /// </remarks>
        public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e)
        {
            base.OnMouseDown(position, e);

            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return; // then there is nothing to do here
            }
            // first, if we have a mousedown without shift key and the
            // position has changed with respect to the last mousedown
            // we have to deselect all objects
            var keyboardModifiers = System.Windows.Input.Keyboard.Modifiers;

            bool bControlKey = keyboardModifiers.HasFlag(ModifierKeys.Control);
            bool bShiftKey   = keyboardModifiers.HasFlag(ModifierKeys.Shift);

            var mousePixelCoord = position;                                                  // Mouse pixel coordinates
            var rootLayerCoord  = _grac.ConvertMouseToRootLayerCoordinates(mousePixelCoord); // Graph area coordinates

            ActiveGrip = GripHitTest(rootLayerCoord);
            if ((ActiveGrip is SuperGrip) && (bShiftKey || bControlKey))
            {
                var superGrip = ActiveGrip as SuperGrip;
                if (superGrip.GetHittedElement(rootLayerCoord, out var gripHandle, out var hitTestObj))
                {
                    _selectedObjects.Remove(hitTestObj);
                    superGrip.Remove(gripHandle);
                    return;
                }
            }
            else if (ActiveGrip != null)
            {
                ActiveGrip.Activate(rootLayerCoord, false);
                return;
            }
            _grac.FindGraphObjectAtPixelPosition(mousePixelCoord, false, out var clickedObject, out var clickedLayerNumber);

            if (!bShiftKey && !bControlKey) // if shift or control are pressed, we add the object to the selection list and start moving mode
            {
                ClearSelections();
            }

            if (null != clickedObject)
            {
                AddSelectedObject(rootLayerCoord, clickedObject);
            }
        } // end of function
Esempio n. 2
0
        public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e)
        {
            base.OnMouseDown(position, e);

            _positionCurrentMouseInRootLayerCoordinates = _grac.ConvertMouseToRootLayerCoordinates(position);
            GetClosestGridLine(out var minDistanceSquared, out var minIndex, out var minInXGrid);

            if (minDistanceSquared < _catchDistance_RLC * _catchDistance_RLC)
            {
                _movedGridLineIndex   = minIndex;
                _movedGridLineIsXGrid = minInXGrid;
            }
            else
            {
                FinishDrawing();
            }
        }
Esempio n. 3
0
        public override void OnMouseMove(PointD2D position, MouseEventArgs e)
        {
            base.OnMouseMove(position, e);

            _positionCurrentMouseInRootLayerCoordinates = _grac.ConvertMouseToRootLayerCoordinates(position);

            ModifyCurrentMousePrintAreaCoordinate();

            _grac.RenderOverlay();
        }
        /// <summary>
        /// Handles the MouseDown event when the plot point tool is selected
        /// </summary>
        /// <param name="position">Mouse position.</param>
        /// <param name="e">The mouse event args</param>
        public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e)
        {
            base.OnMouseDown(position, e);

            if (null != _cachedActiveLayer && (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))) // if M is pressed, we don't move the cross, but instead we display not only the cross coordinates but also the difference
            {
                var printableCoord = _grac.ConvertMouseToRootLayerCoordinates(position);
                DisplayCrossCoordinatesAndDifference(printableCoord);
            }
            else
            {
                _cachedActiveLayer = _grac.ActiveLayer;
                _cachedActiveLayerTransformation    = _cachedActiveLayer.TransformationFromRootToHere();
                _cachedActiveLayerTransformationGdi = _cachedActiveLayerTransformation;

                _positionOfCrossInRootLayerCoordinates = _grac.ConvertMouseToRootLayerCoordinates(position);
                DisplayCrossCoordinates();
            }

            _grac.RenderOverlay(); // no refresh necessary, only invalidate to show the cross
        } // end of function
Esempio n. 5
0
        /// <summary>
        /// Handles the click event by opening the text tool dialog.
        /// </summary>
        /// <param name="e">EventArgs.</param>
        /// <param name="position">Mouse position.</param>
        /// <returns>The mouse state handler for handling the next mouse events.</returns>
        public override void OnClick(PointD2D position, MouseButtonEventArgs e)
        {
            base.OnClick(position, e);

            _cachedActiveLayer = _grac.ActiveLayer;
            _cachedActiveLayerTransformation    = _cachedActiveLayer.TransformationFromRootToHere();
            _cachedActiveLayerTransformationGdi = _cachedActiveLayerTransformation;

            // get the page coordinates (in Point (1/72") units)
            var rootLayerCoord = _grac.ConvertMouseToRootLayerCoordinates(_positionLastMouseDownInMouseCoordinates);
            // with knowledge of the current active layer, calculate the layer coordinates from them
            var layerCoord = _cachedActiveLayerTransformation.InverseTransformPoint(rootLayerCoord);

            var tgo = new TextGraphic(_grac.Doc.GetPropertyContext());

            tgo.SetParentSize(_grac.ActiveLayer.Size, false);
            tgo.Position     = layerCoord;
            tgo.ParentObject = _grac.ActiveLayer;

            // deselect the text tool
            _grac.SetGraphToolFromInternal(GraphToolType.ObjectPointer);

            object tgoo = tgo;

            if (Current.Gui.ShowDialog(ref tgoo, "Text", false))
            {
                tgo = (TextGraphic)tgoo;
                if (tgo != null && !tgo.Empty)
                {
                    _grac.ActiveLayer.GraphObjects.Add(tgo);
                }
            }

            /*
             *                TextControlDialog dlg = new TextControlDialog(_grac.Layers[_grac.CurrentLayerNumber],tgo);
             *                if(DialogResult.OK==dlg.ShowDialog(_grac.View.Window))
             *                {
             *                        // add the resulting textgraphobject to the layer
             *                        if(!dlg.SimpleTextGraphics.Empty)
             *                        {
             *                                _grac.Layers[_grac.CurrentLayerNumber].GraphObjects.Add(dlg.SimpleTextGraphics);
             *                                _grac.RefreshGraph();
             *                        }
             *                }
             */
            _grac.SetGraphToolFromInternal(GraphToolType.ObjectPointer);
        }
Esempio n. 6
0
        public override void OnMouseMove(PointD2D position, MouseEventArgs e)
        {
            base.OnMouseMove(position, e);

            _positionCurrentMouseInRootLayerCoordinates = _grac.ConvertMouseToRootLayerCoordinates(position);

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                ModifyCurrentMousePrintAreaCoordinate();
                _grac.RenderOverlay();
            }
            else if (_currentPoint != 0)
            {
                _currentPoint = 0;
                _grac.RenderOverlay();
            }
        }
        /// <summary>
        /// Handles the MouseDown event when the plot point tool is selected
        /// </summary>
        /// <param name="position">Mouse position.</param>
        /// <param name="e">The mouse event args</param>
        public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e)
        {
            base.OnMouseDown(position, e);

            var graphXY = _grac.ConvertMouseToRootLayerCoordinates(position);

            _grac.FindGraphObjectAtPixelPosition(position, true, out var clickedObject, out var clickedLayerNumber);
            if (null != clickedObject && clickedObject.HittedObject is XYColumnPlotItem)
            {
                _PlotItem = (XYColumnPlotItem)clickedObject.HittedObject;
                var transXY = clickedObject.Transformation.InverseTransformPoint(graphXY);

                _layer = (XYPlotLayer)(clickedObject.ParentLayer);
                XYScatterPointInformation scatterPoint = _PlotItem.GetNearestPlotPoint(_layer, transXY);
                _PlotItemNumber = GetPlotItemNumber(_layer, _PlotItem);

                if (null != scatterPoint)
                {
                    _PlotIndex = scatterPoint.PlotIndex;
                    _RowIndex  = scatterPoint.RowIndex;
                    // convert this layer coordinates first to PrintableAreaCoordinates
                    var rootLayerCoord = clickedObject.ParentLayer.TransformCoordinatesFromHereToRoot(scatterPoint.LayerCoordinates);
                    _positionOfCrossInRootLayerCoordinates = rootLayerCoord;
                    // m_Cross.X -= _grac.GraphViewOffset.X;
                    // m_Cross.Y -= _grac.GraphViewOffset.Y;

                    var newPixelCoord = _grac.ConvertGraphToMouseCoordinates(rootLayerCoord);

                    // TODO (Wpf)
                    //var newCursorPosition = new Point((int)(Cursor.Position.X + newPixelCoord.X - mouseXY.X),(int)(Cursor.Position.Y + newPixelCoord.Y - mouseXY.Y));
                    //SetCursorPos(newCursorPosition.X, newCursorPosition.Y);

                    DisplayData(_PlotItem, scatterPoint.RowIndex,
                                _PlotItem.XYColumnPlotData.XColumn[scatterPoint.RowIndex],
                                _PlotItem.XYColumnPlotData.YColumn[scatterPoint.RowIndex]);

                    // here we shoud switch the bitmap cache mode on and link us with the AfterPaint event
                    // of the grac
                    _grac.RenderOverlay(); // no refresh necessary, only invalidate to show the cross
                }
            }
        } // end of function