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
|
// ViewCommands.cs
//
// Author:
// Carlo Kok (ck@remobjects.com)
//
// Copyright (c) 2009 RemObjects Software
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//
using System;
using MonoDevelop.Ide.Gui.Dialogs;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Components.DockNotebook;
using System.Collections.Generic;
namespace MonoDevelop.Ide.Commands
{
public enum ViewCommands
{
ViewList,
LayoutList,
NewLayout,
DeleteCurrentLayout,
LayoutSelector,
FullScreen,
Open,
TreeDisplayOptionList,
ResetTreeDisplayOptions,
RefreshTree,
CollapseAllTreeNodes,
OpenWithList,
ShowNext,
ShowPrevious,
ZoomIn,
ZoomOut,
ZoomReset,
FocusCurrentDocument,
ShowWelcomePage
}
// MonoDevelop.Ide.Commands.ViewCommands.ViewList
public class ViewListHandler : CommandHandler
{
protected override void Update (CommandArrayInfo info)
{
for (int i = 0; i < IdeApp.Workbench.Pads.Count; i++) {
Pad pad = IdeApp.Workbench.Pads[i];
CommandInfo ci = new CommandInfo(pad.Title);
ci.Icon = pad.Icon;
ci.UseMarkup = true;
ci.Description = GettextCatalog.GetString ("Show {0}", pad.Title);
ActionCommand cmd = IdeApp.CommandService.GetActionCommand ("Pad|" + pad.Id);
if (cmd != null) ci.AccelKey = cmd.AccelKey;
CommandArrayInfo list = info;
if (pad.Categories != null) {
for (int j = 0; j < pad.Categories.Length; j++) {
bool found = false;
for (int k = list.Count - 1; k >= 0; k--) {
if (list[k].Text == pad.Categories[j] && list[k] is CommandInfoSet) {
list = ((CommandInfoSet)list[k]).CommandInfos;
found = true;
break;
}
}
if (!found) {
CommandInfoSet set = new CommandInfoSet();
set.Text = pad.Categories[j];
set.Description = GettextCatalog.GetString ("Show {0}", set.Text);
list.Add (set);
list = set.CommandInfos;
}
}
}
for (int j = list.Count - 1; j >= 0; j--) {
if (!(list[j] is CommandInfoSet)) {
list.Insert (j + 1, ci, pad);
pad = null;
break;
}
}
if (pad != null) list.Insert (0, ci, pad);
}
}
protected override void Run (object dataItem)
{
if (dataItem == null) return;
Pad pad = (Pad)dataItem;
pad.Visible = true;
pad.BringToFront (true);
Counters.PadShown.Inc (new Dictionary<string,string> {{ "Pad", pad.Id }});
}
}
// MonoDevelop.Ide.Commands.ViewCommands.LayoutList
public class LayoutListHandler : CommandHandler
{
protected override void Update (CommandArrayInfo info)
{
foreach (var name in IdeApp.Workbench.Layouts) {
CommandInfo item = new CommandInfo(GettextCatalog.GetString (name));
item.Checked = IdeApp.Workbench.CurrentLayout == name;
item.Description = GettextCatalog.GetString ("Switch to layout '{0}'", name);
info.Add (item, name);
}
}
protected override void Run (object dataItem)
{
IdeApp.Workbench.CurrentLayout = (string)dataItem;
}
}
// MonoDevelop.Ide.Commands.ViewCommands.NewLayout
public class NewLayoutHandler : CommandHandler
{
protected override void Run ()
{
string newLayoutName = null;
var dlg = new NewLayoutDialog();
try {
if (MessageService.RunCustomDialog (dlg) == (int)Gtk.ResponseType.Ok)
newLayoutName = dlg.LayoutName;
} finally {
dlg.Destroy ();
dlg.Dispose ();
}
if (newLayoutName != null) {
IdeApp.Workbench.CurrentLayout = newLayoutName;
}
}
}
// MonoDevelop.Ide.Commands.ViewCommands.DeleteCurrentLayout
public class DeleteCurrentLayoutHandler : CommandHandler
{
protected override void Update (CommandInfo info)
{
info.Enabled = !String.Equals ("Solution", IdeApp.Workbench.CurrentLayout, StringComparison.OrdinalIgnoreCase);
}
protected override void Run ()
{
if (MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to delete the active layout?"), AlertButton.Delete)) {
string clayout = IdeApp.Workbench.CurrentLayout;
IdeApp.Workbench.CurrentLayout = "Solution";
IdeApp.Workbench.DeleteLayout (clayout);
}
}
}
// MonoDevelop.Ide.Commands.ViewCommands.FullScreen
public class FullScreenHandler : CommandHandler
{
protected override void Update (CommandInfo info)
{
if (Platform.IsMac) {
info.Text = IdeApp.Workbench.FullScreen
? GettextCatalog.GetString ("Exit Full Screen")
: GettextCatalog.GetString ("Enter Full Screen");
} else {
info.Checked = IdeApp.Workbench.FullScreen;
}
}
protected override void Run ()
{
IdeApp.Workbench.FullScreen = !IdeApp.Workbench.FullScreen;
}
}
// MonoDevelop.Ide.Commands.ViewCommands.ShowNext
public class ShowNextHandler : CommandHandler
{
protected override void Run ()
{
IdeApp.Workbench.ShowNext ();
}
protected override void Update (CommandInfo info)
{
ILocationList list = IdeApp.Workbench.ActiveLocationList;
if (list == null)
info.Enabled = false;
else
info.Text = GettextCatalog.GetString ("Show Next ({0})", list.ItemName);
}
}
// MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious
public class ShowPreviousHandler : CommandHandler
{
protected override void Run ()
{
IdeApp.Workbench.ShowPrevious ();
}
protected override void Update (CommandInfo info)
{
ILocationList list = IdeApp.Workbench.ActiveLocationList;
if (list == null)
info.Enabled = false;
else
info.Text = GettextCatalog.GetString ("Show Previous ({0})", list.ItemName);
}
}
// MonoDevelop.Ide.Commands.ViewCommands.ZoomIn
public class ZoomIn : CommandHandler
{
protected override void Update (CommandInfo info)
{
if (IdeApp.Workbench.ActiveDocument == null)
info.Enabled = false;
else {
IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent<IZoomable> ();
info.Enabled = zoom != null && zoom.EnableZoomIn;
}
}
protected override void Run ()
{
IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent<IZoomable> ();
zoom.ZoomIn ();
}
}
// MonoDevelop.Ide.Commands.ViewCommands.ZoomOut
public class ZoomOut : CommandHandler
{
protected override void Update (CommandInfo info)
{
if (IdeApp.Workbench.ActiveDocument == null)
info.Enabled = false;
else {
IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent<IZoomable> ();
info.Enabled = zoom != null && zoom.EnableZoomOut;
}
}
protected override void Run ()
{
IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent<IZoomable> ();
zoom.ZoomOut ();
}
}
// MonoDevelop.Ide.Commands.ViewCommands.ZoomReset
public class ZoomReset : CommandHandler
{
protected override void Update (CommandInfo info)
{
if (IdeApp.Workbench.ActiveDocument == null)
info.Enabled = false;
else {
IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent<IZoomable> ();
info.Enabled = zoom != null && zoom.EnableZoomReset;
}
}
protected override void Run ()
{
IZoomable zoom = IdeApp.Workbench.ActiveDocument.GetContent<IZoomable> ();
zoom.ZoomReset ();
}
}
public class SideBySideModeHandler : CommandHandler
{
protected override void Update (CommandInfo info)
{
info.Enabled = DockNotebook.ActiveNotebook != null && DockNotebook.ActiveNotebook.TabCount > 1 && DockNotebook.ActiveNotebook.Container.AllowRightInsert;
}
protected override void Run ()
{
IdeApp.Workbench.LockActiveWindowChangeEvent ();
var container = DockNotebook.ActiveNotebook.Container;
var tab = DockNotebook.ActiveNotebook.CurrentTab;
var window = (SdiWorkspaceWindow)tab.Content;
DockNotebook.ActiveNotebook.RemoveTab (tab.Index, false);
container.InsertRight (window);
window.SelectWindow ();
IdeApp.Workbench.UnlockActiveWindowChangeEvent ();
}
}
public class SingleModeHandler : CommandHandler
{
protected override void Update (CommandInfo info)
{
info.Enabled = DockNotebook.ActiveNotebook != null && DockNotebook.ActiveNotebook.Container.SplitCount > 0;
}
protected override void Run ()
{
IdeApp.Workbench.LockActiveWindowChangeEvent ();
SdiWorkspaceWindow window = null;
if (DockNotebook.ActiveNotebook != null) {
var tab = DockNotebook.ActiveNotebook.CurrentTab;
if (tab != null)
window = (SdiWorkspaceWindow)tab.Content;
}
DockNotebook.ActiveNotebook.Container.SetSingleMode ();
if (window != null)
window.SelectWindow ();
IdeApp.Workbench.UnlockActiveWindowChangeEvent ();
}
}
public class NextNotebookHandler : CommandHandler
{
protected override void Update (CommandInfo info)
{
if (IdeApp.Workbench.ActiveDocument == null) {
info.Enabled = false;
} else {
var window = (SdiWorkspaceWindow)IdeApp.Workbench.ActiveDocument.Window;
info.Enabled = window.CanMoveToNextNotebook ();
}
}
protected override void Run ()
{
var window = (SdiWorkspaceWindow)IdeApp.Workbench.ActiveDocument.Window;
window.MoveToNextNotebook ();
}
}
public class PreviousNotebookHandler : CommandHandler
{
protected override void Update (CommandInfo info)
{
if (IdeApp.Workbench.ActiveDocument == null) {
info.Enabled = false;
} else {
var window = (SdiWorkspaceWindow)IdeApp.Workbench.ActiveDocument.Window;
info.Enabled = window.CanMoveToPreviousNotebook ();
}
}
protected override void Run ()
{
var window = (SdiWorkspaceWindow)IdeApp.Workbench.ActiveDocument.Window;
window.MoveToPreviousNotebook ();
}
}
public class FocusCurrentDocumentHandler : CommandHandler
{
protected override void Update (CommandInfo info)
{
info.Enabled = IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.Editor != null;
}
protected override void Run ()
{
IdeApp.Workbench.ActiveDocument.Editor.StartCaretPulseAnimation ();
}
}
}
|