/// <summary> /// Draws the rectangle on the provided Graphics /// </summary> /// <param name="g">The graphics on which the drawing happens</param> /// <param name="ViewInfo">Information about the current map view</param> public void Draw(Graphics g, MapViewInfo ViewInfo) { Point p = ViewInfo.MapToControl(m_Location); int x = p.X; int y = p.Y; Brush brush = new SolidBrush(m_Color); Pen pen = new Pen(brush); g.DrawLine(pen, x - m_Length, y, x + m_Length, y); g.DrawLine(pen, x, y - m_Length, x, y + m_Length); }
/// <summary> /// Draws the rectangle on the provided Graphics /// </summary> /// <param name="g">The graphics on which the drawing happens</param> /// <param name="ViewInfo">Information about the current map view</param> public void Draw(Graphics g, MapViewInfo ViewInfo) { Point p1 = ViewInfo.MapToControl(new Point(m_Location.X, m_Location.Y)); Point p2 = ViewInfo.MapToControl(new Point(m_Location.Right, m_Location.Bottom)); Brush borderBrush = new SolidBrush(m_Color); Pen borderPen = new Pen(borderBrush); g.DrawRectangle(borderPen, p1.X, p1.Y, p2.X - p1.X, p2.Y - p1.Y); if (m_Fill) { Brush fillBrush = new SolidBrush(m_FillColor); g.FillRectangle(fillBrush, p1.X, p1.Y, p2.X - p1.X, p2.Y - p1.Y); } }
/// <summary> /// Draws the circle /// </summary> /// <param name="g">The Graphics object used for the drawing</param> /// <param name="ViewInfo">Information about the current map view</param> public void Draw(Graphics g, MapViewInfo ViewInfo) { // Draw at specified location Point p = ViewInfo.MapToControl(m_Location); int x = p.X; int y = p.Y; Brush brush = new SolidBrush(m_Color); Pen pen = new Pen(brush); // Change radius accordingly to zoom level int radius = ViewInfo.MapToControl(m_Radius); // Draw the circle g.DrawEllipse(pen, x - radius, y - radius, radius * 2, radius * 2); if (m_Fill) { // Fill it brush = new SolidBrush(m_FillColor); g.FillEllipse(brush, x - radius, y - radius, radius * 2, radius * 2); } }
/// <summary> /// Creates a MapViewer control /// </summary> public MapViewer() { // Set styles needed to reduce flickering SetStyle( ControlStyles.DoubleBuffer, true ); SetStyle( ControlStyles.UserPaint, true ); SetStyle( ControlStyles.AllPaintingInWmPaint, true ); // Initialize variables //m_MapArray = new ArrayList(); m_ColorMap = new short[ 65536 ]; // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert m_DrawObjects = new List<IMapDrawable>(); // Issue 10 - End // Generate the Difl data GeneratePatchData(); // Read the colors // Issues 43 - Problems when the client path isn't found - http://code.google.com/p/pandorasbox3/issues/detail?id=43 - Smjert if (!LoadRadarcol()) { MessageBox.Show("Impossible to load .mul files", "Error"); Environment.Exit(1); } // Issues 43 - End // Create the default view. This will be most likely changed by the frame m_ViewInfo = new MapViewInfo( this ); }