-
Notifications
You must be signed in to change notification settings - Fork 2
/
GetSymbolByControl.cs
123 lines (105 loc) · 4.14 KB
/
GetSymbolByControl.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Controls;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class GetSymbolByControl : Form
{
public IStyleGalleryItem m_styleGalleryItem = null;
string stylesPath = string.Empty;
esriSymbologyStyleClass gStyleClass;
public GetSymbolByControl(esriSymbologyStyleClass styleClass)
{
InitializeComponent();
gStyleClass = styleClass;
}
private void GetSymbolByControl_Load(object sender, EventArgs e)
{
//Get the ArcGIS install location
string sInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;
//Load the ESRI.ServerStyle file into the SymbologyControl
axSymbologyControl1.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle");
//Set the style class
//axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps;
axSymbologyControl1.StyleClass = gStyleClass;
//Select the color ramp item
//axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass).SelectItem(0);
stylesPath = sInstall + "\\Styles";
cbxStyles.Items.Clear();
cbxStylesAddItems(stylesPath);
}
private void cbxStylesAddItems(string path)
{
string[] serverstyleFiles = System.IO.Directory.GetFiles(stylesPath, "*.serverstyle", SearchOption.AllDirectories);
//string[] styleFiles = System.IO.Directory.GetFiles(stylesPath, "*.style", SearchOption.AllDirectories);
cbxStylesAddItems(serverstyleFiles);
//cbxStylesAddItems(styleFiles);
}
private void cbxStylesAddItems(string[] files)
{
if (files.GetLength(0) == 0) return;
foreach (string file in files)
{
cbxStyles.Items.Add(file);
}
cbxStyles.SelectedIndex = 0;
}
private void btnOtherStyles_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
stylesPath = folderBrowserDialog1.SelectedPath;
cbxStylesAddItems(stylesPath);
}
}
private void cbxStyles_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbxStyles.SelectedItem != null)
{
axSymbologyControl1.Clear();
stylesPath = cbxStyles.SelectedItem.ToString();
string ext = System.IO.Path.GetExtension(stylesPath).ToLower();
//Load the ESRI.ServerStyle file into the SymbologyControl
if (ext == ".serverstyle")
axSymbologyControl1.LoadStyleFile(stylesPath);
if (ext == ".style")
axSymbologyControl1.LoadDesktopStyleFile(stylesPath);
//if (axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass).get_ItemCount(string.Empty) != 0)
// axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass).SelectItem(0);
}
}
private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e)
{
//Get the selected item
m_styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem;
}
public bool IsInteger(string s)
{
try
{
Int32.Parse(s);
}
catch
{
return false;
}
return true;
}
private void btnOK_Click(object sender, EventArgs e)
{
this.Hide();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}