コード例 #1
0
        public RectPanel(Size MapSize, MapRectangle3D rect)
        {
            m_Updating = true;

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            m_MapSize         = MapSize;
            NumX.Maximum      = MapSize.Width;
            NumY.Maximum      = MapSize.Height;
            NumWidth.Maximum  = MapSize.Width;
            NumHeight.Maximum = MapSize.Height;
            m_X             = rect.Rectangle.X;
            NumX.Value      = rect.Rectangle.X;
            m_Y             = rect.Rectangle.Y;
            NumY.Value      = rect.Rectangle.Y;
            m_Width         = rect.Rectangle.Width;
            NumWidth.Value  = rect.Rectangle.Width;
            m_Height        = rect.Rectangle.Height;
            NumHeight.Value = rect.Rectangle.Height;

            NumMinZ.Value = rect.MinZ;
            m_MinZ        = rect.MinZ;
            NumMaxZ.Value = rect.MaxZ;
            m_MaxZ        = rect.MaxZ;

            m_Updating = false;
        }
コード例 #2
0
ファイル: RectPanel.cs プロジェクト: svn2github/fiddler-plus
        public RectPanel( Size MapSize, MapRectangle3D rect )
        {
            m_Updating = true;

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            m_MapSize = MapSize;
            NumX.Maximum = MapSize.Width;
            NumY.Maximum = MapSize.Height;
            NumWidth.Maximum = MapSize.Width;
            NumHeight.Maximum = MapSize.Height;
            m_X = rect.Rectangle.X;
            NumX.Value = rect.Rectangle.X;
            m_Y = rect.Rectangle.Y;
            NumY.Value = rect.Rectangle.Y;
            m_Width = rect.Rectangle.Width;
            NumWidth.Value = rect.Rectangle.Width;
            m_Height = rect.Rectangle.Height;
            NumHeight.Value = rect.Rectangle.Height;

            NumMinZ.Value = rect.MinZ;
            m_MinZ = rect.MinZ;
            NumMaxZ.Value = rect.MaxZ;
            m_MaxZ = rect.MaxZ;

            m_Updating = false;
        }
コード例 #3
0
        /// <summary>
        /// Deletes the rectangle currently selected
        /// </summary>
        private void DeleteSelectedRectangle()
        {
            if (SelectedRect == null)
                return;

            int index = m_DisplayedRects.IndexOf(SelectedRect);

            Map.RemoveDrawObject(SelectedRect);

            // This is only on the display
            ArrayList dispRects = new ArrayList(DisplayedRects);
            dispRects.RemoveAt(index);
            DisplayedRects = dispRects;

            if (Tree.SelectedNode.Tag is MapRegion)
            {
                // Region node
                MapRegion region = Tree.SelectedNode.Tag as MapRegion;

                region.Area.RemoveAt(index);
            }

            m_LockSelection = false;
            SelectedRect = null;
        }
コード例 #4
0
        //
        // Mouse Down on the rectangles list
        private void RectList_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            int index = RectList.SelectedIndex;

            if (index >= 0)
            {
                int currentIndex = m_DisplayedRects.IndexOf(SelectedRect);

                bool temp = m_LockSelection;

                m_LockSelection = false;

                SelectedRect = (MapRectangle3D)m_DisplayedRects[index];

                // Focus the map
                Map.Center = new Point(m_SelectedRect.Rectangle.X, m_SelectedRect.Rectangle.Y);

                m_LockSelection = temp;

                if (currentIndex != index)
                {
                    // Lock unlock
                    m_LockSelection = true;

                    AddRectanglePanel();
                }
                else
                {
                    LockRectangle(!m_LockSelection);

                    if (m_LockSelection)
                        AddRectanglePanel();
                }
            }
        }
コード例 #5
0
        //
        // MOUSE MOVE
        //
        private void Map_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (m_SetGo)
                return;

            if (e.Button == MouseButtons.None)
            {
                // No button pressed, check for draw objects at given location
                SelectedRect = GetRectAt(new Point(e.X, e.Y));

                return;
            }

            // Left button: either dragging or drawing
            if (e.Button == MouseButtons.Left)
            {
                if (SelectedRect != null)
                {
                    Point endDrag = Map.ControlToMap(new Point(e.X, e.Y));

                    // Make sure the rect is actually dragged
                    if ((m_DragStart.X == endDrag.X) && (m_DragStart.Y == endDrag.Y))
                        return;

                    // A rectangle is selected: this is a dragging
                    m_DraggingRect = true;

                    int xOffset = endDrag.X - m_DragStart.X;
                    int yOffset = endDrag.Y - m_DragStart.Y;

                    Rectangle rect = SelectedRect.Rectangle;

                    rect.X += xOffset;
                    rect.Y += yOffset;

                    rect = FitRectangle(rect);

                    SelectedRect.Rectangle = rect;

                    // Update the dragging origin
                    m_DragStart = endDrag;

                    Map.Refresh();

                    return;
                }
                else
                {
                    // Do this only if we're drawing a rectangle
                    if (!m_DrawingRect)
                        return;

                    Point end = Map.ControlToMap(new Point(e.X, e.Y));

                    // Make sure the point is inside the map
                    end = FitPoint(end);

                    Rectangle rect = GetRectangle(m_DragStart, end);

                    if (DrawingRect == null)
                    {
                        int minZ = MapRegion.DefaultMinZ;
                        int maxZ = MapRegion.DefaultMaxZ;

                        MapRegion region = Tree.SelectedNode.Tag as MapRegion;
                        if (region != null)
                        {
                            minZ = region.MinZ;
                            maxZ = region.MaxZ;
                        }

                        // Just starting to draw
                        MapRectangle3D mapRect = new MapRectangle3D(rect, Map.Map, DrawRectBorder, DrawRectFill, minZ, maxZ);

                        DrawingRect = mapRect;
                    }
                    else
                    {
                        DrawingRect.Rectangle = rect;

                        Map.Refresh();
                    }

                    return;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Creates and sets the MapRectangle3D objects from a list of given rectangles
        /// </summary>
        /// <param name="list">The list of rectangles to be used as base for the map objects</param>
        private void MakeRectangles(ArrayList list)
        {
            // Initialize the displayed rectanlges
            ArrayList dispRects = new ArrayList();

            // Draw the rectangles
            foreach (MapRect rect in list)
            {
                Rectangle rectangle = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
                // Create new rectangle
                MapRectangle3D r = new MapRectangle3D(rectangle, Map.Map, RectBorder, RectFill, rect.MinZ, rect.MaxZ);
                Map.AddDrawObject(r, false);

                dispRects.Add(r);
            }

            DisplayedRects = dispRects;
        }