Пример #1
0
        private void axPageLayoutControl1_OnMouseDown(object sender, IPageLayoutControlEvents_OnMouseDownEvent e)
        {
            int m_reszEng;//��������
            IPoint m_point = m_pageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            m_origenalElement = m_element;
            if (e.button == 1)
            {
                getElement(e.pageX, e.pageY);
                if (e.pageX < -0.03 || e.pageY < -0.03 || e.pageX > 29.71 || e.pageY > 29.71)
                {
                    m_element = null;
                }
                if (m_element != null)
                {
                    m_selectionTracker = m_element.SelectionTracker;
                    if (m_element is IFrameElement || m_element is ITextElement)
                    {
                        m_reszEng = Convert.ToInt32(m_selectionTracker.HitTest(m_point));// ���Ե����λ�ã������λ��ֵ

                        if (m_reszEng == 0 || m_reszEng == 1 || m_element is ITextElement) //�������ѡ��Ԫ�ص��м䲿λʱ
                        {
                            m_selectionTracker = null;
                            m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSize; //���������ʽΪ�ƶ�Ԫ����ʽ
                        }
                        else if (m_reszEng == 2 || m_reszEng == 3 || m_reszEng == 4 || m_reszEng == 5 || m_reszEng == 6 || m_reszEng == 7 || m_reszEng == 8 || m_reszEng == 9)
                        {
                            m_reszEng = m_reszEng - 2;
                            if (m_reszEng == 4 || m_reszEng == 3)
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeWE;//���������ʽ �����ı�Ԫ�ش�С
                            if (m_reszEng == 2 || m_reszEng == 5)
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNESW;
                            if (m_reszEng == 1 || m_reszEng == 6)
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNS;
                            if (m_reszEng == 0 || m_reszEng == 7)
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNWSE;

                            m_resizeEnvelopeFeedback = new ResizeEnvelopeFeedbackClass();

                            m_resizeEnvelopeFeedback.Display = m_pageLayoutControl.ActiveView.ScreenDisplay; //����Display
                            m_resizeEnvelopeFeedback.ResizeEdge = (esriEnvelopeEdge)m_reszEng;//���øı��Сʱ����Ҫ�ƶ��ı�

                            m_resizeEnvelopeFeedback.Constraint = esriEnvelopeConstraints.esriEnvelopeConstraintsNone;
                            m_resizeEnvelopeFeedback.Start(m_element.Geometry.Envelope, m_point); //�����ƶ������λ��
                            // m_resizeEnvelopeFeedback.MoveTo(m_point);
                        }

                    }
                }
                if (m_element == null && m_origenalElement != null)//��û��ѡ��Ԫ��ʱ����ԭ��ѡ���Ԫ�ظ��ٰ���������
                {
                    m_selectionTracker = m_origenalElement.SelectionTracker;
                    m_selectionTracker.Deactivate();//���ذ�����

                }

            }
            #region//�һ�
            if (e.button == 2)  //�һ����
            {
                if (m_resizeEnvelopeFeedback != null)
                {
                    m_resizeEnvelopeFeedback.Constraint = esriEnvelopeConstraints.esriEnvelopeConstraintsSquare;
                }
                #region// �Ҽ��˵�
                m_menuPageLayout.AddItem(new DeleteElement(m_pageLayoutControl, m_element), -1, 7,
                    false, esriCommandStyles.esriCommandStyleIconOnly);//ɾ��ѡ��Ԫ��

                m_menuPageLayout.AddItem(new ChangeFrameBackGround(m_element, m_pageLayoutControl), 8, 8,
               false, esriCommandStyles.esriCommandStyleIconOnly);//����
                m_menuPageLayout.AddItem(new ChangeFrameShadow(m_element, m_pageLayoutControl), 9, 9,
                    false, esriCommandStyles.esriCommandStyleIconOnly);//������Ӱ
                m_menuPageLayout.AddItem(new ChangeFrameBorder(m_element, m_pageLayoutControl), 10, 10,
                    false, esriCommandStyles.esriCommandStyleIconOnly);//���ñ߿�
                m_menuPageLayout.AddItem(new CmdExoprtMapAsPicture(), 11, 11, false, esriCommandStyles.esriCommandStyleIconOnly);
                m_menuPageLayout.PopupMenu(e.x, e.y, m_pageLayoutControl.hWnd);
                m_menuPageLayout.Remove(11);
                m_menuPageLayout.Remove(10);
                m_menuPageLayout.Remove(9);
                m_menuPageLayout.Remove(8);
                m_menuPageLayout.Remove(7);

                #endregion
            }
            #endregion
        }
Пример #2
0
        private void axPageLayoutControl1_OnMouseDown(object sender, IPageLayoutControlEvents_OnMouseDownEvent e)
        {
            int    m_reszEng;//返回鼠标位置
            IPoint m_point = m_pageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            m_origenalElement = m_element;
            if (e.button == 1)
            {
                getElement(e.pageX, e.pageY);
                if (e.pageX < -0.03 || e.pageY < -0.03 || e.pageX > 29.71 || e.pageY > 29.71)
                {
                    m_element = null;
                }
                if (m_element != null)
                {
                    m_selectionTracker = m_element.SelectionTracker;
                    if (m_element is IFrameElement || m_element is ITextElement)
                    {
                        m_reszEng = Convert.ToInt32(m_selectionTracker.HitTest(m_point));  // 测试点击的位置,并获得位置值

                        if (m_reszEng == 0 || m_reszEng == 1 || m_element is ITextElement) //当鼠标在选中元素的中间部位时
                        {
                            m_selectionTracker = null;
                            m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSize; //设置鼠标样式为移动元素样式
                        }
                        else if (m_reszEng == 2 || m_reszEng == 3 || m_reszEng == 4 || m_reszEng == 5 || m_reszEng == 6 || m_reszEng == 7 || m_reszEng == 8 || m_reszEng == 9)
                        {
                            m_reszEng = m_reszEng - 2;
                            if (m_reszEng == 4 || m_reszEng == 3)
                            {
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeWE;//设置鼠标样式 用来改变元素大小
                            }
                            if (m_reszEng == 2 || m_reszEng == 5)
                            {
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNESW;
                            }
                            if (m_reszEng == 1 || m_reszEng == 6)
                            {
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNS;
                            }
                            if (m_reszEng == 0 || m_reszEng == 7)
                            {
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNWSE;
                            }

                            m_resizeEnvelopeFeedback = new ResizeEnvelopeFeedbackClass();

                            m_resizeEnvelopeFeedback.Display    = m_pageLayoutControl.ActiveView.ScreenDisplay; //设置Display
                            m_resizeEnvelopeFeedback.ResizeEdge = (esriEnvelopeEdge)m_reszEng;                  //设置改变大小时,需要移动的边


                            m_resizeEnvelopeFeedback.Constraint = esriEnvelopeConstraints.esriEnvelopeConstraintsNone;
                            m_resizeEnvelopeFeedback.Start(m_element.Geometry.Envelope, m_point); //设置移动的启动位置
                            // m_resizeEnvelopeFeedback.MoveTo(m_point);
                        }
                    }
                }
                if (m_element == null && m_origenalElement != null)//当没有选中元素时,将原来选择的元素跟踪包络线隐藏
                {
                    m_selectionTracker = m_origenalElement.SelectionTracker;
                    m_selectionTracker.Deactivate();//隐藏包络线
                }
            }
            #region            //右击
            if (e.button == 2) //右击鼠标
            {
                if (m_resizeEnvelopeFeedback != null)
                {
                    m_resizeEnvelopeFeedback.Constraint = esriEnvelopeConstraints.esriEnvelopeConstraintsSquare;
                }
                #region                                                                      // 右键菜单
                m_menuPageLayout.AddItem(new DeleteElement(m_pageLayoutControl, m_element), -1, 7,
                                         false, esriCommandStyles.esriCommandStyleIconOnly); //删除选中元素

                m_menuPageLayout.AddItem(new ChangeFrameBackGround(m_element, m_pageLayoutControl), 8, 8,
                                         false, esriCommandStyles.esriCommandStyleIconOnly); //设置背景
                m_menuPageLayout.AddItem(new ChangeFrameShadow(m_element, m_pageLayoutControl), 9, 9,
                                         false, esriCommandStyles.esriCommandStyleIconOnly); //设置阴影
                m_menuPageLayout.AddItem(new ChangeFrameBorder(m_element, m_pageLayoutControl), 10, 10,
                                         false, esriCommandStyles.esriCommandStyleIconOnly); //设置边框
                m_menuPageLayout.AddItem(new CmdExoprtMapAsPicture(), 11, 11, false, esriCommandStyles.esriCommandStyleIconOnly);
                m_menuPageLayout.PopupMenu(e.x, e.y, m_pageLayoutControl.hWnd);
                m_menuPageLayout.Remove(11);
                m_menuPageLayout.Remove(10);
                m_menuPageLayout.Remove(9);
                m_menuPageLayout.Remove(8);
                m_menuPageLayout.Remove(7);

                #endregion
            }
            #endregion
        }
Пример #3
0
        private void axPageLayoutControl1_OnMouseDown(object sender, IPageLayoutControlEvents_OnMouseDownEvent e)
        {
            int m_reszEng;//返回鼠标位置
            IPoint m_point = m_pageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            m_origenalElement = m_element;
            if (e.button == 1)
            {
                getElement(e.pageX, e.pageY);
                if (e.pageX < -0.03 || e.pageY < -0.03 || e.pageX > 29.71 || e.pageY > 29.71)
                {
                    m_element = null;
                }
                if (m_element != null)
                {
                    m_selectionTracker = m_element.SelectionTracker;
                    if (m_element is IFrameElement || m_element is ITextElement)
                    {
                        m_reszEng = Convert.ToInt32(m_selectionTracker.HitTest(m_point));// 测试点击的位置,并获得位置值

                        if (m_reszEng == 0 || m_reszEng == 1 || m_element is ITextElement) //当鼠标在选中元素的中间部位时
                        {
                            m_selectionTracker = null;
                            m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSize; //设置鼠标样式为移动元素样式
                        }
                        else if (m_reszEng == 2 || m_reszEng == 3 || m_reszEng == 4 || m_reszEng == 5 || m_reszEng == 6 || m_reszEng == 7 || m_reszEng == 8 || m_reszEng == 9)
                        {
                            m_reszEng = m_reszEng - 2;
                            if (m_reszEng == 4 || m_reszEng == 3)
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeWE;//设置鼠标样式 用来改变元素大小
                            if (m_reszEng == 2 || m_reszEng == 5)
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNESW;
                            if (m_reszEng == 1 || m_reszEng == 6)
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNS;
                            if (m_reszEng == 0 || m_reszEng == 7)
                                m_pageLayoutControl.MousePointer = esriControlsMousePointer.esriPointerSizeNWSE;

                            m_resizeEnvelopeFeedback = new ResizeEnvelopeFeedbackClass();

                            m_resizeEnvelopeFeedback.Display = m_pageLayoutControl.ActiveView.ScreenDisplay; //设置Display
                            m_resizeEnvelopeFeedback.ResizeEdge = (esriEnvelopeEdge)m_reszEng;//设置改变大小时,需要移动的边

                            m_resizeEnvelopeFeedback.Constraint = esriEnvelopeConstraints.esriEnvelopeConstraintsNone;
                            m_resizeEnvelopeFeedback.Start(m_element.Geometry.Envelope, m_point); //设置移动的启动位置
                            // m_resizeEnvelopeFeedback.MoveTo(m_point);
                        }

                    }
                }
                if (m_element == null && m_origenalElement != null)//当没有选中元素时,将原来选择的元素跟踪包络线隐藏
                {
                    m_selectionTracker = m_origenalElement.SelectionTracker;
                    m_selectionTracker.Deactivate();//隐藏包络线

                }

            }
            #region//右击
            if (e.button == 2)  //右击鼠标
            {
                if (m_resizeEnvelopeFeedback != null)
                {
                    m_resizeEnvelopeFeedback.Constraint = esriEnvelopeConstraints.esriEnvelopeConstraintsSquare;
                }
                #region// 右键菜单
                m_menuPageLayout.AddItem(new DeleteElement(m_pageLayoutControl, m_element), -1, 7,
                    false, esriCommandStyles.esriCommandStyleIconOnly);//删除选中元素

                m_menuPageLayout.AddItem(new ChangeFrameBackGround(m_element, m_pageLayoutControl), 8, 8,
               false, esriCommandStyles.esriCommandStyleIconOnly);//设置背景
                m_menuPageLayout.AddItem(new ChangeFrameShadow(m_element, m_pageLayoutControl), 9, 9,
                    false, esriCommandStyles.esriCommandStyleIconOnly);//设置阴影
                m_menuPageLayout.AddItem(new ChangeFrameBorder(m_element, m_pageLayoutControl), 10, 10,
                    false, esriCommandStyles.esriCommandStyleIconOnly);//设置边框
                m_menuPageLayout.AddItem(new CmdExoprtMapAsPicture(), 11, 11, false, esriCommandStyles.esriCommandStyleIconOnly);
                m_menuPageLayout.PopupMenu(e.x, e.y, m_pageLayoutControl.hWnd);
                m_menuPageLayout.Remove(11);
                m_menuPageLayout.Remove(10);
                m_menuPageLayout.Remove(9);
                m_menuPageLayout.Remove(8);
                m_menuPageLayout.Remove(7);

                #endregion
            }
            #endregion
        }