Example #1
0
        private void SelectionUIOverlay_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if(e.Button != MouseButtons .Left)
                return;
            //
            Point pt=new Point(e.X,e.Y);
            Rectangle rcForm = GetFormRect();

            if(rcForm.Contains(pt)){
                Rectangle rcObject;
                if (m_tracker.HitTest(pt) == RectTracker.TrackerHit.hitNothing) {
                    m_seletedCtrl = null;
                    m_tracker.m_rect = new Rectangle(0,0,0,0);
                    // just to demonstrate RectTracker::TrackRubberBand
                    RectTracker tracker=new RectTracker();
                    if (tracker.TrackRubberBand(this, pt, false)){
                        // see if rubber band intersects with the doc's tracker
                        tracker.NormalizeRect(ref tracker.m_rect);
                        Rectangle rectIntersect = tracker.m_rect;
                        foreach (Control ctrl in m_Form.Controls){
                            rcObject = ctrl.Bounds;
                            rcObject = m_Form.RectangleToScreen(rcObject);
                            rcObject = this.RectangleToClient(rcObject);
                            if(tracker.m_rect.Contains(rcObject)){
                                m_tracker.m_rect = rcObject;
                                m_seletedCtrl = ctrl;
                              //  MainForm.m_propertyWindow.SetSelectedObject(m_seletedCtrl);
                                break;
                            }
                        }
                    }
                    else{
                        // No rubber band, see if the point selects an object.
                        foreach (Control ctrl in m_Form.Controls){
                            rcObject = ctrl.Bounds ;
                            rcObject = m_Form.RectangleToScreen(rcObject);
                            rcObject = this.RectangleToClient(rcObject);
                            if(rcObject.Contains(pt)){
                                m_tracker.m_rect = rcObject;
                                m_seletedCtrl = ctrl;
                            //	MainForm.m_propertyWindow.SetSelectedObject(ctrl);
                                break;
                            }
                        }
                    }
                    if(m_seletedCtrl == null){
                        //MainForm.m_propertyWindow.SetSelectedObject(m_Form);
                        m_FormTracker.m_rect = rcForm;
                    }
                    else{
                        m_FormTracker.Clear();
                    }
                }
                else if(m_seletedCtrl != null){// normal tracking action, when tracker is hit
                    m_tracker.Track(this, pt, false,null);

                }

            }
            else{
                if(m_seletedCtrl == null){//select the container form
                //	MainForm.m_propertyWindow.SetSelectedObject(m_Form);
                    if(m_FormTracker.HitTest(pt) == RectTracker.TrackerHit.hitNothing)
                    {
                        m_FormTracker.m_rect = rcForm;
                    }
                    else if(!m_FormTracker.IsEmpty())
                    {
                        m_FormTracker.Track(this, pt, false,null);
                    }
                }
                else{
                    m_FormTracker.Clear();
                }
            }
            InvalidateEx();
        }
Example #2
0
        private void SelectionUIOverlay_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            //
            Point     pt     = new Point(e.X, e.Y);
            Rectangle rcForm = GetFormRect();

            if (rcForm.Contains(pt))
            {
                Rectangle rcObject;
                if (m_tracker.HitTest(pt) == RectTracker.TrackerHit.hitNothing)
                {
                    m_seletedCtrl    = null;
                    m_tracker.m_rect = new Rectangle(0, 0, 0, 0);
                    // just to demonstrate RectTracker::TrackRubberBand
                    RectTracker tracker = new RectTracker();
                    if (tracker.TrackRubberBand(this, pt, false))
                    {
                        // see if rubber band intersects with the doc's tracker
                        tracker.NormalizeRect(ref tracker.m_rect);
                        Rectangle rectIntersect = tracker.m_rect;
                        foreach (Control ctrl in m_Form.Controls)
                        {
                            rcObject = ctrl.Bounds;
                            rcObject = m_Form.RectangleToScreen(rcObject);
                            rcObject = this.RectangleToClient(rcObject);
                            if (tracker.m_rect.Contains(rcObject))
                            {
                                m_tracker.m_rect = rcObject;
                                m_seletedCtrl    = ctrl;
                                MainForm.m_propertyWindow.SetSelectedObject(m_seletedCtrl);
                                break;
                            }
                        }
                    }
                    else
                    {
                        // No rubber band, see if the point selects an object.
                        foreach (Control ctrl in m_Form.Controls)
                        {
                            rcObject = ctrl.Bounds;
                            rcObject = m_Form.RectangleToScreen(rcObject);
                            rcObject = this.RectangleToClient(rcObject);
                            if (rcObject.Contains(pt))
                            {
                                m_tracker.m_rect = rcObject;
                                m_seletedCtrl    = ctrl;
                                MainForm.m_propertyWindow.SetSelectedObject(ctrl);
                                break;
                            }
                        }
                    }
                    if (m_seletedCtrl == null)
                    {
                        MainForm.m_propertyWindow.SetSelectedObject(m_Form);
                        m_FormTracker.m_rect = rcForm;
                    }
                    else
                    {
                        m_FormTracker.Clear();
                    }
                }
                else if (m_seletedCtrl != null)                // normal tracking action, when tracker is hit
                {
                    m_tracker.Track(this, pt, false, null);
                }
            }
            else
            {
                if (m_seletedCtrl == null)                //select the container form
                {
                    MainForm.m_propertyWindow.SetSelectedObject(m_Form);
                    if (m_FormTracker.HitTest(pt) == RectTracker.TrackerHit.hitNothing)
                    {
                        m_FormTracker.m_rect = rcForm;
                    }
                    else if (!m_FormTracker.IsEmpty())
                    {
                        m_FormTracker.Track(this, pt, false, null);
                    }
                }
                else
                {
                    m_FormTracker.Clear();
                }
            }
            InvalidateEx();
        }