|
@@ -107,31 +107,31 @@ public class DynamicMenuBar : Scenario
|
|
|
var _lblTitle = new Label { Y = 1, Text = "Title:" };
|
|
|
Add (_lblTitle);
|
|
|
|
|
|
- TextTitle = new TextField { X = Pos.Right (_lblTitle) + 2, Y = Pos.Top (_lblTitle), Width = Dim.Fill () };
|
|
|
+ TextTitle = new() { X = Pos.Right (_lblTitle) + 2, Y = Pos.Top (_lblTitle), Width = Dim.Fill () };
|
|
|
Add (TextTitle);
|
|
|
|
|
|
var _lblHelp = new Label { X = Pos.Left (_lblTitle), Y = Pos.Bottom (_lblTitle) + 1, Text = "Help:" };
|
|
|
Add (_lblHelp);
|
|
|
|
|
|
- TextHelp = new TextField { X = Pos.Left (TextTitle), Y = Pos.Top (_lblHelp), Width = Dim.Fill () };
|
|
|
+ TextHelp = new() { X = Pos.Left (TextTitle), Y = Pos.Top (_lblHelp), Width = Dim.Fill () };
|
|
|
Add (TextHelp);
|
|
|
|
|
|
var _lblAction = new Label { X = Pos.Left (_lblTitle), Y = Pos.Bottom (_lblHelp) + 1, Text = "Action:" };
|
|
|
Add (_lblAction);
|
|
|
|
|
|
- TextAction = new TextView
|
|
|
+ TextAction = new()
|
|
|
{
|
|
|
X = Pos.Left (TextTitle), Y = Pos.Top (_lblAction), Width = Dim.Fill (), Height = 5
|
|
|
};
|
|
|
Add (TextAction);
|
|
|
|
|
|
- CkbIsTopLevel = new CheckBox
|
|
|
+ CkbIsTopLevel = new()
|
|
|
{
|
|
|
X = Pos.Left (_lblTitle), Y = Pos.Bottom (_lblAction) + 5, Text = "IsTopLevel"
|
|
|
};
|
|
|
Add (CkbIsTopLevel);
|
|
|
|
|
|
- CkbSubMenu = new CheckBox
|
|
|
+ CkbSubMenu = new()
|
|
|
{
|
|
|
X = Pos.Left (_lblTitle),
|
|
|
Y = Pos.Bottom (CkbIsTopLevel),
|
|
@@ -140,7 +140,7 @@ public class DynamicMenuBar : Scenario
|
|
|
};
|
|
|
Add (CkbSubMenu);
|
|
|
|
|
|
- CkbNullCheck = new CheckBox
|
|
|
+ CkbNullCheck = new()
|
|
|
{
|
|
|
X = Pos.Left (_lblTitle), Y = Pos.Bottom (CkbSubMenu), Text = "Allow null checked"
|
|
|
};
|
|
@@ -148,7 +148,7 @@ public class DynamicMenuBar : Scenario
|
|
|
|
|
|
var _rChkLabels = new [] { "NoCheck", "Checked", "Radio" };
|
|
|
|
|
|
- RbChkStyle = new RadioGroup
|
|
|
+ RbChkStyle = new()
|
|
|
{
|
|
|
X = Pos.Left (_lblTitle), Y = Pos.Bottom (CkbSubMenu) + 1, RadioLabels = _rChkLabels
|
|
|
};
|
|
@@ -160,7 +160,7 @@ public class DynamicMenuBar : Scenario
|
|
|
};
|
|
|
Add (_lblShortcut);
|
|
|
|
|
|
- TextShortcut = new TextField
|
|
|
+ TextShortcut = new()
|
|
|
{
|
|
|
X = Pos.X (_lblShortcut), Y = Pos.Bottom (_lblShortcut), Width = Dim.Fill (), ReadOnly = true
|
|
|
};
|
|
@@ -194,7 +194,7 @@ public class DynamicMenuBar : Scenario
|
|
|
|
|
|
bool CheckShortcut (KeyCode k, bool pre)
|
|
|
{
|
|
|
- MenuItem m = _menuItem != null ? _menuItem : new MenuItem ();
|
|
|
+ MenuItem m = _menuItem != null ? _menuItem : new ();
|
|
|
|
|
|
if (pre && !ShortcutHelper.PreShortcutValidation (k))
|
|
|
{
|
|
@@ -422,24 +422,24 @@ public class DynamicMenuBar : Scenario
|
|
|
var btnOk = new Button { IsDefault = true, Text = "Ok" };
|
|
|
|
|
|
btnOk.Accept += (s, e) =>
|
|
|
- {
|
|
|
- if (string.IsNullOrEmpty (TextTitle.Text))
|
|
|
- {
|
|
|
- MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- valid = true;
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty (TextTitle.Text))
|
|
|
+ {
|
|
|
+ MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ valid = true;
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
var btnCancel = new Button { Text = "Cancel" };
|
|
|
|
|
|
btnCancel.Accept += (s, e) =>
|
|
|
- {
|
|
|
- TextTitle.Text = string.Empty;
|
|
|
- Application.RequestStop ();
|
|
|
- };
|
|
|
+ {
|
|
|
+ TextTitle.Text = string.Empty;
|
|
|
+ Application.RequestStop ();
|
|
|
+ };
|
|
|
var dialog = new Dialog { Title = "Enter the menu details.", Buttons = [btnOk, btnCancel] };
|
|
|
|
|
|
Width = Dim.Fill ();
|
|
@@ -452,7 +452,7 @@ public class DynamicMenuBar : Scenario
|
|
|
|
|
|
if (valid)
|
|
|
{
|
|
|
- return new DynamicMenuItem
|
|
|
+ return new()
|
|
|
{
|
|
|
Title = TextTitle.Text,
|
|
|
Help = TextHelp.Text,
|
|
@@ -486,13 +486,13 @@ public class DynamicMenuBar : Scenario
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- menuItem = new MenuItem (
|
|
|
- menuItem.Title,
|
|
|
- menuItem.Help,
|
|
|
- CreateAction (menuItem, new DynamicMenuItem ()),
|
|
|
- null,
|
|
|
- menuItem.Parent
|
|
|
- );
|
|
|
+ menuItem = new (
|
|
|
+ menuItem.Title,
|
|
|
+ menuItem.Help,
|
|
|
+ CreateAction (menuItem, new ()),
|
|
|
+ null,
|
|
|
+ menuItem.Parent
|
|
|
+ );
|
|
|
|
|
|
if (idx > -1)
|
|
|
{
|
|
@@ -569,7 +569,7 @@ public class DynamicMenuBar : Scenario
|
|
|
|
|
|
public DynamicMenuBarSample ()
|
|
|
{
|
|
|
- DataContext = new DynamicMenuItemModel ();
|
|
|
+ DataContext = new ();
|
|
|
|
|
|
var _frmDelimiter = new FrameView
|
|
|
{
|
|
@@ -626,7 +626,7 @@ public class DynamicMenuBar : Scenario
|
|
|
TextAlignment = TextAlignment.Centered,
|
|
|
X = Pos.Right (_btnPrevious) + 1,
|
|
|
Y = Pos.Top (_btnPrevious),
|
|
|
- AutoSize = false,
|
|
|
+
|
|
|
Width = Dim.Fill () - Dim.Function (() => _btnAdd.Frame.Width + 1),
|
|
|
Height = 1
|
|
|
};
|
|
@@ -639,7 +639,7 @@ public class DynamicMenuBar : Scenario
|
|
|
TextAlignment = TextAlignment.Centered,
|
|
|
X = Pos.Right (_btnPrevious) + 1,
|
|
|
Y = Pos.Top (_btnPrevious) + 1,
|
|
|
- AutoSize = false,
|
|
|
+
|
|
|
Width = Dim.Fill () - Dim.Width (_btnAdd) - 1
|
|
|
};
|
|
|
_frmMenu.Add (_lblParent);
|
|
@@ -650,7 +650,7 @@ public class DynamicMenuBar : Scenario
|
|
|
};
|
|
|
_frmMenu.Add (_btnPreviowsParent);
|
|
|
|
|
|
- _lstMenus = new ListView
|
|
|
+ _lstMenus = new()
|
|
|
{
|
|
|
ColorScheme = Colors.ColorSchemes ["Dialog"],
|
|
|
X = Pos.Right (_btnPrevious) + 1,
|
|
@@ -688,121 +688,121 @@ public class DynamicMenuBar : Scenario
|
|
|
Add (_frmMenuDetails);
|
|
|
|
|
|
_btnMenuBarUp.Accept += (s, e) =>
|
|
|
- {
|
|
|
- int i = _currentSelectedMenuBar;
|
|
|
+ {
|
|
|
+ int i = _currentSelectedMenuBar;
|
|
|
|
|
|
- MenuBarItem menuItem = _menuBar != null && _menuBar.Menus.Length > 0
|
|
|
- ? _menuBar.Menus [i]
|
|
|
- : null;
|
|
|
+ MenuBarItem menuItem = _menuBar != null && _menuBar.Menus.Length > 0
|
|
|
+ ? _menuBar.Menus [i]
|
|
|
+ : null;
|
|
|
|
|
|
- if (menuItem != null)
|
|
|
- {
|
|
|
- MenuBarItem [] menus = _menuBar.Menus;
|
|
|
+ if (menuItem != null)
|
|
|
+ {
|
|
|
+ MenuBarItem [] menus = _menuBar.Menus;
|
|
|
|
|
|
- if (i > 0)
|
|
|
- {
|
|
|
- menus [i] = menus [i - 1];
|
|
|
- menus [i - 1] = menuItem;
|
|
|
- _currentSelectedMenuBar = i - 1;
|
|
|
- _menuBar.SetNeedsDisplay ();
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ if (i > 0)
|
|
|
+ {
|
|
|
+ menus [i] = menus [i - 1];
|
|
|
+ menus [i - 1] = menuItem;
|
|
|
+ _currentSelectedMenuBar = i - 1;
|
|
|
+ _menuBar.SetNeedsDisplay ();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
_btnMenuBarDown.Accept += (s, e) =>
|
|
|
- {
|
|
|
- int i = _currentSelectedMenuBar;
|
|
|
+ {
|
|
|
+ int i = _currentSelectedMenuBar;
|
|
|
|
|
|
- MenuBarItem menuItem = _menuBar != null && _menuBar.Menus.Length > 0
|
|
|
- ? _menuBar.Menus [i]
|
|
|
- : null;
|
|
|
+ MenuBarItem menuItem = _menuBar != null && _menuBar.Menus.Length > 0
|
|
|
+ ? _menuBar.Menus [i]
|
|
|
+ : null;
|
|
|
|
|
|
- if (menuItem != null)
|
|
|
- {
|
|
|
- MenuBarItem [] menus = _menuBar.Menus;
|
|
|
+ if (menuItem != null)
|
|
|
+ {
|
|
|
+ MenuBarItem [] menus = _menuBar.Menus;
|
|
|
|
|
|
- if (i < menus.Length - 1)
|
|
|
- {
|
|
|
- menus [i] = menus [i + 1];
|
|
|
- menus [i + 1] = menuItem;
|
|
|
- _currentSelectedMenuBar = i + 1;
|
|
|
- _menuBar.SetNeedsDisplay ();
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ if (i < menus.Length - 1)
|
|
|
+ {
|
|
|
+ menus [i] = menus [i + 1];
|
|
|
+ menus [i + 1] = menuItem;
|
|
|
+ _currentSelectedMenuBar = i + 1;
|
|
|
+ _menuBar.SetNeedsDisplay ();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
_btnUp.Accept += (s, e) =>
|
|
|
- {
|
|
|
- int i = _lstMenus.SelectedItem;
|
|
|
- MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null;
|
|
|
+ {
|
|
|
+ int i = _lstMenus.SelectedItem;
|
|
|
+ MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null;
|
|
|
|
|
|
- if (menuItem != null)
|
|
|
- {
|
|
|
- MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children;
|
|
|
+ if (menuItem != null)
|
|
|
+ {
|
|
|
+ MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children;
|
|
|
|
|
|
- if (i > 0)
|
|
|
- {
|
|
|
- childrens [i] = childrens [i - 1];
|
|
|
- childrens [i - 1] = menuItem;
|
|
|
- DataContext.Menus [i] = DataContext.Menus [i - 1];
|
|
|
+ if (i > 0)
|
|
|
+ {
|
|
|
+ childrens [i] = childrens [i - 1];
|
|
|
+ childrens [i - 1] = menuItem;
|
|
|
+ DataContext.Menus [i] = DataContext.Menus [i - 1];
|
|
|
|
|
|
- DataContext.Menus [i - 1] =
|
|
|
- new DynamicMenuItemList { Title = menuItem.Title, MenuItem = menuItem };
|
|
|
- _lstMenus.SelectedItem = i - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ DataContext.Menus [i - 1] =
|
|
|
+ new() { Title = menuItem.Title, MenuItem = menuItem };
|
|
|
+ _lstMenus.SelectedItem = i - 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
_btnDown.Accept += (s, e) =>
|
|
|
- {
|
|
|
- int i = _lstMenus.SelectedItem;
|
|
|
- MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null;
|
|
|
+ {
|
|
|
+ int i = _lstMenus.SelectedItem;
|
|
|
+ MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null;
|
|
|
|
|
|
- if (menuItem != null)
|
|
|
- {
|
|
|
- MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children;
|
|
|
+ if (menuItem != null)
|
|
|
+ {
|
|
|
+ MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children;
|
|
|
|
|
|
- if (i < childrens.Length - 1)
|
|
|
- {
|
|
|
- childrens [i] = childrens [i + 1];
|
|
|
- childrens [i + 1] = menuItem;
|
|
|
- DataContext.Menus [i] = DataContext.Menus [i + 1];
|
|
|
+ if (i < childrens.Length - 1)
|
|
|
+ {
|
|
|
+ childrens [i] = childrens [i + 1];
|
|
|
+ childrens [i + 1] = menuItem;
|
|
|
+ DataContext.Menus [i] = DataContext.Menus [i + 1];
|
|
|
|
|
|
- DataContext.Menus [i + 1] =
|
|
|
- new DynamicMenuItemList { Title = menuItem.Title, MenuItem = menuItem };
|
|
|
- _lstMenus.SelectedItem = i + 1;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ DataContext.Menus [i + 1] =
|
|
|
+ new() { Title = menuItem.Title, MenuItem = menuItem };
|
|
|
+ _lstMenus.SelectedItem = i + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
_btnPreviowsParent.Accept += (s, e) =>
|
|
|
- {
|
|
|
- if (_currentMenuBarItem != null && _currentMenuBarItem.Parent != null)
|
|
|
- {
|
|
|
- MenuItem mi = _currentMenuBarItem;
|
|
|
- _currentMenuBarItem = _currentMenuBarItem.Parent as MenuBarItem;
|
|
|
- SetListViewSource (_currentMenuBarItem, true);
|
|
|
- int i = ((MenuBarItem)_currentMenuBarItem).GetChildrenIndex (mi);
|
|
|
-
|
|
|
- if (i > -1)
|
|
|
- {
|
|
|
- _lstMenus.SelectedItem = i;
|
|
|
- }
|
|
|
-
|
|
|
- if (_currentMenuBarItem.Parent != null)
|
|
|
- {
|
|
|
- DataContext.Parent = _currentMenuBarItem.Title;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DataContext.Parent = string.Empty;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DataContext.Parent = string.Empty;
|
|
|
- }
|
|
|
- };
|
|
|
+ {
|
|
|
+ if (_currentMenuBarItem != null && _currentMenuBarItem.Parent != null)
|
|
|
+ {
|
|
|
+ MenuItem mi = _currentMenuBarItem;
|
|
|
+ _currentMenuBarItem = _currentMenuBarItem.Parent as MenuBarItem;
|
|
|
+ SetListViewSource (_currentMenuBarItem, true);
|
|
|
+ int i = ((MenuBarItem)_currentMenuBarItem).GetChildrenIndex (mi);
|
|
|
+
|
|
|
+ if (i > -1)
|
|
|
+ {
|
|
|
+ _lstMenus.SelectedItem = i;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_currentMenuBarItem.Parent != null)
|
|
|
+ {
|
|
|
+ DataContext.Parent = _currentMenuBarItem.Title;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DataContext.Parent = string.Empty;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DataContext.Parent = string.Empty;
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
var _btnOk = new Button { X = Pos.Right (_frmMenu) + 20, Y = Pos.Bottom (_frmMenuDetails), Text = "Ok" };
|
|
|
Add (_btnOk);
|
|
@@ -814,157 +814,157 @@ public class DynamicMenuBar : Scenario
|
|
|
_lstMenus.SelectedItemChanged += (s, e) => { SetFrameDetails (); };
|
|
|
|
|
|
_btnOk.Accept += (s, e) =>
|
|
|
- {
|
|
|
- if (string.IsNullOrEmpty (_frmMenuDetails.TextTitle.Text) && _currentEditMenuBarItem != null)
|
|
|
- {
|
|
|
- MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok");
|
|
|
- }
|
|
|
- else if (_currentEditMenuBarItem != null)
|
|
|
- {
|
|
|
- var menuItem = new DynamicMenuItem
|
|
|
- {
|
|
|
- Title = _frmMenuDetails.TextTitle.Text,
|
|
|
- Help = _frmMenuDetails.TextHelp.Text,
|
|
|
- Action = _frmMenuDetails.TextAction.Text,
|
|
|
- IsTopLevel = _frmMenuDetails.CkbIsTopLevel?.Checked ?? false,
|
|
|
- HasSubMenu = _frmMenuDetails.CkbSubMenu?.Checked ?? false,
|
|
|
- CheckStyle = _frmMenuDetails.RbChkStyle.SelectedItem == 0
|
|
|
- ? MenuItemCheckStyle.NoCheck
|
|
|
- : _frmMenuDetails.RbChkStyle.SelectedItem == 1
|
|
|
- ? MenuItemCheckStyle.Checked
|
|
|
- : MenuItemCheckStyle.Radio,
|
|
|
- Shortcut = _frmMenuDetails.TextShortcut.Text
|
|
|
- };
|
|
|
- UpdateMenuItem (_currentEditMenuBarItem, menuItem, _lstMenus.SelectedItem);
|
|
|
- }
|
|
|
- };
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty (_frmMenuDetails.TextTitle.Text) && _currentEditMenuBarItem != null)
|
|
|
+ {
|
|
|
+ MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok");
|
|
|
+ }
|
|
|
+ else if (_currentEditMenuBarItem != null)
|
|
|
+ {
|
|
|
+ var menuItem = new DynamicMenuItem
|
|
|
+ {
|
|
|
+ Title = _frmMenuDetails.TextTitle.Text,
|
|
|
+ Help = _frmMenuDetails.TextHelp.Text,
|
|
|
+ Action = _frmMenuDetails.TextAction.Text,
|
|
|
+ IsTopLevel = _frmMenuDetails.CkbIsTopLevel?.Checked ?? false,
|
|
|
+ HasSubMenu = _frmMenuDetails.CkbSubMenu?.Checked ?? false,
|
|
|
+ CheckStyle = _frmMenuDetails.RbChkStyle.SelectedItem == 0
|
|
|
+ ? MenuItemCheckStyle.NoCheck
|
|
|
+ : _frmMenuDetails.RbChkStyle.SelectedItem == 1
|
|
|
+ ? MenuItemCheckStyle.Checked
|
|
|
+ : MenuItemCheckStyle.Radio,
|
|
|
+ Shortcut = _frmMenuDetails.TextShortcut.Text
|
|
|
+ };
|
|
|
+ UpdateMenuItem (_currentEditMenuBarItem, menuItem, _lstMenus.SelectedItem);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
_btnAdd.Accept += (s, e) =>
|
|
|
- {
|
|
|
- if (MenuBar == null)
|
|
|
- {
|
|
|
- MessageBox.ErrorQuery ("Menu Bar Error", "Must add a MenuBar first!", "Ok");
|
|
|
- _btnAddMenuBar.SetFocus ();
|
|
|
+ {
|
|
|
+ if (MenuBar == null)
|
|
|
+ {
|
|
|
+ MessageBox.ErrorQuery ("Menu Bar Error", "Must add a MenuBar first!", "Ok");
|
|
|
+ _btnAddMenuBar.SetFocus ();
|
|
|
|
|
|
- return;
|
|
|
- }
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- var frameDetails = new DynamicMenuBarDetails (null, _currentMenuBarItem != null);
|
|
|
- DynamicMenuItem item = frameDetails.EnterMenuItem ();
|
|
|
+ var frameDetails = new DynamicMenuBarDetails (null, _currentMenuBarItem != null);
|
|
|
+ DynamicMenuItem item = frameDetails.EnterMenuItem ();
|
|
|
|
|
|
- if (item == null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (item == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (!(_currentMenuBarItem is MenuBarItem))
|
|
|
- {
|
|
|
- var parent = _currentMenuBarItem.Parent as MenuBarItem;
|
|
|
- int idx = parent.GetChildrenIndex (_currentMenuBarItem);
|
|
|
-
|
|
|
- _currentMenuBarItem = new MenuBarItem (
|
|
|
- _currentMenuBarItem.Title,
|
|
|
- new MenuItem [] { },
|
|
|
- _currentMenuBarItem.Parent
|
|
|
- );
|
|
|
- _currentMenuBarItem.CheckType = item.CheckStyle;
|
|
|
- parent.Children [idx] = _currentMenuBarItem;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MenuItem newMenu = CreateNewMenu (item, _currentMenuBarItem);
|
|
|
- var menuBarItem = _currentMenuBarItem as MenuBarItem;
|
|
|
+ if (!(_currentMenuBarItem is MenuBarItem))
|
|
|
+ {
|
|
|
+ var parent = _currentMenuBarItem.Parent as MenuBarItem;
|
|
|
+ int idx = parent.GetChildrenIndex (_currentMenuBarItem);
|
|
|
+
|
|
|
+ _currentMenuBarItem = new MenuBarItem (
|
|
|
+ _currentMenuBarItem.Title,
|
|
|
+ new MenuItem [] { },
|
|
|
+ _currentMenuBarItem.Parent
|
|
|
+ );
|
|
|
+ _currentMenuBarItem.CheckType = item.CheckStyle;
|
|
|
+ parent.Children [idx] = _currentMenuBarItem;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MenuItem newMenu = CreateNewMenu (item, _currentMenuBarItem);
|
|
|
+ var menuBarItem = _currentMenuBarItem as MenuBarItem;
|
|
|
|
|
|
- if (menuBarItem == null)
|
|
|
- {
|
|
|
- menuBarItem = new MenuBarItem (
|
|
|
- _currentMenuBarItem.Title,
|
|
|
- new [] { newMenu },
|
|
|
- _currentMenuBarItem.Parent
|
|
|
- );
|
|
|
- }
|
|
|
- else if (menuBarItem.Children == null)
|
|
|
- {
|
|
|
- menuBarItem.Children = new [] { newMenu };
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MenuItem [] childrens = menuBarItem.Children;
|
|
|
- Array.Resize (ref childrens, childrens.Length + 1);
|
|
|
- childrens [childrens.Length - 1] = newMenu;
|
|
|
- menuBarItem.Children = childrens;
|
|
|
- }
|
|
|
+ if (menuBarItem == null)
|
|
|
+ {
|
|
|
+ menuBarItem = new (
|
|
|
+ _currentMenuBarItem.Title,
|
|
|
+ new [] { newMenu },
|
|
|
+ _currentMenuBarItem.Parent
|
|
|
+ );
|
|
|
+ }
|
|
|
+ else if (menuBarItem.Children == null)
|
|
|
+ {
|
|
|
+ menuBarItem.Children = new [] { newMenu };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MenuItem [] childrens = menuBarItem.Children;
|
|
|
+ Array.Resize (ref childrens, childrens.Length + 1);
|
|
|
+ childrens [childrens.Length - 1] = newMenu;
|
|
|
+ menuBarItem.Children = childrens;
|
|
|
+ }
|
|
|
|
|
|
- DataContext.Menus.Add (new DynamicMenuItemList { Title = newMenu.Title, MenuItem = newMenu });
|
|
|
- _lstMenus.MoveDown ();
|
|
|
- }
|
|
|
- };
|
|
|
+ DataContext.Menus.Add (new() { Title = newMenu.Title, MenuItem = newMenu });
|
|
|
+ _lstMenus.MoveDown ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
_btnRemove.Accept += (s, e) =>
|
|
|
- {
|
|
|
- MenuItem menuItem = DataContext.Menus.Count > 0
|
|
|
- ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem
|
|
|
- : null;
|
|
|
+ {
|
|
|
+ MenuItem menuItem = DataContext.Menus.Count > 0
|
|
|
+ ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem
|
|
|
+ : null;
|
|
|
|
|
|
- if (menuItem != null)
|
|
|
- {
|
|
|
- MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children;
|
|
|
- childrens [_lstMenus.SelectedItem] = null;
|
|
|
- var i = 0;
|
|
|
+ if (menuItem != null)
|
|
|
+ {
|
|
|
+ MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children;
|
|
|
+ childrens [_lstMenus.SelectedItem] = null;
|
|
|
+ var i = 0;
|
|
|
|
|
|
- foreach (MenuItem c in childrens)
|
|
|
- {
|
|
|
- if (c != null)
|
|
|
- {
|
|
|
- childrens [i] = c;
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
+ foreach (MenuItem c in childrens)
|
|
|
+ {
|
|
|
+ if (c != null)
|
|
|
+ {
|
|
|
+ childrens [i] = c;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- Array.Resize (ref childrens, childrens.Length - 1);
|
|
|
+ Array.Resize (ref childrens, childrens.Length - 1);
|
|
|
|
|
|
- if (childrens.Length == 0)
|
|
|
- {
|
|
|
- if (_currentMenuBarItem.Parent == null)
|
|
|
- {
|
|
|
- ((MenuBarItem)_currentMenuBarItem).Children = null;
|
|
|
+ if (childrens.Length == 0)
|
|
|
+ {
|
|
|
+ if (_currentMenuBarItem.Parent == null)
|
|
|
+ {
|
|
|
+ ((MenuBarItem)_currentMenuBarItem).Children = null;
|
|
|
|
|
|
- //_currentMenuBarItem.Action = _frmMenuDetails.CreateAction (_currentEditMenuBarItem, new DynamicMenuItem (_currentMenuBarItem.Title));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _currentMenuBarItem = new MenuItem (
|
|
|
- _currentMenuBarItem.Title,
|
|
|
- _currentMenuBarItem.Help,
|
|
|
- _frmMenuDetails.CreateAction (
|
|
|
- _currentEditMenuBarItem,
|
|
|
- new DynamicMenuItem
|
|
|
- {
|
|
|
- Title = _currentEditMenuBarItem
|
|
|
- .Title
|
|
|
- }
|
|
|
- ),
|
|
|
- null,
|
|
|
- _currentMenuBarItem.Parent
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ((MenuBarItem)_currentMenuBarItem).Children = childrens;
|
|
|
- }
|
|
|
+ //_currentMenuBarItem.Action = _frmMenuDetails.CreateAction (_currentEditMenuBarItem, new DynamicMenuItem (_currentMenuBarItem.Title));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _currentMenuBarItem = new (
|
|
|
+ _currentMenuBarItem.Title,
|
|
|
+ _currentMenuBarItem.Help,
|
|
|
+ _frmMenuDetails.CreateAction (
|
|
|
+ _currentEditMenuBarItem,
|
|
|
+ new()
|
|
|
+ {
|
|
|
+ Title = _currentEditMenuBarItem
|
|
|
+ .Title
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ null,
|
|
|
+ _currentMenuBarItem.Parent
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((MenuBarItem)_currentMenuBarItem).Children = childrens;
|
|
|
+ }
|
|
|
|
|
|
- DataContext.Menus.RemoveAt (_lstMenus.SelectedItem);
|
|
|
+ DataContext.Menus.RemoveAt (_lstMenus.SelectedItem);
|
|
|
|
|
|
- if (_lstMenus.Source.Count > 0 && _lstMenus.SelectedItem > _lstMenus.Source.Count - 1)
|
|
|
- {
|
|
|
- _lstMenus.SelectedItem = _lstMenus.Source.Count - 1;
|
|
|
- }
|
|
|
+ if (_lstMenus.Source.Count > 0 && _lstMenus.SelectedItem > _lstMenus.Source.Count - 1)
|
|
|
+ {
|
|
|
+ _lstMenus.SelectedItem = _lstMenus.Source.Count - 1;
|
|
|
+ }
|
|
|
|
|
|
- _lstMenus.SetNeedsDisplay ();
|
|
|
- SetFrameDetails ();
|
|
|
- }
|
|
|
- };
|
|
|
+ _lstMenus.SetNeedsDisplay ();
|
|
|
+ SetFrameDetails ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
_lstMenus.OpenSelectedItem += (s, e) =>
|
|
|
{
|
|
@@ -978,7 +978,7 @@ public class DynamicMenuBar : Scenario
|
|
|
}
|
|
|
|
|
|
DataContext.Parent = _currentMenuBarItem.Title;
|
|
|
- DataContext.Menus = new List<DynamicMenuItemList> ();
|
|
|
+ DataContext.Menus = new ();
|
|
|
SetListViewSource (_currentMenuBarItem, true);
|
|
|
MenuItem menuBarItem = DataContext.Menus.Count > 0 ? DataContext.Menus [0].MenuItem : null;
|
|
|
SetFrameDetails (menuBarItem);
|
|
@@ -993,24 +993,24 @@ public class DynamicMenuBar : Scenario
|
|
|
};
|
|
|
|
|
|
_btnNext.Accept += (s, e) =>
|
|
|
- {
|
|
|
- if (_menuBar != null && _currentSelectedMenuBar + 1 < _menuBar.Menus.Length)
|
|
|
- {
|
|
|
- _currentSelectedMenuBar++;
|
|
|
- }
|
|
|
+ {
|
|
|
+ if (_menuBar != null && _currentSelectedMenuBar + 1 < _menuBar.Menus.Length)
|
|
|
+ {
|
|
|
+ _currentSelectedMenuBar++;
|
|
|
+ }
|
|
|
|
|
|
- SelectCurrentMenuBarItem ();
|
|
|
- };
|
|
|
+ SelectCurrentMenuBarItem ();
|
|
|
+ };
|
|
|
|
|
|
_btnPrevious.Accept += (s, e) =>
|
|
|
- {
|
|
|
- if (_currentSelectedMenuBar - 1 > -1)
|
|
|
- {
|
|
|
- _currentSelectedMenuBar--;
|
|
|
- }
|
|
|
+ {
|
|
|
+ if (_currentSelectedMenuBar - 1 > -1)
|
|
|
+ {
|
|
|
+ _currentSelectedMenuBar--;
|
|
|
+ }
|
|
|
|
|
|
- SelectCurrentMenuBarItem ();
|
|
|
- };
|
|
|
+ SelectCurrentMenuBarItem ();
|
|
|
+ };
|
|
|
|
|
|
_lblMenuBar.Enter += (s, e) =>
|
|
|
{
|
|
@@ -1022,89 +1022,89 @@ public class DynamicMenuBar : Scenario
|
|
|
};
|
|
|
|
|
|
_btnAddMenuBar.Accept += (s, e) =>
|
|
|
- {
|
|
|
- var frameDetails = new DynamicMenuBarDetails (null);
|
|
|
- DynamicMenuItem item = frameDetails.EnterMenuItem ();
|
|
|
+ {
|
|
|
+ var frameDetails = new DynamicMenuBarDetails (null);
|
|
|
+ DynamicMenuItem item = frameDetails.EnterMenuItem ();
|
|
|
|
|
|
- if (item == null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (item == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (MenuBar == null)
|
|
|
- {
|
|
|
- _menuBar = new MenuBar ();
|
|
|
- Add (_menuBar);
|
|
|
- }
|
|
|
+ if (MenuBar == null)
|
|
|
+ {
|
|
|
+ _menuBar = new ();
|
|
|
+ Add (_menuBar);
|
|
|
+ }
|
|
|
|
|
|
- var newMenu = CreateNewMenu (item) as MenuBarItem;
|
|
|
-
|
|
|
- MenuBarItem [] menus = _menuBar.Menus;
|
|
|
- Array.Resize (ref menus, menus.Length + 1);
|
|
|
- menus [^1] = newMenu;
|
|
|
- _menuBar.Menus = menus;
|
|
|
- _currentMenuBarItem = newMenu;
|
|
|
- _currentMenuBarItem.CheckType = item.CheckStyle;
|
|
|
- _currentSelectedMenuBar = menus.Length - 1;
|
|
|
- _menuBar.Menus [_currentSelectedMenuBar] = newMenu;
|
|
|
- _lblMenuBar.Text = newMenu.Title;
|
|
|
- SetListViewSource (_currentMenuBarItem, true);
|
|
|
- SetFrameDetails (_menuBar.Menus [_currentSelectedMenuBar]);
|
|
|
- _menuBar.SetNeedsDisplay ();
|
|
|
- };
|
|
|
+ var newMenu = CreateNewMenu (item) as MenuBarItem;
|
|
|
+
|
|
|
+ MenuBarItem [] menus = _menuBar.Menus;
|
|
|
+ Array.Resize (ref menus, menus.Length + 1);
|
|
|
+ menus [^1] = newMenu;
|
|
|
+ _menuBar.Menus = menus;
|
|
|
+ _currentMenuBarItem = newMenu;
|
|
|
+ _currentMenuBarItem.CheckType = item.CheckStyle;
|
|
|
+ _currentSelectedMenuBar = menus.Length - 1;
|
|
|
+ _menuBar.Menus [_currentSelectedMenuBar] = newMenu;
|
|
|
+ _lblMenuBar.Text = newMenu.Title;
|
|
|
+ SetListViewSource (_currentMenuBarItem, true);
|
|
|
+ SetFrameDetails (_menuBar.Menus [_currentSelectedMenuBar]);
|
|
|
+ _menuBar.SetNeedsDisplay ();
|
|
|
+ };
|
|
|
|
|
|
_btnRemoveMenuBar.Accept += (s, e) =>
|
|
|
- {
|
|
|
- if (_menuBar == null || _menuBar.Menus.Length == 0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ {
|
|
|
+ if (_menuBar == null || _menuBar.Menus.Length == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (_menuBar != null && _menuBar.Menus.Length > 0)
|
|
|
- {
|
|
|
- _menuBar.Menus [_currentSelectedMenuBar] = null;
|
|
|
- var i = 0;
|
|
|
+ if (_menuBar != null && _menuBar.Menus.Length > 0)
|
|
|
+ {
|
|
|
+ _menuBar.Menus [_currentSelectedMenuBar] = null;
|
|
|
+ var i = 0;
|
|
|
|
|
|
- foreach (MenuBarItem m in _menuBar.Menus)
|
|
|
- {
|
|
|
- if (m != null)
|
|
|
- {
|
|
|
- _menuBar.Menus [i] = m;
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
+ foreach (MenuBarItem m in _menuBar.Menus)
|
|
|
+ {
|
|
|
+ if (m != null)
|
|
|
+ {
|
|
|
+ _menuBar.Menus [i] = m;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- MenuBarItem [] menus = _menuBar.Menus;
|
|
|
- Array.Resize (ref menus, menus.Length - 1);
|
|
|
- _menuBar.Menus = menus;
|
|
|
+ MenuBarItem [] menus = _menuBar.Menus;
|
|
|
+ Array.Resize (ref menus, menus.Length - 1);
|
|
|
+ _menuBar.Menus = menus;
|
|
|
|
|
|
- if (_currentSelectedMenuBar - 1 >= 0 && _menuBar.Menus.Length > 0)
|
|
|
- {
|
|
|
- _currentSelectedMenuBar--;
|
|
|
- }
|
|
|
+ if (_currentSelectedMenuBar - 1 >= 0 && _menuBar.Menus.Length > 0)
|
|
|
+ {
|
|
|
+ _currentSelectedMenuBar--;
|
|
|
+ }
|
|
|
|
|
|
- _currentMenuBarItem = _menuBar.Menus?.Length > 0
|
|
|
- ? _menuBar.Menus [_currentSelectedMenuBar]
|
|
|
- : null;
|
|
|
- }
|
|
|
+ _currentMenuBarItem = _menuBar.Menus?.Length > 0
|
|
|
+ ? _menuBar.Menus [_currentSelectedMenuBar]
|
|
|
+ : null;
|
|
|
+ }
|
|
|
|
|
|
- if (MenuBar != null && _currentMenuBarItem == null && _menuBar.Menus.Length == 0)
|
|
|
- {
|
|
|
- Remove (_menuBar);
|
|
|
- _menuBar = null;
|
|
|
- DataContext.Menus = new List<DynamicMenuItemList> ();
|
|
|
- _currentMenuBarItem = null;
|
|
|
- _currentSelectedMenuBar = -1;
|
|
|
- _lblMenuBar.Text = string.Empty;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _lblMenuBar.Text = _menuBar.Menus [_currentSelectedMenuBar].Title;
|
|
|
- }
|
|
|
+ if (MenuBar != null && _currentMenuBarItem == null && _menuBar.Menus.Length == 0)
|
|
|
+ {
|
|
|
+ Remove (_menuBar);
|
|
|
+ _menuBar = null;
|
|
|
+ DataContext.Menus = new ();
|
|
|
+ _currentMenuBarItem = null;
|
|
|
+ _currentSelectedMenuBar = -1;
|
|
|
+ _lblMenuBar.Text = string.Empty;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _lblMenuBar.Text = _menuBar.Menus [_currentSelectedMenuBar].Title;
|
|
|
+ }
|
|
|
|
|
|
- SetListViewSource (_currentMenuBarItem, true);
|
|
|
- SetFrameDetails ();
|
|
|
- };
|
|
|
+ SetListViewSource (_currentMenuBarItem, true);
|
|
|
+ SetFrameDetails ();
|
|
|
+ };
|
|
|
|
|
|
SetFrameDetails ();
|
|
|
|
|
@@ -1153,14 +1153,14 @@ public class DynamicMenuBar : Scenario
|
|
|
|
|
|
SetFrameDetails (menuBarItem);
|
|
|
_currentMenuBarItem = menuBarItem;
|
|
|
- DataContext.Menus = new List<DynamicMenuItemList> ();
|
|
|
+ DataContext.Menus = new ();
|
|
|
SetListViewSource (_currentMenuBarItem, true);
|
|
|
_lblParent.Text = string.Empty;
|
|
|
}
|
|
|
|
|
|
void SetListViewSource (MenuItem _currentMenuBarItem, bool fill = false)
|
|
|
{
|
|
|
- DataContext.Menus = new List<DynamicMenuItemList> ();
|
|
|
+ DataContext.Menus = new ();
|
|
|
var menuBarItem = _currentMenuBarItem as MenuBarItem;
|
|
|
|
|
|
if (menuBarItem != null && menuBarItem?.Children == null)
|
|
@@ -1193,7 +1193,7 @@ public class DynamicMenuBar : Scenario
|
|
|
}
|
|
|
else if (parent != null)
|
|
|
{
|
|
|
- newMenu = new MenuItem (item.Title, item.Help, null, null, parent);
|
|
|
+ newMenu = new (item.Title, item.Help, null, null, parent);
|
|
|
newMenu.CheckType = item.CheckStyle;
|
|
|
newMenu.Action = _frmMenuDetails.CreateAction (newMenu, item);
|
|
|
newMenu.Shortcut = ShortcutHelper.GetShortcutFromTag (item.Shortcut);
|
|
@@ -1266,20 +1266,20 @@ public class DynamicMenuBar : Scenario
|
|
|
{
|
|
|
_frmMenuDetails.UpdateParent (ref _currentEditMenuBarItem);
|
|
|
|
|
|
- _currentEditMenuBarItem = new MenuItem (
|
|
|
- menuItem.Title,
|
|
|
- menuItem.Help,
|
|
|
- _frmMenuDetails.CreateAction (_currentEditMenuBarItem, menuItem),
|
|
|
- null,
|
|
|
- _currentEditMenuBarItem.Parent
|
|
|
- );
|
|
|
+ _currentEditMenuBarItem = new (
|
|
|
+ menuItem.Title,
|
|
|
+ menuItem.Help,
|
|
|
+ _frmMenuDetails.CreateAction (_currentEditMenuBarItem, menuItem),
|
|
|
+ null,
|
|
|
+ _currentEditMenuBarItem.Parent
|
|
|
+ );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (_currentEditMenuBarItem is MenuBarItem)
|
|
|
{
|
|
|
((MenuBarItem)_currentEditMenuBarItem).Children = null;
|
|
|
- DataContext.Menus = new List<DynamicMenuItemList> ();
|
|
|
+ DataContext.Menus = new ();
|
|
|
}
|
|
|
|
|
|
_currentEditMenuBarItem.Action =
|
|
@@ -1298,7 +1298,7 @@ public class DynamicMenuBar : Scenario
|
|
|
if (DataContext.Menus.Count == 0)
|
|
|
{
|
|
|
DataContext.Menus.Add (
|
|
|
- new DynamicMenuItemList
|
|
|
+ new()
|
|
|
{
|
|
|
Title = _currentEditMenuBarItem.Title, MenuItem = _currentEditMenuBarItem
|
|
|
}
|
|
@@ -1306,7 +1306,7 @@ public class DynamicMenuBar : Scenario
|
|
|
}
|
|
|
|
|
|
DataContext.Menus [index] =
|
|
|
- new DynamicMenuItemList
|
|
|
+ new()
|
|
|
{
|
|
|
Title = _currentEditMenuBarItem.Title, MenuItem = _currentEditMenuBarItem
|
|
|
};
|
|
@@ -1362,7 +1362,7 @@ public class DynamicMenuBar : Scenario
|
|
|
|
|
|
PropertyChanged?.Invoke (
|
|
|
this,
|
|
|
- new PropertyChangedEventArgs (GetPropertyName ())
|
|
|
+ new (GetPropertyName ())
|
|
|
);
|
|
|
}
|
|
|
}
|
|
@@ -1381,7 +1381,7 @@ public class DynamicMenuBar : Scenario
|
|
|
|
|
|
PropertyChanged?.Invoke (
|
|
|
this,
|
|
|
- new PropertyChangedEventArgs (GetPropertyName ())
|
|
|
+ new (GetPropertyName ())
|
|
|
);
|
|
|
}
|
|
|
}
|
|
@@ -1400,7 +1400,7 @@ public class DynamicMenuBar : Scenario
|
|
|
|
|
|
PropertyChanged?.Invoke (
|
|
|
this,
|
|
|
- new PropertyChangedEventArgs (GetPropertyName ())
|
|
|
+ new (GetPropertyName ())
|
|
|
);
|
|
|
}
|
|
|
}
|