| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #nullable enable
- namespace UICatalog.Scenarios;
- /// <summary>
- /// Provides an editor UI for the Margin, Border, and Padding of a View.
- /// </summary>
- public class LayoutEditor : EditorBase
- {
- public LayoutEditor ()
- {
- Title = "_LayoutEditor";
- CanFocus = true;
- Initialized += LayoutEditor_Initialized;
- }
- private PosEditor? _xEditor;
- private PosEditor? _yEditor;
- private DimEditor? _widthEditor;
- private DimEditor? _heightEditor;
- protected override void OnViewToEditChanged ()
- {
- if (_xEditor is { })
- {
- _xEditor.ViewToEdit = ViewToEdit;
- }
- if (_yEditor is { })
- {
- _yEditor.ViewToEdit = ViewToEdit;
- }
- if (_widthEditor is { })
- {
- _widthEditor.ViewToEdit = ViewToEdit;
- }
- if (_heightEditor is { })
- {
- _heightEditor.ViewToEdit = ViewToEdit;
- }
- }
- private void LayoutEditor_Initialized (object? sender, EventArgs e)
- {
- _xEditor = new ()
- {
- Title = "_X",
- BorderStyle = LineStyle.None,
- Dimension = Dimension.Width
- };
- _yEditor = new ()
- {
- Title = "_Y",
- BorderStyle = LineStyle.None,
- Dimension = Dimension.Height,
- X = Pos.Right (_xEditor) + 1
- };
- _widthEditor = new ()
- {
- Title = "_Width",
- BorderStyle = LineStyle.None,
- Dimension = Dimension.Width,
- X = Pos.Right (_yEditor) + 1
- };
- _heightEditor = new ()
- {
- Title = "_Height",
- BorderStyle = LineStyle.None,
- Dimension = Dimension.Height,
- X = Pos.Right (_widthEditor) + 1
- };
- Add (_xEditor, _yEditor, _widthEditor, _heightEditor);
- }
- }
|