コード例 #1
0
ファイル: NewLabelUI.cs プロジェクト: 15831944/backsight
        /// <summary>
        /// Handles mouse-move.
        /// </summary>
        /// <param name="pos">The new position of the mouse</param>
        internal override void MouseMove(IPosition pos)
        {
            // If we previously drew a text outline, erase it now.
            EraseRect();

            // Find the polygon (if any) that encloses the mouse position.
            CadastralMapModel map   = CadastralMapModel.Current;
            ISpatialIndex     index = map.Index;
            IPointGeometry    pg    = PointGeometry.Create(pos);
            Polygon           enc   = new FindPointContainerQuery(index, pg).Result;

            // If it's different from what we previously had, remember the
            // new enclosing polygon.
            if (!Object.ReferenceEquals(enc, m_Polygon))
            {
                // If we had something before, and we filled it, erase
                // the fill now.
                //DrawPolygon(false);

                // Remember the polygon we're now enclosed by (if any).
                m_Polygon = enc;

                // Draw the new polygon.
                //DrawPolygon(true);

                // Ensure any calculated position has been cleared
                m_AutoPosition = null;

                // See if a new orientation applies
                CheckOrientation(pg);

                // If the enclosing polygon does not have a label, use the
                // standard cursor and fill the polygon. Otherwise use the
                // gray cursor.
                SetCommandCursor();
            }

            // Draw a rectangle representing the outline of the text.
            if (m_IsAutoPos && m_Polygon != null)
            {
                if (m_AutoPosition == null)
                {
                    m_AutoPosition = m_Polygon.GetLabelPosition(Width, Height);
                }
            }

            if (m_IsAutoPos && m_AutoPosition != null)
            {
                DrawText(m_AutoPosition);
            }
            else
            {
                DrawText(pos);
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles mouse-move.
        /// </summary>
        /// <param name="p">The new position of the mouse</param>
        internal override void MouseMove(IPosition p)
        {
            if (m_LastPolygon == null || !m_LastPolygon.IsEnclosing(p))
            {
                IPointGeometry pg    = PointGeometry.Create(p);
                ISpatialIndex  index = CadastralMapModel.Current.Index;
                Polygon        pol   = new FindPointContainerQuery(index, pg).Result;

                if (pol != null || (m_LastPolygon != null && pol == null))
                {
                    Controller.ActiveDisplay.RestoreLastDraw();
                    m_LastPolygon = pol;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Handles a mouse down event
        /// </summary>
        /// <param name="p">The position where the click occurred</param>
        /// <returns>True if the command handled the mouse down. False if it did nothing.</returns>
        internal override bool LButtonDown(IPosition p)
        {
            // Find out what polygon we need to subdivide
            IPointGeometry pg    = PointGeometry.Create(p);
            ISpatialIndex  index = CadastralMapModel.Current.Index;
            Polygon        pol   = new FindPointContainerQuery(index, pg).Result;

            if (pol == null)
            {
                MessageBox.Show("Specified position does not fall inside any polygon.");
                return(false);
            }


            PolygonSubdivisionOperation op = null;

            try
            {
                // Form the links. Return if we didn't find any links.
                PolygonSub   sub = new PolygonSub(pol);
                PointFeature start, end;
                if (!sub.GetLink(0, out start, out end))
                {
                    MessageBox.Show("Cannot locate any points to connect.");
                    return(true);
                }

                op = new PolygonSubdivisionOperation();
                op.Execute(sub);
                FinishCommand();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
                AbortCommand();
            }

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Handles a mouse down event
        /// </summary>
        /// <param name="p">The position where the click occurred</param>
        /// <returns>True if the command handled the mouse down. False if it did nothing.</returns>
        internal override bool LButtonDown(IPosition p)
        {
            // Find out what polygon we need to subdivide
            IPointGeometry pg = PointGeometry.Create(p);
            ISpatialIndex index = CadastralMapModel.Current.Index;
            Polygon pol = new FindPointContainerQuery(index, pg).Result;
            if (pol==null)
            {
                MessageBox.Show("Specified position does not fall inside any polygon.");
                return false;
            }

            PolygonSubdivisionOperation op = null;

            try
            {
                // Form the links. Return if we didn't find any links.
                PolygonSub sub = new PolygonSub(pol);
                PointFeature start, end;
                if (!sub.GetLink(0, out start, out end))
                {
                    MessageBox.Show("Cannot locate any points to connect.");
                    return true;
                }

                op = new PolygonSubdivisionOperation();
                op.Execute(sub);
                FinishCommand();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
                AbortCommand();
            }

            return true;
        }
コード例 #5
0
ファイル: NewLabelUI.cs プロジェクト: steve-stanton/backsight
        /// <summary>
        /// Handles mouse-move.
        /// </summary>
        /// <param name="pos">The new position of the mouse</param>
        internal override void MouseMove(IPosition pos)
        {
            // If we previously drew a text outline, erase it now.
            EraseRect();

            // Find the polygon (if any) that encloses the mouse position.
            CadastralMapModel map = CadastralMapModel.Current;
            ISpatialIndex index = map.Index;
            IPointGeometry pg = PointGeometry.Create(pos);
            Polygon enc = new FindPointContainerQuery(index, pg).Result;

            // If it's different from what we previously had, remember the
            // new enclosing polygon.
            if (!Object.ReferenceEquals(enc, m_Polygon))
            {
                // If we had something before, and we filled it, erase
                // the fill now.
                //DrawPolygon(false);

                // Remember the polygon we're now enclosed by (if any).
                m_Polygon = enc;

                // Draw the new polygon.
                //DrawPolygon(true);

                // Ensure any calculated position has been cleared
                m_AutoPosition = null;

                // See if a new orientation applies
                CheckOrientation(pg);

                // If the enclosing polygon does not have a label, use the
                // standard cursor and fill the polygon. Otherwise use the
                // gray cursor.
                SetCommandCursor();
            }

            // Draw a rectangle representing the outline of the text.
            if (m_IsAutoPos && m_Polygon!=null)
            {
                if (m_AutoPosition==null)
                    m_AutoPosition = m_Polygon.GetLabelPosition(Width, Height);
            }

            if (m_IsAutoPos && m_AutoPosition!=null)
                DrawText(m_AutoPosition);
            else
                DrawText(pos);
        }
コード例 #6
0
        /// <summary>
        /// Handles mouse-move.
        /// </summary>
        /// <param name="p">The new position of the mouse</param>
        internal override void MouseMove(IPosition p)
        {
            if (m_LastPolygon == null || !m_LastPolygon.IsEnclosing(p))
            {
                IPointGeometry pg = PointGeometry.Create(p);
                ISpatialIndex index = CadastralMapModel.Current.Index;
                Polygon pol = new FindPointContainerQuery(index, pg).Result;

                if (pol != null || (m_LastPolygon != null && pol == null))
                {
                    Controller.ActiveDisplay.RestoreLastDraw();
                    m_LastPolygon = pol;
                }
            }
        }