コード例 #1
0
ファイル: PlotSelection.cs プロジェクト: lijielife/Florence
        /// <summary>
        /// MouseUp method for RubberBand selection
        /// </summary>
        /// <param name="X">mouse X position</param>
        /// <param name="Y"> mouse Y position</param>
        /// <param name="keys"> mouse and keyboard modifiers</param>
        /// <param name="ps">the InteractivePlotSurface2D</param>
        public override bool DoMouseUp(int X, int Y, Modifier keys, InteractivePlotSurface2D ps)
        {
            bool modified = false;

            // delete previous overlay rectangle
            ps.QueueDraw(selection);
            if (selectionActive)
            {
                selectionActive = false;
                Rectangle bounds = ps.PlotAreaBoundingBoxCache;
                if (!bounds.Contains(endPoint))
                {
                    // MouseUp outside plotArea - cancel selection
                    modified = false;
                }
                else
                {
                    ps.CacheAxes();
                    // Redefine range based on selection. The proportions for
                    // Min and Max do not require Min < Max, since they will
                    // be re-ordered by Axis.DefineRange if necessary
                    double xMin = startPoint.X - bounds.Left;
                    double yMin = bounds.Bottom - startPoint.Y;

                    double xMax = endPoint.X - bounds.Left;
                    double yMax = bounds.Bottom - endPoint.Y;

                    double xMinProp = xMin / bounds.Width;
                    double xMaxProp = xMax / bounds.Width;
                    double yMinProp = yMin / bounds.Height;
                    double yMaxProp = yMax / bounds.Height;

                    ps.DefineXAxes(xMinProp, xMaxProp);
                    ps.DefineYAxes(yMinProp, yMaxProp);
                    modified = true;
                }
            }
            return(modified);
        }
コード例 #2
0
        /// <summary>
        /// MouseUp method for RubberBand selection
        /// </summary>
        /// <param name="X">mouse X position</param>
        /// <param name="Y"> mouse Y position</param>
        /// <param name="keys"> mouse and keyboard modifiers</param>
        /// <param name="ps">the InteractivePlotSurface2D</param>
        public override bool DoMouseUp(int X, int Y, Modifier keys, InteractivePlotSurface2D ps)
        {
            bool modified = false;

            // delete previous overlay rectangle
            ps.QueueDraw(selection);
            if (selectionActive)
            {

                selectionActive = false;
                Rectangle bounds = ps.PlotAreaBoundingBoxCache;
                if (!bounds.Contains(endPoint))
                {
                    // MouseUp outside plotArea - cancel selection
                    modified = false;
                }
                else
                {
                    ps.CacheAxes();
                    // Redefine range based on selection. The proportions for
                    // Min and Max do not require Min < Max, since they will
                    // be re-ordered by Axis.DefineRange if necessary
                    double xMin = startPoint.X - bounds.Left;
                    double yMin = bounds.Bottom - startPoint.Y;

                    double xMax = endPoint.X - bounds.Left;
                    double yMax = bounds.Bottom - endPoint.Y;

                    double xMinProp = xMin / bounds.Width;
                    double xMaxProp = xMax / bounds.Width;
                    double yMinProp = yMin / bounds.Height;
                    double yMaxProp = yMax / bounds.Height;

                    ps.DefineXAxes(xMinProp, xMaxProp);
                    ps.DefineYAxes(yMinProp, yMaxProp);
                    modified = true;
                }
            }
            return modified;
        }