|
@@ -38,13 +38,13 @@ public class Shortcuts : Scenario
|
|
|
var eventLog = new ListView
|
|
|
{
|
|
|
X = Pos.AnchorEnd (),
|
|
|
- Width = 40,
|
|
|
Height = Dim.Fill (4),
|
|
|
ColorScheme = Colors.ColorSchemes ["Toplevel"],
|
|
|
Source = new ListWrapper<string> (eventSource),
|
|
|
BorderStyle = LineStyle.Double,
|
|
|
Title = "E_vents"
|
|
|
};
|
|
|
+ eventLog.Width = Dim.Func (() => Math.Min (Application.Top.Viewport.Width / 2, eventLog?.MaxLength + eventLog.GetAdornmentsThickness ().Horizontal ?? 0));
|
|
|
Application.Top.Add (eventLog);
|
|
|
|
|
|
var vShortcut1 = new Shortcut
|
|
@@ -72,15 +72,16 @@ public class Shortcuts : Scenario
|
|
|
CommandView = new RadioGroup
|
|
|
{
|
|
|
Orientation = Orientation.Vertical,
|
|
|
- RadioLabels = ["O_ne", "T_wo", "Th_ree", "Fo_ur"]
|
|
|
+ RadioLabels = ["O_ne", "T_wo", "Th_ree", "Fo_ur"],
|
|
|
+ CanFocus = false
|
|
|
},
|
|
|
};
|
|
|
|
|
|
((RadioGroup)vShortcut2.CommandView).SelectedItemChanged += (o, args) =>
|
|
|
- {
|
|
|
- eventSource.Add ($"SelectedItemChanged: {o.GetType ().Name} - {args.SelectedItem}");
|
|
|
- eventLog.MoveDown ();
|
|
|
- };
|
|
|
+ {
|
|
|
+ eventSource.Add ($"SelectedItemChanged: {o.GetType ().Name} - {args.SelectedItem}");
|
|
|
+ eventLog.MoveDown ();
|
|
|
+ };
|
|
|
|
|
|
Application.Top.Add (vShortcut2);
|
|
|
|
|
@@ -89,7 +90,12 @@ public class Shortcuts : Scenario
|
|
|
Orientation = Orientation.Vertical,
|
|
|
X = 0,
|
|
|
Y = Pos.Bottom (vShortcut2),
|
|
|
- CommandView = new CheckBox { Text = "_Align" },
|
|
|
+ CommandView = new CheckBox
|
|
|
+ {
|
|
|
+ Text = "_Align",
|
|
|
+ CanFocus = false,
|
|
|
+ HighlightStyle = HighlightStyle.None,
|
|
|
+ },
|
|
|
Key = Key.F5.WithCtrl.WithAlt.WithShift,
|
|
|
HelpText = "Width is Fill",
|
|
|
Width = Dim.Fill () - Dim.Width (eventLog),
|
|
@@ -97,30 +103,30 @@ public class Shortcuts : Scenario
|
|
|
};
|
|
|
|
|
|
((CheckBox)vShortcut3.CommandView).CheckedStateChanging += (s, e) =>
|
|
|
- {
|
|
|
- if (vShortcut3.CommandView is CheckBox cb)
|
|
|
- {
|
|
|
- eventSource.Add ($"Toggle: {cb.Text}");
|
|
|
- eventLog.MoveDown ();
|
|
|
-
|
|
|
- var max = 0;
|
|
|
- var toAlign = Application.Top.Subviews.Where (v => v is Shortcut { Orientation: Orientation.Vertical, Width: not DimAbsolute });
|
|
|
-
|
|
|
- if (e.NewValue == CheckState.Checked)
|
|
|
- {
|
|
|
- foreach (Shortcut peer in toAlign)
|
|
|
- {
|
|
|
- // DANGER: KeyView is internal so we can't access it. So we assume this is how it works.
|
|
|
- max = Math.Max (max, peer.Key.ToString ().GetColumns ());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- foreach (Shortcut peer in toAlign)
|
|
|
- {
|
|
|
- peer.MinimumKeyTextSize = max;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ {
|
|
|
+ if (vShortcut3.CommandView is CheckBox cb)
|
|
|
+ {
|
|
|
+ eventSource.Add ($"{vShortcut3.Id}.CommandView.CheckedStateChanging: {cb.Text}");
|
|
|
+ eventLog.MoveDown ();
|
|
|
+
|
|
|
+ var max = 0;
|
|
|
+ var toAlign = Application.Top.Subviews.Where (v => v is Shortcut { Orientation: Orientation.Vertical, Width: not DimAbsolute });
|
|
|
+
|
|
|
+ if (e.NewValue == CheckState.Checked)
|
|
|
+ {
|
|
|
+ foreach (Shortcut peer in toAlign)
|
|
|
+ {
|
|
|
+ // DANGER: KeyView is internal so we can't access it. So we assume this is how it works.
|
|
|
+ max = Math.Max (max, peer.Key.ToString ().GetColumns ());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (Shortcut peer in toAlign)
|
|
|
+ {
|
|
|
+ peer.MinimumKeyTextSize = max;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
Application.Top.Add (vShortcut3);
|
|
|
|
|
|
var vShortcut4 = new Shortcut
|
|
@@ -132,6 +138,8 @@ public class Shortcuts : Scenario
|
|
|
CommandView = new Button
|
|
|
{
|
|
|
Title = "_Button",
|
|
|
+ ShadowStyle = ShadowStyle.None,
|
|
|
+ HighlightStyle = HighlightStyle.None
|
|
|
},
|
|
|
HelpText = "Width is Fill",
|
|
|
Key = Key.K,
|
|
@@ -156,21 +164,21 @@ public class Shortcuts : Scenario
|
|
|
};
|
|
|
|
|
|
((CheckBox)vShortcut5.CommandView).CheckedStateChanging += (s, e) =>
|
|
|
- {
|
|
|
- if (vShortcut5.CommandView is CheckBox cb)
|
|
|
- {
|
|
|
- eventSource.Add ($"Toggle: {cb.Text}");
|
|
|
- eventLog.MoveDown ();
|
|
|
-
|
|
|
- foreach (Shortcut peer in Application.Top.Subviews.Where (v => v is Shortcut)!)
|
|
|
- {
|
|
|
- if (peer.CanFocus)
|
|
|
- {
|
|
|
- peer.CommandView.CanFocus = e.NewValue == CheckState.Checked;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ {
|
|
|
+ if (vShortcut5.CommandView is CheckBox cb)
|
|
|
+ {
|
|
|
+ eventSource.Add ($"Toggle: {cb.Text}");
|
|
|
+ eventLog.MoveDown ();
|
|
|
+
|
|
|
+ //foreach (Shortcut peer in Application.Top.Subviews.Where (v => v is Shortcut)!)
|
|
|
+ //{
|
|
|
+ // if (peer.CanFocus)
|
|
|
+ // {
|
|
|
+ // peer.CommandView.CanFocus = e.NewValue == CheckState.Checked;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ };
|
|
|
Application.Top.Add (vShortcut5);
|
|
|
|
|
|
var vShortcutSlider = new Shortcut
|
|
@@ -194,10 +202,10 @@ public class Shortcuts : Scenario
|
|
|
((Slider<string>)vShortcutSlider.CommandView).SetOption (0);
|
|
|
|
|
|
((Slider<string>)vShortcutSlider.CommandView).OptionsChanged += (o, args) =>
|
|
|
- {
|
|
|
- eventSource.Add ($"OptionsChanged: {o.GetType ().Name} - {string.Join (",", ((Slider<string>)o).GetSetOptions ())}");
|
|
|
- eventLog.MoveDown ();
|
|
|
- };
|
|
|
+ {
|
|
|
+ eventSource.Add ($"OptionsChanged: {o.GetType ().Name} - {string.Join (",", ((Slider<string>)o).GetSetOptions ())}");
|
|
|
+ eventLog.MoveDown ();
|
|
|
+ };
|
|
|
|
|
|
Application.Top.Add (vShortcutSlider);
|
|
|
|
|
@@ -258,20 +266,20 @@ public class Shortcuts : Scenario
|
|
|
AutoReset = true,
|
|
|
};
|
|
|
timer.Elapsed += (o, args) =>
|
|
|
- {
|
|
|
- if (hShortcut1.CommandView is ProgressBar pb)
|
|
|
- {
|
|
|
- if (pb.Fraction == 1.0)
|
|
|
- {
|
|
|
- pb.Fraction = 0;
|
|
|
- }
|
|
|
- pb.Fraction += 0.01f;
|
|
|
-
|
|
|
- Application.Wakeup ();
|
|
|
-
|
|
|
- pb.SetNeedsDisplay ();
|
|
|
- }
|
|
|
- };
|
|
|
+ {
|
|
|
+ if (hShortcut1.CommandView is ProgressBar pb)
|
|
|
+ {
|
|
|
+ if (pb.Fraction == 1.0)
|
|
|
+ {
|
|
|
+ pb.Fraction = 0;
|
|
|
+ }
|
|
|
+ pb.Fraction += 0.01f;
|
|
|
+
|
|
|
+ Application.Wakeup ();
|
|
|
+
|
|
|
+ pb.SetNeedsDisplay ();
|
|
|
+ }
|
|
|
+ };
|
|
|
timer.Start ();
|
|
|
|
|
|
Application.Top.Add (hShortcut1);
|
|
@@ -314,12 +322,12 @@ public class Shortcuts : Scenario
|
|
|
CanFocus = false
|
|
|
};
|
|
|
bgColor.ColorChanged += (o, args) =>
|
|
|
- {
|
|
|
- Application.Top.ColorScheme = new ColorScheme (Application.Top.ColorScheme)
|
|
|
- {
|
|
|
- Normal = new Attribute (Application.Top.ColorScheme.Normal.Foreground, args.CurrentValue),
|
|
|
- };
|
|
|
- };
|
|
|
+ {
|
|
|
+ Application.Top.ColorScheme = new ColorScheme (Application.Top.ColorScheme)
|
|
|
+ {
|
|
|
+ Normal = new Attribute (Application.Top.ColorScheme.Normal.Foreground, args.CurrentValue),
|
|
|
+ };
|
|
|
+ };
|
|
|
hShortcutBG.CommandView = bgColor;
|
|
|
|
|
|
Application.Top.Add (hShortcutBG);
|
|
@@ -336,9 +344,9 @@ public class Shortcuts : Scenario
|
|
|
CanFocus = false
|
|
|
};
|
|
|
hShortcut3.Accept += (o, args) =>
|
|
|
- {
|
|
|
- Application.RequestStop ();
|
|
|
- };
|
|
|
+ {
|
|
|
+ Application.RequestStop ();
|
|
|
+ };
|
|
|
|
|
|
Application.Top.Add (hShortcut3);
|
|
|
|
|
@@ -347,30 +355,30 @@ public class Shortcuts : Scenario
|
|
|
if (sh is Shortcut shortcut)
|
|
|
{
|
|
|
shortcut.Select += (o, args) =>
|
|
|
- {
|
|
|
- eventSource.Add ($"Select: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
|
|
- eventLog.MoveDown ();
|
|
|
- args.Handled = true;
|
|
|
- };
|
|
|
+ {
|
|
|
+ eventSource.Add ($"{shortcut!.Id}.Select: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
|
|
+ eventLog.MoveDown ();
|
|
|
+ args.Handled = true;
|
|
|
+ };
|
|
|
|
|
|
shortcut.CommandView.Select += (o, args) =>
|
|
|
- {
|
|
|
- eventSource.Add ($"CommandView.Select: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
|
|
- eventLog.MoveDown ();
|
|
|
- };
|
|
|
+ {
|
|
|
+ eventSource.Add ($"{shortcut!.Id}.CommandView.Select: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
|
|
+ eventLog.MoveDown ();
|
|
|
+ };
|
|
|
|
|
|
shortcut.Accept += (o, args) =>
|
|
|
- {
|
|
|
- eventSource.Add ($"Accept: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
|
|
- eventLog.MoveDown ();
|
|
|
- args.Handled = true;
|
|
|
- };
|
|
|
+ {
|
|
|
+ eventSource.Add ($"{shortcut!.Id}.Accept: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
|
|
+ eventLog.MoveDown ();
|
|
|
+ args.Handled = true;
|
|
|
+ };
|
|
|
|
|
|
shortcut.CommandView.Accept += (o, args) =>
|
|
|
- {
|
|
|
- eventSource.Add ($"CommandView.Accept: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
|
|
- eventLog.MoveDown ();
|
|
|
- };
|
|
|
+ {
|
|
|
+ eventSource.Add ($"{shortcut!.Id}.CommandView.Accept: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
|
|
+ eventLog.MoveDown ();
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -380,6 +388,7 @@ public class Shortcuts : Scenario
|
|
|
private void Button_Clicked (object sender, HandledEventArgs e)
|
|
|
{
|
|
|
e.Handled = true;
|
|
|
- MessageBox.Query ("Hi", $"You clicked {sender}");
|
|
|
+ View view = sender as View;
|
|
|
+ MessageBox.Query ("Hi", $"You clicked {view!.Text}", "_Ok");
|
|
|
}
|
|
|
}
|