arcgis runtime .net: extending views and view models · extending views and view models mark...

24
ArcGIS Runtime .NET: Extending Views and View Models Mark Cederholm UniSource Energy Services Flagstaff, Arizona

Upload: dodat

Post on 12-Sep-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

ArcGIS Runtime .NET:

Extending Views

and View Models

Mark Cederholm

UniSource Energy Services

Flagstaff, Arizona

Page 2: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

“How can I design a single, relatively simple GIS field application, that can be

configured to look completely different, in order to accomplish

different tasks?”

Page 3: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

My First Attempt

� Built using ArcGIS Runtime WPF, and later .NET

� Modeled after the architecture of the ArcGIS Viewer for Silverlight

� Layout design was challenging (not really WYSIWYG)

� Changing appearance of dialog windows required creating different extensions

Page 4: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

A Mix-and-Match Problem

� How to extend a single view model to accommodate any view?

� How to avoid custom or Runtime elements in view XAML?

� How to interact with the MapView?

� How to wire it all together?

Page 5: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

An Extensible View Model

11:44:21 AM

All view elements in the main windowbind to this property

Page 6: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

The DataContexts Property

� An instance of the DataHelper class

� Returns null if a key is not present

� Notifies if a value is set

� Model extensions are added to this collection

11:44:21 AM

Page 7: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

<RadioButton

DataContext="{Binding DataContexts[QueryAddin.QueryTools]}"

Command="{Binding IdentifyCommand}"

ToolTip="Identify"

Style="{StaticResource LayoutToolStyle}"

IsChecked="{Binding IdentifyToolChecked}">

<Image

Source="Images/Identify.png"

Style="{StaticResource LayoutIconStyle}"/>

</RadioButton>

<ContentPresenter

Grid.Column="1"

Content="{Binding DataContexts[MapViewContainerContent]}" />

A typical tool button:

A MapView container:

Page 8: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

A Model Extension

� Typically acts as a data context

� Provides bindable properties that may or may not be consumed by a particular configuration

� May bind to views and/or view extensions

� May implement IConfigurable

11:44:21 AM

Page 9: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

A View Extension

� A subclass of Behavior<MapView>

� Handles interaction with the MapView

� May implement IConfigurable

� Typically has a model extension bound to it

� Bindings are declared in the configuration

11:44:21 AM

Page 10: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

ViewViewModel

ModelExtension

ViewExtension

MapViewConfigHelper

Assigns

Page 11: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Demo

Page 12: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

Application Architecture

Extensibility.dll

MapApplication

ChildWindowInterfaces

Helper Classes

MyApp.exe

IMainWindow

MyAddin.dll (1+)

Model Extensions

View Extensions

MyViews.dll (1+)

Main Layout

Dialogs

Resources.xaml

MyConfig.xml

Configuration

Page 13: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Subfolders

11:44:21 AM

Application (or Updates) Folder

Config

Extensions

Views

Page 14: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Starting MapApplication

� Implement IMainWindow

� Init MapApplication:

� IMainWindow supplies the configuration keyword

11:44:21 AM

MapApplication.Init(pMainWindow);

Page 15: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Extensibility Interfaces

� IMainWindow: app main window

� IStatus: reporting status, messages

� IConfigurable: configured extensions

� IWindowContent: nonmodal dialogs

� IDialogContent: modal dialogs

� IMapTool: tools

11:44:21 AM

Page 16: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Major Extensibility Classes

� MapApplication: entry point and basic management

� ResourceHelper: access to view resources

� SettingsHelper: manages settings

� CommandHelper: ICommand support

� ToolHelper: IMapTool support

11:44:21 AM

Page 17: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Configuration: Basic Structure

11:44:21 AM

<?xml version="1.0" encoding="utf-8" ?>

<Application>

<MainLayout>

. . .

</MainLayout>

<Extensions>

. . .

</Extensions>

</Application>

Page 18: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

Configuration: MainLayout

<MainLayout>

<Title>FieldApp - Gas</Title>

<ViewAssembly>BasicViews</ViewAssembly>

<MainLayoutName>BasicLayout</MainLayoutName>

</MainLayout>

Page 19: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

<Extensions>

<Extension Name="NavAddin">

<ViewAssembly>BasicViews</ViewAssembly>

<ModelExtensions>

. . .

</ModelExtensions>

<ViewExtensions>

. . .

</ViewExtensions>

</Extension>

. . .

</Extensions>

Configuration: Extensions

Page 20: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

<ModelExtensions>

<ModelExtension Name="MapModelExt">

<ConfigData>

<EnableTOC>True</EnableTOC>

<DataModelTOC

Assembly="WebAddin"

ClassName="TocWebDataItem" />

</ConfigData>

</ModelExtension>

<ModelExtension Name="NavModelExt" />

. . .

</ModelExtensions>

Configuration: Model Extensions

Page 21: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

11:44:21 AM

<ViewExtensions>

<ViewExtension Name="NavViewExt">

<DataContext Name="NavAddin.NavModelExt" />

<Bindings>

<Binding

TargetDependencyProperty="..."

SourceProperty="..."

BindingMode="..." />

. . .

</Bindings>

</ViewExtension>

. . .

</ViewExtensions>

Configuration: View Extensions

BindingMode can be: “OneWay”, “TwoWay”, “OneWayToSource”

Page 22: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Available Examples [10.2.7]

� NavAddin: map navigation, TOC

� QueryAddin: identify, find, measure

� LayoutAddin: printable layouts

� WebAddin: map services/packages

� EditAddin: sync framework support

� AppUpdateAddin: receive updates

� RTReader: example finished app

11:44:21 AM

Page 23: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Future Directions and

Possible Ideas

� Runtime 100 version

� NavAddin: MMPK support

� Utility network support

� Overview map extension

� Docking windows extension

� ???

11:44:21 AM

Page 24: ArcGIS Runtime .NET: Extending Views and View Models · Extending Views and View Models Mark Cederholm ... Built using ArcGIS Runtime WPF, and later .NET Modeled after the architecture

Questions?

� Mark Cederholm

[email protected]

� This presentation and examples may be downloaded at:

11:44:21 AM

http://www.pierssen.com/arcgis/runtime.htm