コード例 #1
0
        /// <summary>
        /// Raises the MouseDown event</summary>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data</param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // grab focus
            Focus();

            // Check if we've hit a manipulator. Only control with the left mouse button so that
            //  right-clicks can bring up the context menu rather than hitting the manipulator.
            if (CanvasControl3D.ControlScheme.IsControllingCamera(ModifierKeys, e) == false &&
                e.Button == MouseButtons.Left)
            {
                FirstMousePoint = new Point(e.X, e.Y);
                Clear();

                HitRecord[]  hits;
                IManipulator manipulator = TestForManipulator(e.X, e.Y, out hits);
                if (manipulator != null)
                {
                    SetManipulator(manipulator, hits);
                    OnManipulatorStart(new ManipulatorEventArgs(manipulator));

                    int   width  = base.Width;
                    int   height = base.Height;
                    float x      = (float)e.X / (float)width - 0.5f;
                    float y      = 1.0f - ((float)e.Y / (float)height) - 0.5f;
                    manipulator.OnHit(hits, x, y, m_pickAction, m_renderAction, Camera, m_context);

                    // Don't call base method if a manipulator was found. Why?
                    return;
                }
            }
            base.OnMouseDown(e);
        }