-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtensions.cs
67 lines (60 loc) · 2.41 KB
/
Extensions.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
// <copyright file="Extensions.cs" company="FC">
// Copyright (c) 2011 Fraser Chapman
// </copyright>
// <author>Fraser Chapman</author>
// <email>fraser.chapman@gmail.com</email>
// <date>2011-03-06</date>
// <summary>This file is part of FC.GEPluginCtrls
// FC.GEPluginCtrls is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
// </summary>
namespace FC.GEPluginCtrls
{
using System;
using System.ComponentModel;
using System.Reflection;
/// <summary>
/// Extension helper methods for enumerations in the control library
/// </summary>
internal static class Extensions
{
/// <summary>
/// Gets the internal ID for a Layer
/// </summary>
/// <param name="layer">Layer type</param>
/// <returns>The layer ID or an empty string</returns>
internal static string GetId(this Layer layer)
{
FieldInfo fi = layer.GetType().GetField(layer.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attributes.Length > 0)
{
return attributes[0].Description;
}
return string.Empty;
}
internal static bool GetInheritedVisibility(this Layer layer, GEWebBrowser browser)
{
if (!browser.PluginIsReady)
{
return false;
}
var target = browser.Plugin.getLayerRoot().getLayerById(layer.GetId());
if (target == null || !Convert.ToBoolean(target.getVisibility()))
{
return false;
}
var parent = target.getParentNode();
return parent != null || GetInheritedVisibility(parent, browser);
}
}
}