Skip to content
Browse files

Obsolete all old action apis and weak event handler helper

Rename MapPlatformAction to MapPlatformCommand
Add Check/RadioCommand to have the ability to create check/radio commands e.g. from system commands or other
  • Loading branch information...
1 parent 38854eb commit 4fe56ac4e029600fc85957a416841cbe7aa10f51 @cwensley cwensley committed
Showing with 704 additions and 141 deletions.
  1. +2 −0 Source/Eto.Platform.Gtk/Eto.Platform.Gtk.csproj
  2. +1 −1 Source/Eto.Platform.Gtk/Forms/Controls/GtkControl.cs
  3. +2 −2 Source/Eto.Platform.Gtk/Forms/GtkWindow.cs
  4. +1 −1 Source/Eto.Platform.Gtk/Forms/Menu/MenuHandler.cs
  5. +4 −4 Source/Eto.Platform.Mac/Eto.Platform.Mac.csproj
  6. +4 −4 Source/Eto.Platform.Mac/Eto.Platform.XamMac.csproj
  7. +1 −1 Source/Eto.Platform.Mac/Forms/MacView.cs
  8. +1 −1 Source/Eto.Platform.Mac/Forms/ToolBar/{ToolBarButtonHandler.cs → ButtonToolItemHandler.cs}
  9. +1 −1 Source/Eto.Platform.Mac/Forms/ToolBar/{CheckToolBarButtonHandler.cs → CheckToolItemHandler.cs}
  10. +2 −2 Source/Eto.Platform.Mac/Forms/ToolBar/{SeparatorToolBarItemHandler.cs → SeparatorToolItemHandler.cs}
  11. +2 −2 Source/Eto.Platform.Mac/Forms/ToolBar/{ToolBarItemHandler.cs → ToolItemHandler.cs}
  12. +3 −3 Source/Eto.Platform.Mac/Generator.cs
  13. +2 −0 Source/Eto.Platform.Windows/Eto.Platform.Windows.csproj
  14. +1 −1 Source/Eto.Platform.Windows/Forms/Controls/WindowsControl.cs
  15. +2 −0 Source/Eto.Platform.Wpf/Eto.Platform.Wpf.csproj
  16. +1 −1 Source/Eto.Platform.Wpf/Forms/Menu/MenuItemHandler.cs
  17. +1 −1 Source/Eto.Platform.Wpf/Forms/WpfFrameworkElement.cs
  18. +2 −1 Source/Eto.Platform.iOS/Forms/ApplicationHandler.cs
  19. +2 −2 Source/Eto.Platform.iOS/Forms/Controls/ToolbarHandler.cs
  20. +1 −1 Source/Eto.Platform.iOS/Forms/IosView.cs
  21. +1 −1 Source/Eto.Test/Eto.Test.Mac/Startup.cs
  22. +0 −1 Source/Eto.Test/Eto.Test/Eto.Test - iOS.csproj
  23. +2 −2 Source/Eto.Test/Eto.Test/MainForm.cs
  24. +1 −1 Source/Eto.Test/Eto.Test/TestSectionList.cs
  25. +338 −1 Source/Eto/Eto - iOS.csproj
  26. +1 −0 Source/Eto/Eto.csproj
  27. +1 −0 Source/Eto/Forms/Actions/ActionCollection.cs
  28. +5 −0 Source/Eto/Forms/Actions/ActionItem.cs
  29. +22 −0 Source/Eto/Forms/Actions/ActionItemCollection.cs
  30. +1 −1 Source/Eto/Forms/Actions/ActionItemCollection.desktop.cs
  31. +1 −0 Source/Eto/Forms/Actions/BaseAction.cs
  32. +4 −2 Source/Eto/Forms/Actions/ButtonAction.cs
  33. +6 −1 Source/Eto/Forms/Actions/ButtonAction.desktop.cs
  34. +2 −1 Source/Eto/Forms/Actions/CheckAction.cs
  35. +2 −0 Source/Eto/Forms/Actions/CheckAction.desktop.cs
  36. +1 −1 Source/Eto/Forms/Actions/GenerateActionArgs.cs
  37. +2 −0 Source/Eto/Forms/Actions/RadioAction.cs
  38. +3 −1 Source/Eto/Forms/Actions/RadioAction.desktop.cs
  39. +32 −0 Source/Eto/Forms/Application.cs
  40. +80 −52 Source/Eto/Forms/Command.cs
  41. +24 −3 Source/Eto/Forms/Controls/Control.cs
  42. +2 −2 Source/Eto/Forms/Controls/ThemedControlHandler.cs
  43. +23 −6 Source/Eto/Forms/Menu/ButtonMenuItem.cs
  44. +15 −5 Source/Eto/Forms/Menu/CheckMenuItem.cs
  45. +4 −1 Source/Eto/Forms/Menu/ContextMenu.cs
  46. +4 −1 Source/Eto/Forms/Menu/MenuBar.cs
  47. +3 −1 Source/Eto/Forms/Menu/MenuItem.cs
  48. +23 −13 Source/Eto/Forms/Menu/RadioMenuItem.cs
  49. +5 −6 Source/Eto/Forms/Menu/SeparatorMenuItem.cs
  50. +1 −1 Source/Eto/Forms/Menu/SubMenu.cs
  51. +23 −7 Source/Eto/Forms/ToolBar/CheckToolItem.cs
  52. +0 −1 Source/Eto/Forms/ToolBar/ToolItem.cs
  53. +32 −0 Source/Eto/Forms/ToolBar/ToolItem.obsolete.cs
  54. +4 −0 Source/Eto/WeakEventHandler.cs
View
2 Source/Eto.Platform.Gtk/Eto.Platform.Gtk.csproj
@@ -10,6 +10,8 @@
<OutputType>Library</OutputType>
<RootNamespace>Eto.Platform.GtkSharp</RootNamespace>
<AssemblyName>Eto.Platform.Gtk</AssemblyName>
+ <ReleaseVersion>
+ </ReleaseVersion>
</PropertyGroup>
<PropertyGroup>
<FileAlignment>512</FileAlignment>
View
2 Source/Eto.Platform.Gtk/Forms/Controls/GtkControl.cs
@@ -538,7 +538,7 @@ public string ToolTip
set { Control.TooltipText = value; }
}
- public virtual void MapPlatformAction(string systemAction, Command action)
+ public virtual void MapPlatformCommand(string systemAction, Command action)
{
}
View
4 Source/Eto.Platform.Gtk/Forms/GtkWindow.cs
@@ -304,7 +304,7 @@ public MenuBar Menu
}
}
- void SetAccelerators(IMenuItemsSource item)
+ void SetAccelerators(ISubMenuWidget item)
{
if (item != null && item.Items != null)
foreach (var child in item.Items)
@@ -316,7 +316,7 @@ void SetAccelerators(IMenuItemsSource item)
var key = new Gtk.AccelKey(actionItem.Shortcut.ToGdkKey(), actionItem.Shortcut.ToGdkModifier(), Gtk.AccelFlags.Visible | Gtk.AccelFlags.Locked);
widget.AddAccelerator("activate", accelGroup, key);
}
- SetAccelerators(child as IMenuItemsSource);
+ SetAccelerators(child as ISubMenuWidget);
}
}
View
2 Source/Eto.Platform.Gtk/Forms/Menu/MenuHandler.cs
@@ -9,7 +9,7 @@ public abstract class MenuHandler<TControl, TWidget> : WidgetHandler<TControl, T
{
protected void ValidateItems()
{
- var subMenu = Widget as IMenuItemsSource;
+ var subMenu = Widget as ISubMenuWidget;
if (subMenu != null) {
foreach (var item in subMenu.Items) {
item.OnValidate(EventArgs.Empty);
View
8 Source/Eto.Platform.Mac/Eto.Platform.Mac.csproj
@@ -121,12 +121,8 @@
<Compile Include="Forms\Menu\MenuHandler.cs" />
<Compile Include="Forms\Menu\RadioMenuItemHandler.cs" />
<Compile Include="Forms\Menu\SeparatorMenuItem.cs" />
- <Compile Include="Forms\ToolBar\CheckToolBarButtonHandler.cs" />
<Compile Include="Forms\Controls\MacControl.cs" />
- <Compile Include="Forms\ToolBar\SeparatorToolBarItemHandler.cs" />
- <Compile Include="Forms\ToolBar\ToolBarButtonHandler.cs" />
<Compile Include="Forms\ToolBar\ToolBarHandler.cs" />
- <Compile Include="Forms\ToolBar\ToolBarItemHandler.cs" />
<Compile Include="Forms\Controls\MacText.cs" />
<Compile Include="Forms\Controls\DrawableHandler.cs" />
<Compile Include="Forms\Controls\MacButton.cs" />
@@ -191,6 +187,10 @@
<Compile Include="MacExtensions.cs" />
<Compile Include="Forms\Controls\SpinnerHandler.cs" />
<Compile Include="Forms\Actions\MacCommand.cs" />
+ <Compile Include="Forms\ToolBar\CheckToolItemHandler.cs" />
+ <Compile Include="Forms\ToolBar\SeparatorToolItemHandler.cs" />
+ <Compile Include="Forms\ToolBar\ButtonToolItemHandler.cs" />
+ <Compile Include="Forms\ToolBar\ToolItemHandler.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup />
View
8 Source/Eto.Platform.Mac/Eto.Platform.XamMac.csproj
@@ -126,12 +126,8 @@
<Compile Include="Forms\Menu\MenuHandler.cs" />
<Compile Include="Forms\Menu\RadioMenuItemHandler.cs" />
<Compile Include="Forms\Menu\SeparatorMenuItem.cs" />
- <Compile Include="Forms\ToolBar\CheckToolBarButtonHandler.cs" />
<Compile Include="Forms\Controls\MacControl.cs" />
- <Compile Include="Forms\ToolBar\SeparatorToolBarItemHandler.cs" />
- <Compile Include="Forms\ToolBar\ToolBarButtonHandler.cs" />
<Compile Include="Forms\ToolBar\ToolBarHandler.cs" />
- <Compile Include="Forms\ToolBar\ToolBarItemHandler.cs" />
<Compile Include="Forms\Controls\MacText.cs" />
<Compile Include="Forms\Controls\DrawableHandler.cs" />
<Compile Include="Forms\Controls\MacButton.cs" />
@@ -196,6 +192,10 @@
<Compile Include="MacExtensions.cs" />
<Compile Include="Forms\Controls\SpinnerHandler.cs" />
<Compile Include="Forms\Actions\MacCommand.cs" />
+ <Compile Include="Forms\ToolBar\CheckToolItemHandler.cs" />
+ <Compile Include="Forms\ToolBar\SeparatorToolItemHandler.cs" />
+ <Compile Include="Forms\ToolBar\ButtonToolItemHandler.cs" />
+ <Compile Include="Forms\ToolBar\ToolItemHandler.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup />
View
2 Source/Eto.Platform.Mac/Forms/MacView.cs
@@ -648,7 +648,7 @@ static bool ValidateSystemToolbarAction(IntPtr sender, IntPtr sel, IntPtr item)
{ "performMiniaturize", selPerformMiniaturize }
};
- public virtual void MapPlatformAction(string systemAction, Command command)
+ public virtual void MapPlatformCommand(string systemAction, Command command)
{
IntPtr sel;
if (systemActionSelectors.TryGetValue(systemAction, out sel))
View
2 ...Mac/Forms/ToolBar/ToolBarButtonHandler.cs → ...ac/Forms/ToolBar/ButtonToolItemHandler.cs
@@ -5,7 +5,7 @@
namespace Eto.Platform.Mac
{
- public class ToolBarButtonHandler : ToolBarItemHandler<NSToolbarItem, ButtonToolItem>, IButtonToolItem
+ public class ButtonToolItemHandler : ToolItemHandler<NSToolbarItem, ButtonToolItem>, IButtonToolItem
{
public override void InvokeButton()
{
View
2 ...orms/ToolBar/CheckToolBarButtonHandler.cs → ...Mac/Forms/ToolBar/CheckToolItemHandler.cs
@@ -5,7 +5,7 @@
namespace Eto.Platform.Mac
{
- public class CheckToolBarButtonHandler : ToolBarItemHandler<NSToolbarItem, CheckToolItem>, ICheckToolItem
+ public class CheckToolItemHandler : ToolItemHandler<NSToolbarItem, CheckToolItem>, ICheckToolItem
{
bool isChecked;
ToolBarHandler toolbarHandler;
View
4 ...ms/ToolBar/SeparatorToolBarItemHandler.cs → ...Forms/ToolBar/SeparatorToolItemHandler.cs
@@ -4,9 +4,9 @@
namespace Eto.Platform.Mac
{
- public class SeparatorToolBarItemHandler : WidgetHandler<NSToolbarItem, SeparatorToolItem>, ISeparatorToolItem, IToolBarBaseItemHandler
+ public class SeparatorToolItemHandler : WidgetHandler<NSToolbarItem, SeparatorToolItem>, ISeparatorToolItem, IToolBarBaseItemHandler
{
- public SeparatorToolBarItemHandler()
+ public SeparatorToolItemHandler()
{
Type = SeparatorToolItemType.Divider;
}
View
4 ...m.Mac/Forms/ToolBar/ToolBarItemHandler.cs → ...form.Mac/Forms/ToolBar/ToolItemHandler.cs
@@ -74,7 +74,7 @@ public enum MacToolBarItemStyle
LargeButton
}
- public abstract class ToolBarItemHandler<TControl, TWidget> : WidgetHandler<TControl, TWidget>, IToolItem, IToolBarItemHandler
+ public abstract class ToolItemHandler<TControl, TWidget> : WidgetHandler<TControl, TWidget>, IToolItem, IToolBarItemHandler
where TControl: NSToolbarItem
where TWidget: ToolItem
{
@@ -136,7 +136,7 @@ public NSButton Button
public virtual string Identifier { get; set; }
- protected ToolBarItemHandler()
+ protected ToolItemHandler()
{
this.Identifier = Guid.NewGuid().ToString();
}
View
6 Source/Eto.Platform.Mac/Generator.cs
@@ -110,9 +110,9 @@ public static void AddTo(Eto.Generator g)
g.Add<IPrintSettings>(() => new PrintSettingsHandler());
// Forms.ToolBar
- g.Add<ICheckToolItem>(() => new CheckToolBarButtonHandler());
- g.Add<ISeparatorToolItem>(() => new SeparatorToolBarItemHandler());
- g.Add<IButtonToolItem>(() => new ToolBarButtonHandler());
+ g.Add<ICheckToolItem>(() => new CheckToolItemHandler());
+ g.Add<ISeparatorToolItem>(() => new SeparatorToolItemHandler());
+ g.Add<IButtonToolItem>(() => new ButtonToolItemHandler());
g.Add<IToolBar>(() => new ToolBarHandler());
// Forms
View
2 Source/Eto.Platform.Windows/Eto.Platform.Windows.csproj
@@ -12,6 +12,8 @@
<RootNamespace>Eto.Platform.Windows</RootNamespace>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <ReleaseVersion>
+ </ReleaseVersion>
</PropertyGroup>
<PropertyGroup>
<FileAlignment>512</FileAlignment>
View
2 Source/Eto.Platform.Windows/Forms/Controls/WindowsControl.cs
@@ -548,7 +548,7 @@ public Font Font
}
}
- public virtual void MapPlatformAction(string systemAction, Command command)
+ public virtual void MapPlatformCommand(string systemAction, Command command)
{
}
View
2 Source/Eto.Platform.Wpf/Eto.Platform.Wpf.csproj
@@ -12,6 +12,8 @@
<AssemblyName>Eto.Platform.Wpf</AssemblyName>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <ReleaseVersion>
+ </ReleaseVersion>
</PropertyGroup>
<PropertyGroup>
<FileAlignment>512</FileAlignment>
View
2 Source/Eto.Platform.Wpf/Forms/Menu/MenuItemHandler.cs
@@ -115,7 +115,7 @@ bool swi.ICommand.CanExecute (object parameter)
void HandleContextMenuOpening (object sender, sw.RoutedEventArgs e)
{
- var submenu = Widget as IMenuItemsSource;
+ var submenu = Widget as ISubMenuWidget;
if (submenu != null) {
foreach (var item in submenu.Items) {
item.OnValidate (EventArgs.Empty);
View
2 Source/Eto.Platform.Wpf/Forms/WpfFrameworkElement.cs
@@ -443,7 +443,7 @@ public virtual void SetParent(Container parent)
}
}
- public void MapPlatformAction(string systemAction, Command command)
+ public void MapPlatformCommand(string systemAction, Command command)
{
}
View
3 Source/Eto.Platform.iOS/Forms/ApplicationHandler.cs
@@ -87,8 +87,9 @@ public void AsyncInvoke(Action action)
});
}
- public void GetSystemActions(List<BaseAction> actions, ISubMenuWidget menu, ToolBar toolBar, bool addStandardItems)
+ public IEnumerable<Command> GetSystemCommands()
{
+ yield break;
}
public void Quit()
View
4 Source/Eto.Platform.iOS/Forms/Controls/ToolbarHandler.cs
@@ -8,12 +8,12 @@ namespace Eto.Platform.iOS.Forms.Controls
{
public class ToolBarHandler : WidgetHandler<UIToolbar, ToolBar>, IToolBar
{
- public void AddButton(ToolBarItem button)
+ public void AddButton(ToolItem button)
{
throw new NotImplementedException();
}
- public void RemoveButton(ToolBarItem button)
+ public void RemoveButton(ToolItem button)
{
throw new NotImplementedException();
}
View
2 Source/Eto.Platform.iOS/Forms/IosView.cs
@@ -263,7 +263,7 @@ public virtual void OnUnLoad(EventArgs e)
{
}
- public void MapPlatformAction(string systemAction, BaseAction action)
+ public void MapPlatformCommand(string systemAction, Command command)
{
}
View
2 Source/Eto.Test/Eto.Test.Mac/Startup.cs
@@ -42,7 +42,7 @@ static void AddStyles ()
handler.Control.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.SourceList;
});
- Style.Add<ToolBarButtonHandler> (null, handler => {
+ Style.Add<ButtonToolItemHandler> (null, handler => {
// use standard textured/round buttons, and make the image grayscale
handler.UseStandardButton (grayscale: true);
});
View
1 Source/Eto.Test/Eto.Test/Eto.Test - iOS.csproj
@@ -78,7 +78,6 @@
<Compile Include="Dialogs\About.cs" />
<Compile Include="Actions\About.cs" />
<Compile Include="Actions\Quit.cs" />
- <Compile Include="Actions\Close.cs" />
<Compile Include="Sections\Controls\ButtonSection.cs" />
<Compile Include="Sections\Controls\CheckBoxSection.cs" />
<Compile Include="Sections\Controls\ComboBoxSection.cs" />
View
4 Source/Eto.Test/Eto.Test/MainForm.cs
@@ -182,15 +182,15 @@ void GenerateMenuToolBar()
menu.Items.Trim();
Menu = menu;
-#endif
// generate and set the toolbar
var toolBar = new ToolBar();
toolBar.Items.Add(quit);
toolBar.Items.Add(new ButtonToolItem(about));
- // TODO for mobile
ToolBar = toolBar;
+#endif
+
}
#if DESKTOP
View
2 Source/Eto.Test/Eto.Test/TestSectionList.cs
@@ -13,7 +13,7 @@ public static IEnumerable<Section> TopNodes()
yield return new Section("Behaviors", BehaviorsSection());
yield return new Section("Drawing", DrawingSection());
- if (EtoEnvironment.Platform.IsWindows)
+ if (Generator.Current.IsWinForms)
yield return new Section("Drawing using Direct2D on a Winforms Control", DrawingSectionDirect2D());
yield return new Section("Controls", ControlSection());
View
339 Source/Eto/Eto - iOS.csproj
@@ -41,10 +41,347 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
- <Compile Include="**\*.cs" />
+ <Compile Include="Binding\ColumnBinding.cs" />
+ <Compile Include="CancelEventHandler.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="ContentProperty.cs" />
+ <Compile Include="Drawing\Colors.cs" />
+ <Compile Include="Drawing\DashStyle.cs" />
+ <Compile Include="Drawing\DashStyles.cs" />
+ <Compile Include="Drawing\FillMode.cs" />
+ <Compile Include="Drawing\ImageConverter.cs" />
+ <Compile Include="Drawing\ImageInterpolation.cs" />
+ <Compile Include="Drawing\PenLineJoin.cs" />
+ <Compile Include="Drawing\PixelOffsetMode.cs" />
+ <Compile Include="Drawing\Region.cs" />
+ <Compile Include="Drawing\Matrix.cs" />
+ <Compile Include="EmbeddedAssemblyLoader.cs" />
+ <Compile Include="EtoEnvironment.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="EtoException.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Controls\Drawable.mobile.cs" />
+ <Compile Include="Forms\Controls\Grid.cs" />
+ <Compile Include="Forms\Controls\GridViewSelection.cs" />
+ <Compile Include="Forms\Controls\PasswordBox.cs" />
+ <Compile Include="Forms\Controls\ProgressBar.cs" />
+ <Compile Include="Forms\Controls\Scrollable.mobile.cs" />
+ <Compile Include="Forms\Controls\SearchBox.cs" />
+ <Compile Include="Forms\Controls\TextInputEventArgs.cs" />
+ <Compile Include="Forms\Controls\ThemedContainerHandler.cs" />
+ <Compile Include="Forms\Controls\ThemedControlHandler.cs" />
+ <Compile Include="Forms\Controls\TreeItem.cs" />
+ <Compile Include="Forms\Controls\TreeView.cs" />
+ <Compile Include="Forms\Controls\TreeView.desktop.cs" />
+ <Compile Include="Forms\DataStoreView.cs" />
+ <Compile Include="Forms\DataStoreVirtualCollection.cs" />
+ <Compile Include="Forms\Layout\DynamicControl.cs" />
+ <Compile Include="Forms\Layout\DynamicItem.cs" />
+ <Compile Include="Forms\Layout\DynamicTable.cs" />
+ <Compile Include="Forms\Mouse.cs" />
+ <Compile Include="Forms\Printing\PageSettings.cs" />
+ <Compile Include="Forms\Printing\PrintDocument.cs" />
+ <Compile Include="Forms\Printing\PrintSettings.cs" />
+ <Compile Include="Generator.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="GeneratorContext.cs" />
+ <Compile Include="Generators.cs" />
+ <Compile Include="Int32ArrayConverter.cs" />
+ <Compile Include="InstanceWidget.cs" />
+ <Compile Include="NamespaceInfo.cs" />
+ <Compile Include="OperatingSystemPlatform.cs" />
+ <Compile Include="PropertyStore.cs" />
+ <Compile Include="ResourceNotFoundException.cs" />
+ <Compile Include="Resources.cs" />
+ <Compile Include="Threading\Thread.cs" />
+ <Compile Include="TypeHelper.cs" />
+ <Compile Include="WeakEventHandler.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Widget.cs" />
+ <Compile Include="WidgetHandler.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Application.cs" />
+ <Compile Include="Forms\Container.cs" />
+ <Compile Include="Forms\Dialog.cs" />
+ <Compile Include="Forms\Layout\DockLayout.cs" />
+ <Compile Include="Forms\FileDialog.cs" />
+ <Compile Include="Forms\Form.cs" />
+ <Compile Include="Forms\Key.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Layout\Layout.cs" />
+ <Compile Include="Forms\MessageBox.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\OpenFileDialog.cs" />
+ <Compile Include="Forms\Layout\PixelLayout.cs" />
+ <Compile Include="Forms\SaveFileDialog.cs" />
+ <Compile Include="Forms\SelectFolderDialog.cs" />
+ <Compile Include="Forms\Layout\TableLayout.cs" />
+ <Compile Include="Forms\UITimer.cs" />
+ <Compile Include="Forms\Window.cs" />
+ <Compile Include="Forms\Window.desktop.cs" />
+ <Compile Include="Forms\Actions\ActionCollection.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\ActionItem.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\ActionItem.desktop.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\ActionItemCollection.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\ActionItemCollection.desktop.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\ButtonAction.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\ButtonAction.desktop.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\CheckAction.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\CheckAction.desktop.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\RadioAction.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\RadioAction.desktop.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Controls\Button.cs" />
+ <Compile Include="Forms\Controls\CheckBox.cs" />
+ <Compile Include="Forms\Controls\ComboBox.cs" />
+ <Compile Include="Forms\Controls\Control.cs" />
+ <Compile Include="Forms\Controls\Drawable.cs" />
+ <Compile Include="Forms\Controls\GroupBox.cs" />
+ <Compile Include="Forms\Controls\ImageView.cs" />
+ <Compile Include="Forms\Controls\Label.cs" />
+ <Compile Include="Forms\Controls\ListBox.cs" />
+ <Compile Include="Forms\Controls\ListControl.cs" />
+ <Compile Include="Forms\Controls\MouseEventArgs.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Controls\NumericUpDown.cs" />
+ <Compile Include="Forms\Controls\Panel.cs" />
+ <Compile Include="Forms\Controls\RadioButton.cs" />
+ <Compile Include="Forms\Controls\Scrollable.cs" />
+ <Compile Include="Forms\Controls\Splitter.cs" />
+ <Compile Include="Forms\Controls\TabControl.cs" />
+ <Compile Include="Forms\Controls\TabPage.cs" />
+ <Compile Include="Forms\Controls\TextArea.cs" />
+ <Compile Include="Forms\Controls\TextBox.cs" />
+ <Compile Include="Forms\Controls\TextControl.cs" />
+ <Compile Include="Forms\Controls\TreeGridView.cs" />
+ <Compile Include="Forms\Menu\CheckMenuItem.cs" />
+ <Compile Include="Forms\Menu\Menu.cs" />
+ <Compile Include="Forms\Menu\MenuBar.cs" />
+ <Compile Include="Forms\Menu\MenuItem.cs" />
+ <Compile Include="Forms\Menu\RadioMenuItem.cs" />
+ <Compile Include="Forms\Menu\SeparatorMenuItem.cs" />
+ <Compile Include="Forms\ToolBar\ToolBar.cs" />
+ <Compile Include="IO\DiskDirectoryInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\DiskFileInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\EtoDirectoryInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\EtoDriveInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\EtoFileInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\EtoSystemObjectInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\SystemIcons.cs" />
+ <Compile Include="IO\VirtualDirectoryInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\VirtualDirectoryType.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\VirtualFileEntry.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="IO\VirtualFileInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Misc\Platform.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Xaml\EtoXamlSchemaContext.cs" />
+ <Compile Include="Xaml\Extensions\ResourceExtension.cs" />
+ <Compile Include="Xaml\XamlReader.cs" />
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
+ <Compile Include="Forms\Controls\WebView.cs" />
+ <Compile Include="Forms\Clipboard.cs" />
+ <Compile Include="Forms\Application.desktop.cs" />
+ <Compile Include="Forms\CommonDialog.cs" />
+ <Compile Include="Forms\ColorDialog.cs" />
+ <Compile Include="Forms\Controls\DateTimePicker.cs" />
+ <Compile Include="Style.cs" />
+ <Compile Include="Forms\Menu\ContextMenu.cs" />
+ <Compile Include="Forms\Layout\DynamicLayout.cs" />
+ <Compile Include="Forms\ListItem.cs" />
+ <Compile Include="Forms\Controls\ListBox.desktop.cs" />
+ <Compile Include="Forms\Controls\CommonControl.cs" />
+ <Compile Include="Forms\Controls\Slider.cs" />
+ <Compile Include="Forms\Cursor.cs" />
+ <Compile Include="Forms\Controls\Control.desktop.cs" />
+ <Compile Include="Drawing\Bitmap.cs" />
+ <Compile Include="Drawing\Color.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\Font.cs" />
+ <Compile Include="Drawing\Graphics.cs" />
+ <Compile Include="Drawing\Icon.cs" />
+ <Compile Include="Drawing\Image.cs" />
+ <Compile Include="Drawing\IndexedBitmap.cs" />
+ <Compile Include="Drawing\Padding.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\Palette.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\Point.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\PointF.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\Rectangle.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\RectangleF.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\Size.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\SizeF.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Drawing\BitmapData.cs" />
+ <Compile Include="Drawing\GraphicsPath.cs" />
+ <Compile Include="Drawing\ColorHSB.cs" />
+ <Compile Include="Drawing\ColorHSL.cs" />
+ <Compile Include="Drawing\ColorCMYK.cs" />
+ <Compile Include="Drawing\ColorConverter.cs" />
+ <Compile Include="Drawing\SizeConverter.cs" />
+ <Compile Include="Drawing\SizeFConverter.cs" />
+ <Compile Include="Drawing\RectangleConverter.cs" />
+ <Compile Include="Drawing\RectangleFConverter.cs" />
+ <Compile Include="Drawing\PointConverter.cs" />
+ <Compile Include="Drawing\PointFConverter.cs" />
+ <Compile Include="Drawing\PaddingConverter.cs" />
+ <Compile Include="Forms\Controls\GridView.cs" />
+ <Compile Include="Forms\Controls\GridItem.cs" />
+ <Compile Include="Forms\IDataStore.cs" />
+ <Compile Include="CollectionChangedHandler.cs" />
+ <Compile Include="Forms\Controls\GridColumn.cs" />
+ <Compile Include="Forms\Cells\Cell.cs" />
+ <Compile Include="Forms\Cells\ComboBoxCell.cs" />
+ <Compile Include="Forms\Cells\DrawableCell.cs" />
+ <Compile Include="Forms\Cells\ImageTextCell.cs" />
+ <Compile Include="Forms\Cells\SingleValueCell.cs" />
+ <Compile Include="Forms\Controls\TreeGridItem.cs" />
+ <Compile Include="Forms\Cells\TextBoxCell.cs" />
+ <Compile Include="Forms\Cells\ImageViewCell.cs" />
+ <Compile Include="Forms\Controls\GridView.desktop.cs" />
+ <Compile Include="Forms\Controls\TreeGridView.desktop.cs" />
+ <Compile Include="Forms\Cells\CheckBoxCell.cs" />
+ <Compile Include="Forms\Controls\EnumComboBox.cs" />
+ <Compile Include="Binding\Binding.cs" />
+ <Compile Include="Binding\BindingCollection.cs" />
+ <Compile Include="Binding\BindingChangingEventArgs.cs" />
+ <Compile Include="Binding\BindingChangedEventArgs.cs" />
+ <Compile Include="Binding\IndirectBinding.cs" />
+ <Compile Include="Binding\PropertyBinding.cs" />
+ <Compile Include="Binding\DirectBinding.cs" />
+ <Compile Include="Binding\ObjectBinding.cs" />
+ <Compile Include="Binding\DualBinding.cs" />
+ <Compile Include="Binding\BindingExtensions.cs" />
+ <Compile Include="Forms\Printing\PrintDialog.cs" />
+ <Compile Include="Forms\Printing\PrintPageEventArgs.cs" />
+ <Compile Include="Widget.xaml.cs" />
+ <Compile Include="EtoMemberIdentifier.cs" />
+ <Compile Include="HandlerInvalidException.cs" />
+ <Compile Include="Forms\Range.cs" />
+ <Compile Include="Xaml\Extensions\FileExtension.cs" />
+ <Compile Include="Forms\Controls\Navigation.cs" />
+ <Compile Include="Forms\Controls\NavigationItem.cs" />
+ <Compile Include="Forms\FontDialog.cs" />
+ <Compile Include="Drawing\FontFamily.cs" />
+ <Compile Include="Drawing\FontTypeface.cs" />
+ <Compile Include="Drawing\Fonts.cs" />
+ <Compile Include="Drawing\FontFamilies.cs" />
+ <Compile Include="Forms\Cursors.cs" />
+ <Compile Include="Drawing\Pen.cs" />
+ <Compile Include="Drawing\Pens.cs" />
+ <Compile Include="Drawing\Brushes.cs" />
+ <Compile Include="Drawing\SolidBrush.cs" />
+ <Compile Include="Drawing\Brush.cs" />
+ <Compile Include="Drawing\PenLineCap.cs" />
+ <Compile Include="Drawing\TextureBrush.cs" />
+ <Compile Include="Drawing\LinearGradientBrush.cs" />
+ <Compile Include="Forms\Screen.cs" />
+ <Compile Include="Helper.cs" />
+ <Compile Include="Forms\Controls\RadioButtonList.cs" />
+ <Compile Include="Forms\Controls\EnumRadioButtonList.cs" />
+ <Compile Include="Forms\Controls\KeyEventArgs.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Binding\DelegateBinding.cs" />
+ <Compile Include="Forms\IKeyboardInputSource.cs" />
+ <Compile Include="Forms\IMouseInputSource.cs" />
+ <Compile Include="Forms\DockContainer.cs" />
+ <Compile Include="XmlExtensions.cs" />
+ <Compile Include="Drawing\XmlExtensions.cs" />
+ <Compile Include="Drawing\SystemFonts.cs" />
+ <Compile Include="Forms\Controls\Control.binding.cs" />
+ <Compile Include="EventLookup.cs" />
+ <Compile Include="Forms\Layout\DynamicItemConverter.cs" />
+ <Compile Include="Forms\Layout\DynamicRowConverter.cs" />
+ <Compile Include="Forms\Controls\Spinner.cs" />
+ <Compile Include="Forms\ThemedControls\ThemedSpinnerHandler.cs" />
+ <Compile Include="Forms\Actions\GenerateActionArgs.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Actions\BaseAction.desktop.cs" />
+ <Compile Include="Forms\Actions\BaseAction.cs" />
+ <Compile Include="Forms\Command.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Forms\Menu\SubMenu.cs" />
+ <Compile Include="Forms\Menu\MenuItemCollection.cs" />
+ <Compile Include="Forms\ToolBar\ToolItem.cs" />
+ <Compile Include="Forms\ToolBar\SeparatorToolItem.cs" />
+ <Compile Include="Forms\ToolBar\ButtonToolItem.cs" />
+ <Compile Include="Forms\ToolBar\CheckToolItem.cs" />
+ <Compile Include="Forms\ToolBar\ToolItemCollection.cs" />
+ <Compile Include="Forms\Menu\ButtonMenuItem.cs" />
+ <Compile Include="Forms\ToolBar\ToolItem.obsolete.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
View
1 Source/Eto/Eto.csproj
@@ -383,6 +383,7 @@
<Compile Include="Forms\ToolBar\CheckToolItem.cs" />
<Compile Include="Forms\ToolBar\ToolItemCollection.cs" />
<Compile Include="Forms\Menu\ButtonMenuItem.cs" />
+ <Compile Include="Forms\ToolBar\ToolItem.obsolete.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
View
1 Source/Eto/Forms/Actions/ActionCollection.cs
@@ -3,6 +3,7 @@
namespace Eto.Forms
{
+ [Obsolete("Use Command apis instead")]
public class ActionCollection : KeyedCollection<string, BaseAction>
{
readonly Generator generator;
View
5 Source/Eto/Forms/Actions/ActionItem.cs
@@ -2,6 +2,7 @@
namespace Eto.Forms
{
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public partial interface IActionItem
{
ToolItem GenerateToolBarItem(Generator generator, ToolBarTextAlign textAlign);
@@ -9,6 +10,7 @@ public partial interface IActionItem
int Order { get; }
}
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public abstract partial class ActionItemBase : IActionItem
{
int order = 500;
@@ -26,6 +28,7 @@ public int Order
public string MenuItemStyle { get; set; }
}
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public partial class ActionItemSeparator : ActionItemBase
{
public SeparatorToolItemType ToolBarType { get; set; }
@@ -40,6 +43,7 @@ public override ToolItem GenerateToolBarItem(Generator generator, ToolBarTextAli
}
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public partial class ActionItemSubMenu : ActionItemBase
{
public ActionItemSubMenu(ActionCollection actions, string subMenuText)
@@ -60,6 +64,7 @@ public override ToolItem GenerateToolBarItem(Generator generator, ToolBarTextAli
}
}
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public partial class ActionItem : ActionItemBase
{
View
22 Source/Eto/Forms/Actions/ActionItemCollection.cs
@@ -4,6 +4,7 @@
namespace Eto.Forms
{
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public partial class ActionItemCollection : List<IActionItem>
{
readonly ActionCollection actions;
@@ -162,5 +163,26 @@ public void Generate(ToolBar toolBar)
lastSeparator = isSeparator;
}
}
+
+ internal void ExtractMenu(ISubMenuWidget menu)
+ {
+ foreach (var item in menu.Items)
+ {
+ var button = item as ButtonMenuItem;
+ if (button != null && button.Items.Count > 0)
+ {
+ // submenu
+ var subMenu = this.GetSubmenu(button.Text, button.Order, true);
+ subMenu.Actions.ExtractMenu(button);
+ continue;
+ }
+ var separator = item as SeparatorMenuItem;
+ if (separator != null)
+ AddSeparator(separator.Order);
+
+ if (item.ID != null)
+ Add(item.ID, item.Order);
+ }
+ }
}
}
View
2 Source/Eto/Forms/Actions/ActionItemCollection.desktop.cs
@@ -14,7 +14,7 @@ public MenuBar GenerateMenuBar()
return menu;
}
- public void Generate(IMenuItemsSource menu)
+ public void Generate(ISubMenuWidget menu)
{
Generate(menu.Items);
}
View
1 Source/Eto/Forms/Actions/BaseAction.cs
@@ -4,6 +4,7 @@
namespace Eto.Forms
{
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public abstract partial class BaseAction
{
#region Members
View
6 Source/Eto/Forms/Actions/ButtonAction.cs
@@ -4,7 +4,7 @@
namespace Eto.Forms
{
-
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public static class ButtonActionExtensions
{
@@ -67,9 +67,11 @@ public static ButtonAction AddButton(this ActionCollection actions, string id, s
}
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public partial class ButtonAction : BaseAction
{
-
+ internal Command command;
+
public ButtonAction(string id, string text, Icon icon, EventHandler<EventArgs> activated)
: base(id, text, icon, activated)
{
View
7 Source/Eto/Forms/Actions/ButtonAction.desktop.cs
@@ -8,6 +8,9 @@ public partial class ButtonAction
{
public override MenuItem GenerateMenuItem(Generator generator)
{
+ if (command != null)
+ return command.CreateMenuItem(generator);
+
var mi = new ButtonMenuItem(generator);
mi.Text = MenuText;
mi.Shortcut = Accelerator;
@@ -18,7 +21,8 @@ public override MenuItem GenerateMenuItem(Generator generator)
new MenuConnector(this, mi);
return mi;
}
-
+
+ #pragma warning disable 0618
protected class MenuConnector
{
readonly ButtonMenuItem menuItem;
@@ -42,6 +46,7 @@ void HandleValidate (object sender, EventArgs e)
menuItem.Enabled = action.Enabled;
}
}
+ #pragma warning restore 0618
}
}
#endif
View
3 Source/Eto/Forms/Actions/CheckAction.cs
@@ -5,7 +5,7 @@
namespace Eto.Forms
{
-
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public static class CheckActionExtensions
{
public static CheckAction AddCheck(this ActionCollection actions, string id, string text, string iconResource, EventHandler<EventArgs> activated)
@@ -46,6 +46,7 @@ public static bool RemoveCheckHandler(this ActionCollection actions, string acti
}
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public partial class CheckAction : BaseAction
{
bool isChecked;
View
2 Source/Eto/Forms/Actions/CheckAction.desktop.cs
@@ -20,6 +20,7 @@ public override MenuItem GenerateMenuItem(Generator generator)
return mi;
}
+ #pragma warning disable 0618
class MenuConnector
{
readonly CheckMenuItem menuItem;
@@ -52,6 +53,7 @@ void action_EnabledChanged(Object sender, EventArgs e)
menuItem.Enabled = action.Enabled;
}
}
+ #pragma warning restore 0618
}
}
View
2 Source/Eto/Forms/Actions/GenerateActionArgs.cs
@@ -4,7 +4,7 @@
namespace Eto.Forms
{
- [Obsolete("Use separate collections for actions, menu and toolbar.")]
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public class GenerateActionArgs : EventArgs
{
#region Members
View
2 Source/Eto/Forms/Actions/RadioAction.cs
@@ -4,6 +4,7 @@
namespace Eto.Forms
{
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public static class RadioActionExtensions
{
public static RadioAction AddRadio(this ActionCollection actions, RadioAction controller, string id, string text)
@@ -27,6 +28,7 @@ public static RadioAction AddRadio(this ActionCollection actions, RadioAction co
}
+ [Obsolete("Use Command and menu/toolbar apis directly instead")]
public partial class RadioAction : BaseAction
{
bool isChecked;
View
4 Source/Eto/Forms/Actions/RadioAction.desktop.cs
@@ -22,6 +22,7 @@ public override MenuItem GenerateMenuItem(Generator generator)
return mi;
}
+ #pragma warning disable 0618
class MenuConnector
{
readonly RadioMenuItem menuItem;
@@ -54,7 +55,8 @@ void action_EnabledChanged(Object sender, EventArgs e)
{
menuItem.Enabled = action.Enabled;
}
- }
+ }
+ #pragma warning restore 0618
}
}
#endif
View
32 Source/Eto/Forms/Application.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Linq;
namespace Eto.Forms
{
@@ -146,6 +147,37 @@ public IEnumerable<Command> GetSystemCommands()
return Handler.GetSystemCommands();
}
+ [Obsolete("Use CreateStandardMenu and/or GetSystemCommands instead")]
+ public void GetSystemActions(GenerateActionArgs args, bool addStandardItems = false)
+ {
+ // map new commands/menus back to actions for backwards compatibility
+ var commands = GetSystemCommands().ToArray();
+ foreach (var command in commands)
+ {
+ var currentCommand = command;
+ var action = new ButtonAction
+ {
+ ID = currentCommand.ID,
+ MenuText = currentCommand.MenuText,
+ ToolBarText = currentCommand.ToolBarText,
+ TooltipText = currentCommand.ToolTip,
+ Accelerator = currentCommand.Shortcut,
+ command = currentCommand
+ };
+ currentCommand.Executed += (sender, e) => action.Activate();
+ action.EnabledChanged += (sender, e) => currentCommand.Enabled = action.Enabled;
+ args.Actions.Add(action);
+ }
+ #if DESKTOP
+ if (addStandardItems)
+ {
+ var menu = new MenuBar(Generator);
+ CreateStandardMenu(menu.Items, commands);
+ args.Menu.ExtractMenu(menu);
+ }
+ #endif
+ }
+
public string BadgeLabel
{
get { return Handler.BadgeLabel; }
View
132 Source/Eto/Forms/Command.cs
@@ -4,6 +4,84 @@
namespace Eto.Forms
{
+ public class CheckCommand : Command
+ {
+ #region Events
+
+ public event EventHandler<EventArgs> CheckedChanged;
+
+ protected virtual void OnCheckedChanged(EventArgs e)
+ {
+ if (CheckedChanged != null)
+ CheckedChanged(this, e);
+ }
+
+ #endregion
+
+ #region Properties
+
+ bool ischecked;
+
+ public bool Checked
+ {
+ get { return ischecked; }
+ set
+ {
+ if (ischecked != value)
+ {
+ ischecked = value;
+ OnCheckedChanged(EventArgs.Empty);
+ }
+ }
+ }
+
+ #endregion
+
+ public CheckCommand()
+ {
+ }
+
+ public CheckCommand(EventHandler<EventArgs> execute)
+ : base(execute)
+ {
+ }
+
+ public override MenuItem CreateMenuItem(Generator generator = null)
+ {
+ return new CheckMenuItem(this, generator);
+ }
+
+ public override ToolItem CreateToolItem(Generator generator = null)
+ {
+ return new CheckToolItem(this, generator);
+ }
+ }
+
+ public class RadioCommand : CheckCommand
+ {
+ public RadioCommand Controller { get; set; }
+ RadioMenuItem menuItem;
+
+ public RadioCommand()
+ {
+ }
+
+ public RadioCommand(EventHandler<EventArgs> execute)
+ : base(execute)
+ {
+ }
+
+ public override MenuItem CreateMenuItem(Generator generator = null)
+ {
+ return menuItem = new RadioMenuItem(this, Controller != null ? Controller.menuItem : null, generator);
+ }
+
+ public override ToolItem CreateToolItem(Generator generator = null)
+ {
+ throw new NotSupportedException();
+ }
+ }
+
public class Command
{
#region Events
@@ -22,13 +100,6 @@ public virtual void OnExecuted(EventArgs e)
if (Executed != null) Executed(this, e);
}
- public event EventHandler<EventArgs> Removed;
-
- protected virtual void OnRemoved(EventArgs e)
- {
- if (Removed != null) Removed(this, e);
- }
-
#endregion
#region Properties
@@ -57,42 +128,12 @@ public virtual bool Enabled
public virtual string ToolTip { get; set; }
- public string Description { get; set; }
-
public bool ShowLabel { get; set; }
public virtual Image Image { get; set; }
- public virtual Keys Shortcut
- {
- get { return (ShortcutKeys != null && ShortcutKeys.Length > 0) ? ShortcutKeys[0] : Keys.None; }
- set { ShortcutKeys = new [] { value }; }
- }
-
- public Keys[] ShortcutKeys { get; set; }
-
- public string ShortcutText
- {
- get
- {
- if (ShortcutKeys == null) return string.Empty;
- if (Shortcut != Keys.None)
- {
- string val = string.Empty;
- Keys modifier = (Shortcut & Keys.ModifierMask);
- if (modifier != Keys.None) val += modifier.ToString();
- Keys mainKey = (Shortcut & Keys.KeyMask);
- if (mainKey != Keys.None)
- {
- if (val.Length > 0) val += "+";
- val += mainKey.ToString();
- }
- return val;
- }
- return string.Empty;
- }
- }
-
+ public virtual Keys Shortcut { get; set; }
+
#endregion
public Command()
@@ -104,19 +145,6 @@ public Command(EventHandler<EventArgs> execute)
Executed += execute;
}
- public Command(string id, string text, string tooltip, EventHandler<EventArgs> execute)
- {
- ID = id;
- MenuText = ToolBarText = text;
- ToolTip = tooltip;
- Executed += execute;
- }
-
- internal void Remove()
- {
- OnRemoved(EventArgs.Empty);
- }
-
public void Execute()
{
OnExecuted(EventArgs.Empty);
View
27 Source/Eto/Forms/Controls/Control.cs
@@ -36,7 +36,7 @@ public partial interface IControl : IInstanceWidget
void SetParent(Container parent);
- void MapPlatformAction(string systemAction, Command action);
+ void MapPlatformCommand(string systemAction, Command action);
PointF PointFromScreen(PointF point);
@@ -462,6 +462,7 @@ public virtual object DataContext
public Container ParentLayout { get { return Parent; } }
Container parent;
+
public Container Parent
{
get { return parent; }
@@ -556,9 +557,29 @@ public Window ParentWindow
}
}
- public void MapPlatformAction(string systemAction, Command action)
+ [Obsolete("Use MapPlatformCommand instead")]
+ public void MapPlatformAction(string systemAction, BaseAction action)
+ {
+ Command command = null;
+ if (action != null)
+ {
+ command = new Command
+ {
+ ID = action.ID,
+ MenuText = action.MenuText,
+ ToolBarText = action.ToolBarText,
+ ToolTip = action.TooltipText
+ };
+ action.EnabledChanged += (sender, e) => command.Enabled = action.Enabled;
+ command.Executed += (sender, e) => action.Activate();
+ }
+
+ Handler.MapPlatformCommand(systemAction, command);
+ }
+
+ public void MapPlatformCommand(string systemAction, Command command)
{
- Handler.MapPlatformAction(systemAction, action);
+ Handler.MapPlatformCommand(systemAction, command);
}
public PointF PointFromScreen(PointF point)
View
4 Source/Eto/Forms/Controls/ThemedControlHandler.cs
@@ -113,9 +113,9 @@ public virtual PointF PointToScreen(PointF point)
return Control.PointToScreen(point);
}
- public virtual void MapPlatformAction(string systemAction, Command action)
+ public virtual void MapPlatformCommand(string systemAction, Command action)
{
- Control.MapPlatformAction(systemAction, action);
+ Control.MapPlatformCommand(systemAction, action);
}
public virtual Point Location
View
29 Source/Eto/Forms/Menu/ButtonMenuItem.cs
@@ -10,12 +10,29 @@ public interface IButtonMenuItem : IMenuItem, ISubMenu
Image Image { get; set; }
}
- public class ButtonMenuItem : MenuItem, IMenuItemsSource
+ [Obsolete("Use ButtonMenuItem instead")]
+ public class ImageMenuItem : ButtonMenuItem
+ {
+ public ImageMenuItem()
+ : this((Generator)null)
+ {
+ }
+
+ public ImageMenuItem(Generator generator)
+ : base(generator)
+ {
+ }
+ }
+
+ public class ButtonMenuItem : MenuItem, ISubMenuWidget
{
new IButtonMenuItem Handler { get { return (IButtonMenuItem)base.Handler; } }
public MenuItemCollection Items { get; private set; }
+ [Obsolete("Use Items instead")]
+ public MenuItemCollection MenuItems { get { return Items; } }
+
public bool Trim { get; set; }
public ButtonMenuItem()
@@ -23,16 +40,16 @@ public ButtonMenuItem()
{
}
+ public ButtonMenuItem(Generator generator)
+ : this(generator, typeof(IButtonMenuItem))
+ {
+ }
+
public ButtonMenuItem(Command command, Generator generator = null)
: base(command, generator, typeof(IButtonMenuItem))
{
Items = new MenuItemCollection(Handler);
Image = command.Image;
- Handler.CreateFromCommand(command);
- }
-
- public ButtonMenuItem(Generator generator) : this(generator, typeof(IButtonMenuItem))
- {
}
protected ButtonMenuItem(Generator generator, Type type, bool initialize = true)
View
20 Source/Eto/Forms/Menu/CheckMenuItem.cs
@@ -6,7 +6,7 @@ public interface ICheckMenuItem : IMenuItem
{
bool Checked { get; set; }
}
-
+
public class CheckMenuItem : MenuItem
{
new ICheckMenuItem Handler { get { return (ICheckMenuItem)base.Handler; } }
@@ -16,16 +16,26 @@ public CheckMenuItem()
{
}
- public CheckMenuItem (Generator generator) : this (generator, typeof(ICheckMenuItem))
+ public CheckMenuItem(Generator generator)
+ : this(generator, typeof(ICheckMenuItem))
{
}
- protected CheckMenuItem (Generator generator, Type type, bool initialize = true)
- : base (generator, type, initialize)
+ public CheckMenuItem(CheckCommand command, Generator generator = null)
+ : base(command, generator, typeof(ICheckMenuItem))
{
+ Checked = command.Checked;
+ command.CheckedChanged += (sender, e) => Checked = command.Checked;
+ Click += (sender, e) => command.Checked = Checked;
}
- public bool Checked {
+ protected CheckMenuItem(Generator generator, Type type, bool initialize = true)
+ : base(generator, type, initialize)
+ {
+ }
+
+ public bool Checked
+ {
get { return Handler.Checked; }
set { Handler.Checked = value; }
}
View
5 Source/Eto/Forms/Menu/ContextMenu.cs
@@ -8,12 +8,15 @@ public interface IContextMenu : ISubMenu
void Show(Control relativeTo);
}
- public class ContextMenu : Menu, IMenuItemsSource
+ public class ContextMenu : Menu, ISubMenuWidget
{
new IContextMenu Handler { get { return (IContextMenu)base.Handler; } }
public MenuItemCollection Items { get; private set; }
+ [Obsolete("Use Items instead")]
+ public MenuItemCollection MenuItems { get { return Items; } }
+
public ContextMenu()
: this((Generator)null)
{
View
5 Source/Eto/Forms/Menu/MenuBar.cs
@@ -7,12 +7,15 @@ public interface IMenuBar : IMenu, ISubMenu
{
}
- public class MenuBar : Menu, IMenuItemsSource
+ public class MenuBar : Menu, ISubMenuWidget
{
new IMenuBar Handler { get { return (IMenuBar)base.Handler; } }
public MenuItemCollection Items { get; private set; }
+ [Obsolete("Use Items instead")]
+ public MenuItemCollection MenuItems { get { return Items; } }
+
public MenuBar()
: this((Generator)null)
{
View
4 Source/Eto/Forms/Menu/MenuItem.cs
@@ -47,12 +47,14 @@ public virtual void OnValidate(EventArgs e)
protected MenuItem(Command command, Generator generator, Type type, bool initialize = true)
: base(generator, type, initialize)
{
+ ID = command.ID;
Text = command.MenuText;
ToolTip = command.ToolTip;
Shortcut = command.Shortcut;
Click += (sender, e) => command.OnExecuted(e);
- // CWEN: Need to unregister when removed from menu?
command.EnabledChanged += (sender, e) => Enabled = command.Enabled;
+ if (initialize)
+ Handler.CreateFromCommand(command);
}
protected MenuItem(Generator g, Type type, bool initialize = true)
View
36 Source/Eto/Forms/Menu/RadioMenuItem.cs
@@ -1,41 +1,51 @@
-#if DESKTOP
using System;
namespace Eto.Forms
{
public interface IRadioMenuItem : IMenuItem
{
- void Create (RadioMenuItem controller);
+ void Create(RadioMenuItem controller);
bool Checked { get; set; }
}
-
+
public class RadioMenuItem : MenuItem
{
new IRadioMenuItem Handler { get { return (IRadioMenuItem)base.Handler; } }
public RadioMenuItem()
- : this(null, null)
+ : this(null, typeof(IRadioMenuItem), null)
{
}
- public RadioMenuItem (RadioMenuItem controller = null, Generator generator = null)
- : this (generator, typeof(IRadioMenuItem), controller)
+ public RadioMenuItem(RadioMenuItem controller, Generator generator = null)
+ : this(generator, typeof(IRadioMenuItem), controller)
{
}
- protected RadioMenuItem (Generator generator, Type type, RadioMenuItem controller, bool initialize = true)
- : base (generator, type, false)
+ public RadioMenuItem(RadioCommand command, RadioMenuItem controller, Generator generator = null)
+ : base(command, generator, typeof(IRadioMenuItem), false)
{
- Handler.Create (controller);
+ Checked = command.Checked;
+ Click += (sender, e) => command.Checked = Checked;
+ command.CheckedChanged += (sender, e) => Checked = command.Checked;
+ Handler.Create(controller);
+ Initialize();
+ Handler.CreateFromCommand(command);
+ }
+
+ protected RadioMenuItem(Generator generator, Type type, RadioMenuItem controller, bool initialize = true)
+ : base(generator, type, false)
+ {
+ Handler.Create(controller);
if (initialize)
- Initialize ();
+ Initialize();
}
- public bool Checked {
+ public bool Checked
+ {
get { return Handler.Checked; }
set { Handler.Checked = value; }
}
}
-}
-#endif
+}
View
11 Source/Eto/Forms/Menu/SeparatorMenuItem.cs
@@ -5,7 +5,7 @@ namespace Eto.Forms
public interface ISeparatorMenuItem : IMenuItem
{
}
-
+
public class SeparatorMenuItem : MenuItem
{
public SeparatorMenuItem()
@@ -13,14 +13,13 @@ public SeparatorMenuItem()
{
}
- public SeparatorMenuItem (Generator generator) : this (generator, typeof(ISeparatorMenuItem))
+ public SeparatorMenuItem(Generator generator) : this(generator, typeof(ISeparatorMenuItem))
{
}
-
- protected SeparatorMenuItem (Generator generator, Type type, bool initialize = true)
- : base (generator, type, initialize)
+
+ protected SeparatorMenuItem(Generator generator, Type type, bool initialize = true)
+ : base(generator, type, initialize)
{
-
}
}
}
View
2 Source/Eto/Forms/Menu/SubMenu.cs
@@ -13,7 +13,7 @@ public interface ISubMenu : IMenu
void Clear ();
}
- public interface IMenuItemsSource
+ public interface ISubMenuWidget
{
MenuItemCollection Items { get; }
}
View
30 Source/Eto/Forms/ToolBar/CheckToolItem.cs
@@ -6,26 +6,42 @@ public interface ICheckToolItem : IToolItem
{
bool Checked { get; set; }
}
-
+
public class CheckToolItem : ToolItem
{
new ICheckToolItem Handler { get { return (ICheckToolItem)base.Handler; } }
-
+
public event EventHandler<EventArgs> CheckedChanged;
-
- public CheckToolItem(Generator g) : base(g, typeof(ICheckToolItem))
+
+ public CheckToolItem()
+ : this((Generator)null)
+ {
+ }
+
+ public CheckToolItem(Generator generator)
+ : base(generator, typeof(ICheckToolItem))
{
}
-
+
+ public CheckToolItem(CheckCommand command, Generator generator = null)
+ : base(command, generator, typeof(ICheckToolItem))
+ {
+ Checked = command.Checked;
+ command.CheckedChanged += (sender, e) => Checked = command.Checked;
+ Click += (sender, e) => command.Checked = Checked;
+ Handler.CreateFromCommand(command);
+ }
+
public bool Checked
{
get { return Handler.Checked; }
set { Handler.Checked = value; }
}
-
+
public void OnCheckedChanged(EventArgs e)
{
- if (CheckedChanged != null) CheckedChanged(this, e);
+ if (CheckedChanged != null)
+ CheckedChanged(this, e);
}
}
}
View
1 Source/Eto/Forms/ToolBar/ToolItem.cs
@@ -31,7 +31,6 @@ protected ToolItem(Command command, Generator generator, Type type, bool initial
ToolTip = command.ToolTip;
Image = command.Image;
Click += (sender, e) => command.OnExecuted(e);
- // CWEN: Need to unregister when removed from toolbar
command.EnabledChanged += (sender, e) => Enabled = command.Enabled;
Order = -1;
}
View
32 Source/Eto/Forms/ToolBar/ToolItem.obsolete.cs
@@ -0,0 +1,32 @@
+using System;
+
+namespace Eto.Forms
+{
+ [Obsolete("Use ButtonToolItem instead")]
+ public class ToolBarButton : ButtonToolItem
+ {
+ public ToolBarButton(Generator generator = null)
+ : base(generator)
+ {
+ }
+ }
+
+ [Obsolete("Use CheckToolItem instead")]
+ public class CheckToolBarButton : CheckToolItem
+ {
+ public CheckToolBarButton(Generator generator = null)
+ : base(generator)
+ {
+ }
+ }
+
+ [Obsolete("Use SeparatorToolItem instead")]
+ public class SeparatorToolBarItem : SeparatorToolItem
+ {
+ public SeparatorToolBarItem(Generator generator = null)
+ : base(generator)
+ {
+ }
+ }
+}
+
View
4 Source/Eto/WeakEventHandler.cs
@@ -8,6 +8,7 @@ namespace Eto
/// </summary>
/// <typeparam name="TArgs">Type of <see cref="EventArgs"/> used in the event handler</typeparam>
/// <param name="eventHandler">The event handler that was registered that should be unregistered</param>
+ [Obsolete("No longer provided by this library")]
public delegate void UnregisterCallback<TArgs> (EventHandler<TArgs> eventHandler)
where TArgs: EventArgs;
@@ -18,6 +19,7 @@ namespace Eto
/// This is used by the <see cref="WeakEventExtensions"/>
/// </remarks>
/// <typeparam name="TArgs"></typeparam>
+ [Obsolete("No longer provided by this library")]
public interface IWeakEventHandler<TArgs>
where TArgs: EventArgs
{
@@ -38,6 +40,7 @@ public interface IWeakEventHandler<TArgs>
/// </remarks>
/// <typeparam name="T">Type of the class the event handler is on</typeparam>
/// <typeparam name="TArgs">Type of arguments for the event handler</typeparam>
+ [Obsolete("No longer provided by this library")]
public class WeakEventHandler<T, TArgs>: IWeakEventHandler<TArgs>
where T: class
where TArgs: EventArgs
@@ -103,6 +106,7 @@ public void Invoke (object sender, TArgs e)
/// <summary>
/// Extensions for weak events
/// </summary>
+ [Obsolete("No longer provided by this library")]
public static class WeakEventExtensions
{
/// <summary>

0 comments on commit 4fe56ac

Please sign in to comment.
Something went wrong with that request. Please try again.