-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton_Legend_Renderer.cs
66 lines (55 loc) · 1.77 KB
/
Button_Legend_Renderer.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
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.SystemUI;
namespace GSC_Legend_Renderer
{
public class Button_Legend_Renderer : ESRI.ArcGIS.Desktop.AddIns.Button
{
public Button_Legend_Renderer()
{
}
protected override void OnClick()
{
//Validation - Get document and set layout view if not already set
IMxDocument currentDoc = (IMxDocument)ArcMap.Application.Document;
ActivateLayoutView(currentDoc.ActiveView);
ArcMap.Application.CurrentTool = null;
}
protected override void OnUpdate()
{
Enabled = ArcMap.Application != null;
}
/// <summary>
/// Will navigate to layout view, if user was in data view.
/// </summary>
/// <param name="actView"></param>
public void ActivateLayoutView(IActiveView actView)
{
//Activate
Services.MXD mxdService = new Services.MXD();
mxdService.ActivateLayoutView(actView);
//Issue #78 - Code fails when user is within map, within layout.
//Enforce activate view to be set in layer.
if (actView.IsMapActivated)
{
try
{
actView.IsMapActivated = false;
actView.Refresh();
}
catch (Exception)
{
}
}
//Open renderer form
Form_Legend_Renderer inputForm = new Form_Legend_Renderer();
inputForm.Show();
}
}
}