private void OnPaint(object sender, PaintEventArgs e) { _map = _currMap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3, (int)(e.ClipRectangle.Width / Zoom + 8) >> 3, (int)(e.ClipRectangle.Height / Zoom + 8) >> 3, showStaticsToolStripMenuItem1.Checked); ZoomMap(ref _map); e.Graphics.DrawImageUnscaledAndClipped(_map, e.ClipRectangle); if (showCenterCrossToolStripMenuItem1.Checked) { Brush brush = new SolidBrush(Color.FromArgb(180, Color.White)); Pen pen = new Pen(brush); int x = Round(pictureBox.Width / 2); int y = Round(pictureBox.Height / 2); e.Graphics.DrawLine(pen, x - 4, y, x + 4, y); e.Graphics.DrawLine(pen, x, y - 4, x, y + 4); pen.Dispose(); brush.Dispose(); } if (showClientCrossToolStripMenuItem.Checked) { if (Client.Running) { if (_clientX > hScrollBar.Value && _clientX < hScrollBar.Value + e.ClipRectangle.Width / Zoom && _clientY > vScrollBar.Value && _clientY < vScrollBar.Value + e.ClipRectangle.Height / Zoom && _clientMap == _currMapInt) { Brush brush = new SolidBrush(Color.FromArgb(180, Color.Yellow)); Pen pen = new Pen(brush); int x = (int)((_clientX - Round(hScrollBar.Value)) * Zoom); int y = (int)((_clientY - Round(vScrollBar.Value)) * Zoom); e.Graphics.DrawLine(pen, x - 4, y, x + 4, y); e.Graphics.DrawLine(pen, x, y - 4, x, y + 4); e.Graphics.DrawEllipse(pen, x - 2, y - 2, 2 * 2, 2 * 2); pen.Dispose(); brush.Dispose(); } } } if (OverlayObjectTree.Nodes.Count <= 0 || !showMarkersToolStripMenuItem.Checked) { return; } foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapInt].Nodes) { OverlayObject o = (OverlayObject)obj.Tag; if (o.IsVisible(e.ClipRectangle, _currMapInt)) { o.Draw(e.Graphics); } } }
private void OnPaint(object sender, PaintEventArgs e) { if (FormsDesignerHelper.IsInDesignMode()) { return; } if (PreloadWorker.IsBusy) { e.Graphics.DrawString("Preloading map. Please wait...", SystemFonts.DefaultFont, Brushes.Black, 60, 60); return; } _map = _currMap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3, (int)((e.ClipRectangle.Width / Zoom) + 8) >> 3, (int)((e.ClipRectangle.Height / Zoom) + 8) >> 3, showStaticsToolStripMenuItem1.Checked); ZoomMap(ref _map); e.Graphics.DrawImageUnscaledAndClipped(_map, e.ClipRectangle); if (showCenterCrossToolStripMenuItem1.Checked) { using (Brush brush = new SolidBrush(Color.FromArgb(180, Color.White))) using (Pen pen = new Pen(brush)) { int x = Round(pictureBox.Width / 2); int y = Round(pictureBox.Height / 2); e.Graphics.DrawLine(pen, x - 4, y, x + 4, y); e.Graphics.DrawLine(pen, x, y - 4, x, y + 4); } } if (showClientCrossToolStripMenuItem.Checked && Client.Running) { if (_clientX > hScrollBar.Value && _clientX < hScrollBar.Value + (e.ClipRectangle.Width / Zoom) && _clientY > vScrollBar.Value && _clientY < vScrollBar.Value + (e.ClipRectangle.Height / Zoom) && _clientMap == _currMapId) { using (Brush brush = new SolidBrush(Color.FromArgb(180, Color.Yellow))) using (Pen pen = new Pen(brush)) { int x = (int)((_clientX - Round(hScrollBar.Value)) * Zoom); int y = (int)((_clientY - Round(vScrollBar.Value)) * Zoom); e.Graphics.DrawLine(pen, x - 4, y, x + 4, y); e.Graphics.DrawLine(pen, x, y - 4, x, y + 4); e.Graphics.DrawEllipse(pen, x - 2, y - 2, 2 * 2, 2 * 2); } } } if (OverlayObjectTree.Nodes.Count <= 0 || !showMarkersToolStripMenuItem.Checked) { return; } foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapId].Nodes) { OverlayObject o = (OverlayObject)obj.Tag; if (o.IsVisible(e.ClipRectangle, _currMapId)) { o.Draw(e.Graphics); } } }