|
@@ -19,6 +19,7 @@ public class AllViewsTester : Scenario
|
|
|
private ListView _classListView;
|
|
|
private View _curView;
|
|
|
private FrameView _hostPane;
|
|
|
+ private AdornmentsEditor _adornmentsEditor;
|
|
|
private RadioGroup _hRadioGroup;
|
|
|
private TextField _hText;
|
|
|
private int _hVal;
|
|
@@ -48,58 +49,29 @@ public class AllViewsTester : Scenario
|
|
|
Application.Init ();
|
|
|
ConfigurationManager.Apply ();
|
|
|
|
|
|
- var app = new Window ();
|
|
|
- app.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
|
|
|
-
|
|
|
- var statusBar = new StatusBar (
|
|
|
- new StatusItem []
|
|
|
- {
|
|
|
- new (
|
|
|
- Application.QuitKey,
|
|
|
- $"{Application.QuitKey} to Quit",
|
|
|
- () => Quit ()
|
|
|
- ),
|
|
|
- new (
|
|
|
- KeyCode.F2,
|
|
|
- "~F2~ Toggle Frame Ruler",
|
|
|
- () =>
|
|
|
- {
|
|
|
- View.Diagnostics ^=
|
|
|
- ViewDiagnosticFlags.Ruler;
|
|
|
- app.SetNeedsDisplay ();
|
|
|
- }
|
|
|
- ),
|
|
|
- new (
|
|
|
- KeyCode.F3,
|
|
|
- "~F3~ Toggle Frame Padding",
|
|
|
- () =>
|
|
|
- {
|
|
|
- View.Diagnostics ^=
|
|
|
- ViewDiagnosticFlags.Padding;
|
|
|
- app.SetNeedsDisplay ();
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- );
|
|
|
- app.Add (statusBar);
|
|
|
+ var app = new Window
|
|
|
+ {
|
|
|
+ Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}",
|
|
|
+ ColorScheme = Colors.ColorSchemes ["TopLevel"]
|
|
|
+ };
|
|
|
|
|
|
_viewClasses = GetAllViewClassesCollection ()
|
|
|
.OrderBy (t => t.Name)
|
|
|
.Select (t => new KeyValuePair<string, Type> (t.Name, t))
|
|
|
.ToDictionary (t => t.Key, t => t.Value);
|
|
|
|
|
|
- _leftPane = new FrameView
|
|
|
+ _leftPane = new ()
|
|
|
{
|
|
|
X = 0,
|
|
|
Y = 0,
|
|
|
Width = Dim.Auto (DimAutoStyle.Content),
|
|
|
- Height = Dim.Fill (1), // for status bar
|
|
|
+ Height = Dim.Fill (),
|
|
|
CanFocus = false,
|
|
|
ColorScheme = Colors.ColorSchemes ["TopLevel"],
|
|
|
Title = "Classes"
|
|
|
};
|
|
|
|
|
|
- _classListView = new ListView
|
|
|
+ _classListView = new ()
|
|
|
{
|
|
|
X = 0,
|
|
|
Y = 0,
|
|
@@ -128,9 +100,26 @@ public class AllViewsTester : Scenario
|
|
|
};
|
|
|
_leftPane.Add (_classListView);
|
|
|
|
|
|
- _settingsPane = new FrameView
|
|
|
+ _adornmentsEditor = new ()
|
|
|
{
|
|
|
X = Pos.Right (_leftPane),
|
|
|
+ Y = 0,
|
|
|
+ Width = Dim.Auto (),
|
|
|
+ Height = Dim.Fill (),
|
|
|
+ ColorScheme = Colors.ColorSchemes ["TopLevel"],
|
|
|
+ BorderStyle = LineStyle.Single
|
|
|
+ };
|
|
|
+
|
|
|
+ var expandButton = new ExpanderButton
|
|
|
+ {
|
|
|
+ CanFocus = false,
|
|
|
+ Orientation = Orientation.Horizontal
|
|
|
+ };
|
|
|
+ _adornmentsEditor.Border.Add (expandButton);
|
|
|
+
|
|
|
+ _settingsPane = new ()
|
|
|
+ {
|
|
|
+ X = Pos.Right (_adornmentsEditor),
|
|
|
Y = 0, // for menu
|
|
|
Width = Dim.Fill (),
|
|
|
Height = Dim.Auto (),
|
|
@@ -141,7 +130,7 @@ public class AllViewsTester : Scenario
|
|
|
|
|
|
string [] radioItems = { "_Percent(x)", "_AnchorEnd", "_Center", "A_bsolute(x)" };
|
|
|
|
|
|
- _locationFrame = new FrameView
|
|
|
+ _locationFrame = new ()
|
|
|
{
|
|
|
X = 0,
|
|
|
Y = 0,
|
|
@@ -153,9 +142,9 @@ public class AllViewsTester : Scenario
|
|
|
|
|
|
var label = new Label { X = 0, Y = 0, Text = "X:" };
|
|
|
_locationFrame.Add (label);
|
|
|
- _xRadioGroup = new RadioGroup { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
|
|
|
+ _xRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
|
|
|
_xRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
|
|
|
- _xText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
|
|
|
+ _xText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
|
|
|
|
|
|
_xText.Accept += (s, args) =>
|
|
|
{
|
|
@@ -172,9 +161,9 @@ public class AllViewsTester : Scenario
|
|
|
_locationFrame.Add (_xRadioGroup);
|
|
|
|
|
|
radioItems = new [] { "P_ercent(y)", "A_nchorEnd", "C_enter", "Absolute(_y)" };
|
|
|
- label = new Label { X = Pos.Right (_xRadioGroup) + 1, Y = 0, Text = "Y:" };
|
|
|
+ label = new () { X = Pos.Right (_xRadioGroup) + 1, Y = 0, Text = "Y:" };
|
|
|
_locationFrame.Add (label);
|
|
|
- _yText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_yVal}" };
|
|
|
+ _yText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_yVal}" };
|
|
|
|
|
|
_yText.Accept += (s, args) =>
|
|
|
{
|
|
@@ -187,11 +176,11 @@ public class AllViewsTester : Scenario
|
|
|
{ }
|
|
|
};
|
|
|
_locationFrame.Add (_yText);
|
|
|
- _yRadioGroup = new RadioGroup { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
|
|
|
+ _yRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
|
|
|
_yRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
|
|
|
_locationFrame.Add (_yRadioGroup);
|
|
|
|
|
|
- _sizeFrame = new FrameView
|
|
|
+ _sizeFrame = new ()
|
|
|
{
|
|
|
X = Pos.Right (_locationFrame),
|
|
|
Y = Pos.Y (_locationFrame),
|
|
@@ -201,42 +190,42 @@ public class AllViewsTester : Scenario
|
|
|
};
|
|
|
|
|
|
radioItems = new [] { "Auto", "_Percent(width)", "_Fill(width)", "A_bsolute(width)" };
|
|
|
- label = new Label { X = 0, Y = 0, Text = "Width:" };
|
|
|
+ label = new () { X = 0, Y = 0, Text = "Width:" };
|
|
|
_sizeFrame.Add (label);
|
|
|
- _wRadioGroup = new RadioGroup { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
|
|
|
+ _wRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
|
|
|
_wRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
|
|
|
- _wText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
|
|
|
+ _wText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
|
|
|
|
|
|
_wText.Accept += (s, args) =>
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- switch (_wRadioGroup.SelectedItem)
|
|
|
- {
|
|
|
- case 1:
|
|
|
- _wVal = Math.Min (int.Parse (_wText.Text), 100);
|
|
|
-
|
|
|
- break;
|
|
|
- case 0:
|
|
|
- case 2:
|
|
|
- case 3:
|
|
|
- _wVal = int.Parse (_wText.Text);
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- DimPosChanged (_curView);
|
|
|
- }
|
|
|
- catch
|
|
|
- { }
|
|
|
- };
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ switch (_wRadioGroup.SelectedItem)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ _wVal = Math.Min (int.Parse (_wText.Text), 100);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 0:
|
|
|
+ case 2:
|
|
|
+ case 3:
|
|
|
+ _wVal = int.Parse (_wText.Text);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ DimPosChanged (_curView);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ { }
|
|
|
+ };
|
|
|
_sizeFrame.Add (_wText);
|
|
|
_sizeFrame.Add (_wRadioGroup);
|
|
|
|
|
|
radioItems = new [] { "_Auto", "P_ercent(height)", "F_ill(height)", "Ab_solute(height)" };
|
|
|
- label = new Label { X = Pos.Right (_wRadioGroup) + 1, Y = 0, Text = "Height:" };
|
|
|
+ label = new () { X = Pos.Right (_wRadioGroup) + 1, Y = 0, Text = "Height:" };
|
|
|
_sizeFrame.Add (label);
|
|
|
- _hText = new TextField { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" };
|
|
|
+ _hText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" };
|
|
|
|
|
|
_hText.Accept += (s, args) =>
|
|
|
{
|
|
@@ -263,20 +252,22 @@ public class AllViewsTester : Scenario
|
|
|
};
|
|
|
_sizeFrame.Add (_hText);
|
|
|
|
|
|
- _hRadioGroup = new RadioGroup { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
|
|
|
+ _hRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
|
|
|
_hRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
|
|
|
_sizeFrame.Add (_hRadioGroup);
|
|
|
|
|
|
_settingsPane.Add (_sizeFrame);
|
|
|
|
|
|
- label = new Label { X = 0, Y = Pos.Bottom (_sizeFrame), Text = "_Orientation:" };
|
|
|
- _orientation = new RadioGroup
|
|
|
+ label = new () { X = 0, Y = Pos.Bottom (_sizeFrame), Text = "_Orientation:" };
|
|
|
+
|
|
|
+ _orientation = new ()
|
|
|
{
|
|
|
X = Pos.Right (label) + 1,
|
|
|
Y = Pos.Top (label),
|
|
|
RadioLabels = new [] { "Horizontal", "Vertical" },
|
|
|
Orientation = Orientation.Horizontal
|
|
|
};
|
|
|
+
|
|
|
_orientation.SelectedItemChanged += (s, selected) =>
|
|
|
{
|
|
|
if (_curView?.GetType ().GetProperty ("Orientation") is { } prop)
|
|
@@ -286,7 +277,8 @@ public class AllViewsTester : Scenario
|
|
|
};
|
|
|
_settingsPane.Add (label, _orientation);
|
|
|
|
|
|
- label = new Label { X = 0, Y = Pos.Bottom (_orientation), Text = "_Text:" };
|
|
|
+ label = new () { X = 0, Y = Pos.Bottom (_orientation), Text = "_Text:" };
|
|
|
+
|
|
|
_demoTextView = new ()
|
|
|
{
|
|
|
X = Pos.Right (label) + 1,
|
|
@@ -295,26 +287,31 @@ public class AllViewsTester : Scenario
|
|
|
Height = Dim.Auto (minimumContentDim: 2),
|
|
|
Text = _demoText
|
|
|
};
|
|
|
+
|
|
|
_demoTextView.ContentsChanged += (s, e) =>
|
|
|
- {
|
|
|
- _demoText = _demoTextView.Text;
|
|
|
- _curView.Text = _demoText;
|
|
|
- };
|
|
|
+ {
|
|
|
+ _demoText = _demoTextView.Text;
|
|
|
+
|
|
|
+ if (_curView is { })
|
|
|
+ {
|
|
|
+ _curView.Text = _demoText;
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
_settingsPane.Add (label, _demoTextView);
|
|
|
|
|
|
- _hostPane = new FrameView
|
|
|
+ _hostPane = new ()
|
|
|
{
|
|
|
- X = Pos.Right (_leftPane),
|
|
|
+ X = Pos.Right (_adornmentsEditor),
|
|
|
Y = Pos.Bottom (_settingsPane),
|
|
|
Width = Dim.Fill (),
|
|
|
- Height = Dim.Fill (1), // + 1 for status bar
|
|
|
+ Height = Dim.Fill (), // + 1 for status bar
|
|
|
ColorScheme = Colors.ColorSchemes ["Dialog"]
|
|
|
};
|
|
|
|
|
|
- app.Add (_leftPane, _settingsPane, _hostPane);
|
|
|
+ app.Add (_leftPane, _adornmentsEditor, _settingsPane, _hostPane);
|
|
|
|
|
|
- _curView = CreateClass (_viewClasses.First ().Value);
|
|
|
+ _classListView.SelectedItem = 0;
|
|
|
|
|
|
Application.Run (app);
|
|
|
app.Dispose ();
|
|
@@ -426,40 +423,40 @@ public class AllViewsTester : Scenario
|
|
|
//view.LayoutStyle = LayoutStyle.Absolute;
|
|
|
|
|
|
view.X = _xRadioGroup.SelectedItem switch
|
|
|
- {
|
|
|
- 0 => Pos.Percent (_xVal),
|
|
|
- 1 => Pos.AnchorEnd (),
|
|
|
- 2 => Pos.Center (),
|
|
|
- 3 => Pos.Absolute (_xVal),
|
|
|
- _ => view.X
|
|
|
- };
|
|
|
+ {
|
|
|
+ 0 => Pos.Percent (_xVal),
|
|
|
+ 1 => Pos.AnchorEnd (),
|
|
|
+ 2 => Pos.Center (),
|
|
|
+ 3 => Pos.Absolute (_xVal),
|
|
|
+ _ => view.X
|
|
|
+ };
|
|
|
|
|
|
view.Y = _yRadioGroup.SelectedItem switch
|
|
|
- {
|
|
|
- 0 => Pos.Percent (_yVal),
|
|
|
- 1 => Pos.AnchorEnd (),
|
|
|
- 2 => Pos.Center (),
|
|
|
- 3 => Pos.Absolute (_yVal),
|
|
|
- _ => view.Y
|
|
|
- };
|
|
|
+ {
|
|
|
+ 0 => Pos.Percent (_yVal),
|
|
|
+ 1 => Pos.AnchorEnd (),
|
|
|
+ 2 => Pos.Center (),
|
|
|
+ 3 => Pos.Absolute (_yVal),
|
|
|
+ _ => view.Y
|
|
|
+ };
|
|
|
|
|
|
view.Width = _wRadioGroup.SelectedItem switch
|
|
|
- {
|
|
|
- 0 => Dim.Auto (),
|
|
|
- 1 => Dim.Percent (_wVal),
|
|
|
- 2 => Dim.Fill (_wVal),
|
|
|
- 3 => Dim.Absolute (_wVal),
|
|
|
- _ => view.Width
|
|
|
- };
|
|
|
+ {
|
|
|
+ 0 => Dim.Auto (),
|
|
|
+ 1 => Dim.Percent (_wVal),
|
|
|
+ 2 => Dim.Fill (_wVal),
|
|
|
+ 3 => Dim.Absolute (_wVal),
|
|
|
+ _ => view.Width
|
|
|
+ };
|
|
|
|
|
|
view.Height = _hRadioGroup.SelectedItem switch
|
|
|
- {
|
|
|
- 0 => Dim.Auto (),
|
|
|
- 1 => Dim.Percent (_hVal),
|
|
|
- 2 => Dim.Fill (_hVal),
|
|
|
- 3 => Dim.Absolute (_hVal),
|
|
|
- _ => view.Height
|
|
|
- };
|
|
|
+ {
|
|
|
+ 0 => Dim.Auto (),
|
|
|
+ 1 => Dim.Percent (_hVal),
|
|
|
+ 2 => Dim.Fill (_hVal),
|
|
|
+ 3 => Dim.Absolute (_hVal),
|
|
|
+ _ => view.Height
|
|
|
+ };
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -468,7 +465,7 @@ public class AllViewsTester : Scenario
|
|
|
|
|
|
if (view.Width is DimAuto)
|
|
|
{
|
|
|
- _wText.Text = $"Auto";
|
|
|
+ _wText.Text = "Auto";
|
|
|
_wText.Enabled = false;
|
|
|
}
|
|
|
else
|
|
@@ -479,7 +476,7 @@ public class AllViewsTester : Scenario
|
|
|
|
|
|
if (view.Height is DimAuto)
|
|
|
{
|
|
|
- _hText.Text = $"Auto";
|
|
|
+ _hText.Text = "Auto";
|
|
|
_hText.Enabled = false;
|
|
|
}
|
|
|
else
|
|
@@ -488,8 +485,6 @@ public class AllViewsTester : Scenario
|
|
|
_hText.Enabled = true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
UpdateTitle (view);
|
|
|
}
|
|
|
|
|
@@ -521,6 +516,8 @@ public class AllViewsTester : Scenario
|
|
|
|
|
|
private void UpdateSettings (View view)
|
|
|
{
|
|
|
+ _adornmentsEditor.ViewToEdit = view;
|
|
|
+
|
|
|
var x = view.X.ToString ();
|
|
|
var y = view.Y.ToString ();
|
|
|
_xRadioGroup.SelectedItem = _posNames.IndexOf (_posNames.Where (s => x.Contains (s)).First ());
|
|
@@ -532,28 +529,28 @@ public class AllViewsTester : Scenario
|
|
|
var h = view.Height.ToString ();
|
|
|
_wRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.Where (s => w.Contains (s)).First ());
|
|
|
_hRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.Where (s => h.Contains (s)).First ());
|
|
|
+
|
|
|
if (view.Width is DimAuto)
|
|
|
{
|
|
|
- _wText.Text = $"Auto";
|
|
|
+ _wText.Text = "Auto";
|
|
|
_wText.Enabled = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _wText.Text = $"100";
|
|
|
+ _wText.Text = "100";
|
|
|
_wText.Enabled = true;
|
|
|
}
|
|
|
|
|
|
if (view.Height is DimAuto)
|
|
|
{
|
|
|
- _hText.Text = $"Auto";
|
|
|
+ _hText.Text = "Auto";
|
|
|
_hText.Enabled = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- _hText.Text = $"100";
|
|
|
+ _hText.Text = "100";
|
|
|
_hText.Enabled = true;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void UpdateTitle (View view) { _hostPane.Title = $"{view.GetType ().Name} - {view.X}, {view.Y}, {view.Width}, {view.Height}"; }
|