Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default branch with ArcPro v3 support #149

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions arches_arcgispro_addin/Behaviours/DefaultBrowserBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace arches_arcgispro_addin.Behaviours
{
public static class DefaultBrowserBehaviour
{
public static void OpenBrowser(string url)
{
if (string.IsNullOrEmpty(url))
{
if (string.IsNullOrEmpty(StaticVariables.archesInstanceURL))
{
return;
}
url = StaticVariables.archesInstanceURL;
}
Process process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = url;
process.Start();
}
}
}
58 changes: 0 additions & 58 deletions arches_arcgispro_addin/Behaviours/HoverLinkBehaviour.cs

This file was deleted.

This file was deleted.

39 changes: 16 additions & 23 deletions arches_arcgispro_addin/Config.daml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<ArcGIS defaultAssembly="arches_arcgispro_addin.dll" defaultNamespace="arches_arcgispro_addin" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{ef079a8b-4d20-43cd-92c7-e76e4280243a}" version="1.0" desktopVersion="2.5.22081">
<?xml version="1.0" encoding="utf-8"?>
<ArcGIS defaultAssembly="arches_arcgispro_addin.dll" defaultNamespace="arches_arcgispro_addin" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{ef079a8b-4d20-43cd-92c7-e76e4280243a}" version="1.0" desktopVersion="3.2.49743">
<Name>arches_arcgispro_addin</Name>
<Description>An ESRI add-in that will interface with a Koop.js service backed by an Arches data store</Description>
<Image>Images\AddinDesktop32.png</Image>
Expand Down Expand Up @@ -33,32 +34,29 @@
<button refID="esri_editing_ShowAttributes" size="middle" />
<button refID="esri_mapping_clearSelectionButton" size="middle" />
</group>
<group id="arches_arcgispro_addin_Group3" caption="Chromium Pane" appearsOnAddInTab="false">
<button refID="arches_arcgispro_addin_UI_ChromePane_OpenButton" size="large" />
</group>
</groups>

<group id="arches_arcgispro_addin_Group3" caption="Arches" appearsOnAddInTab="false">
<button refID="arches_arcgispro_addin_UI_Browser_OpenButton" size="large" />
</group>
</groups>
<conditions>
<insertCondition id="token_condition" caption="token state">
<state id="token_state" />
</insertCondition>
</conditions>

<controls>
<button id="arches_arcgispro_addin_MainDockpane_ShowButton" caption="Arches Connection" className="MainDockpane_ShowButton" loadOnClick="true" largeImage="Images\ArchesIcon32.png" smallImage="Images\ArchesIcon16.png">
<tooltip heading="Arches Instance">Connect to Arches Instance<disabledText /></tooltip>
</button>
<button id="arches_arcgispro_addin_SaveResource_ShowButton" caption="Edit Resources" className="SaveResource_ShowButton" loadOnClick="true" largeImage="Images\AddinDesktop32.png" smallImage="Images\AddinDesktop16.png" condition = "token_condition">
<tooltip heading="Edit Resources">Save Geometry to the selected reousrce instance<disabledText />
</tooltip>
<button id="arches_arcgispro_addin_SaveResource_ShowButton" caption="Edit Resources" className="SaveResource_ShowButton" loadOnClick="true" largeImage="Images\AddinDesktop32.png" smallImage="Images\AddinDesktop16.png" condition="token_condition">
<tooltip heading="Edit Resources">Save Geometry to the selected reousrce instance<disabledText /></tooltip>
</button>
<button id="arches_arcgispro_addin_CreateResource_ShowButton" caption="Create Resources" className="CreateResource_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple32.png" condition = "token_condition">
<button id="arches_arcgispro_addin_CreateResource_ShowButton" caption="Create Resources" className="CreateResource_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple32.png" condition="token_condition">
<tooltip heading="Create Resources">Create a New Resource<disabledText /></tooltip>
</button>
<button id="arches_arcgispro_addin_UI_ChromePane_OpenButton" caption="Open Chromium Pane" className="arches_arcgispro_addin.UI.ChromePane_OpenButton" loadOnClick="true" smallImage="Images\chromium16.png" largeImage="Images\chromium32.png">
<tooltip heading="Open Chromium Pane">Open Chromium Pane<disabledText /></tooltip>
</button>
</controls>
<button id="arches_arcgispro_addin_UI_Browser_OpenButton" caption="Open Arches" className="arches_arcgispro_addin.UI.Browser_OpenButton" loadOnClick="true" smallImage="Images\ArchesIcon16.png" largeImage="Images\ArchesIcon32.png">
<tooltip heading="Open Arches">Open Arches<disabledText /></tooltip>
</button>
</controls>
<dockPanes>
<dockPane id="arches_arcgispro_addin_MainDockpane" caption="Arches Connection" className="MainDockpaneViewModel" dock="group" dockWith="esri_core_contentsDockPane">
<content className="MainDockpaneView" />
Expand All @@ -70,11 +68,6 @@
<content className="CreateResourceView" />
</dockPane>
</dockPanes>
<panes>
<pane id="arches_arcgispro_addin_UI_ChromePane" caption="ChromePane" className="arches_arcgispro_addin.UI.ChromePaneViewModel" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonGreen16.png" defaultTab="esri_mapping_homeTab" defaultTool="esri_mapping_navigateTool">
<content className="arches_arcgispro_addin.UI.ChromePaneView" />
</pane>
</panes>
</insertModule>
</insertModule>
</modules>
</ArcGIS>
</ArcGIS>
27 changes: 11 additions & 16 deletions arches_arcgispro_addin/CreateResource.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<!--DockPanel Grid.Row="0" LastChildFill="true" KeyboardNavigation.TabNavigation="Local" Height="25">
<TextBlock Grid.Column="1" Text="{Binding Heading}" Style="{DynamicResource Esri_TextBlockDockPaneHeader}">
<TextBlock.ToolTip>
<WrapPanel Orientation="Vertical" MaxWidth="300">
<TextBlock Text="{Binding Heading}" TextWrapping="Wrap"/>
</WrapPanel>
</TextBlock.ToolTip>
</TextBlock>
</>

<Button Content="Get Geometry Node Info" HorizontalAlignment="Left" Margin="20,20,0,0" Grid.Row="1" VerticalAlignment="Top" Height="25" Width="300" Click="GetNodeList_Button" /-->

<TextBlock HorizontalAlignment="Left" Margin="20,20,0,0" Grid.Row="1" Text="Select a Resource Type" VerticalAlignment="Top"/>

<ComboBox HorizontalAlignment="Left" Margin="20,40,0,0" Grid.Row="1" VerticalAlignment="Top" Height="25" Width="300"
Expand All @@ -48,12 +36,19 @@
Text="Uploaded Features:" />
<Button Content="Clear the List" HorizontalAlignment="Right" Margin="180,190,25,0" Grid.Row="1" VerticalAlignment="Top" Height="25" Width="100" Click="CreateClear_Button"/>

<DataGrid HorizontalAlignment="Stretch" Height="Auto" Margin="0,230,0,0" Grid.Row="1" VerticalAlignment="Top" Width="Auto"
<DataGrid HorizontalAlignment="Left" Height="Auto" Margin="0,230,0,0" Grid.Row="1" VerticalAlignment="Top" Width="Auto"
ItemsSource="{Binding ResourceIdsCreated}" Style="{DynamicResource Esri_DataGrid}"
HeadersVisibility="None" AutoGenerateColumns="True" IsReadOnly="True" SelectionMode="Single" RowHeaderWidth="0"/>
HeadersVisibility="None" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" RowHeaderWidth="0" MouseDoubleClick="DataGrid_MouseDoubleClick">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" />
<DataGridTextColumn Binding="{Binding Id}" />
<DataGridTextColumn Binding="{Binding Model}" />
</DataGrid.Columns>
</DataGrid>

<Button Name="OpenBrowserButton" Content="Edit using Arches Resource Editor" HorizontalAlignment="Left" Margin="20,0,0,20" Grid.Row="1" VerticalAlignment="Bottom" Height="25" Width="300"
IsEnabled="False" Command="{Binding CreateOpenDefaultWebBrowserButton}" />

<Button Name="OpenChromiumButton" Content="Edit using Arches Resource Editor" HorizontalAlignment="Left" Margin="20,0,0,20" Grid.Row="1" VerticalAlignment="Bottom" Height="25" Width="300"
IsEnabled="False" Command="{Binding CreateOpenChromiumButton}" />
<ComboBox HorizontalAlignment="Left" Margin="20,0,0,60" Grid.Row="1" VerticalAlignment="Bottom" Height="25" Width="300"
ItemsSource="{Binding ResourceIdsCreated}" DisplayMemberPath="Name"
SelectedItem="{Binding SelectedResourceId, Mode=TwoWay}" SelectedIndex="0" />
Expand Down
47 changes: 25 additions & 22 deletions arches_arcgispro_addin/CreateResource.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Editing.Attributes;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using arches_arcgispro_addin.Behaviours;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace arches_arcgispro_addin
{
Expand All @@ -42,7 +29,7 @@ public static async Task<List<GeometryNode>> GetGeometryNode()
try
{
HttpClient client = await ArchesHttpClient.GetHttpClient();
if ((DateTime.Now - StaticVariables.archesToken["timestamp"]).TotalSeconds > (StaticVariables.archesToken["expires_in"] - 300))
if ((int)(DateTime.Now - StaticVariables.archesToken["timestamp"]).TotalSeconds > (int)(StaticVariables.archesToken["expires_in"] - 300))
{
StaticVariables.archesToken = await MainDockpaneView.RefreshToken(StaticVariables.myClientid);
}
Expand All @@ -53,12 +40,15 @@ public static async Task<List<GeometryNode>> GetGeometryNode()

response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
var serializer = new JavaScriptSerializer();
dynamic results = serializer.Deserialize<dynamic>(@responseBody);
dynamic results = JsonConvert.DeserializeObject<dynamic>(@responseBody);

foreach (dynamic element in results)
{
nodeidResponse.Add(new GeometryNode(element["resourcemodelname"], element["name"], element["nodeid"]));
var resourceModelName = (string)element["resourcemodelname"];
if (resourceModelName != "Arches System Settings")
{
nodeidResponse.Add(new GeometryNode((string)element["resourcemodelname"], (string)element["name"], (string)element["nodeid"]));
}
}
}
catch (HttpRequestException e)
Expand Down Expand Up @@ -101,6 +91,9 @@ private async void CreateUpload_Button(object sender, RoutedEventArgs e)
{
try
{
StaticVariables.selectedArchesNodeid = StaticVariables.archesNodeid;


if (MapView.Active == null)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("No MapView currently active. Exiting...", "Info");
Expand Down Expand Up @@ -146,7 +139,7 @@ private async void CreateUpload_Button(object sender, RoutedEventArgs e)
StaticVariables.archesResourceid = result["resourceinstance_id"];
CreateResourceViewModel.GetResourceIdsCreated();
SaveResourceView.RefreshMapView();
OpenChromiumButton.IsEnabled = true;
OpenBrowserButton.IsEnabled = true;
}
else
{
Expand All @@ -162,7 +155,17 @@ private async void CreateUpload_Button(object sender, RoutedEventArgs e)
private void CreateClear_Button(object sender, RoutedEventArgs e)
{
CreateResourceViewModel.ClearResourceIdsCreated();
OpenChromiumButton.IsEnabled = false;
OpenBrowserButton.IsEnabled = false;
}

private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var ri = ((DataGrid)sender).SelectedItem as ResourceInstance;
if (!string.IsNullOrEmpty(ri.Id))
{
DefaultBrowserBehaviour.OpenBrowser(ri.URL);
}
}

}
}
Loading