/
fulcrumWindow.xaml.cs
92 lines (90 loc) · 3.34 KB
/
fulcrumWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Shapes;
using System.Threading;
namespace fulcrum
{
/// <summary>
/// Interaction logic for fulcrumWindow.xaml
/// </summary>
public partial class FulcrumWindow : Window
{
fulcrumforms fulcrumForms;
public FulcrumWindow()
{
InitializeComponent();
try
{
//grab the forms associated with the api key and put in the box
fulcrumForms = FulcrumCore.GetForms();
if (fulcrumForms != null)
{
foreach (fulcrumform form in fulcrumForms.forms)
{
ListBoxItem item = new ListBoxItem();
item.Tag = form.id;
item.Content = (form.name);
this.listboxForms.Items.Add(item);
}
}
else
{
MessageBox.Show("Unable to retrieve Fulcrum data at this time.", "Fulcrum Tools", MessageBoxButton.OK, MessageBoxImage.Exclamation);
this.Hide();
}
}
catch (Exception e)
{
string ouch = e.Message;
MessageBox.Show("Unable to retrieve Fulcrum data at this time.", "Fulcrum Tools", MessageBoxButton.OK, MessageBoxImage.Exclamation);
this.Hide();
}
}
private void buttonGetRecords_Click(object sender, RoutedEventArgs e)
{
ESRI.ArcGIS.Framework.IMouseCursor cursor = new ESRI.ArcGIS.Framework.MouseCursorClass();
try
{
ArcMap.Application.StatusBar.set_Message(0, "Fulcrum import...");
cursor.SetCursor(2);
this.Cursor = Cursors.Wait;
ListBoxItem item = (ListBoxItem)this.listboxForms.SelectedItem;
//we have set the Name to the form id when populating the list box
string formid = item.Tag.ToString();
fulcrumform theForm = fulcrumForms.forms.Find(form => form.id == formid);
this.progBar.Visibility = System.Windows.Visibility.Visible;
bool success = FulcrumCore.FireUp(theForm, this.progBar, this.labelStatus);
}
catch(Exception ex)
{
string bomb = ex.Message;
}
finally
{
cursor = null;
this.progBar.Visibility = System.Windows.Visibility.Hidden;
ArcMap.Application.StatusBar.set_Message(0, "");
this.Cursor = Cursors.Arrow;
GC.Collect();
}
}
private void buttonClose_Click(object sender, RoutedEventArgs e)
{
this.Hide();
}
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
}
}