/// <summary> /// Creates the hosted <see cref="MapView"/>.</summary> /// <remarks> /// <b>CreateMapView</b> (re-)creates the associated <see cref="WorldState"/> if none exists /// or if the <see cref="ScenarioChanged"/> flag is set, and then (re-)creates the global /// <see cref="MapViewManager"/> and the hosted <see cref="MapView"/>.</remarks> private void CreateMapView() { if (ScenarioChanged || this._worldState == null) { ScenarioChanged = false; // (re)create world state from scenario this._worldState = new WorldState(); this._worldState.Initialize(null); } // (re)create map view manager for current scenario if (MapViewManager.Instance != null) { MapViewManager.Instance.Dispose(); } MapViewManager.CreateInstance(Dispatcher); // create mouse event handlers MouseButtonEventHandler onMouseDown = OnMapMouseDown; MouseWheelEventHandler onMouseWheel = MainWindow.Instance.OnMapMouseWheel; // create map view from world state MapViewManager.Instance.CreateView("default", this._worldState, MapViewHost, onMouseDown, onMouseWheel); }
/// <summary> /// Creates a new <see cref="MapViewManager"/> instance based on the current scenario. /// </summary> /// <remarks><para> /// <b>CreateMapViewManager</b> creates a new <see cref="MapViewManager"/> instance. To save /// memory, <b>CreateMapViewManager</b> calls <see cref="ImageSection.Unload"/> on the /// current <see cref="ImageSection"/> once a new instance has been created. /// </para><para> /// <b>CreateMapViewManager</b> raises the <see cref="TaskEvents.TaskProgress"/> event twice /// with a value of one. /// </para><note type="implementnotes"> /// The <see cref="MapViewManager"/> is created on the foreground thread for compatiblity /// with the default <see cref="MapView"/> that will be attached to the current <see /// cref="MainWindow"/> instance.</note></remarks> private void CreateMapViewManager() { this._threadEvents.OnTaskMessage(this, Global.Strings.StatusMapViewCreating); // create map view manager Dispatcher.Invoke(() => MapViewManager.CreateInstance(Dispatcher)); this._threadEvents.OnTaskProgress(this, 1); // unload image file bitmaps MasterSection.Instance.Images.Unload(); this._threadEvents.OnTaskProgress(this, 1); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } Build(); }
/// <summary> /// Creates the default <see cref="Session.MapView"/> for the current <see /// cref="Session.WorldState"/>.</summary> /// <remarks><para> /// <b>CreateMapView</b> creates a new <see cref="MapView"/> object whose <see /// cref="MapView.Id"/> is the literal string "default". This matches the identifier by /// which the <see cref="Session.MapView"/> property of the <see cref="Session"/> class /// locates the default map view. /// </para><note type="implementnotes"> /// Callers on a background thread must use <see cref="Dispatcher.Invoke"/> to invoke /// <b>CreateMapView</b> because the new <see cref="MapView"/> is automatically attached to /// the current <see cref="MainWindow"/> instance.</note></remarks> private void CreateMapView() { MapViewManager manager = MapViewManager.Instance; Debug.Assert(manager != null); WorldState world = Session.Instance.WorldState; Debug.Assert(world != null); // create default map view for current world state MainWindow window = MainWindow.Instance; MapView mapView = manager.CreateView("default", world, window.MapViewHost, window.OnMapMouseDown, window.OnMapMouseWheel); Debug.Assert(mapView == Session.MapView); // attach handler for automatic data view updates mapView.SelectedSiteChanged += window.OnSiteSelected; }