admin
2020-06-10 a610f2ab6e543d2cb78c1ef212ac6a74ddc067d9
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
// Copyright © 2013 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
 
namespace CefSharp
{
    /// <summary>
    /// Supports creation and modification of menus. See <see cref="CefMenuCommand"/> for the command ids that have default implementations.
    /// All user-defined command ids should be between <see cref="CefMenuCommand.UserFirst"/> and <see cref="CefMenuCommand.UserFirst"/>.
    /// The methods of this class can only be accessed on the CEF UI thread, which by default is not the same as your application UI thread.
    /// </summary>
    public interface IMenuModel
    {
        /// <summary>
        /// Returns the number of items in this menu.
        /// </summary>
        int Count { get; }
 
        /// <summary>
        /// Remove all menu items. Can be used to disable the context menu. Returns true on success.
        /// </summary>
        /// <returns>Returns true on success</returns>
        bool Clear();
 
        /// <summary>
        /// Returns the label at the specified index or empty if not found due to
        /// invalid range or the index being a separator.
        /// </summary>
        /// <param name="index">specified index</param>
        /// <returns>Label or empty if not found due to invalid range or the index being a separator.</returns>
        string GetLabelAt(int index);
 
        /// <summary>
        /// Returns the command id at the specified index or -1 if not found due to invalid range or the index being a separator.
        /// </summary>
        /// <param name="index">the index</param>
        /// <returns>Command or -1 if not found due to invalid range or the index being a separator.</returns>
        CefMenuCommand GetCommandIdAt(int index);
 
        /// <summary>
        /// Removes the item with the specified commandId.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns true on success</returns>
        bool Remove(CefMenuCommand commandId);
 
        /// <summary>
        /// Add an item to the menu. 
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label of the item</param>
        /// <returns>Returns true on success.</returns>
        bool AddItem(CefMenuCommand commandId, string label);
 
        /// <summary>
        /// Add a separator to the menu. 
        /// </summary>
        /// <returns>Returns true on success.</returns>
        bool AddSeparator();
 
        /// <summary>
        /// Add a check item to the menu.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label of the item</param>
        /// <returns>Returns true on success.</returns>
        bool AddCheckItem(CefMenuCommand commandId, string label);
 
        /// <summary>
        /// Add a radio item to the menu. Only a single item with the specified groupId can be checked at a time.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label of the item</param>
        /// <param name="groupId">the group id</param>
        /// <returns>Returns true on success.</returns>
        bool AddRadioItem(CefMenuCommand commandId, string label, int groupId);
 
        /// <summary>
        /// Add a sub-menu to the menu. The new sub-menu is returned.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label of the item</param>
        /// <returns>Returns the newly created <see cref="IMenuModel"/>.</returns>
        IMenuModel AddSubMenu(CefMenuCommand commandId, string label);
 
        /// <summary>
        /// Insert a separator in the menu at the specified index. 
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns true on success.</returns>
        bool InsertSeparatorAt(int index);
 
        /// <summary>
        /// Insert an item in the menu at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label of the item</param>
        /// <returns>Returns true on success.</returns>        
        bool InsertItemAt(int index, CefMenuCommand commandId, string label);
 
        /// <summary>
        /// Insert a check item in the menu at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label of the item</param>
        /// <returns>Returns true on success.</returns>
        bool InsertCheckItemAt(int index, CefMenuCommand commandId, string label);
 
        /// <summary>
        /// Insert a radio item in the menu at the specified index.
        /// Only a single item with the specified groupId can be checked at a time.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label of the item</param>
        /// <param name="groupId">the group id</param>
        /// <returns>Returns true on success.</returns>        
        bool InsertRadioItemAt(int index, CefMenuCommand commandId, string label, int groupId);
 
        /// <summary>
        /// Insert a sub-menu in the menu at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label of the item</param>
        /// <returns>Returns the newly created <see cref="IMenuModel"/>.</returns>
        IMenuModel InsertSubMenuAt(int index, CefMenuCommand commandId, string label);
 
        /// <summary>
        /// Removes the item at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns true on success.</returns>
        bool RemoveAt(int index);
 
        /// <summary>
        /// Returns the index associated with the specified commandId or -1 if not found due to the command id not existing in the menu.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns the index associated with the specified commandId or -1 if not found due to the command id not existing in the menu.</returns>
        int GetIndexOf(CefMenuCommand commandId);
 
        /// <summary>
        /// Sets the command id at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns true on success.</returns>        
        bool SetCommandIdAt(int index, CefMenuCommand commandId);
 
        /// <summary>
        /// Returns the label for the specified commandId or empty if not found.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns the label for the specified commandId or empty if not found.</returns>
        string GetLabel(CefMenuCommand commandId);
 
        /// <summary>
        /// Sets the label for the specified commandId. 
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="label">the label</param>
        /// <returns>Returns true on success.</returns>
        bool SetLabel(CefMenuCommand commandId, string label);
 
        /// <summary>
        /// Set the label at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="label">the label</param>
        /// <returns>Returns true on success.</returns>
        bool SetLabelAt(int index, string label);
 
        /// <summary>
        /// Returns the item type for the specified commandId.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns the item type for the specified commandId.</returns>
        MenuItemType GetType(CefMenuCommand commandId);
 
        /// <summary>
        /// Returns the item type at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns the item type at the specified index.</returns>
        MenuItemType GetTypeAt(int index);
 
        /// <summary>
        /// Returns the group id for the specified commandId or -1 if invalid.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns the group id for the specified commandId or -1 if invalid.</returns>        
        int GetGroupId(CefMenuCommand commandId);
 
        /// <summary>
        /// Returns the group id at the specified index or -1 if invalid.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns the group id at the specified index or -1 if invalid.</returns>        
        int GetGroupIdAt(int index);
 
        /// <summary>
        /// Sets the group id for the specified commandId.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="groupId">the group id</param>
        /// <returns>Returns true on success.</returns>
        bool SetGroupId(CefMenuCommand commandId, int groupId);
 
        /// <summary>
        /// Sets the group id at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="groupId">the group id</param>
        /// <returns>Returns true on success.</returns>        
        bool SetGroupIdAt(int index, int groupId);
 
        /// <summary>
        /// Returns the <see cref="IMenuModel"/> for the specified commandId or null if invalid.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns the <see cref="IMenuModel"/> for the specified commandId or null if invalid.</returns>        
        IMenuModel GetSubMenu(CefMenuCommand commandId);
 
        /// <summary>
        /// Returns the <see cref="IMenuModel"/> at the specified index or empty if invalid.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns the <see cref="IMenuModel"/> for the specified commandId or null if invalid.</returns>
        IMenuModel GetSubMenuAt(int index);
 
        /// <summary>
        /// Returns true if the specified commandId is visible.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns true if the specified commandId is visible.</returns>        
        bool IsVisible(CefMenuCommand commandId);
 
        /// <summary>
        /// Returns true if the specified index is visible.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns true if the specified index is visible.</returns>
        bool IsVisibleAt(int index);
 
        /// <summary>
        /// Change the visibility of the specified commandId.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="visible">visible</param>
        /// <returns>Returns true on success.</returns>
        bool SetVisible(CefMenuCommand commandId, bool visible);
 
        /// <summary>
        /// Change the visibility at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="visible">visible</param>
        /// <returns>Returns true on success.</returns>
        bool SetVisibleAt(int index, bool visible);
 
        /// <summary>
        /// Returns true if the specified commandId is enabled.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns true if the specified commandId is enabled.</returns>
        bool IsEnabled(CefMenuCommand commandId);
 
        /// <summary>
        /// Returns true if the specified index is enabled.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns true if the specified index is enabled.</returns>
        bool IsEnabledAt(int index);
 
        /// <summary>
        /// Change the enabled status of the specified commandId.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="enabled">is enabled</param>
        /// <returns>Returns true on success.</returns>
        bool SetEnabled(CefMenuCommand commandId, bool enabled);
 
        /// <summary>
        /// Change the enabled status at the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="enabled">is enabled</param>
        /// <returns>Returns true on success.</returns>
        bool SetEnabledAt(int index, bool enabled);
 
        /// <summary>
        /// Returns true if the specified commandId is checked. Only applies to check and radio items.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns true if the specified commandId is checked. Only applies to check and radio items.</returns>
        bool IsChecked(CefMenuCommand commandId);
 
        /// <summary>
        /// Returns true if the specified index is checked. Only applies to check and radio items.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns true if the specified index is checked. Only applies to check and radio items.</returns>
        bool IsCheckedAt(int index);
 
        /// <summary>
        /// Check the specified commandId. Only applies to check and radio items.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="isChecked">set checked</param>
        /// <returns>Returns true on success.</returns>
        bool SetChecked(CefMenuCommand commandId, bool isChecked);
 
        /// <summary>
        /// Check the specified index. Only applies to check and radio items.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="isChecked">set checked</param>
        /// <returns>Returns true on success.</returns>
        bool SetCheckedAt(int index, bool isChecked);
 
        /// <summary>
        /// Returns true if the specified commandId has a keyboard accelerator assigned.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns true if the specified commandId has a keyboard accelerator assigned.</returns>
        bool HasAccelerator(CefMenuCommand commandId);
 
        /// <summary>
        /// Returns true if the specified index has a keyboard accelerator assigned.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns true if the specified index has a keyboard accelerator assigned.</returns>
        bool HasAcceleratorAt(int index);
 
        /// <summary>
        /// Set the keyboard accelerator for the specified commandId. 
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="keyCode">keyCode can be any key or character value. </param>
        /// <param name="shiftPressed">shift key pressed</param>
        /// <param name="ctrlPressed">ctrl key pressed</param>
        /// <param name="altPressed">alt key pressed</param>
        /// <returns>Returns true on success.</returns>
        bool SetAccelerator(CefMenuCommand commandId, int keyCode, bool shiftPressed, bool ctrlPressed, bool altPressed);
 
        /// <summary>
        /// Set the keyboard accelerator at the specified index. keyCode can be any key or character value.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="keyCode">keyCode can be any key or character value. </param>
        /// <param name="shiftPressed">shift key pressed</param>
        /// <param name="ctrlPressed">ctrl key pressed</param>
        /// <param name="altPressed">alt key pressed</param>
        /// <returns>Returns true on success.</returns>
        bool SetAcceleratorAt(int index, int keyCode, bool shiftPressed, bool ctrlPressed, bool altPressed);
 
        /// <summary>
        /// Remove the keyboard accelerator for the specified commandId.
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <returns>Returns true on success.</returns>
        bool RemoveAccelerator(CefMenuCommand commandId);
 
        /// <summary>
        /// Remove the keyboard accelerator at the specified index. 
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Returns true on success.</returns>
        bool RemoveAcceleratorAt(int index);
 
        /// <summary>
        /// Retrieves the keyboard accelerator for the specified commandId. 
        /// </summary>
        /// <param name="commandId">the command Id</param>
        /// <param name="keyCode">keyCode can be any key or character value. </param>
        /// <param name="shiftPressed">shift key pressed</param>
        /// <param name="ctrlPressed">ctrl key pressed</param>
        /// <param name="altPressed">alt key pressed</param>
        /// <returns>Returns true on success.</returns>
        bool GetAccelerator(CefMenuCommand commandId, out int keyCode, out bool shiftPressed, out bool ctrlPressed, out bool altPressed);
 
        /// <summary>
        /// Retrieves the keyboard accelerator for the specified index.
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="keyCode">keyCode can be any key or character value. </param>
        /// <param name="shiftPressed">shift key pressed</param>
        /// <param name="ctrlPressed">ctrl key pressed</param>
        /// <param name="altPressed">alt key pressed</param>
        /// <returns>Returns true on success.</returns>
        bool GetAcceleratorAt(int index, out int keyCode, out bool shiftPressed, out bool ctrlPressed, out bool altPressed);
    }
}