Skip to content

Commit

Permalink
Merge pull request #130 from Esri/UpdateTov100.1
Browse files Browse the repository at this point in the history
Update to v100.1
  • Loading branch information
mstefarov authored Jun 30, 2017
2 parents cac391f + c8e548a commit 687545d
Show file tree
Hide file tree
Showing 50 changed files with 1,234 additions and 245 deletions.
2 changes: 2 additions & 0 deletions src/Esri.ArcGISRuntime.Toolkit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Global
{A59A0CCB-B4EF-4F81-ABE0-E6315407D5F1}.Debug|x86.Build.0 = Debug|x86
{A59A0CCB-B4EF-4F81-ABE0-E6315407D5F1}.Debug|x86.Deploy.0 = Debug|x86
{A59A0CCB-B4EF-4F81-ABE0-E6315407D5F1}.Release|Any CPU.ActiveCfg = Release|x86
{A59A0CCB-B4EF-4F81-ABE0-E6315407D5F1}.Release|Any CPU.Build.0 = Release|x86
{A59A0CCB-B4EF-4F81-ABE0-E6315407D5F1}.Release|Any CPU.Deploy.0 = Release|x86
{A59A0CCB-B4EF-4F81-ABE0-E6315407D5F1}.Release|ARM.ActiveCfg = Release|ARM
{A59A0CCB-B4EF-4F81-ABE0-E6315407D5F1}.Release|ARM.Build.0 = Release|ARM
{A59A0CCB-B4EF-4F81-ABE0-E6315407D5F1}.Release|ARM.Deploy.0 = Release|ARM
Expand Down
91 changes: 91 additions & 0 deletions src/Esri.ArcGISRuntime.Toolkit/Shared/TemplateDatasource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// /*******************************************************************************
// * Copyright 2012-2016 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.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Mapping;

namespace Esri.ArcGISRuntime.Toolkit.UI
{
public class TemplateDataSource
{
private LayerCollectionMonitor<FeatureLayer> _featureLayers;

/// <summary>
/// Initializes a new instance of the <see cref="TemplateDataSource"/> class.
/// </summary>
/// <param name="layers">A collection of layers to pull feature templates from.</param>
public TemplateDataSource(IEnumerable<Layer> layers)
{
_featureLayers = new LayerCollectionMonitor<FeatureLayer>(layers);
_featureLayers.CollectionChanged += FeatureLayers_CollectionChanged;
_templates = new ObservableCollection<KeyValuePair<ArcGISFeatureTable, IList<FeatureTemplate>>>();
Initialize();
}

private void Initialize()
{
_templates.Clear();
foreach (var table in _featureLayers.Select(f => f.FeatureTable).OfType<ArcGISFeatureTable>())
{
KeyValuePair<ArcGISFeatureTable, IList<FeatureTemplate>> l = new KeyValuePair<ArcGISFeatureTable, IList<FeatureTemplate>>(table, new List<FeatureTemplate>());
foreach (var item in table.FeatureTemplates)
{
l.Value.Add(item);
}

foreach (var type in table.FeatureTypes)
{
foreach (var item in type.Templates)
{
l.Value.Add(item);
}
}
_templates.Add(l);
}
}

private void FeatureLayers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
// if (e.Action == NotifyCollectionChangedAction.Reset)
Initialize();

// else {
// if (e.NewItems != null)
// {
// e.NewItems
// }
// }
}

private ObservableCollection<KeyValuePair<ArcGISFeatureTable, IList<FeatureTemplate>>> _templates = new ObservableCollection<KeyValuePair<ArcGISFeatureTable, IList<FeatureTemplate>>>();

/// <summary>
/// Gets an observable read-only list of feature templates
/// from all loaded <see cref="FeatureLayer"/>s in the provider list of layers.
/// </summary>
public IReadOnlyList<KeyValuePair<ArcGISFeatureTable, IList<FeatureTemplate>>> FeatureTemplates
{
get
{
return _templates;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ internal DataItem(Action<object> callback)
internal DataItem(Action<object> callback, object value)
: this(callback)
{
Value = value;
_value = value;
}

/// <summary>
/// Raises <see cref="_callback"/> with the current <see cref="Value"/> property.
/// </summary>
protected virtual void OnValueChanged() => _callback?.Invoke(Value);
protected virtual void OnValueChanged() => _callback?.Invoke(GetBoundValue());

internal virtual object GetBoundValue() => Value;

private object _value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,10 @@ private void Refresh()
_contentControl.Content = new ReadOnlyDataItem($"[{FieldName}]", null);
_contentControl.ContentTemplate = IsReadOnly ? ReadOnlyTemplate : InputTemplate;
}

return;
}

// Content control, container for the control, and Field, which provides schema for attribute field,
// are both required to generate the control.
if (_contentControl == null || Feature == null)
Expand Down Expand Up @@ -456,16 +458,18 @@ private void GenerateSelectorField()
return;
}

var items = new List<KeyValuePair<object, string>>();
var items = new List<Esri.ArcGISRuntime.Data.CodedValue>();
if (_field.IsNullable)
{
items.Add(new KeyValuePair<object, string>(null, string.Empty));
items.Add(default(Esri.ArcGISRuntime.Data.CodedValue));
}

items.AddRange(cvd.CodedValues.Select(kvp => new KeyValuePair<object, string>(kvp.Code, kvp.Name)));
_contentControl.ContentTemplate = SelectorTemplate;
items.AddRange(cvd.CodedValues);
_contentControl.Content = null;
_contentControl.ContentTemplate = null;
_dataItem = new SelectorDataItem(ValueChangedCallback, BindingValue, items);
_contentControl.Content = _dataItem;
_contentControl.ContentTemplate = SelectorTemplate;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ internal sealed class SelectorDataItem : DataItem
/// <param name="callback">callback raised when <see cref="DataItem.Value"/> property changes.</param>
/// <param name="value">default value selected.</param>
/// <param name="items">coded-value domain options.</param>
public SelectorDataItem(Action<object> callback, object value, IEnumerable<KeyValuePair<object, string>> items)
public SelectorDataItem(Action<object> callback, object value, IEnumerable<Esri.ArcGISRuntime.Data.CodedValue> items)
: base(callback)
{
Items = items?.ToList();
_items = items?.ToList();
Value = GetSelectedItem(value);
}

Expand All @@ -49,18 +49,18 @@ public SelectorDataItem(Action<object> callback, object value, IEnumerable<KeyVa
/// </summary>
/// <param name="value">key value.</param>
/// <returns>matching key-value.</returns>
public KeyValuePair<object, string> GetSelectedItem(object value)
public Esri.ArcGISRuntime.Data.CodedValue GetSelectedItem(object value)
{
return Items?.FirstOrDefault(kvp => kvp.Key != null && kvp.Key.Equals(value)) ??
default(KeyValuePair<object, string>);
return Items?.FirstOrDefault(kvp => kvp?.Code != null && kvp.Code.Equals(value)) ??
default(Esri.ArcGISRuntime.Data.CodedValue);
}

private IList<KeyValuePair<object, string>> _items;
private IList<Esri.ArcGISRuntime.Data.CodedValue> _items;

/// <summary>
/// Gets or sets the Items used as source for <see cref="FeatureDataField.SelectorTemplate"/>
/// </summary>
public IList<KeyValuePair<object, string>> Items
public IList<Esri.ArcGISRuntime.Data.CodedValue> Items
{
get
{
Expand All @@ -78,5 +78,33 @@ public IList<KeyValuePair<object, string>> Items
OnValueChanged();
}
}

public override object Value
{
get
{
return base.Value;
}

set
{
if (value != null && !(value is Esri.ArcGISRuntime.Data.CodedValue))
{
// this shouldn't happen!
}

base.Value = value;
}
}

internal override object GetBoundValue()
{
if (Value is Esri.ArcGISRuntime.Data.CodedValue)
{
return ((Esri.ArcGISRuntime.Data.CodedValue)Value).Code;
}

return base.GetBoundValue();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public static double CalculateScale(Esri.ArcGISRuntime.Geometry.Polygon visibleA

var center = visibleArea.Extent.GetCenter();
var centerOnePixelOver = new Geometry.MapPoint(center.X + unitsPerPixel, center.Y, center.SpatialReference);

// Calculate the geodedetic distance between two points one 'pixel' apart
var result = Geometry.GeometryEngine.DistanceGeodetic(center, centerOnePixelOver, Geometry.LinearUnits.Inches, Geometry.AngularUnits.Degrees, Geometry.GeodeticCurveType.Geodesic);
double distanceInInches = result.Distance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<AssemblyName>Esri.ArcGISRuntime.Toolkit</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.10586.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</references>
<dependencies>
<group targetFramework="uap10.0">
<dependency id="Esri.ArcGISRuntime.UWP" version="[100.0,100.1)" />
<dependency id="Esri.ArcGISRuntime.UWP" version="[100.1,100.2)" />
</group>
</dependencies>
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<NuGetToolsPath>$([System.IO.Path]::Combine($(IntermediateOutputPath), ".nuget"))</NuGetToolsPath>
<NuGetExePath>$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageVersion>100.0.0-beta1</PackageVersion>
<PackageVersion>100.1.0-beta2</PackageVersion>
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<!-- Commands -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<DataTemplate>
<ComboBox ItemsSource="{Binding Items}"
SelectedItem="{Binding Value, Mode=TwoWay}"
DisplayMemberPath="Value" />
DisplayMemberPath="Name" HorizontalAlignment="Stretch" />
</DataTemplate>
</Setter.Value>
</Setter>
Expand Down
2 changes: 1 addition & 1 deletion src/Esri.ArcGISRuntime.Toolkit/UWP/project.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"Esri.ArcGISRuntime.UWP": "100.0.0",
"Esri.ArcGISRuntime.UWP": "100.1.0",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
"StyleCop.Analyzers": {
"version": "1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@
<CodeAnalysisRuleSet>..\Shared\Esri.ArcGISRuntime.Toolkit.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Esri.ArcGISRuntime, Version=100.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Esri.ArcGISRuntime.WPF.100.0.0\lib\net452\Esri.ArcGISRuntime.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
<Reference Include="Esri.ArcGISRuntime, Version=100.1.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Esri.ArcGISRuntime.WPF.100.1.0\lib\net452\Esri.ArcGISRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down Expand Up @@ -129,12 +128,12 @@
<Import Project="..\Shared\Esri.ArcGISRuntime.Toolkit.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildThisFileDirectory)GenerateNugetPackage.targets" />
<Import Project="..\..\..\packages\Esri.ArcGISRuntime.WPF.100.0.0\build\net452\Esri.ArcGISRuntime.WPF.targets" Condition="Exists('..\..\..\packages\Esri.ArcGISRuntime.WPF.100.0.0\build\net452\Esri.ArcGISRuntime.WPF.targets')" />
<Import Project="..\..\..\packages\Esri.ArcGISRuntime.WPF.100.1.0\build\net452\Esri.ArcGISRuntime.WPF.targets" Condition="Exists('..\..\..\packages\Esri.ArcGISRuntime.WPF.100.1.0\build\net452\Esri.ArcGISRuntime.WPF.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\Esri.ArcGISRuntime.WPF.100.0.0\build\net452\Esri.ArcGISRuntime.WPF.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Esri.ArcGISRuntime.WPF.100.0.0\build\net452\Esri.ArcGISRuntime.WPF.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Esri.ArcGISRuntime.WPF.100.1.0\build\net452\Esri.ArcGISRuntime.WPF.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Esri.ArcGISRuntime.WPF.100.1.0\build\net452\Esri.ArcGISRuntime.WPF.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</references>
<dependencies>
<group targetFramework="net452">
<dependency id="Esri.ArcGISRuntime.WPF" version="[100.0,100.1)" />
<dependency id="Esri.ArcGISRuntime.WPF" version="[100.1,100.2)" />
</group>
</dependencies>
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<NuGetToolsPath>$([System.IO.Path]::Combine($(IntermediateOutputPath), ".nuget"))</NuGetToolsPath>
<NuGetExePath>$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageVersion>100.0.0-beta1</PackageVersion>
<PackageVersion>100.1.0-beta2</PackageVersion>
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<!-- Commands -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<DataTemplate>
<ComboBox ItemsSource="{Binding Items}"
SelectedItem="{Binding Value, Mode=TwoWay}"
DisplayMemberPath="Value" />
DisplayMemberPath="Name" />
</DataTemplate>
</Setter.Value>
</Setter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ public LayerContentViewModel(ILayerContent layerContent, WeakReference<GeoView>
Layer layer = (LayerContent as Layer);
GeoView gview;
if (layer.LoadStatus != LoadStatus.NotLoaded && _view.TryGetTarget(out gview))
UpdateLayerViewState(gview.GetLayerViewState(layer));
{
try
{
var viewState = gview.GetLayerViewState(layer);
UpdateLayerViewState(viewState);
}
catch(ArgumentException)
{ }
}
else
UpdateLayerViewState(null);
}
Expand Down
Loading

0 comments on commit 687545d

Please sign in to comment.