I used overview in SDK sample code and wanna add graphic on it. The graphic does not show unless I added a messagebox and show it ( the red text below). Can anyone has solution of it?
//sample code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using ArcGIS.Core.CIM;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using ArcGIS.Desktop.Mapping.Controls;
namespace MapControl {
internal class ShowOverview : Button {
private static System.IDisposable _overlayObject = null;
private bool _isOpen = false;
private OverviewWindow _overview = null;
private static readonly object _lock = new object();
private IDisposable _graphic = null;
private CIMLineSymbol _lineSymbol = null;
public ShowOverview() {
RegisterForActiveViewChanged();
}
protected override void OnClick()
{
if (_isOpen)
return;
_overview = new OverviewWindow();
var cam = MapView.Active.Camera;
//cam.Heading = 90;
_overview.ViewContent = MapControlContentFactory.Create(
MapView.Active.Map, cam, MapView.Active.ViewingMode);
_overview.Closed += (s, e) =>
{
_isOpen = false;
lock (_lock)
{
_overview = null;
}
};
_overview.Show();
_isOpen = true;
var extent = MapView.Active.Extent;
var height = extent.Height;
var width = extent.Width;
var centerPt = extent.Center;
ArcGIS.Core.CIM.CIMPointSymbol symbol = null;
_overlayObject = QueuedTask.Run(() =>
{
//add these to the overlay
_overview.MyMapControl.AddOverlay(centerPt,
SymbolFactory.Instance.ConstructPointSymbol(
ColorFactory.Instance.RedRGB, 30.0, SimpleMarkerStyle.Star).MakeSymbolReference());
});
//update the overlay with new point graphic symbol
// MessageBox.Show("test");
//QueuedTask.Run(() =>
// {
// _overview.MyMapControl.AddOverlay(centerPt,
// SymbolFactory.Instance.ConstructPointSymbol(
// ColorFactory.Instance.RedRGB, 30.0, SimpleMarkerStyle.Star).MakeSymbolReference());
// });
}
private void RegisterForActiveViewChanged() {
ArcGIS.Desktop.Mapping.Events.ActiveMapViewChangedEvent.Subscribe((args) => {
if (args.IncomingView == null)
return;
lock (_lock) {
if (_overview == null)
return;
_overview.ViewContent = MapControlContentFactory.Create(
MapView.Active.Map, MapView.Active.Extent, MapView.Active.ViewingMode);
}
});
}
}
}