Esempio n. 1
0
            /// <summary>
            /// MouseMove 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 DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps)
            {
                if (((keys & Modifier.Button1) != 0) && selectionActive_)
                {
                    // clip X and Y to PlotArea
                    Rectangle bounds = ps.PlotAreaBoundingBoxCache;

                    X = Math.Max(X, bounds.Left);
                    X = Math.Min(X, bounds.Right);
                    Y = Math.Max(Y, bounds.Top);
                    Y = Math.Min(Y, bounds.Bottom);

                    Point here = new Point(X,Y);

                    // delete previous overlay rectangle
                    if (endPoint_ != unset_) {
                        ps.DrawOverlayRectangle(startPoint_, endPoint_, Color.White, false);
                    }
                    endPoint_ = here;

                    // draw the latest rectangle
                    ps.DrawOverlayRectangle(startPoint_, endPoint_, Color.White, true);
                }
                return false;
            }
Esempio n. 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;

                if (selectionActive_) {
                    // erase current (clipped) rectangle
                    ps.DrawOverlayRectangle(startPoint_, endPoint_, Color.White, false);

                    endPoint_.X = X;
                    endPoint_.Y = Y;

                    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.DefineAxis(ps.XAxis1, xMinProp, xMaxProp);
                        ps.DefineAxis(ps.XAxis2, xMinProp, xMaxProp);
                        ps.DefineAxis(ps.YAxis1, yMinProp, yMaxProp);
                        ps.DefineAxis(ps.YAxis2, yMinProp, yMaxProp);

                        modified = true;
                    }
                    selectionActive_ = false;
                    startPoint_ = unset_;
                    endPoint_ = unset_;
                }
                return modified;
            }
Esempio n. 3
0
 /// <summary>
 /// MouseLeave method for RubberBand selection
 /// </summary>
 /// <param name="ps">the InteractivePlotSurface2D</param>
 public override bool DoMouseLeave(InteractivePlotSurface2D ps)
 {
     if (selectionActive_) {
         selectionActive_ = false;
         if (endPoint_ != unset_) {
             // erase latest rectangle
             ps.DrawOverlayRectangle(startPoint_, endPoint_, Color.White, false);
         }
         startPoint_ = unset_;
         endPoint_ = unset_;
     }
     return false;
 }