mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Cleans up/Refactors View.Subviews (#3962)
* Subview clean up * New Add/Remove event pattern * Using Logging * cleanup * Subview -> SubView * Test code cleanup. Killed many warnings. * Fix tznind feedback * Refactored AllViewTest helpers * Moved keyboard tests to parallel * Moved mouse tests to parallel * Moved view tests to parallel * Test code cleanup. Killed many warnings. * dupe test * Some mouse tests can't run in parallel because MouseGrabView * Made SpinnerView more testable * Moved more tests * SubViews to IReadOnlyCollection<View> * SubViews to IReadOnlyCollection<View> 2 * scrollbar tests * shortcut tests * Use InternalSubViews vs. _subviews * Nuked View.IsAdded. Added View.SuperViewChanged. * API doc updats * Unit Test tweak * Unit Test tweak
This commit is contained in:
@@ -32,7 +32,7 @@ internal class KeyBindingsDialog : Dialog
|
||||
_commandsListView = new ListView
|
||||
{
|
||||
Width = Dim.Percent (50),
|
||||
Height = Dim.Fill (Dim.Func (() => IsInitialized ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height : 1)),
|
||||
Height = Dim.Fill (Dim.Func (() => IsInitialized ? SubViews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height : 1)),
|
||||
Source = new ListWrapper<Command> (_commands),
|
||||
SelectedItem = 0
|
||||
};
|
||||
@@ -200,16 +200,12 @@ internal class KeyBindingsDialog : Dialog
|
||||
|
||||
// may already have subviews that were added to it
|
||||
// before we got to it
|
||||
foreach (View sub in view.Subviews)
|
||||
foreach (View sub in view.SubViews)
|
||||
{
|
||||
RecordView (sub);
|
||||
}
|
||||
|
||||
// TODO: BUG: Based on my new understanding of Added event I think this is wrong
|
||||
// (and always was wrong). Parents don't get to be told when new views are added
|
||||
// to them
|
||||
|
||||
view.Added += (s, e) => RecordView (e.SubView);
|
||||
view.SubViewAdded += (s, e) => RecordView (e.SubView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class Scenario : IDisposable
|
||||
|
||||
private void OnApplicationNotifyNewRunState (object? sender, RunStateEventArgs e)
|
||||
{
|
||||
SubscribeAllSubviews (Application.Top!);
|
||||
SubscribeAllSubViews (Application.Top!);
|
||||
|
||||
_currentDemoKey = 0;
|
||||
_demoKeys = GetDemoKeyStrokes ();
|
||||
@@ -254,13 +254,13 @@ public class Scenario : IDisposable
|
||||
|
||||
// Get a list of all subviews under Application.Top (and their subviews, etc.)
|
||||
// and subscribe to their DrawComplete event
|
||||
void SubscribeAllSubviews (View view)
|
||||
void SubscribeAllSubViews (View view)
|
||||
{
|
||||
view.DrawComplete += (s, a) => BenchmarkResults.DrawCompleteCount++;
|
||||
view.SubviewsLaidOut += (s, a) => BenchmarkResults.LaidOutCount++;
|
||||
foreach (View subview in view.Subviews)
|
||||
view.SubViewsLaidOut += (s, a) => BenchmarkResults.LaidOutCount++;
|
||||
foreach (View subview in view.SubViews)
|
||||
{
|
||||
SubscribeAllSubviews (subview);
|
||||
SubscribeAllSubViews (subview);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ public class AllViewsTester : Scenario
|
||||
}
|
||||
|
||||
view.Initialized += CurrentView_Initialized;
|
||||
view.SubviewsLaidOut += CurrentView_LayoutComplete;
|
||||
view.SubViewsLaidOut += CurrentView_LayoutComplete;
|
||||
|
||||
view.Id = "_curView";
|
||||
_curView = view;
|
||||
@@ -329,7 +329,7 @@ public class AllViewsTester : Scenario
|
||||
if (_curView != null)
|
||||
{
|
||||
_curView.Initialized -= CurrentView_Initialized;
|
||||
_curView.SubviewsLaidOut -= CurrentView_LayoutComplete;
|
||||
_curView.SubViewsLaidOut -= CurrentView_LayoutComplete;
|
||||
_hostPane!.Remove (_curView);
|
||||
_layoutEditor!.ViewToEdit = null;
|
||||
_viewportSettingsEditor!.ViewToEdit = null;
|
||||
|
||||
@@ -250,11 +250,11 @@ public class Bars : Scenario
|
||||
ConfigStatusBar (bar);
|
||||
statusBarLikeExamples.Add (bar);
|
||||
|
||||
foreach (FrameView frameView in Application.Top.Subviews.Where (f => f is FrameView)!)
|
||||
foreach (FrameView frameView in Application.Top.SubViews.Where (f => f is FrameView)!)
|
||||
{
|
||||
foreach (Bar barView in frameView.Subviews.Where (b => b is Bar)!)
|
||||
foreach (Bar barView in frameView.SubViews.Where (b => b is Bar)!)
|
||||
{
|
||||
foreach (Shortcut sh in barView.Subviews.Where (s => s is Shortcut)!)
|
||||
foreach (Shortcut sh in barView.SubViews.Where (s => s is Shortcut)!)
|
||||
{
|
||||
sh.Accepting += (o, args) =>
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ComputedLayout : Scenario
|
||||
Text = vrule
|
||||
};
|
||||
|
||||
app.SubviewsLaidOut += (s, a) =>
|
||||
app.SubViewsLaidOut += (s, a) =>
|
||||
{
|
||||
if (horizontalRuler.Viewport.Width == 0 || horizontalRuler.Viewport.Height == 0)
|
||||
{
|
||||
@@ -372,7 +372,7 @@ public class ComputedLayout : Scenario
|
||||
{
|
||||
// This demonstrates how to have a dynamically sized button
|
||||
// Each time the button is clicked the button's text gets longer
|
||||
// The call to app.LayoutSubviews causes the Computed layout to
|
||||
// The call to app.LayoutSubViews causes the Computed layout to
|
||||
// get updated.
|
||||
anchorButton.Text += "!";
|
||||
};
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ConfigurationEditor : Scenario
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (ConfigTextView t in _tabView.Subviews.Where (v => v is ConfigTextView).Cast<ConfigTextView> ())
|
||||
foreach (ConfigTextView t in _tabView.SubViews.Where (v => v is ConfigTextView).Cast<ConfigTextView> ())
|
||||
{
|
||||
t.ColorScheme = EditorColorScheme;
|
||||
}
|
||||
|
||||
@@ -97,30 +97,30 @@ public class DynamicStatusBar : Scenario
|
||||
|
||||
public DynamicStatusBarDetails ()
|
||||
{
|
||||
var _lblTitle = new Label { Y = 1, Text = "Title:" };
|
||||
Add (_lblTitle);
|
||||
var lblTitle = new Label { Y = 1, Text = "Title:" };
|
||||
base.Add (lblTitle);
|
||||
|
||||
TextTitle = new TextField { X = Pos.Right (_lblTitle) + 4, Y = Pos.Top (_lblTitle), Width = Dim.Fill () };
|
||||
Add (TextTitle);
|
||||
TextTitle = new TextField { X = Pos.Right (lblTitle) + 4, Y = Pos.Top (lblTitle), Width = Dim.Fill () };
|
||||
base.Add (TextTitle);
|
||||
|
||||
var _lblAction = new Label { X = Pos.Left (_lblTitle), Y = Pos.Bottom (_lblTitle) + 1, Text = "Action:" };
|
||||
Add (_lblAction);
|
||||
var lblAction = new Label { X = Pos.Left (lblTitle), Y = Pos.Bottom (lblTitle) + 1, Text = "Action:" };
|
||||
base.Add (lblAction);
|
||||
|
||||
TextAction = new TextView
|
||||
{
|
||||
X = Pos.Left (TextTitle), Y = Pos.Top (_lblAction), Width = Dim.Fill (), Height = 5
|
||||
X = Pos.Left (TextTitle), Y = Pos.Top (lblAction), Width = Dim.Fill (), Height = 5
|
||||
};
|
||||
Add (TextAction);
|
||||
base.Add (TextAction);
|
||||
|
||||
var _lblShortcut = new Label
|
||||
var lblShortcut = new Label
|
||||
{
|
||||
X = Pos.Left (_lblTitle), Y = Pos.Bottom (TextAction) + 1, Text = "Shortcut:"
|
||||
X = Pos.Left (lblTitle), Y = Pos.Bottom (TextAction) + 1, Text = "Shortcut:"
|
||||
};
|
||||
Add (_lblShortcut);
|
||||
base.Add (lblShortcut);
|
||||
|
||||
TextShortcut = new TextField
|
||||
{
|
||||
X = Pos.X (TextAction), Y = Pos.Y (_lblShortcut), Width = Dim.Fill (), ReadOnly = true
|
||||
X = Pos.X (TextAction), Y = Pos.Y (lblShortcut), Width = Dim.Fill (), ReadOnly = true
|
||||
};
|
||||
|
||||
TextShortcut.KeyDown += (s, e) =>
|
||||
@@ -128,14 +128,14 @@ public class DynamicStatusBar : Scenario
|
||||
TextShortcut.Text = e.ToString ();
|
||||
|
||||
};
|
||||
Add (TextShortcut);
|
||||
base.Add (TextShortcut);
|
||||
|
||||
var _btnShortcut = new Button
|
||||
var btnShortcut = new Button
|
||||
{
|
||||
X = Pos.X (_lblShortcut), Y = Pos.Bottom (TextShortcut) + 1, Text = "Clear Shortcut"
|
||||
X = Pos.X (lblShortcut), Y = Pos.Bottom (TextShortcut) + 1, Text = "Clear Shortcut"
|
||||
};
|
||||
_btnShortcut.Accepting += (s, e) => { TextShortcut.Text = ""; };
|
||||
Add (_btnShortcut);
|
||||
btnShortcut.Accepting += (s, e) => { TextShortcut.Text = ""; };
|
||||
base.Add (btnShortcut);
|
||||
}
|
||||
|
||||
public TextView TextAction { get; }
|
||||
@@ -263,62 +263,62 @@ public class DynamicStatusBar : Scenario
|
||||
|
||||
Title = $"{Application.QuitKey} to Quit - Scenario: Dynamic StatusBar";
|
||||
|
||||
var _frmStatusBar = new FrameView
|
||||
var frmStatusBar = new FrameView
|
||||
{
|
||||
Y = 5, Width = Dim.Percent (50), Height = Dim.Fill (2), Title = "Items:"
|
||||
};
|
||||
|
||||
var _btnAddStatusBar = new Button { Y = 1, Text = "Add a StatusBar" };
|
||||
_frmStatusBar.Add (_btnAddStatusBar);
|
||||
var btnAddStatusBar = new Button { Y = 1, Text = "Add a StatusBar" };
|
||||
frmStatusBar.Add (btnAddStatusBar);
|
||||
|
||||
var _btnRemoveStatusBar = new Button { Y = 1, Text = "Remove a StatusBar" };
|
||||
var btnRemoveStatusBar = new Button { Y = 1, Text = "Remove a StatusBar" };
|
||||
|
||||
_btnRemoveStatusBar.X = Pos.AnchorEnd ();
|
||||
_frmStatusBar.Add (_btnRemoveStatusBar);
|
||||
btnRemoveStatusBar.X = Pos.AnchorEnd ();
|
||||
frmStatusBar.Add (btnRemoveStatusBar);
|
||||
|
||||
var _btnAdd = new Button { Y = Pos.Top (_btnRemoveStatusBar) + 2, Text = " Add " };
|
||||
_btnAdd.X = Pos.AnchorEnd ();
|
||||
_frmStatusBar.Add (_btnAdd);
|
||||
var btnAdd = new Button { Y = Pos.Top (btnRemoveStatusBar) + 2, Text = " Add " };
|
||||
btnAdd.X = Pos.AnchorEnd ();
|
||||
frmStatusBar.Add (btnAdd);
|
||||
|
||||
_lstItems = new ListView
|
||||
{
|
||||
ColorScheme = Colors.ColorSchemes ["Dialog"],
|
||||
Y = Pos.Top (_btnAddStatusBar) + 2,
|
||||
Width = Dim.Fill () - Dim.Width (_btnAdd) - 1,
|
||||
Y = Pos.Top (btnAddStatusBar) + 2,
|
||||
Width = Dim.Fill () - Dim.Width (btnAdd) - 1,
|
||||
Height = Dim.Fill (),
|
||||
Source = new ListWrapper<DynamicStatusItemList> ([])
|
||||
};
|
||||
_frmStatusBar.Add (_lstItems);
|
||||
frmStatusBar.Add (_lstItems);
|
||||
|
||||
var _btnRemove = new Button { X = Pos.Left (_btnAdd), Y = Pos.Top (_btnAdd) + 1, Text = "Remove" };
|
||||
_frmStatusBar.Add (_btnRemove);
|
||||
var btnRemove = new Button { X = Pos.Left (btnAdd), Y = Pos.Top (btnAdd) + 1, Text = "Remove" };
|
||||
frmStatusBar.Add (btnRemove);
|
||||
|
||||
var _btnUp = new Button { X = Pos.Right (_lstItems) + 2, Y = Pos.Top (_btnRemove) + 2, Text = Glyphs.UpArrow.ToString () };
|
||||
_frmStatusBar.Add (_btnUp);
|
||||
var btnUp = new Button { X = Pos.Right (_lstItems) + 2, Y = Pos.Top (btnRemove) + 2, Text = Glyphs.UpArrow.ToString () };
|
||||
frmStatusBar.Add (btnUp);
|
||||
|
||||
var _btnDown = new Button { X = Pos.Right (_lstItems) + 2, Y = Pos.Top (_btnUp) + 1, Text = Glyphs.DownArrow.ToString () };
|
||||
_frmStatusBar.Add (_btnDown);
|
||||
var btnDown = new Button { X = Pos.Right (_lstItems) + 2, Y = Pos.Top (btnUp) + 1, Text = Glyphs.DownArrow.ToString () };
|
||||
frmStatusBar.Add (btnDown);
|
||||
|
||||
Add (_frmStatusBar);
|
||||
Add (frmStatusBar);
|
||||
|
||||
var _frmStatusBarDetails = new DynamicStatusBarDetails
|
||||
var frmStatusBarDetails = new DynamicStatusBarDetails
|
||||
{
|
||||
X = Pos.Right (_frmStatusBar),
|
||||
Y = Pos.Top (_frmStatusBar),
|
||||
X = Pos.Right (frmStatusBar),
|
||||
Y = Pos.Top (frmStatusBar),
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill (4),
|
||||
Title = "Shortcut Details:"
|
||||
};
|
||||
Add (_frmStatusBarDetails);
|
||||
Add (frmStatusBarDetails);
|
||||
|
||||
_btnUp.Accepting += (s, e) =>
|
||||
btnUp.Accepting += (s, e) =>
|
||||
{
|
||||
int i = _lstItems.SelectedItem;
|
||||
Shortcut statusItem = DataContext.Items.Count > 0 ? DataContext.Items [i].Shortcut : null;
|
||||
|
||||
if (statusItem != null)
|
||||
{
|
||||
Shortcut [] items = _statusBar.Subviews.Cast<Shortcut> ().ToArray ();
|
||||
Shortcut [] items = _statusBar.SubViews.Cast<Shortcut> ().ToArray ();
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
@@ -334,14 +334,14 @@ public class DynamicStatusBar : Scenario
|
||||
}
|
||||
};
|
||||
|
||||
_btnDown.Accepting += (s, e) =>
|
||||
btnDown.Accepting += (s, e) =>
|
||||
{
|
||||
int i = _lstItems.SelectedItem;
|
||||
Shortcut statusItem = DataContext.Items.Count > 0 ? DataContext.Items [i].Shortcut : null;
|
||||
|
||||
if (statusItem != null)
|
||||
{
|
||||
Shortcut [] items = _statusBar.Subviews.Cast<Shortcut> ().ToArray ();
|
||||
Shortcut [] items = _statusBar.SubViews.Cast<Shortcut> ().ToArray ();
|
||||
|
||||
if (i < items.Length - 1)
|
||||
{
|
||||
@@ -357,21 +357,21 @@ public class DynamicStatusBar : Scenario
|
||||
}
|
||||
};
|
||||
|
||||
var _btnOk = new Button
|
||||
var btnOk = new Button
|
||||
{
|
||||
X = Pos.Right (_frmStatusBar) + 20, Y = Pos.Bottom (_frmStatusBarDetails), Text = "Ok"
|
||||
X = Pos.Right (frmStatusBar) + 20, Y = Pos.Bottom (frmStatusBarDetails), Text = "Ok"
|
||||
};
|
||||
Add (_btnOk);
|
||||
Add (btnOk);
|
||||
|
||||
var _btnCancel = new Button { X = Pos.Right (_btnOk) + 3, Y = Pos.Top (_btnOk), Text = "Cancel" };
|
||||
_btnCancel.Accepting += (s, e) => { SetFrameDetails (_currentEditStatusItem); };
|
||||
Add (_btnCancel);
|
||||
var btnCancel = new Button { X = Pos.Right (btnOk) + 3, Y = Pos.Top (btnOk), Text = "Cancel" };
|
||||
btnCancel.Accepting += (s, e) => { SetFrameDetails (_currentEditStatusItem); };
|
||||
Add (btnCancel);
|
||||
|
||||
_lstItems.SelectedItemChanged += (s, e) => { SetFrameDetails (); };
|
||||
|
||||
_btnOk.Accepting += (s, e) =>
|
||||
btnOk.Accepting += (s, e) =>
|
||||
{
|
||||
if (string.IsNullOrEmpty (_frmStatusBarDetails.TextTitle.Text) && _currentEditStatusItem != null)
|
||||
if (string.IsNullOrEmpty (frmStatusBarDetails.TextTitle.Text) && _currentEditStatusItem != null)
|
||||
{
|
||||
MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok");
|
||||
}
|
||||
@@ -380,15 +380,15 @@ public class DynamicStatusBar : Scenario
|
||||
|
||||
var statusItem = new DynamicStatusItem
|
||||
{
|
||||
Title = _frmStatusBarDetails.TextTitle.Text,
|
||||
Action = _frmStatusBarDetails.TextAction.Text,
|
||||
Shortcut = _frmStatusBarDetails.TextShortcut.Text
|
||||
Title = frmStatusBarDetails.TextTitle.Text,
|
||||
Action = frmStatusBarDetails.TextAction.Text,
|
||||
Shortcut = frmStatusBarDetails.TextShortcut.Text
|
||||
};
|
||||
UpdateStatusItem (_currentEditStatusItem, statusItem, _lstItems.SelectedItem);
|
||||
}
|
||||
};
|
||||
|
||||
_btnAdd.Accepting += (s, e) =>
|
||||
btnAdd.Accepting += (s, e) =>
|
||||
{
|
||||
//if (StatusBar == null)
|
||||
//{
|
||||
@@ -418,7 +418,7 @@ public class DynamicStatusBar : Scenario
|
||||
SetFrameDetails ();
|
||||
};
|
||||
|
||||
_btnRemove.Accepting += (s, e) =>
|
||||
btnRemove.Accepting += (s, e) =>
|
||||
{
|
||||
Shortcut statusItem = DataContext.Items.Count > 0
|
||||
? DataContext.Items [_lstItems.SelectedItem].Shortcut
|
||||
@@ -448,7 +448,7 @@ public class DynamicStatusBar : Scenario
|
||||
SetFrameDetails (statusItem);
|
||||
};
|
||||
|
||||
_btnAddStatusBar.Accepting += (s, e) =>
|
||||
btnAddStatusBar.Accepting += (s, e) =>
|
||||
{
|
||||
if (_statusBar != null)
|
||||
{
|
||||
@@ -459,7 +459,7 @@ public class DynamicStatusBar : Scenario
|
||||
Add (_statusBar);
|
||||
};
|
||||
|
||||
_btnRemoveStatusBar.Accepting += (s, e) =>
|
||||
btnRemoveStatusBar.Accepting += (s, e) =>
|
||||
{
|
||||
if (_statusBar == null)
|
||||
{
|
||||
@@ -499,20 +499,20 @@ public class DynamicStatusBar : Scenario
|
||||
}
|
||||
|
||||
_currentEditStatusItem = newStatusItem;
|
||||
_frmStatusBarDetails.EditStatusItem (newStatusItem);
|
||||
bool f = _btnOk.Enabled == _frmStatusBarDetails.Enabled;
|
||||
frmStatusBarDetails.EditStatusItem (newStatusItem);
|
||||
bool f = btnOk.Enabled == frmStatusBarDetails.Enabled;
|
||||
|
||||
if (!f)
|
||||
{
|
||||
_btnOk.Enabled = _frmStatusBarDetails.Enabled;
|
||||
_btnCancel.Enabled = _frmStatusBarDetails.Enabled;
|
||||
btnOk.Enabled = frmStatusBarDetails.Enabled;
|
||||
btnCancel.Enabled = frmStatusBarDetails.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
void SetListViewSource (Shortcut _currentStatusItem, bool fill = false)
|
||||
void SetListViewSource (Shortcut currentStatusItem, bool fill = false)
|
||||
{
|
||||
DataContext.Items = [];
|
||||
Shortcut statusItem = _currentStatusItem;
|
||||
Shortcut statusItem = currentStatusItem;
|
||||
|
||||
if (!fill)
|
||||
{
|
||||
@@ -521,7 +521,7 @@ public class DynamicStatusBar : Scenario
|
||||
|
||||
if (statusItem != null)
|
||||
{
|
||||
foreach (Shortcut si in _statusBar.Subviews.Cast<Shortcut> ())
|
||||
foreach (Shortcut si in _statusBar.SubViews.Cast<Shortcut> ())
|
||||
{
|
||||
DataContext.Items.Add (new DynamicStatusItemList (si.Title, si));
|
||||
}
|
||||
@@ -530,36 +530,36 @@ public class DynamicStatusBar : Scenario
|
||||
|
||||
Shortcut CreateNewStatusBar (DynamicStatusItem item)
|
||||
{
|
||||
var newStatusItem = new Shortcut (item.Shortcut, item.Title, _frmStatusBarDetails.CreateAction (item));
|
||||
var newStatusItem = new Shortcut (item.Shortcut, item.Title, frmStatusBarDetails.CreateAction (item));
|
||||
|
||||
return newStatusItem;
|
||||
}
|
||||
|
||||
void UpdateStatusItem (
|
||||
Shortcut _currentEditStatusItem,
|
||||
Shortcut currentEditStatusItem,
|
||||
DynamicStatusItem statusItem,
|
||||
int index
|
||||
)
|
||||
{
|
||||
_statusBar.Subviews [index].Title = statusItem.Title;
|
||||
((Shortcut)_statusBar.Subviews [index]).Action = _frmStatusBarDetails.CreateAction (statusItem);
|
||||
((Shortcut)_statusBar.Subviews [index]).Key = statusItem.Shortcut;
|
||||
_statusBar.SubViews.ElementAt (index).Title = statusItem.Title;
|
||||
((Shortcut)_statusBar.SubViews.ElementAt (index)).Action = frmStatusBarDetails.CreateAction (statusItem);
|
||||
((Shortcut)_statusBar.SubViews.ElementAt (index)).Key = statusItem.Shortcut;
|
||||
|
||||
if (DataContext.Items.Count == 0)
|
||||
{
|
||||
DataContext.Items.Add (
|
||||
new DynamicStatusItemList (
|
||||
_currentEditStatusItem.Title,
|
||||
_currentEditStatusItem
|
||||
currentEditStatusItem.Title,
|
||||
currentEditStatusItem
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
DataContext.Items [index] = new DynamicStatusItemList (
|
||||
_currentEditStatusItem.Title,
|
||||
_currentEditStatusItem
|
||||
currentEditStatusItem.Title,
|
||||
currentEditStatusItem
|
||||
);
|
||||
SetFrameDetails (_currentEditStatusItem);
|
||||
SetFrameDetails (currentEditStatusItem);
|
||||
}
|
||||
|
||||
//_frmStatusBarDetails.Initialized += (s, e) => _frmStatusBarDetails.Enabled = false;
|
||||
|
||||
@@ -741,7 +741,7 @@ public class Editor : Scenario
|
||||
private void ShowFindReplace (bool isFind = true)
|
||||
{
|
||||
_findReplaceWindow.Visible = true;
|
||||
_findReplaceWindow.SuperView.MoveSubviewToStart (_findReplaceWindow);
|
||||
_findReplaceWindow.SuperView.MoveSubViewToStart (_findReplaceWindow);
|
||||
_tabView.SetFocus ();
|
||||
_tabView.SelectedTab = isFind ? _tabView.Tabs.ToArray () [0] : _tabView.Tabs.ToArray () [1];
|
||||
_tabView.SelectedTab.View.FocusDeepest (NavigationDirection.Forward, null);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BorderEditor : AdornmentEditor
|
||||
{
|
||||
X = 0,
|
||||
|
||||
Y = Pos.Bottom (Subviews [^1]),
|
||||
Y = Pos.Bottom (SubViews.ToArray() [^1]),
|
||||
Width = Dim.Fill (),
|
||||
SelectedItem = (int)(((Border)AdornmentToEdit!)?.LineStyle ?? LineStyle.None),
|
||||
BorderStyle = LineStyle.Single,
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DimEditor : EditorBase
|
||||
{
|
||||
if (ViewToEdit is { })
|
||||
{
|
||||
ViewToEdit.SubviewsLaidOut += (_, _) => { OnUpdateSettings (); };
|
||||
ViewToEdit.SubViewsLaidOut += (_, _) => { OnUpdateSettings (); };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,14 +92,14 @@ public abstract class EditorBase : View
|
||||
|
||||
if (value is null && _viewToEdit is { })
|
||||
{
|
||||
_viewToEdit.SubviewsLaidOut -= View_LayoutComplete;
|
||||
_viewToEdit.SubViewsLaidOut -= View_LayoutComplete;
|
||||
}
|
||||
|
||||
_viewToEdit = value;
|
||||
|
||||
if (_viewToEdit is { })
|
||||
{
|
||||
_viewToEdit.SubviewsLaidOut += View_LayoutComplete;
|
||||
_viewToEdit.SubViewsLaidOut += View_LayoutComplete;
|
||||
}
|
||||
|
||||
OnViewToEditChanged ();
|
||||
|
||||
@@ -250,7 +250,7 @@ public class ExpanderButton : Button
|
||||
}
|
||||
}
|
||||
|
||||
foreach (View subview in superView.Subviews)
|
||||
foreach (View subview in superView.SubViews)
|
||||
{
|
||||
subview.Visible = !Collapsed;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed class ViewportSettingsEditor : EditorBase
|
||||
|
||||
protected override void OnUpdateSettings ()
|
||||
{
|
||||
foreach (View subview in Subviews)
|
||||
foreach (View subview in SubViews)
|
||||
{
|
||||
subview.Enabled = ViewToEdit is not Adornment;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public sealed class KeyBindings : Scenario
|
||||
};
|
||||
appWindow.Add (hotkeyBindingsListView);
|
||||
|
||||
foreach (var subview in appWindow.Subviews)
|
||||
foreach (var subview in appWindow.SubViews)
|
||||
{
|
||||
foreach (KeyValuePair<Key, KeyBinding> binding in subview.HotKeyBindings.GetBindings ())
|
||||
{
|
||||
|
||||
@@ -111,15 +111,15 @@ public class ListsAndCombos : Scenario
|
||||
comboBox.SelectedItemChanged += (s, text) => lbComboBox.Text = text.Value.ToString ();
|
||||
win.Add (lbComboBox, comboBox);
|
||||
|
||||
//var scrollBarCbx = new ScrollBarView (comboBox.Subviews [1], true);
|
||||
//var scrollBarCbx = new ScrollBarView (comboBox.SubViews.ElementAt (1), true);
|
||||
|
||||
//scrollBarCbx.ChangedPosition += (s, e) =>
|
||||
// {
|
||||
// ((ListView)comboBox.Subviews [1]).TopItem = scrollBarCbx.Position;
|
||||
// ((ListView)comboBox.SubViews.ElementAt (1)).TopItem = scrollBarCbx.Position;
|
||||
|
||||
// if (((ListView)comboBox.Subviews [1]).TopItem != scrollBarCbx.Position)
|
||||
// if (((ListView)comboBox.SubViews.ElementAt (1)).TopItem != scrollBarCbx.Position)
|
||||
// {
|
||||
// scrollBarCbx.Position = ((ListView)comboBox.Subviews [1]).TopItem;
|
||||
// scrollBarCbx.Position = ((ListView)comboBox.SubViews.ElementAt (1)).TopItem;
|
||||
// }
|
||||
|
||||
// comboBox.SetNeedsDraw ();
|
||||
@@ -127,11 +127,11 @@ public class ListsAndCombos : Scenario
|
||||
|
||||
//scrollBarCbx.OtherScrollBarView.ChangedPosition += (s, e) =>
|
||||
// {
|
||||
// ((ListView)comboBox.Subviews [1]).LeftItem = scrollBarCbx.OtherScrollBarView.Position;
|
||||
// ((ListView)comboBox.SubViews.ElementAt (1)).LeftItem = scrollBarCbx.OtherScrollBarView.Position;
|
||||
|
||||
// if (((ListView)comboBox.Subviews [1]).LeftItem != scrollBarCbx.OtherScrollBarView.Position)
|
||||
// if (((ListView)comboBox.SubViews.ElementAt (1)).LeftItem != scrollBarCbx.OtherScrollBarView.Position)
|
||||
// {
|
||||
// scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.Subviews [1]).LeftItem;
|
||||
// scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.SubViews.ElementAt (1)).LeftItem;
|
||||
// }
|
||||
|
||||
// comboBox.SetNeedsDraw ();
|
||||
@@ -140,9 +140,9 @@ public class ListsAndCombos : Scenario
|
||||
//comboBox.DrawingContent += (s, e) =>
|
||||
// {
|
||||
// scrollBarCbx.Size = comboBox.Source.Count;
|
||||
// scrollBarCbx.Position = ((ListView)comboBox.Subviews [1]).TopItem;
|
||||
// scrollBarCbx.OtherScrollBarView.Size = ((ListView)comboBox.Subviews [1]).MaxLength - 1;
|
||||
// scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.Subviews [1]).LeftItem;
|
||||
// scrollBarCbx.Position = ((ListView)comboBox.SubViews.ElementAt (1)).TopItem;
|
||||
// scrollBarCbx.OtherScrollBarView.Size = ((ListView)comboBox.SubViews.ElementAt (1)).MaxLength - 1;
|
||||
// scrollBarCbx.OtherScrollBarView.Position = ((ListView)comboBox.SubViews.ElementAt (1)).LeftItem;
|
||||
// scrollBarCbx.Refresh ();
|
||||
// };
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class MenuBarScenario : Scenario
|
||||
};
|
||||
|
||||
// There's no focus change event, so this is a bit of a hack.
|
||||
menuBar.SubviewsLaidOut += (s, e) => { _focusedView.Text = appWindow.MostFocused?.ToString () ?? "None"; };
|
||||
menuBar.SubViewsLaidOut += (s, e) => { _focusedView.Text = appWindow.MostFocused?.ToString () ?? "None"; };
|
||||
|
||||
var openBtn = new Button { X = Pos.Center (), Y = 4, Text = "_Open Menu", IsDefault = true };
|
||||
openBtn.Accepting += (s, e) => { menuBar.OpenMenu (); };
|
||||
|
||||
@@ -147,7 +147,7 @@ public class Mouse : Scenario
|
||||
demo.HighlightStyle = HighlightStyle.None;
|
||||
}
|
||||
|
||||
foreach (View subview in demo.Subviews)
|
||||
foreach (View subview in demo.SubViews)
|
||||
{
|
||||
if (e.NewValue == CheckState.Checked)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ public class Mouse : Scenario
|
||||
}
|
||||
}
|
||||
|
||||
foreach (View subview in demo.Padding.Subviews)
|
||||
foreach (View subview in demo.Padding.SubViews)
|
||||
{
|
||||
if (e.NewValue == CheckState.Checked)
|
||||
{
|
||||
@@ -177,12 +177,12 @@ public class Mouse : Scenario
|
||||
{
|
||||
demo.WantContinuousButtonPressed = !demo.WantContinuousButtonPressed;
|
||||
|
||||
foreach (View subview in demo.Subviews)
|
||||
foreach (View subview in demo.SubViews)
|
||||
{
|
||||
subview.WantContinuousButtonPressed = demo.WantContinuousButtonPressed;
|
||||
}
|
||||
|
||||
foreach (View subview in demo.Padding.Subviews)
|
||||
foreach (View subview in demo.Padding.SubViews)
|
||||
{
|
||||
subview.WantContinuousButtonPressed = demo.WantContinuousButtonPressed;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public sealed class PosAlignDemo : Scenario
|
||||
|
||||
private void UpdatePosAlignObjects (View superView, Dimension dimension, Aligner aligner)
|
||||
{
|
||||
foreach (View view in superView.Subviews.Where (v => dimension == Dimension.Width ? v.X is PosAlign : v.Y is PosAlign))
|
||||
foreach (View view in superView.SubViews.Where (v => dimension == Dimension.Width ? v.X is PosAlign : v.Y is PosAlign))
|
||||
{
|
||||
if (dimension == Dimension.Width ? view.X is PosAlign : view.Y is PosAlign)
|
||||
{
|
||||
|
||||
@@ -156,7 +156,7 @@ public class Progress : Scenario
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
foreach (ProgressDemo v in win.Subviews.OfType<ProgressDemo> ())
|
||||
foreach (ProgressDemo v in win.SubViews.OfType<ProgressDemo> ())
|
||||
{
|
||||
v?.StopBtnClick ();
|
||||
}
|
||||
|
||||
@@ -241,14 +241,14 @@ public class ProgressBarStyles : Scenario
|
||||
|
||||
_pbList.SetSource (
|
||||
new ObservableCollection<string> (
|
||||
container.Subviews.Where (v => v.GetType () == typeof (ProgressBar))
|
||||
container.SubViews.Where (v => v.GetType () == typeof (ProgressBar))
|
||||
.Select (v => v.Title)
|
||||
.ToList ())
|
||||
);
|
||||
|
||||
_pbList.SelectedItemChanged += (sender, e) =>
|
||||
{
|
||||
editor.ViewToEdit = container.Subviews.First (
|
||||
editor.ViewToEdit = container.SubViews.First (
|
||||
v =>
|
||||
v.GetType () == typeof (ProgressBar)
|
||||
&& v.Title == (string)e.Value
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ScrollBarDemo : Scenario
|
||||
|
||||
int GetMaxLabelWidth (int groupId)
|
||||
{
|
||||
return demoFrame.Subviews.Max (
|
||||
return demoFrame.SubViews.Max (
|
||||
v =>
|
||||
{
|
||||
if (v.Y.Has<PosAlign> (out var pos) && pos.GroupId == groupId)
|
||||
@@ -329,7 +329,7 @@ public class ScrollBarDemo : Scenario
|
||||
};
|
||||
demoFrame.Add (lblScrollContentSize);
|
||||
|
||||
scrollBar.SubviewsLaidOut += (s, e) =>
|
||||
scrollBar.SubViewsLaidOut += (s, e) =>
|
||||
{
|
||||
lblScrollFrame.Text = $"Scroll Frame: {scrollBar.Frame.ToString ()}";
|
||||
lblScrollViewport.Text = $"Scroll Viewport: {scrollBar.Viewport.ToString ()}";
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Shortcuts : Scenario
|
||||
eventLog.MoveDown ();
|
||||
|
||||
var max = 0;
|
||||
IEnumerable<View> toAlign = Application.Top.Subviews.Where (v => v is Shortcut { Width: not DimAbsolute });
|
||||
IEnumerable<View> toAlign = Application.Top.SubViews.Where (v => v is Shortcut { Width: not DimAbsolute });
|
||||
IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
|
||||
|
||||
if (e.NewValue == CheckState.Checked)
|
||||
@@ -122,7 +122,7 @@ public class Shortcuts : Scenario
|
||||
eventSource.Add ($"{commandFirstShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}");
|
||||
eventLog.MoveDown ();
|
||||
|
||||
IEnumerable<View> toAlign = Application.Top.Subviews.Where (v => v is Shortcut { Width: not DimAbsolute });
|
||||
IEnumerable<View> toAlign = Application.Top.SubViews.Where (v => v is Shortcut { Width: not DimAbsolute });
|
||||
IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
|
||||
|
||||
foreach (var view in enumerable)
|
||||
@@ -161,7 +161,7 @@ public class Shortcuts : Scenario
|
||||
eventLog.MoveDown ();
|
||||
//cb.CanFocus = e.NewValue == CheckState.Checked;
|
||||
|
||||
foreach (Shortcut peer in Application.Top.Subviews.Where (v => v is Shortcut)!)
|
||||
foreach (Shortcut peer in Application.Top.SubViews.Where (v => v is Shortcut)!)
|
||||
{
|
||||
if (peer.CanFocus)
|
||||
{
|
||||
@@ -463,7 +463,7 @@ public class Shortcuts : Scenario
|
||||
|
||||
Application.Top.Add (appQuitShortcut);
|
||||
|
||||
foreach (View sh in Application.Top.Subviews.Where (v => v is Shortcut)!)
|
||||
foreach (View sh in Application.Top.SubViews.Where (v => v is Shortcut)!)
|
||||
{
|
||||
if (sh is Shortcut shortcut)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Sliders : Scenario
|
||||
AllowEmpty = false
|
||||
};
|
||||
|
||||
single.SubviewLayout += (s, e) =>
|
||||
single.SubViewLayout += (s, e) =>
|
||||
{
|
||||
if (single.Orientation == Orientation.Horizontal)
|
||||
{
|
||||
@@ -189,7 +189,7 @@ public class Sliders : Scenario
|
||||
|
||||
optionsSlider.OptionsChanged += (sender, e) =>
|
||||
{
|
||||
foreach (Slider s in app.Subviews.OfType<Slider> ())
|
||||
foreach (Slider s in app.SubViews.OfType<Slider> ())
|
||||
{
|
||||
s.ShowLegends = e.Options.ContainsKey (0);
|
||||
s.RangeAllowSingle = e.Options.ContainsKey (1);
|
||||
@@ -233,7 +233,7 @@ public class Sliders : Scenario
|
||||
|
||||
dimAutoUsesMin.CheckedStateChanging += (sender, e) =>
|
||||
{
|
||||
foreach (Slider s in app.Subviews.OfType<Slider> ())
|
||||
foreach (Slider s in app.SubViews.OfType<Slider> ())
|
||||
{
|
||||
s.UseMinimumSize = !s.UseMinimumSize;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ public class Sliders : Scenario
|
||||
{
|
||||
View prev = null;
|
||||
|
||||
foreach (Slider s in app.Subviews.OfType<Slider> ())
|
||||
foreach (Slider s in app.SubViews.OfType<Slider> ())
|
||||
{
|
||||
if (e.Options.ContainsKey (0))
|
||||
{
|
||||
@@ -341,7 +341,7 @@ public class Sliders : Scenario
|
||||
|
||||
legendsOrientationSlider.OptionsChanged += (sender, e) =>
|
||||
{
|
||||
foreach (Slider s in app.Subviews.OfType<Slider> ())
|
||||
foreach (Slider s in app.SubViews.OfType<Slider> ())
|
||||
{
|
||||
if (e.Options.ContainsKey (0))
|
||||
{
|
||||
@@ -404,7 +404,7 @@ public class Sliders : Scenario
|
||||
X = Pos.Right (label) + 1
|
||||
};
|
||||
|
||||
innerSpacingUpDown.Value = app.Subviews.OfType<Slider> ().First ().MinimumInnerSpacing;
|
||||
innerSpacingUpDown.Value = app.SubViews.OfType<Slider> ().First ().MinimumInnerSpacing;
|
||||
|
||||
innerSpacingUpDown.ValueChanging += (sender, e) =>
|
||||
{
|
||||
@@ -415,7 +415,7 @@ public class Sliders : Scenario
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Slider s in app.Subviews.OfType<Slider> ())
|
||||
foreach (Slider s in app.SubViews.OfType<Slider> ())
|
||||
{
|
||||
s.MinimumInnerSpacing = e.NewValue;
|
||||
}
|
||||
@@ -430,7 +430,7 @@ public class Sliders : Scenario
|
||||
|
||||
#region Color Slider
|
||||
|
||||
foreach (Slider s in app.Subviews.OfType<Slider> ())
|
||||
foreach (Slider s in app.SubViews.OfType<Slider> ())
|
||||
{
|
||||
s.Style.OptionChar = s.Style.OptionChar with { Attribute = app.GetNormalColor () };
|
||||
s.Style.SetChar = s.Style.SetChar with { Attribute = app.GetNormalColor () };
|
||||
@@ -485,7 +485,7 @@ public class Sliders : Scenario
|
||||
{
|
||||
(Color, Color) data = e.Options.First ().Value.Data;
|
||||
|
||||
foreach (Slider s in app.Subviews.OfType<Slider> ())
|
||||
foreach (Slider s in app.SubViews.OfType<Slider> ())
|
||||
{
|
||||
s.ColorScheme = new ColorScheme (s.ColorScheme);
|
||||
|
||||
@@ -555,7 +555,7 @@ public class Sliders : Scenario
|
||||
{
|
||||
(Color, Color) data = e.Options.First ().Value.Data;
|
||||
|
||||
foreach (Slider s in app.Subviews.OfType<Slider> ())
|
||||
foreach (Slider s in app.SubViews.OfType<Slider> ())
|
||||
{
|
||||
s.ColorScheme = new ColorScheme (s.ColorScheme)
|
||||
{
|
||||
@@ -585,7 +585,7 @@ public class Sliders : Scenario
|
||||
configView.Add (eventLog);
|
||||
|
||||
|
||||
foreach (Slider slider in app.Subviews.Where (v => v is Slider)!)
|
||||
foreach (Slider slider in app.SubViews.Where (v => v is Slider)!)
|
||||
{
|
||||
slider.Accepting += (o, args) =>
|
||||
{
|
||||
|
||||
@@ -120,7 +120,7 @@ public class TextViewAutocompletePopup : Scenario
|
||||
);
|
||||
appWindow.Add (statusBar);
|
||||
|
||||
appWindow.SubviewLayout += Win_LayoutStarted;
|
||||
appWindow.SubViewLayout += Win_LayoutStarted;
|
||||
|
||||
// Run - Start the application.
|
||||
Application.Run (appWindow);
|
||||
|
||||
@@ -159,7 +159,7 @@ public class TileViewNesting : Scenario
|
||||
CheckState border = _cbBorder.CheckedState;
|
||||
CheckState startHorizontal = _cbHorizontal.CheckedState;
|
||||
|
||||
foreach (View sub in _workArea.Subviews)
|
||||
foreach (View sub in _workArea.SubViews)
|
||||
{
|
||||
sub.Dispose ();
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ViewportSettings : Scenario
|
||||
|
||||
private void VirtualDemoView_LayoutComplete (object sender, DrawEventArgs drawEventArgs)
|
||||
{
|
||||
Label frameLabel = Padding?.Subviews.OfType<Label> ().FirstOrDefault ();
|
||||
Label frameLabel = Padding?.SubViews.OfType<Label> ().FirstOrDefault ();
|
||||
|
||||
if (frameLabel is { })
|
||||
{
|
||||
|
||||
@@ -287,7 +287,7 @@ public class VkeyPacketSimulator : Scenario
|
||||
..outputVerticalRuler.Viewport.Height];
|
||||
}
|
||||
|
||||
win.SubviewsLaidOut += Win_LayoutComplete;
|
||||
win.SubViewsLaidOut += Win_LayoutComplete;
|
||||
|
||||
Application.Run (win);
|
||||
win.Dispose ();
|
||||
|
||||
@@ -284,7 +284,7 @@ public class Wizards : Scenario
|
||||
someText.Height = Dim.Fill (
|
||||
Dim.Func (
|
||||
() => someText.SuperView is { IsInitialized: true }
|
||||
? someText.SuperView.Subviews
|
||||
? someText.SuperView.SubViews
|
||||
.First (view => view.Y.Has<PosAnchorEnd> (out _))
|
||||
.Frame.Height
|
||||
: 1));
|
||||
|
||||
@@ -1016,7 +1016,7 @@ public class UICatalogApp
|
||||
|
||||
MenuBar!.Menus [0].Children! [0]!.ShortcutKey = Application.QuitKey;
|
||||
|
||||
((Shortcut)_statusBar!.Subviews [0]).Key = Application.QuitKey;
|
||||
((Shortcut)_statusBar!.SubViews.ElementAt (0)).Key = Application.QuitKey;
|
||||
_statusBar.Visible = ShowStatusBar;
|
||||
|
||||
MiIsMouseDisabled!.Checked = Application.IsMouseDisabled;
|
||||
|
||||
Reference in New Issue
Block a user