[mapguide-commits] r7054 - trunk/Tools/Maestro/Maestro.MapViewer
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Oct 1 05:02:18 PDT 2012
Author: jng
Date: 2012-10-01 05:02:18 -0700 (Mon, 01 Oct 2012)
New Revision: 7054
Modified:
trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs
trunk/Tools/Maestro/Maestro.MapViewer/Legend.cs
trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs
Log:
#2018: Legend control improvements:
- Expose a MapRefreshing event in the IMapViewer and have the legend refresh from that. This way both the legend refreshing and rendering of the updated map image happens at the same time instead of the legend refresh happening *after* the updated map image has been rendered.
- Reduce the scope of the BeginUpdate()/EndUpdate() calls on the legend TreeView. The clearing and re-populating of tree nodes now happens upon completion of the legend background worker.
- Disable the legend when viewer is busy, this prevents any unwanted map state manipulation while the map is being rendered.
Modified: trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs 2012-10-01 10:49:46 UTC (rev 7053)
+++ trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs 2012-10-01 12:02:18 UTC (rev 7054)
@@ -207,8 +207,15 @@
void RefreshMap();
/// <summary>
- /// Raised when the map has been refreshed
+ /// Raised when the viewer has started refreshing the map. This is to allow
+ /// any actions dependent on map state to update themselves asynchronously
+ /// without needing to wait for the updated map to be rendered.
/// </summary>
+ event EventHandler MapRefreshing;
+
+ /// <summary>
+ /// Raised when the map has been refreshed and the updated map image has been rendered
+ /// </summary>
event EventHandler MapRefreshed;
/// <summary>
Modified: trunk/Tools/Maestro/Maestro.MapViewer/Legend.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/Legend.cs 2012-10-01 10:49:46 UTC (rev 7053)
+++ trunk/Tools/Maestro/Maestro.MapViewer/Legend.cs 2012-10-01 12:02:18 UTC (rev 7054)
@@ -82,21 +82,28 @@
if (_viewer != null && !this.DesignMode)
{
_map = _viewer.GetMap();
- _viewer.MapRefreshed += new EventHandler(OnMapRefreshed);
- _viewer.MapLoaded += new EventHandler(OnMapLoaded);
+ _viewer.PropertyChanged += OnViewerPropertyChanged;
+ _viewer.MapRefreshing += OnMapRefreshing;
+ _viewer.MapLoaded += OnMapLoaded;
_selectableIcon = Properties.Resources.lc_select;
_unselectableIcon = Properties.Resources.lc_unselect;
}
}
}
+ void OnViewerPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == "IsBusy")
+ this.Enabled = !_viewer.IsBusy;
+ }
+
void OnMapLoaded(object sender, EventArgs e)
{
_map = _viewer.GetMap();
_presenter = new LegendControlPresenter(this, _map);
}
- void OnMapRefreshed(object sender, EventArgs e)
+ void OnMapRefreshing(object sender, EventArgs e)
{
this.RefreshLegend();
}
@@ -128,7 +135,6 @@
return;
ResetTreeView();
- trvLegend.BeginUpdate();
_legendUpdateStopwatch.Start();
this.IsBusy = true;
bgLegendUpdate.RunWorkerAsync();
@@ -171,6 +177,8 @@
{
this.IsBusy = bgLegendUpdate.IsBusy;
var nodes = e.Result as TreeNode[];
+ trvLegend.BeginUpdate();
+ ClearNodes(trvLegend.Nodes);
if (nodes != null)
{
//Attach relevant context menus based on attached metadata
@@ -228,7 +236,6 @@
private void ResetTreeView()
{
- ClearNodes(trvLegend.Nodes);
imgLegend.Images.Clear();
imgLegend.Images.Add(IMG_BROKEN, Properties.Resources.lc_broken);
Modified: trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs 2012-10-01 10:49:46 UTC (rev 7053)
+++ trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs 2012-10-01 12:02:18 UTC (rev 7054)
@@ -1418,6 +1418,10 @@
internal void RefreshMap(bool raiseEvents)
{
+ var h = this.MapRefreshing;
+ if (h != null)
+ h(this, EventArgs.Empty);
+
//This is our refresh action
RefreshAction action = new RefreshAction(() =>
{
@@ -1450,9 +1454,18 @@
}
/// <summary>
- /// Raised when the map has been refreshed
+ /// Raised when the viewer has started refreshing the map. This is to allow
+ /// any actions dependent on map state to update themselves asynchronously
+ /// without needing to wait for the updated map to be rendered.
/// </summary>
[Category("MapGuide Viewer")]
+ [Description("Raised when the viewer has started refreshing the map")]
+ public event EventHandler MapRefreshing;
+
+ /// <summary>
+ /// Raised when the map has been refreshed and the updated map image has been rendered
+ /// </summary>
+ [Category("MapGuide Viewer")]
[Description("Raised after the viewer has refreshed")]
public event EventHandler MapRefreshed;
More information about the mapguide-commits
mailing list