FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
MapWindow5/src/MW5.UI/Menu/MenuItem.cs at develop · MapWindow/MapWindow5 · GitHub
MapWindow
/
MapWindow5
Public
Notifications
You must be signed in to change notification settings
Fork
102
Star
308
Code
Issues
14
Pull requests
12
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
MapWindow5
/
src
/
MW5.UI
/
Menu
/
MenuItem.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
133 lines (114 loc) · 3.51 KB
Breadcrumbs
MapWindow5
/
src
/
MW5.UI
/
Menu
/
MenuItem.cs
Copy path
File metadata and controls
133 lines (114 loc) · 3.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
124
125
126
127
128
129
130
131
132
133
using
System
;
using
System
.
ComponentModel
;
using
System
.
Drawing
;
using
System
.
Windows
.
Forms
;
using
MW5
.
Plugins
.
Concrete
;
using
MW5
.
Plugins
.
Events
;
using
MW5
.
Plugins
.
Interfaces
;
using
MW5
.
Shared
;
using
Syncfusion
.
Windows
.
Forms
.
Tools
.
XPMenus
;
namespace
MW5
.
UI
.
Menu
{
internal
class
MenuItem
:
MenuItemBase
,
IMenuItem
{
private
const
int
IconSize
=
24
;
protected
readonly
BarItem
_item
;
internal
MenuItem
(
BarItem
item
)
{
_item
=
item
;
if
(
item
==
null
)
{
throw
new
NullReferenceException
(
"Bar item reference is null."
)
;
}
item
.
ShowTooltip
=
false
;
Skip
=
false
;
}
public
virtual
string
Text
{
get
{
return
_item
.
Text
;
}
set
{
_item
.
Text
=
value
;
FireItemChanged
(
"Text"
)
;
}
}
public
IMenuIcon
Icon
{
get
{
return
new
MenuIcon
(
_item
.
Image
.
GetImage
(
)
)
;
}
set
{
if
(
value
==
null
||
value
.
Image
==
null
)
return
;
_item
.
Image
=
new
ImageExt
(
value
.
Image
)
;
int
width
=
value
.
UseNativeSize
?
value
.
Image
.
Width
:
IconSize
;
int
height
=
value
.
UseNativeSize
?
value
.
Image
.
Height
:
IconSize
;
_item
.
ImageSize
=
new
Size
(
width
,
height
)
;
}
}
public
string
Category
{
get
{
return
Metadata
.
Category
;
}
set
{
Metadata
.
Category
=
value
;
}
}
public
bool
Checked
{
get
{
return
_item
.
Checked
;
}
set
{
_item
.
Checked
=
value
;
}
}
public
bool
Enabled
{
get
{
return
_item
.
Enabled
;
}
set
{
_item
.
Enabled
=
value
;
}
}
public
override
bool
HasKey
{
get
{
return
_item
.
Tag
is
MenuItemMetadata
;
}
}
protected
override
MenuItemMetadata
Metadata
{
get
{
var
data
=
_item
.
Tag
as
MenuItemMetadata
;
if
(
data
==
null
)
{
throw
new
ApplicationException
(
"Tag property of menu items must store an instance of MenuItemMetadata class."
)
;
}
return
data
;
}
}
public
bool
Visible
{
get
{
return
_item
.
Visible
;
}
set
{
_item
.
Visible
=
value
;
}
}
internal
protected
virtual
void
DetachItemListeners
(
)
{
EventHelper
.
RemoveEventHandler
(
_item
,
"Click"
)
;
// so it can be collected by GC
EventHelper
.
RemoveEventHandler
(
_item
,
"Selected"
)
;
EventHelper
.
RemoveEventHandler
(
this
,
"ItemChanged"
)
;
}
public
object
GetInternalObject
(
)
{
return
_item
;
}
public
event
EventHandler
<
MenuItemEventArgs
>
ItemClicked
{
add
{
_item
.
Click
+=
(
s
,
e
)
=>
value
.
Invoke
(
this
,
new
MenuItemEventArgs
(
Key
)
)
;
}
remove
{
// will be unsubscribed in DetachItemListeners
}
}
/// <summary>
/// Gets or sets a value indicating whether the item should be skipped during processing (e.g. separator).
/// </summary>
public
bool
Skip
{
get
;
private
set
;
}
/// <summary>
/// Gets or sets the shortcut keys.
/// </summary>
public
Keys
ShortcutKeys
{
get
;
set
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL