Пример #1
0
        public override bool DoMouseUp(int x, int y, Modifier keys, InteractivePlotSurface2D ps)
        {
            ps.QueueDraw(this.extent);

            this.active = false;
            this.extent = Rectangle.Empty;

            if (this.Measurement != null)
            {
                if (ps.PhysicalXAxis1Cache != null && ps.PhysicalYAxis1Cache != null)
                {
                    var args = new MeasurementArgs();

                    args.End = args.Start = new PointF(
                        (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.start, true),
                        (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.start, true)
                    );

                    this.Measurement(ps, args);
                }
            }

            return false;
        }
Пример #2
0
        public override bool DoMouseMove(int x, int y, Modifier keys, InteractivePlotSurface2D ps)
        {
            Rectangle previous = this.extent;

            // If the mouse is being dragged then set the end point and extent
            // rectangle accordingly. Otherwise simply set the start coordinates
            // the current cursor position.
            if (this.active)
            {
                this.end	= new Point(x, y);
                this.extent	= new Rectangle(
                    Math.Min(this.start.X, this.end.X) - this.offset,
                    Math.Min(this.start.Y, this.end.Y) - this.offset,
                    Math.Abs(this.end.X - this.start.X) + this.offset * 2 + 1,
                    Math.Abs(this.end.Y - this.start.Y) + this.offset * 2 + 1
                );
            }
            else
            {
                this.start	= new Point(x, y);
                this.extent = Rectangle.Empty;
            }

            // If an event handler has been set then throw the latest world
            // coordinates at it. Start and end points are set the same if
            // the cursor is not being dragged.
            if (this.Measurement != null)
            {
                if (ps.PhysicalXAxis1Cache != null && ps.PhysicalYAxis1Cache != null)
                {
                    var args	= new MeasurementArgs();
                    args.Start	= new PointF(
                        (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.start, true),
                        (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.start, true)
                    );

                    args.End = !this.active ? args.Start : new PointF(
                        (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.end, true),
                        (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.end, true)
                    );

                    this.Measurement(ps, args);
                }
            }

            ps.QueueDraw(previous);
            ps.QueueDraw(this.extent);

            return false;
        }