Content-Length: 595749 | pFad | http://github.com/dotnet/winforms/commit/59367612e9f0ad716a28f0f8a69ebdfa0060bd85

D6 related to issue 10466: add short cut ↑, ↓, ←, → to demo console (#13… · dotnet/winforms@5936761 · GitHub
Skip to content

Commit 5936761

Browse files
authored
related to issue 10466: add short cut ↑, ↓, ←, → to demo console (#13513)
1 parent 94e240e commit 5936761

File tree

2 files changed

+51
-34
lines changed

2 files changed

+51
-34
lines changed

src/test/integration/DesignSurface/DemoConsole/MainForm.cs

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,49 @@ public MainForm()
2020

2121
private void InitFormDesigner()
2222
{
23-
CreateDesignSurface(1);
24-
CreateDesignSurface(2);
25-
CreateDesignSurface(3);
26-
CreateDesignSurface(4);
27-
CreateDesignSurface(5);
28-
CreateDesignSurface(6);
29-
3023
tabPage1.Text = "Use SnapLines";
3124
tabPage2.Text = "Use Grid (Snap to the grid)";
3225
tabPage3.Text = "Use Grid";
3326
tabPage4.Text = "Align control by hand";
3427
tabPage5.Text = "TabControl and TableLayoutPanel";
3528
tabPage6.Text = "ToolStripContainer";
3629

37-
// - enable the UndoEngines
3830
for (int i = 0; i < tabControl1.TabCount; i++)
3931
{
40-
IDesignSurfaceExtended isurf = _listOfDesignSurface[i];
41-
isurf.GetUndoEngineExt().Enabled = true;
42-
}
32+
CreateDesignSurface(i + 1);
4333

44-
// - ISelectionService
45-
// - try to get a ptr to ISelectionService interface
46-
// - if we obtain it then hook the SelectionChanged event
47-
for (int i = 0; i < tabControl1.TabCount; i++)
48-
{
49-
IDesignSurfaceExtended isurf = _listOfDesignSurface[i];
50-
_selectionService = (ISelectionService)(isurf.GetIDesignerHost().GetService(typeof(ISelectionService)));
34+
IDesignSurfaceExtended designSurfaceExtended = _listOfDesignSurface[i];
35+
36+
// - enable the UndoEngines
37+
designSurfaceExtended.GetUndoEngineExt().Enabled = true;
38+
39+
// - ISelectionService
40+
// - try to get a ptr to ISelectionService interface
41+
// - if we obtain it then hook the SelectionChanged event
42+
_selectionService = (ISelectionService)designSurfaceExtended.GetIDesignerHost().GetService(typeof(ISelectionService));
5143
if (_selectionService is not null)
44+
{
5245
_selectionService.SelectionChanged += OnSelectionChanged;
46+
}
47+
48+
((Control)(designSurfaceExtended as DesignSurface).View).KeyUp += (s, e) =>
49+
{
50+
switch (e.KeyCode)
51+
{
52+
case Keys.Up:
53+
designSurfaceExtended.DoAction("KeyMoveUp");
54+
break;
55+
case Keys.Down:
56+
designSurfaceExtended.DoAction("KeyMoveDown");
57+
break;
58+
case Keys.Left:
59+
designSurfaceExtended.DoAction("KeyMoveLeft");
60+
break;
61+
case Keys.Right:
62+
designSurfaceExtended.DoAction("KeyMoveRight");
63+
break;
64+
}
65+
};
5366
}
5467
}
5568

@@ -59,10 +72,10 @@ private void OnSelectionChanged(object sender, EventArgs e)
5972
if (_selectionService is null)
6073
return;
6174

62-
IDesignSurfaceExtended isurf = _listOfDesignSurface[tabControl1.SelectedIndex];
63-
if (isurf is not null)
75+
IDesignSurfaceExtended designSurfaceExtended = _listOfDesignSurface[tabControl1.SelectedIndex];
76+
if (designSurfaceExtended is not null)
6477
{
65-
ISelectionService selectionService = isurf.GetIDesignerHost().GetService(typeof(ISelectionService)) as ISelectionService;
78+
ISelectionService selectionService = designSurfaceExtended.GetIDesignerHost().GetService(typeof(ISelectionService)) as ISelectionService;
6679
propertyGrid.SelectedObject = selectionService.PrimarySelection;
6780
}
6881
}
@@ -441,21 +454,21 @@ private void CreateDesignSurface(int n)
441454
private void SelectRootComponent()
442455
{
443456
// - find out the DesignSurfaceExt control hosted by the TabPage
444-
IDesignSurfaceExtended isurf = _listOfDesignSurface[tabControl1.SelectedIndex];
445-
if (isurf is not null)
457+
IDesignSurfaceExtended designSurfaceExtended = _listOfDesignSurface[tabControl1.SelectedIndex];
458+
if (designSurfaceExtended is not null)
446459
{
447460
splitContainer.Panel2.Controls.Remove(propertyGrid);
448461
propertyGrid.Dispose();
449462
propertyGrid = new()
450463
{
451-
DesignerHost = isurf.GetIDesignerHost(),
464+
DesignerHost = designSurfaceExtended.GetIDesignerHost(),
452465
Dock = DockStyle.Fill,
453466
Location = new Point(0, 0),
454467
Margin = new Padding(4),
455468
Name = "propertyGrid",
456469
Size = new Size(226, 502),
457470
TabIndex = 0,
458-
SelectedObject = isurf.GetIDesignerHost().RootComponent
471+
SelectedObject = designSurfaceExtended.GetIDesignerHost().RootComponent
459472
};
460473

461474
splitContainer.Panel2.Controls.Add(propertyGrid);
@@ -464,14 +477,14 @@ private void SelectRootComponent()
464477

465478
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
466479
{
467-
IDesignSurfaceExtended isurf = _listOfDesignSurface[tabControl1.SelectedIndex];
468-
isurf?.GetUndoEngineExt().Undo();
480+
IDesignSurfaceExtended designSurfaceExtended = _listOfDesignSurface[tabControl1.SelectedIndex];
481+
designSurfaceExtended?.GetUndoEngineExt().Undo();
469482
}
470483

471484
private void redoToolStripMenuItem_Click(object sender, EventArgs e)
472485
{
473-
IDesignSurfaceExtended isurf = _listOfDesignSurface[tabControl1.SelectedIndex];
474-
isurf?.GetUndoEngineExt().Redo();
486+
IDesignSurfaceExtended designSurfaceExtended = _listOfDesignSurface[tabControl1.SelectedIndex];
487+
designSurfaceExtended?.GetUndoEngineExt().Redo();
475488
}
476489

477490
private void OnAbout(object sender, EventArgs e)
@@ -482,8 +495,8 @@ private void OnAbout(object sender, EventArgs e)
482495
private void toolStripMenuItemTabOrder_Click(object sender, EventArgs e)
483496
{
484497
// - find out the DesignSurfaceExt control hosted by the TabPage
485-
IDesignSurfaceExtended isurf = _listOfDesignSurface[tabControl1.SelectedIndex];
486-
isurf?.SwitchTabOrder();
498+
IDesignSurfaceExtended designSurfaceExtended = _listOfDesignSurface[tabControl1.SelectedIndex];
499+
designSurfaceExtended?.SwitchTabOrder();
487500
}
488501

489502
private void MainForm_Load(object sender, EventArgs e)
@@ -492,7 +505,7 @@ private void MainForm_Load(object sender, EventArgs e)
492505

493506
tabControl1.Selected += OnTabPageSelected;
494507

495-
// - select into the propertygrid the current Form
508+
// - select into the propertyGrid the current Form
496509
SelectRootComponent();
497510
}
498511

@@ -503,7 +516,7 @@ private void OnTabPageSelected(object sender, TabControlEventArgs e)
503516

504517
private void OnMenuClick(object sender, EventArgs e)
505518
{
506-
IDesignSurfaceExtended isurf = _listOfDesignSurface[tabControl1.SelectedIndex];
507-
isurf?.DoAction((sender as ToolStripMenuItem).Text);
519+
IDesignSurfaceExtended designSurfaceExtended = _listOfDesignSurface[tabControl1.SelectedIndex];
520+
designSurfaceExtended?.DoAction((sender as ToolStripMenuItem).Text);
508521
}
509522
}

src/test/integration/DesignSurface/DesignSurfaceExt/DesignSurfaceExt.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ public void DoAction(string command)
350350
"PASTE" => StandardCommands.Paste,
351351
"DELETE" => StandardCommands.Delete,
352352
"INVOKESMARTTAG" => MenuCommands.KeyInvokeSmartTag,
353+
"KEYMOVEUP" => MenuCommands.KeyMoveUp,
354+
"KEYMOVEDOWN" => MenuCommands.KeyMoveDown,
355+
"KEYMOVELEFT" => MenuCommands.KeyMoveLeft,
356+
"KEYMOVERIGHT" => MenuCommands.KeyMoveRight,
353357
_ => null,
354358
};
355359

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/dotnet/winforms/commit/59367612e9f0ad716a28f0f8a69ebdfa0060bd85

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy