diff --git a/Examples/UICatalog/Scenarios/Adornments.cs b/Examples/UICatalog/Scenarios/Adornments.cs
index 6dd491f65..453ee2478 100644
--- a/Examples/UICatalog/Scenarios/Adornments.cs
+++ b/Examples/UICatalog/Scenarios/Adornments.cs
@@ -19,6 +19,7 @@ public class Adornments : Scenario
var editor = new AdornmentsEditor
{
+ BorderStyle = LineStyle.Single,
AutoSelectViewToEdit = true,
// This is for giggles, to show that the editor can be moved around.
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentEditor.cs
index 907cbb42e..f4339b801 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentEditor.cs
@@ -1,6 +1,4 @@
#nullable enable
-using System;
-
namespace UICatalog.Scenarios;
///
@@ -57,11 +55,13 @@ public class AdornmentEditor : EditorBase
_bottomEdit!.Value = _adornment.Thickness.Bottom;
_rightEdit!.Value = _adornment.Thickness.Right;
- _adornment.Initialized += (sender, args) =>
+ _adornment.Initialized += (_, _) =>
{
- Scheme? cs = _adornment.GetScheme ();
- _foregroundColorPicker.SelectedColor = _adornment.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
- _backgroundColorPicker.SelectedColor = _adornment.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
+ _foregroundColorPicker.SelectedColor =
+ _adornment.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
+
+ _backgroundColorPicker.SelectedColor =
+ _adornment.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
};
}
@@ -125,12 +125,12 @@ public class AdornmentEditor : EditorBase
_bottomEdit.ValueChanging += Bottom_ValueChanging;
Add (_bottomEdit);
- var copyTop = new Button
+ Button copyTop = new ()
{
X = Pos.Center (), Y = Pos.Bottom (_bottomEdit), Text = "Cop_y Top"
};
- copyTop.Accepting += (s, e) =>
+ copyTop.Accepting += (_, _) =>
{
AdornmentToEdit!.Thickness = new (_topEdit.Value);
_leftEdit.Value = _rightEdit.Value = _bottomEdit.Value = _topEdit.Value;
@@ -168,9 +168,9 @@ public class AdornmentEditor : EditorBase
_diagThicknessCheckBox.CheckedState = Diagnostics.FastHasFlags (ViewDiagnosticFlags.Thickness) ? CheckState.Checked : CheckState.UnChecked;
}
- _diagThicknessCheckBox.CheckedStateChanging += (s, e) =>
+ _diagThicknessCheckBox.CheckedStateChanging += (_, args) =>
{
- if (e.Result == CheckState.Checked)
+ if (args.Result == CheckState.Checked)
{
AdornmentToEdit!.Diagnostics |= ViewDiagnosticFlags.Thickness;
}
@@ -194,9 +194,9 @@ public class AdornmentEditor : EditorBase
_diagRulerCheckBox.CheckedState = Diagnostics.FastHasFlags (ViewDiagnosticFlags.Ruler) ? CheckState.Checked : CheckState.UnChecked;
}
- _diagRulerCheckBox.CheckedStateChanging += (s, e) =>
+ _diagRulerCheckBox.CheckedStateChanging += (_, args) =>
{
- if (e.Result == CheckState.Checked)
+ if (args.Result == CheckState.Checked)
{
AdornmentToEdit!.Diagnostics |= ViewDiagnosticFlags.Ruler;
}
@@ -212,18 +212,19 @@ public class AdornmentEditor : EditorBase
private EventHandler> ColorPickerColorChanged ()
{
- return (o, a) =>
+ return (_, _) =>
{
if (AdornmentToEdit is null)
{
return;
}
- AdornmentToEdit.SetScheme (new (AdornmentToEdit.GetScheme ())
- {
- Normal = new (_foregroundColorPicker.SelectedColor, _backgroundColorPicker.SelectedColor)
- })
- ;
+ AdornmentToEdit.SetScheme (
+ new (AdornmentToEdit.GetScheme ())
+ {
+ Normal = new (_foregroundColorPicker.SelectedColor, _backgroundColorPicker.SelectedColor)
+ })
+ ;
};
}
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentsEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentsEditor.cs
index 30c3ffda4..b65169f5d 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentsEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/AdornmentsEditor.cs
@@ -14,8 +14,6 @@ public class AdornmentsEditor : EditorBase
TabStop = TabBehavior.TabGroup;
- ExpanderButton!.Orientation = Orientation.Horizontal;
-
Initialized += AdornmentsEditor_Initialized;
SchemeName = "Dialog";
@@ -28,8 +26,6 @@ public class AdornmentsEditor : EditorBase
///
protected override void OnViewToEditChanged ()
{
- //Enabled = ViewToEdit is not Adornment;
-
if (MarginEditor is { })
{
MarginEditor.AdornmentToEdit = ViewToEdit?.Margin ?? null;
@@ -47,7 +43,7 @@ public class AdornmentsEditor : EditorBase
if (Padding is { })
{
- Padding.Text = $"View: {GetIdentifyingString (ViewToEdit)}";
+ Padding.Text = GetIdentifyingString (ViewToEdit);
}
}
@@ -92,12 +88,17 @@ public class AdornmentsEditor : EditorBase
private void AdornmentsEditor_Initialized (object? sender, EventArgs e)
{
+ if (ExpanderButton is { })
+ {
+ ExpanderButton.Orientation = Orientation.Horizontal;
+ }
+
MarginEditor = new ()
{
X = -1,
Y = 0,
SuperViewRendersLineCanvas = true,
- BorderStyle = LineStyle.Single
+ BorderStyle = BorderStyle
};
MarginEditor.Border!.Thickness = MarginEditor.Border!.Thickness with { Bottom = 0 };
Add (MarginEditor);
@@ -107,7 +108,7 @@ public class AdornmentsEditor : EditorBase
X = Pos.Left (MarginEditor),
Y = Pos.Bottom (MarginEditor),
SuperViewRendersLineCanvas = true,
- BorderStyle = LineStyle.Single
+ BorderStyle = BorderStyle
};
BorderEditor.Border!.Thickness = BorderEditor.Border!.Thickness with { Bottom = 0 };
Add (BorderEditor);
@@ -117,7 +118,7 @@ public class AdornmentsEditor : EditorBase
X = Pos.Left (BorderEditor),
Y = Pos.Bottom (BorderEditor),
SuperViewRendersLineCanvas = true,
- BorderStyle = LineStyle.Single
+ BorderStyle = BorderStyle
};
PaddingEditor.Border!.Thickness = PaddingEditor.Border!.Thickness with { Bottom = 0 };
Add (PaddingEditor);
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/AllViewsView.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/AllViewsView.cs
index f8f78ac6f..b495cc200 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/AllViewsView.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/AllViewsView.cs
@@ -77,7 +77,7 @@ public class AllViewsView : View
View? previousView = null;
- foreach (Type? type in allClasses)
+ foreach (Type type in allClasses)
{
View? view = CreateView (type);
@@ -118,15 +118,8 @@ public class AllViewsView : View
// Check if the generic parameter has constraints
Type [] constraints = arg.GetGenericParameterConstraints ();
- if (constraints.Length > 0)
- {
- // Use the first constraint type to satisfy the constraint
- typeArguments.Add (constraints [0]);
- }
- else
- {
- typeArguments.Add (typeof (object));
- }
+ // Use the first constraint type to satisfy the constraint
+ typeArguments.Add (constraints.Length > 0 ? constraints [0] : typeof (object));
}
}
@@ -193,17 +186,17 @@ public class AllViewsView : View
return;
}
- if (view.Width == Dim.Absolute (0) || view.Width is null)
+ if (view.Width == Dim.Absolute (0))
{
view.Width = Dim.Fill ();
}
- if (view.Height == Dim.Absolute (0) || view.Height is null)
+ if (view.Height == Dim.Absolute (0))
{
view.Height = MAX_VIEW_FRAME_HEIGHT - 2;
}
- if (!view.Width!.Has (out _))
+ if (!view.Width.Has (out _))
{
view.Width = Dim.Fill ();
}
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/BorderEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/BorderEditor.cs
index ca962eb30..9f1f799cc 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/BorderEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/BorderEditor.cs
@@ -1,7 +1,6 @@
#nullable enable
-using System;
-using System.Collections.Generic;
-using System.Linq;
+using System.Reflection;
+using Terminal.Gui.ViewBase;
namespace UICatalog.Scenarios;
@@ -33,10 +32,10 @@ public class BorderEditor : AdornmentEditor
Y = Pos.Bottom (SubViews.ToArray () [^1]),
Width = Dim.Fill (),
- Value = ((Border)AdornmentToEdit!)?.LineStyle ?? LineStyle.None,
+ Value = (AdornmentToEdit as Border)?.LineStyle ?? LineStyle.None,
BorderStyle = LineStyle.Single,
Title = "Border St_yle",
- SuperViewRendersLineCanvas = true,
+ SuperViewRendersLineCanvas = true
};
Add (_osBorderStyle);
@@ -49,7 +48,7 @@ public class BorderEditor : AdornmentEditor
CheckedState = CheckState.Checked,
SuperViewRendersLineCanvas = true,
- Text = "Title",
+ Text = "Title"
};
_ckbTitle.CheckedStateChanging += OnCkbTitleOnToggle;
@@ -62,7 +61,7 @@ public class BorderEditor : AdornmentEditor
CheckedState = CheckState.Checked,
SuperViewRendersLineCanvas = true,
- Text = "Gradient",
+ Text = "Gradient"
};
_ckbGradient.CheckedStateChanging += OnCkbGradientOnToggle;
@@ -72,51 +71,55 @@ public class BorderEditor : AdornmentEditor
void OnRbBorderStyleOnValueChanged (object? s, EventArgs args)
{
- LineStyle prevBorderStyle = AdornmentToEdit!.BorderStyle;
+ if (AdornmentToEdit is not Border border)
+ {
+ return;
+ }
if (args.Value is { })
{
- ((Border)AdornmentToEdit).LineStyle = (LineStyle)args.Value;
+ border.LineStyle = (LineStyle)args.Value;
}
- if (((Border)AdornmentToEdit).LineStyle == LineStyle.None)
- {
- ((Border)AdornmentToEdit).Thickness = new (0);
- }
- else if (prevBorderStyle == LineStyle.None && ((Border)AdornmentToEdit).LineStyle != LineStyle.None)
- {
- ((Border)AdornmentToEdit).Thickness = new (1);
- }
-
- ((Border)AdornmentToEdit).SetNeedsDraw ();
+ border.SetNeedsDraw ();
SetNeedsLayout ();
}
void OnCkbTitleOnToggle (object? _, ResultEventArgs args)
{
+ if (AdornmentToEdit is not Border border)
+ {
+ return;
+ }
+
if (args.Result == CheckState.Checked)
{
- ((Border)AdornmentToEdit!).Settings |= BorderSettings.Title;
+ border.Settings |= BorderSettings.Title;
}
else
{
- ((Border)AdornmentToEdit!).Settings &= ~BorderSettings.Title;
+ border.Settings &= ~BorderSettings.Title;
}
}
void OnCkbGradientOnToggle (object? _, ResultEventArgs args)
{
+ if (AdornmentToEdit is not Border border)
+ {
+ return;
+ }
+
if (args.Result == CheckState.Checked)
{
- ((Border)AdornmentToEdit!).Settings |= BorderSettings.Gradient;
+ border.Settings |= BorderSettings.Gradient;
}
else
{
- ((Border)AdornmentToEdit!).Settings &= ~BorderSettings.Gradient;
+ border.Settings &= ~BorderSettings.Gradient;
}
}
}
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/DimEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/DimEditor.cs
index 7f1f795c9..b8e28730c 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/DimEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/DimEditor.cs
@@ -1,8 +1,5 @@
#nullable enable
-using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
namespace UICatalog.Scenarios;
@@ -21,7 +18,7 @@ public class DimEditor : EditorBase
private OptionSelector? _dimOptionSelector;
private TextField? _valueEdit;
- ///
+ ///
protected override void OnViewToEditChanged ()
{
if (ViewToEdit is { })
@@ -39,12 +36,11 @@ public class DimEditor : EditorBase
return;
}
- Dim? dim;
- dim = Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height;
+ Dim dim = Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height;
try
{
- _dimOptionSelector!.Value = _dimNames.IndexOf (_dimNames.First (s => dim!.ToString ().StartsWith (s)));
+ _dimOptionSelector!.Value = _dimNames.IndexOf (_dimNames.First (s => dim.ToString ().StartsWith (s)));
}
catch (InvalidOperationException e)
{
@@ -53,31 +49,37 @@ public class DimEditor : EditorBase
}
_valueEdit!.Enabled = false;
+
switch (dim)
{
case DimAbsolute absolute:
_valueEdit.Enabled = true;
_value = absolute.Size;
_valueEdit!.Text = _value.ToString ();
+
break;
case DimFill fill:
var margin = fill.Margin as DimAbsolute;
_valueEdit.Enabled = margin is { };
_value = margin?.Size ?? 0;
_valueEdit!.Text = _value.ToString ();
+
break;
case DimFunc func:
_valueEdit.Enabled = true;
_value = func.Fn (null);
_valueEdit!.Text = _value.ToString ();
+
break;
case DimPercent percent:
_valueEdit.Enabled = true;
_value = percent.Percentage;
_valueEdit!.Text = _value.ToString ();
+
break;
default:
- _valueEdit!.Text = dim!.ToString ();
+ _valueEdit!.Text = dim.ToString ();
+
break;
}
}
@@ -94,6 +96,7 @@ public class DimEditor : EditorBase
Add (label);
_dimOptionSelector = new () { X = 0, Y = Pos.Bottom (label), Labels = _optionLabels };
_dimOptionSelector.ValueChanged += OnOptionSelectorOnValueChanged;
+
_valueEdit = new ()
{
X = Pos.Right (label) + 1,
@@ -102,30 +105,30 @@ public class DimEditor : EditorBase
Text = $"{_value}"
};
- _valueEdit.Accepting += (s, args) =>
- {
- try
- {
- _value = int.Parse (_valueEdit.Text);
- DimChanged ();
- }
- catch
- {
- // ignored
- }
- args.Handled = true;
- };
+ _valueEdit.Accepting += (_, args) =>
+ {
+ try
+ {
+ _value = int.Parse (_valueEdit.Text);
+ DimChanged ();
+ }
+ catch
+ {
+ // ignored
+ }
+
+ args.Handled = true;
+ };
Add (_valueEdit);
Add (_dimOptionSelector);
-
}
private void OnOptionSelectorOnValueChanged (object? s, EventArgs selected) { DimChanged (); }
- // These need to have same order
- private readonly List _dimNames = ["Absolute", "Auto", "Fill", "Func", "Percent",];
- private readonly string [] _optionLabels = ["Absolute(n)", "Auto", "Fill(n)", "Func(()=>n)", "Percent(n)",];
+ // These need to have same order
+ private readonly List _dimNames = ["Absolute", "Auto", "Fill", "Func", "Percent"];
+ private readonly string [] _optionLabels = ["Absolute(n)", "Auto", "Fill(n)", "Func(()=>n)", "Percent(n)"];
private void DimChanged ()
{
@@ -136,15 +139,15 @@ public class DimEditor : EditorBase
try
{
- Dim? dim = _dimOptionSelector!.Value switch
- {
- 0 => Dim.Absolute (_value),
- 1 => Dim.Auto (),
- 2 => Dim.Fill (_value),
- 3 => Dim.Func (_ => _value),
- 4 => Dim.Percent (_value),
- _ => Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height
- };
+ Dim dim = _dimOptionSelector!.Value switch
+ {
+ 0 => Dim.Absolute (_value),
+ 1 => Dim.Auto (),
+ 2 => Dim.Fill (_value),
+ 3 => Dim.Func (_ => _value),
+ 4 => Dim.Percent (_value),
+ _ => Dimension == Dimension.Width ? ViewToEdit.Width : ViewToEdit.Height
+ };
if (Dimension == Dimension.Width)
{
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/EditorBase.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/EditorBase.cs
index b4c548d0c..9556be4a2 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/EditorBase.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/EditorBase.cs
@@ -1,8 +1,4 @@
#nullable enable
-using System;
-using System.Diagnostics;
-using System.Linq;
-
namespace UICatalog.Scenarios;
public abstract class EditorBase : View
@@ -19,36 +15,21 @@ public abstract class EditorBase : View
Orientation = Orientation.Vertical
};
-
TabStop = TabBehavior.TabStop;
Initialized += OnInitialized;
void OnInitialized (object? sender, EventArgs e)
{
- if (Border is { })
- {
- Border.Add (ExpanderButton);
-
- if (ExpanderButton.Orientation == Orientation.Vertical)
- {
- ExpanderButton.X = Pos.AnchorEnd () - 1;
- }
- else
- {
- ExpanderButton.Y = Pos.AnchorEnd () - 1;
- }
- }
-
- Application.MouseEvent += ApplicationOnMouseEvent;
- Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
+ Border?.Add (ExpanderButton);
+ App!.Mouse.MouseEvent += ApplicationOnMouseEvent;
+ App!.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
}
AddCommand (Command.Accept, () => true);
SchemeName = "Dialog";
-
}
private readonly ExpanderButton? _expanderButton;
@@ -58,15 +39,16 @@ public abstract class EditorBase : View
get => _expanderButton;
init
{
- if (_expanderButton == value)
+ if (ReferenceEquals (_expanderButton, value))
{
return;
}
+
_expanderButton = value;
}
}
- public bool UpdatingLayoutSettings { get; private set; } = false;
+ public bool UpdatingLayoutSettings { get; private set; }
private void View_LayoutComplete (object? sender, LayoutEventArgs e)
{
@@ -77,7 +59,6 @@ public abstract class EditorBase : View
UpdatingLayoutSettings = false;
}
-
private View? _viewToEdit;
public View? ViewToEdit
@@ -90,7 +71,6 @@ public abstract class EditorBase : View
return;
}
-
if (value is null && _viewToEdit is { })
{
_viewToEdit.SubViewsLaidOut -= View_LayoutComplete;
@@ -127,7 +107,6 @@ public abstract class EditorBase : View
///
public bool AutoSelectAdornments { get; set; }
-
private void NavigationOnFocusedChanged (object? sender, EventArgs e)
{
if (AutoSelectSuperView is null)
@@ -135,17 +114,17 @@ public abstract class EditorBase : View
return;
}
- if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation!.GetFocused ()))
+ if (ApplicationNavigation.IsInHierarchy (this, App?.Navigation?.GetFocused ()))
{
return;
}
- if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, Application.Navigation!.GetFocused ()))
+ if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, App?.Navigation?.GetFocused ()))
{
return;
}
- ViewToEdit = Application.Navigation!.GetFocused ();
+ ViewToEdit = App!.Navigation!.GetFocused ();
}
private void ApplicationOnMouseEvent (object? sender, MouseEventArgs e)
@@ -177,4 +156,16 @@ public abstract class EditorBase : View
ViewToEdit = view;
}
}
+
+ ///
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing && App is {})
+ {
+ App.Navigation!.FocusedChanged -= NavigationOnFocusedChanged;
+ App.Mouse.MouseEvent -= ApplicationOnMouseEvent;
+ }
+
+ base.Dispose (disposing);
+ }
}
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs
index 4bdd61066..25acdb876 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/EventLog.cs
@@ -1,5 +1,4 @@
#nullable enable
-using System;
using System.Collections.ObjectModel;
namespace UICatalog.Scenarios;
@@ -19,8 +18,7 @@ public class EventLog : ListView
X = Pos.AnchorEnd ();
Y = 0;
- Width = Dim.Func (
- _ =>
+ Width = Dim.Func (_ =>
{
if (!IsInitialized)
{
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/ExpanderButton.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/ExpanderButton.cs
index 13c2aee8a..2630703fa 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/ExpanderButton.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/ExpanderButton.cs
@@ -1,5 +1,4 @@
#nullable enable
-using System;
using System.Text;
namespace UICatalog.Scenarios;
@@ -43,14 +42,11 @@ public class ExpanderButton : Button
Orientation = Orientation.Vertical;
- HighlightStates = Terminal.Gui.ViewBase.MouseState.None;
+ HighlightStates = MouseState.In;
Initialized += ExpanderButton_Initialized;
- EnabledChanged += (sender, args) =>
- {
- ShowHide ();
- };
+ EnabledChanged += (_, _) => { ShowHide (); };
}
private void ShowHide ()
@@ -85,7 +81,7 @@ public class ExpanderButton : Button
if (SuperView is Border { } border)
{
- border.ThicknessChanged += (o, args) => ShowHide ();
+ border.ThicknessChanged += (_, _) => ShowHide ();
}
}
@@ -111,7 +107,7 @@ public class ExpanderButton : Button
/// True of the event was cancelled.
protected virtual bool OnOrientationChanging (Orientation newOrientation)
{
- CancelEventArgs args = new CancelEventArgs (in _orientation, ref newOrientation);
+ CancelEventArgs args = new (in _orientation, ref newOrientation);
OrientationChanging?.Invoke (this, args);
if (!args.Cancel)
@@ -120,7 +116,7 @@ public class ExpanderButton : Button
if (Orientation == Orientation.Vertical)
{
- X = Pos.AnchorEnd ();
+ X = Pos.AnchorEnd () - 1;
Y = 0;
CollapseGlyph = new ('\u21d1'); // ⇑
ExpandGlyph = new ('\u21d3'); // ⇓
@@ -128,7 +124,7 @@ public class ExpanderButton : Button
else
{
X = 0;
- Y = Pos.AnchorEnd ();
+ Y = Pos.AnchorEnd () - 1;
CollapseGlyph = new ('\u21d0'); // ⇐
ExpandGlyph = new ('\u21d2'); // ⇒
}
@@ -222,12 +218,12 @@ public class ExpanderButton : Button
// Collapse
if (Orientation == Orientation.Vertical)
{
- _previousDim = superView!.Height!;
+ _previousDim = superView.Height;
superView.Height = 1;
}
else
{
- _previousDim = superView!.Width!;
+ _previousDim = superView.Width;
superView.Width = 1;
}
}
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/LayoutEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/LayoutEditor.cs
index cb84ac31d..a0034ee2a 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/LayoutEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/LayoutEditor.cs
@@ -1,8 +1,4 @@
#nullable enable
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
namespace UICatalog.Scenarios;
///
@@ -64,7 +60,6 @@ public class LayoutEditor : EditorBase
X = Pos.Right (_xEditor) + 1
};
-
_widthEditor = new ()
{
Title = "_Width",
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/MarginEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/MarginEditor.cs
index 7d5d0f254..2904171d8 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/MarginEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/MarginEditor.cs
@@ -1,6 +1,4 @@
#nullable enable
-using System;
-
namespace UICatalog.Scenarios;
public class MarginEditor : AdornmentEditor
@@ -34,7 +32,7 @@ public class MarginEditor : AdornmentEditor
_optionsShadow = new ()
{
X = 0,
- Y = Pos.Bottom (SubViews.ElementAt(SubViews.Count-1)),
+ Y = Pos.Bottom (SubViews.ElementAt (SubViews.Count - 1)),
SuperViewRendersLineCanvas = true,
Title = "_Shadow",
@@ -51,14 +49,14 @@ public class MarginEditor : AdornmentEditor
Add (_optionsShadow);
- _flagSelectorTransparent = new FlagSelector ()
+ _flagSelectorTransparent = new FlagSelector
{
X = 0,
Y = Pos.Bottom (_optionsShadow),
SuperViewRendersLineCanvas = true,
Title = "_ViewportSettings",
- BorderStyle = LineStyle.Single,
+ BorderStyle = LineStyle.Single
};
_flagSelectorTransparent.Values = [(int)ViewportSettingsFlags.Transparent, (int)ViewportSettingsFlags.TransparentMouse];
_flagSelectorTransparent.Labels = ["Transparent", "TransparentMouse"];
@@ -71,11 +69,6 @@ public class MarginEditor : AdornmentEditor
_flagSelectorTransparent.Value = (int)((Margin)AdornmentToEdit).ViewportSettings;
}
- _flagSelectorTransparent.ValueChanged += (_, args) =>
- {
- ((Margin)AdornmentToEdit!).ViewportSettings = (ViewportSettingsFlags)args.Value!;
- };
-
-
+ _flagSelectorTransparent.ValueChanged += (_, args) => { ((Margin)AdornmentToEdit!).ViewportSettings = (ViewportSettingsFlags)args.Value!; };
}
-}
\ No newline at end of file
+}
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/PosEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/PosEditor.cs
index 467b54756..ae35161e6 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/PosEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/PosEditor.cs
@@ -1,8 +1,5 @@
#nullable enable
-using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
namespace UICatalog.Scenarios;
@@ -102,7 +99,7 @@ public class PosEditor : EditorBase
Text = $"{_value}"
};
- _valueEdit.Accepting += (s, args) =>
+ _valueEdit.Accepting += (_, args) =>
{
try
{
@@ -123,7 +120,7 @@ public class PosEditor : EditorBase
private void OnOptionSelectorOnValueChanged (object? s, EventArgs selected) { PosChanged (); }
- // These need to have same order
+ // These need to have same order
private readonly List _posNames = ["Absolute", "Align", "AnchorEnd", "Center", "Func", "Percent"];
private readonly string [] _optionLabels = ["Absolute(n)", "Align", "AnchorEnd", "Center", "Func(()=>n)", "Percent(n)"];
@@ -136,7 +133,7 @@ public class PosEditor : EditorBase
try
{
- Pos? pos = _posOptionSelector!.Value switch
+ Pos pos = _posOptionSelector!.Value switch
{
0 => Pos.Absolute (_value),
1 => Pos.Align (Alignment.Start),
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewPropertiesEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewPropertiesEditor.cs
index cfca9f433..5b6679bbf 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewPropertiesEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewPropertiesEditor.cs
@@ -20,7 +20,7 @@ public class ViewPropertiesEditor : EditorBase
CheckedState = ViewToEdit is { } ? ViewToEdit.CanFocus ? CheckState.Checked : CheckState.UnChecked : CheckState.UnChecked
};
- _canFocusCheckBox.CheckedStateChanged += (s, args) =>
+ _canFocusCheckBox.CheckedStateChanged += (_, _) =>
{
if (ViewToEdit is { })
{
@@ -37,7 +37,7 @@ public class ViewPropertiesEditor : EditorBase
CheckedState = ViewToEdit is { } ? ViewToEdit.Enabled ? CheckState.Checked : CheckState.UnChecked : CheckState.UnChecked
};
- _enabledCheckBox.CheckedStateChanged += (s, args) =>
+ _enabledCheckBox.CheckedStateChanged += (_, _) =>
{
if (ViewToEdit is { })
{
@@ -55,13 +55,13 @@ public class ViewPropertiesEditor : EditorBase
Orientation = Orientation.Horizontal
};
- _orientationOptionSelector.ValueChanged += (s, selected) =>
- {
- if (ViewToEdit is IOrientation orientatedView)
- {
- orientatedView.Orientation = _orientationOptionSelector.Value!.Value;
- }
- };
+ _orientationOptionSelector.ValueChanged += (_, _) =>
+ {
+ if (ViewToEdit is IOrientation orientatedView)
+ {
+ orientatedView.Orientation = _orientationOptionSelector.Value!.Value;
+ }
+ };
Add (label, _orientationOptionSelector);
label = new () { X = 0, Y = Pos.Bottom (_orientationOptionSelector), Text = "Text:" };
@@ -75,7 +75,7 @@ public class ViewPropertiesEditor : EditorBase
Text = "This is demo text"
};
- _text.ContentsChanged += (s, e) =>
+ _text.ContentsChanged += (_, _) =>
{
if (ViewToEdit is { })
{
@@ -90,15 +90,7 @@ public class ViewPropertiesEditor : EditorBase
public string DemoText
{
- get
- {
- if (_text is null)
- {
- return string.Empty;
- }
-
- return _text!.Text;
- }
+ get => _text is null ? string.Empty : _text!.Text;
set => _text!.Text = value;
}
diff --git a/Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewportSettingsEditor.cs b/Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewportSettingsEditor.cs
index e54835989..b7a86feaf 100644
--- a/Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewportSettingsEditor.cs
+++ b/Examples/UICatalog/Scenarios/EditorsAndHelpers/ViewportSettingsEditor.cs
@@ -1,6 +1,4 @@
#nullable enable
-using System;
-
namespace UICatalog.Scenarios;
///
@@ -60,8 +58,8 @@ public sealed class ViewportSettingsEditor : EditorBase
: CheckState.UnChecked;
_cbTransparentMouse!.CheckedState = ViewToEdit.ViewportSettings.HasFlag (ViewportSettingsFlags.TransparentMouse)
- ? CheckState.Checked
- : CheckState.UnChecked;
+ ? CheckState.Checked
+ : CheckState.UnChecked;
_cbVerticalScrollBar!.CheckedState = ViewToEdit.VerticalScrollBar.Visible ? CheckState.Checked : CheckState.UnChecked;
_cbAutoShowVerticalScrollBar!.CheckedState = ViewToEdit.VerticalScrollBar.AutoShow ? CheckState.Checked : CheckState.UnChecked;
@@ -115,27 +113,27 @@ public sealed class ViewportSettingsEditor : EditorBase
Add (_cbAllowXGreaterThanContentWidth);
- void AllowNegativeXToggle (object? sender, ResultEventArgs e)
+ void AllowNegativeXToggle (object? sender, ResultEventArgs rea)
{
- if (e.Result == CheckState.Checked)
+ if (rea.Result == CheckState.Checked)
{
- ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowNegativeX;
+ ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.AllowNegativeX;
}
else
{
- ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowNegativeX;
+ ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.AllowNegativeX;
}
}
- void AllowXGreaterThanContentWidthToggle (object? sender, ResultEventArgs e)
+ void AllowXGreaterThanContentWidthToggle (object? sender, ResultEventArgs rea)
{
- if (e.Result == CheckState.Checked)
+ if (rea.Result == CheckState.Checked)
{
- ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowXGreaterThanContentWidth;
+ ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.AllowXGreaterThanContentWidth;
}
else
{
- ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowXGreaterThanContentWidth;
+ ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.AllowXGreaterThanContentWidth;
}
}
@@ -153,27 +151,27 @@ public sealed class ViewportSettingsEditor : EditorBase
Add (_cbAllowYGreaterThanContentHeight);
- void AllowNegativeYToggle (object? sender, ResultEventArgs e)
+ void AllowNegativeYToggle (object? sender, ResultEventArgs rea)
{
- if (e.Result == CheckState.Checked)
+ if (rea.Result == CheckState.Checked)
{
- ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowNegativeY;
+ ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.AllowNegativeY;
}
else
{
- ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowNegativeY;
+ ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.AllowNegativeY;
}
}
- void AllowYGreaterThanContentHeightToggle (object? sender, ResultEventArgs e)
+ void AllowYGreaterThanContentHeightToggle (object? sender, ResultEventArgs rea)
{
- if (e.Result == CheckState.Checked)
+ if (rea.Result == CheckState.Checked)
{
- ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowYGreaterThanContentHeight;
+ ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.AllowYGreaterThanContentHeight;
}
else
{
- ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.AllowYGreaterThanContentHeight;
+ ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.AllowYGreaterThanContentHeight;
}
}
@@ -193,17 +191,16 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_contentSizeWidth.ValueChanging += ContentSizeWidthValueChanged;
- void ContentSizeWidthValueChanged (object? sender, CancelEventArgs e)
+ void ContentSizeWidthValueChanged (object? sender, CancelEventArgs cea)
{
- if (e.NewValue < 0)
+ if (cea.NewValue < 0)
{
- e.Cancel = true;
+ cea.Cancel = true;
return;
}
- // BUGBUG: set_ContentSize is supposed to be `protected`.
- ViewToEdit!.SetContentSize (ViewToEdit.GetContentSize () with { Width = e.NewValue });
+ ViewToEdit!.SetContentSize (ViewToEdit.GetContentSize () with { Width = cea.NewValue });
}
var labelComma = new Label
@@ -221,17 +218,16 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_contentSizeHeight.ValueChanging += ContentSizeHeightValueChanged;
- void ContentSizeHeightValueChanged (object? sender, CancelEventArgs e)
+ void ContentSizeHeightValueChanged (object? sender, CancelEventArgs cea)
{
- if (e.NewValue < 0)
+ if (cea.NewValue < 0)
{
- e.Cancel = true;
+ cea.Cancel = true;
return;
}
- // BUGBUG: set_ContentSize is supposed to be `protected`.
- ViewToEdit?.SetContentSize (ViewToEdit.GetContentSize () with { Height = e.NewValue });
+ ViewToEdit?.SetContentSize (ViewToEdit.GetContentSize () with { Height = cea.NewValue });
}
_cbClearContentOnly = new ()
@@ -243,15 +239,15 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_cbClearContentOnly.CheckedStateChanging += ClearContentOnlyToggle;
- void ClearContentOnlyToggle (object? sender, ResultEventArgs e)
+ void ClearContentOnlyToggle (object? sender, ResultEventArgs rea)
{
- if (e.Result == CheckState.Checked)
+ if (rea.Result == CheckState.Checked)
{
- ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.ClearContentOnly;
+ ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.ClearContentOnly;
}
else
{
- ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.ClearContentOnly;
+ ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.ClearContentOnly;
}
}
@@ -264,15 +260,15 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_cbClipContentOnly.CheckedStateChanging += ClipContentOnlyToggle;
- void ClipContentOnlyToggle (object? sender, ResultEventArgs e)
+ void ClipContentOnlyToggle (object? sender, ResultEventArgs rea)
{
- if (e.Result == CheckState.Checked)
+ if (rea.Result == CheckState.Checked)
{
- ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.ClipContentOnly;
+ ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.ClipContentOnly;
}
else
{
- ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.ClipContentOnly;
+ ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.ClipContentOnly;
}
}
@@ -285,15 +281,15 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_cbTransparent.CheckedStateChanging += TransparentToggle;
- void TransparentToggle (object? sender, ResultEventArgs e)
+ void TransparentToggle (object? sender, ResultEventArgs rea)
{
- if (e.Result == CheckState.Checked)
+ if (rea.Result == CheckState.Checked)
{
- ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.Transparent;
+ ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.Transparent;
}
else
{
- ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.Transparent;
+ ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.Transparent;
}
}
@@ -306,15 +302,15 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_cbTransparentMouse.CheckedStateChanging += TransparentMouseToggle;
- void TransparentMouseToggle (object? sender, ResultEventArgs e)
+ void TransparentMouseToggle (object? sender, ResultEventArgs rea)
{
- if (e.Result == CheckState.Checked)
+ if (rea.Result == CheckState.Checked)
{
- ViewToEdit!.ViewportSettings |= Terminal.Gui.ViewBase.ViewportSettingsFlags.TransparentMouse;
+ ViewToEdit!.ViewportSettings |= ViewportSettingsFlags.TransparentMouse;
}
else
{
- ViewToEdit!.ViewportSettings &= ~Terminal.Gui.ViewBase.ViewportSettingsFlags.TransparentMouse;
+ ViewToEdit!.ViewportSettings &= ~ViewportSettingsFlags.TransparentMouse;
}
}
@@ -327,9 +323,9 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_cbVerticalScrollBar.CheckedStateChanging += VerticalScrollBarToggle;
- void VerticalScrollBarToggle (object? sender, ResultEventArgs e)
+ void VerticalScrollBarToggle (object? sender, ResultEventArgs rea)
{
- ViewToEdit!.VerticalScrollBar.Visible = e.Result == CheckState.Checked;
+ ViewToEdit!.VerticalScrollBar.Visible = rea.Result == CheckState.Checked;
}
_cbAutoShowVerticalScrollBar = new ()
@@ -341,9 +337,9 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_cbAutoShowVerticalScrollBar.CheckedStateChanging += AutoShowVerticalScrollBarToggle;
- void AutoShowVerticalScrollBarToggle (object? sender, ResultEventArgs e)
+ void AutoShowVerticalScrollBarToggle (object? sender, ResultEventArgs rea)
{
- ViewToEdit!.VerticalScrollBar.AutoShow = e.Result == CheckState.Checked;
+ ViewToEdit!.VerticalScrollBar.AutoShow = rea.Result == CheckState.Checked;
}
_cbHorizontalScrollBar = new ()
@@ -355,9 +351,9 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_cbHorizontalScrollBar.CheckedStateChanging += HorizontalScrollBarToggle;
- void HorizontalScrollBarToggle (object? sender, ResultEventArgs e)
+ void HorizontalScrollBarToggle (object? sender, ResultEventArgs rea)
{
- ViewToEdit!.HorizontalScrollBar.Visible = e.Result == CheckState.Checked;
+ ViewToEdit!.HorizontalScrollBar.Visible = rea.Result == CheckState.Checked;
}
_cbAutoShowHorizontalScrollBar = new ()
@@ -369,9 +365,9 @@ public sealed class ViewportSettingsEditor : EditorBase
};
_cbAutoShowHorizontalScrollBar.CheckedStateChanging += AutoShowHorizontalScrollBarToggle;
- void AutoShowHorizontalScrollBarToggle (object? sender, ResultEventArgs e)
+ void AutoShowHorizontalScrollBarToggle (object? sender, ResultEventArgs rea)
{
- ViewToEdit!.HorizontalScrollBar.AutoShow = e.Result == CheckState.Checked;
+ ViewToEdit!.HorizontalScrollBar.AutoShow = rea.Result == CheckState.Checked;
}
Add (
diff --git a/Examples/UICatalog/Scenarios/ShadowStyles.cs b/Examples/UICatalog/Scenarios/ShadowStyles.cs
index 25a2a335c..2ca3002d5 100644
--- a/Examples/UICatalog/Scenarios/ShadowStyles.cs
+++ b/Examples/UICatalog/Scenarios/ShadowStyles.cs
@@ -62,6 +62,22 @@ public class ShadowStyles : Scenario
shadowWindow.Add (buttonInWin);
app.Add (shadowWindow);
+ Window shadowWindow2 = new ()
+ {
+
+ Id = "shadowWindow2",
+ X = Pos.Right (editor) + 10,
+ Y = 10,
+ Width = Dim.Percent (30),
+ Height = Dim.Percent (30),
+ Title = "Shadow Window #2",
+ Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped,
+ BorderStyle = LineStyle.Double,
+ ShadowStyle = ShadowStyle.Transparent,
+ };
+ app.Add (shadowWindow2);
+
+
var button = new Button
{
Id = "button",
@@ -69,6 +85,7 @@ public class ShadowStyles : Scenario
Y = Pos.Center (), Text = "Button",
ShadowStyle = ShadowStyle.Opaque
};
+ button.Accepting += ButtonOnAccepting;
ColorPicker colorPicker = new ()
{
@@ -77,12 +94,12 @@ public class ShadowStyles : Scenario
Id = "colorPicker16",
X = Pos.Center (),
Y = Pos.AnchorEnd (),
- Width = Dim.Percent(80),
+ Width = Dim.Percent (80),
};
colorPicker.ColorChanged += (sender, args) =>
{
var normal = app.GetScheme ().Normal;
- app.SetScheme (app.GetScheme() with {Normal = new Attribute(normal.Foreground, args.Result)});
+ app.SetScheme (app.GetScheme () with { Normal = new Attribute (normal.Foreground, args.Result) });
};
app.Add (button, colorPicker);
@@ -96,4 +113,10 @@ public class ShadowStyles : Scenario
Application.Shutdown ();
}
+
+ private void ButtonOnAccepting (object sender, CommandEventArgs e)
+ {
+ MessageBox.Query ((sender as View)?.App, "Hello", "You pushed the button!");
+ e.Handled = true;
+ }
}
diff --git a/Examples/UICatalog/Scenarios/ViewportSettings.cs b/Examples/UICatalog/Scenarios/ViewportSettings.cs
index b4934a064..4a3f66c4f 100644
--- a/Examples/UICatalog/Scenarios/ViewportSettings.cs
+++ b/Examples/UICatalog/Scenarios/ViewportSettings.cs
@@ -108,6 +108,7 @@ public class ViewportSettings : Scenario
var adornmentsEditor = new AdornmentsEditor
{
+ BorderStyle = LineStyle.Single,
X = Pos.AnchorEnd (),
AutoSelectViewToEdit = true,
ShowViewIdentifier = true
@@ -224,6 +225,7 @@ public class ViewportSettings : Scenario
view.Initialized += (s, e) =>
{
viewportSettingsEditor.ViewToEdit = view;
+ adornmentsEditor.ViewToEdit = view;
};
view.SetFocus ();
Application.Run (app);
diff --git a/Examples/UICatalog/Scenarios/WideGlyphs.cs b/Examples/UICatalog/Scenarios/WideGlyphs.cs
index 16e30b723..9b2e80d26 100644
--- a/Examples/UICatalog/Scenarios/WideGlyphs.cs
+++ b/Examples/UICatalog/Scenarios/WideGlyphs.cs
@@ -24,6 +24,31 @@ public sealed class WideGlyphs : Scenario
BorderStyle = LineStyle.None
};
+ // Add Editors
+
+ AdornmentsEditor adornmentsEditor = new ()
+ {
+ BorderStyle = LineStyle.Single,
+ X = Pos.AnchorEnd (),
+ AutoSelectViewToEdit = true,
+ AutoSelectAdornments = false,
+ ShowViewIdentifier = true
+ };
+ adornmentsEditor.ExpanderButton.Accepting += (sender, args) =>
+ {
+ //adornmentsEditor.ExpanderButton.Collapsed = args.NewValue;
+ };
+ appWindow.Add (adornmentsEditor);
+
+ ViewportSettingsEditor viewportSettingsEditor = new ()
+ {
+ BorderStyle = LineStyle.Single,
+ Y = Pos.AnchorEnd (),
+ X = Pos.AnchorEnd (),
+ AutoSelectViewToEdit = true,
+ };
+ appWindow.Add (viewportSettingsEditor);
+
// Build the array of codepoints once when subviews are laid out
appWindow.SubViewsLaidOut += (s, _) =>
{
@@ -53,7 +78,7 @@ public sealed class WideGlyphs : Scenario
// Fill the window with the pre-built codepoints array
// For detailed documentation on the draw code flow from Application.Run to this event,
// see WideGlyphs.DrawFlow.md in this directory
- appWindow.DrawingContent += (s, _) =>
+ appWindow.DrawingContent += (s, e) =>
{
View? view = s as View;
if (view is null || _codepoints is null)
@@ -73,6 +98,7 @@ public sealed class WideGlyphs : Scenario
}
}
}
+ e.DrawContext?.AddDrawnRectangle (view.Viewport);
};
Line verticalLineAtEven = new ()
@@ -99,12 +125,12 @@ public sealed class WideGlyphs : Scenario
Y = 5,
Width = 15,
Height = 5,
- //BorderStyle = LineStyle.Dashed,
+ //BorderStyle = LineStyle.Dashed
};
// Proves it's not LineCanvas related
arrangeableViewAtEven!.Border!.Thickness = new (1);
- arrangeableViewAtEven.Border.Add(new View () { Height = Dim.Auto(), Width = Dim.Auto(), Text = "Even" });
+ arrangeableViewAtEven.Border.Add (new View () { Height = Dim.Auto (), Width = Dim.Auto (), Text = "Even" });
appWindow.Add (arrangeableViewAtEven);
View arrangeableViewAtOdd = new ()
@@ -117,6 +143,7 @@ public sealed class WideGlyphs : Scenario
Height = 5,
BorderStyle = LineStyle.Dashed,
};
+
appWindow.Add (arrangeableViewAtOdd);
var superView = new View
@@ -124,8 +151,8 @@ public sealed class WideGlyphs : Scenario
CanFocus = true,
X = 30, // on an even column to start
Y = Pos.Center (),
- Width = Dim.Auto () + 4,
- Height = Dim.Auto () + 1,
+ Width = Dim.Auto (),
+ Height = Dim.Auto (),
BorderStyle = LineStyle.Single,
Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable
};
diff --git a/Terminal.Gui/App/ApplicationImpl.Run.cs b/Terminal.Gui/App/ApplicationImpl.Run.cs
index 9f8e0a9b8..8926f2423 100644
--- a/Terminal.Gui/App/ApplicationImpl.Run.cs
+++ b/Terminal.Gui/App/ApplicationImpl.Run.cs
@@ -36,7 +36,7 @@ internal partial class ApplicationImpl
public event EventHandler>? Iteration;
///
- public void RaiseIteration () { Iteration?.Invoke (null, new (this)); }
+ public void RaiseIteration () { Iteration?.Invoke (this, new (this)); }
#endregion Main Loop Iteration
diff --git a/Terminal.Gui/App/ApplicationNavigation.cs b/Terminal.Gui/App/ApplicationNavigation.cs
index 871bd3691..a852f642e 100644
--- a/Terminal.Gui/App/ApplicationNavigation.cs
+++ b/Terminal.Gui/App/ApplicationNavigation.cs
@@ -89,7 +89,7 @@ public class ApplicationNavigation
_focused = value;
- FocusedChanged?.Invoke (null, EventArgs.Empty);
+ FocusedChanged?.Invoke (this, EventArgs.Empty);
}
///
diff --git a/Terminal.Gui/App/CWP/CWPEventHelper.cs b/Terminal.Gui/App/CWP/CWPEventHelper.cs
index 4840a358c..72fd9f7b5 100644
--- a/Terminal.Gui/App/CWP/CWPEventHelper.cs
+++ b/Terminal.Gui/App/CWP/CWPEventHelper.cs
@@ -49,6 +49,7 @@ public static class CWPEventHelper
return false;
}
+ // BUGBUG: This should pass this not null; need to test
eventHandler.Invoke (null, args);
return args.Handled;
}
diff --git a/Terminal.Gui/App/CWP/CWPPropertyHelper.cs b/Terminal.Gui/App/CWP/CWPPropertyHelper.cs
index 09bcd7fa0..d7095fd7e 100644
--- a/Terminal.Gui/App/CWP/CWPPropertyHelper.cs
+++ b/Terminal.Gui/App/CWP/CWPPropertyHelper.cs
@@ -84,6 +84,7 @@ public static class CWPPropertyHelper
}
}
+ // BUGBUG: This should pass this not null; need to test
changingEvent?.Invoke (null, args);
if (args.Handled)
@@ -100,13 +101,14 @@ public static class CWPPropertyHelper
}
finalValue = args.NewValue;
-
+
// Do the work (set backing field, update related properties, etc.) BEFORE raising Changed events
doWork (finalValue);
-
+
ValueChangedEventArgs changedArgs = new (currentValue, finalValue);
currentValue = finalValue;
onChanged?.Invoke (changedArgs);
+ // BUGBUG: This should pass this not null; need to test
changedEvent?.Invoke (null, changedArgs);
return true;
diff --git a/Terminal.Gui/App/CWP/CWPWorkflowHelper.cs b/Terminal.Gui/App/CWP/CWPWorkflowHelper.cs
index 4c0328589..061df53d9 100644
--- a/Terminal.Gui/App/CWP/CWPWorkflowHelper.cs
+++ b/Terminal.Gui/App/CWP/CWPWorkflowHelper.cs
@@ -53,6 +53,7 @@ public static class CWPWorkflowHelper
return true;
}
+ // BUGBUG: This should pass this not null; need to test
eventHandler?.Invoke (null, args);
if (args.Handled)
{
@@ -112,6 +113,7 @@ public static class CWPWorkflowHelper
return args.Result!;
}
+ // BUGBUG: This should pass this not null; need to test
eventHandler?.Invoke (null, args);
if (!args.Handled)
diff --git a/Terminal.Gui/App/Keyboard/KeyboardImpl.cs b/Terminal.Gui/App/Keyboard/KeyboardImpl.cs
index dbdd2d67c..40041c974 100644
--- a/Terminal.Gui/App/Keyboard/KeyboardImpl.cs
+++ b/Terminal.Gui/App/Keyboard/KeyboardImpl.cs
@@ -160,7 +160,7 @@ internal class KeyboardImpl : IKeyboard, IDisposable
//#endif
// TODO: This should match standard event patterns
- KeyDown?.Invoke (null, key);
+ KeyDown?.Invoke (this, key);
if (key.Handled)
{
@@ -216,7 +216,7 @@ internal class KeyboardImpl : IKeyboard, IDisposable
return true;
}
- KeyUp?.Invoke (null, key);
+ KeyUp?.Invoke (this, key);
if (key.Handled)
{
diff --git a/Terminal.Gui/App/Mouse/MouseImpl.cs b/Terminal.Gui/App/Mouse/MouseImpl.cs
index 59b5d16f9..355c72879 100644
--- a/Terminal.Gui/App/Mouse/MouseImpl.cs
+++ b/Terminal.Gui/App/Mouse/MouseImpl.cs
@@ -86,7 +86,7 @@ internal class MouseImpl : IMouse, IDisposable
mouseEvent.View = deepestViewUnderMouse;
}
- MouseEvent?.Invoke (null, mouseEvent);
+ MouseEvent?.Invoke (this, mouseEvent);
if (mouseEvent.Handled)
{
diff --git a/Terminal.sln.DotSettings b/Terminal.sln.DotSettings
index e3f73a543..a2ec2772f 100644
--- a/Terminal.sln.DotSettings
+++ b/Terminal.sln.DotSettings
@@ -416,6 +416,7 @@
True
True
True
+ True
True
True