From 4aa1fb4b86c179d425c1f7d1695df4dbb51c4fde Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 2 Nov 2010 11:16:30 +1300 Subject: [PATCH] refactor mouse position label hooking for Surface --- OpenRA.Editor/Form1.cs | 2 +- OpenRA.Editor/Surface.cs | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index c34181cb09..c9ff2ed1a7 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -36,7 +36,7 @@ namespace OpenRA.Editor Rules.LoadRules(Game.modData.Manifest, new Map()); surface1.AfterChange += OnMapChanged; - surface1.SetMousePositionLabel(toolStripStatusLabelMousePosition); + surface1.MousePositionChanged += s => toolStripStatusLabelMousePosition.Text = s; } void OnMapChanged() diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 1ca42671e9..184ca8bce7 100755 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -35,8 +35,7 @@ namespace OpenRA.Editor public bool IsPanning; public event Action AfterChange = () => { }; - - private ToolStripStatusLabel MousePositionLabel = null; + public event Action MousePositionChanged = _ => { }; Dictionary ActorTemplates = new Dictionary(); Dictionary ResourceTemplates = new Dictionary(); @@ -87,11 +86,6 @@ namespace OpenRA.Editor Invalidate(); } - public void SetMousePositionLabel(ToolStripStatusLabel mouseLabel) - { - MousePositionLabel = mouseLabel; - } - protected override void OnMouseWheel(MouseEventArgs e) { base.OnMouseWheel(e); @@ -129,11 +123,7 @@ namespace OpenRA.Editor var oldMousePos = MousePos; MousePos = new int2(e.Location); - - if (MousePositionLabel != null) - { - MousePositionLabel.Text = GetBrushLocation().ToString(); - } + MousePositionChanged(GetBrushLocation().ToString()); if (e.Button == MouseButtons.Middle || (e.Button != MouseButtons.None && IsPanning)) Scroll(oldMousePos - MousePos);