This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from jmccausland/master
Pull request for current sprint ending March 17/18th
- Loading branch information
Showing
26 changed files
with
945 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
source/MilitaryPlanner/Controllers/BasemapGalleryController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright 2015 Esri | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Windows; | ||
using Esri.ArcGISRuntime.Layers; | ||
using Esri.ArcGISRuntime.Portal; | ||
using Esri.ArcGISRuntime.WebMap; | ||
using MilitaryPlanner.Helpers; | ||
using MilitaryPlanner.Views; | ||
using MapView = Esri.ArcGISRuntime.Controls.MapView; | ||
|
||
namespace MilitaryPlanner.Controllers | ||
{ | ||
class BasemapGalleryController | ||
{ | ||
private readonly MapView _mapView; | ||
private readonly BasemapGalleryView _basemapGalleryView; | ||
private ArcGISPortal _arcGisPortal; | ||
|
||
public BasemapGalleryController(MapView mapView) | ||
{ | ||
_mapView = mapView; | ||
|
||
_basemapGalleryView = new BasemapGalleryView { PlacementTarget = mapView, ViewModel = { mapView = mapView } }; | ||
|
||
var owner = Window.GetWindow(mapView); | ||
|
||
if (owner != null) | ||
{ | ||
owner.LocationChanged += (sender, e) => | ||
{ | ||
_basemapGalleryView.HorizontalOffset += 1; | ||
_basemapGalleryView.HorizontalOffset -= 1; | ||
}; | ||
} | ||
|
||
InitializeArcGISPortal(); | ||
|
||
Mediator.Register(Constants.ACTION_UPDATE_BASEMAP, DoUpdateBasemap); | ||
} | ||
|
||
public void Toggle() | ||
{ | ||
_basemapGalleryView.ViewModel.Toggle(); | ||
} | ||
|
||
private async void InitializeArcGISPortal() | ||
{ | ||
_arcGisPortal = await ArcGISPortal.CreateAsync(); | ||
|
||
// Load portal basemaps | ||
var result = await _arcGisPortal.ArcGISPortalInfo.SearchBasemapGalleryAsync(); | ||
_basemapGalleryView.ViewModel.Basemaps = new ObservableCollection<ArcGISPortalItem>(result.Results); | ||
} | ||
|
||
private async void DoUpdateBasemap(object obj) | ||
{ | ||
try | ||
{ | ||
var item = obj as ArcGISPortalItem; | ||
|
||
if (item != null) | ||
{ | ||
var webmap = await WebMap.FromPortalItemAsync(item); | ||
|
||
while (_mapView.Map.Layers.Any(l => l.ID == "basemap")) | ||
{ | ||
_mapView.Map.Layers.Remove("basemap"); | ||
} | ||
|
||
foreach (var s in webmap.Basemap.Layers.Reverse()) | ||
{ | ||
switch (s.LayerType) | ||
{ | ||
case WebMapLayerType.ArcGISTiledMapServiceLayer: | ||
case WebMapLayerType.Unknown: | ||
_mapView.Map.Layers.Insert(0,new ArcGISTiledMapServiceLayer(new Uri(s.Url)){ID="basemap"}); | ||
break; | ||
case WebMapLayerType.OpenStreetMap: | ||
var layer = new OpenStreetMapLayer(){ID="basemap"}; | ||
_mapView.Map.Layers.Insert(0,layer); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
catch (Exception) | ||
{ | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Windows.Data; | ||
using MilitaryPlanner.Properties; | ||
|
||
namespace MilitaryPlanner.Helpers | ||
{ | ||
public class SettingBindingExtension : Binding | ||
{ | ||
public SettingBindingExtension() | ||
{ | ||
Initialize(); | ||
} | ||
|
||
public SettingBindingExtension(string path) | ||
: base(path) | ||
{ | ||
Initialize(); | ||
} | ||
|
||
private void Initialize() | ||
{ | ||
this.Source = Settings.Default; | ||
this.Mode = BindingMode.TwoWay; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.