diff --git a/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj b/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj index c61d4049..e81c656b 100644 --- a/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj +++ b/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj @@ -42,34 +42,36 @@ ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll True - - ..\packages\Dapplo.Addons.0.3.87\lib\net45\Dapplo.Addons.dll + + ..\packages\Dapplo.Addons.0.3.88\lib\net45\Dapplo.Addons.dll True - - ..\packages\Dapplo.Config.0.3.54\lib\net45\Dapplo.Config.dll + + ..\packages\Dapplo.Config.0.4.2\lib\net45\Dapplo.Config.dll True - - ..\packages\Dapplo.InterfaceImpl.0.1.37\lib\net45\Dapplo.InterfaceImpl.dll + + ..\packages\Dapplo.InterfaceImpl.0.2.5\lib\net45\Dapplo.InterfaceImpl.dll True - - ..\packages\Dapplo.Log.1.0.21\lib\net45\Dapplo.Log.dll + + ..\packages\Dapplo.Log.1.0.22\lib\net45\Dapplo.Log.dll True ..\packages\Dapplo.Log.Facade.0.5.4\lib\net45\Dapplo.Log.Facade.dll True - - ..\packages\Dapplo.Utils.0.1.122\lib\net45\Dapplo.Utils.dll + + ..\packages\Dapplo.Utils.1.0.128\lib\net45\Dapplo.Utils.dll True + + @@ -86,10 +88,12 @@ ..\packages\System.Reactive.Linq.3.1.0\lib\net45\System.Reactive.Linq.dll True + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll True + ..\packages\Caliburn.Micro.3.0.1\lib\net45\System.Windows.Interactivity.dll True diff --git a/Dapplo.CaliburnMicro.Demo.Addon/packages.config b/Dapplo.CaliburnMicro.Demo.Addon/packages.config index dabd5de5..5c9e41e9 100644 --- a/Dapplo.CaliburnMicro.Demo.Addon/packages.config +++ b/Dapplo.CaliburnMicro.Demo.Addon/packages.config @@ -2,12 +2,12 @@ - - - - + + + + - + diff --git a/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj b/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj index b4b09907..fad86931 100644 --- a/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj +++ b/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj @@ -54,32 +54,32 @@ ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll True - - ..\packages\Dapplo.Addons.0.3.87\lib\net45\Dapplo.Addons.dll + + ..\packages\Dapplo.Addons.0.3.88\lib\net45\Dapplo.Addons.dll True - - ..\packages\Dapplo.Config.0.3.54\lib\net45\Dapplo.Config.dll + + ..\packages\Dapplo.Config.0.4.2\lib\net45\Dapplo.Config.dll True - - ..\packages\Dapplo.InterfaceImpl.0.1.37\lib\net45\Dapplo.InterfaceImpl.dll + + ..\packages\Dapplo.InterfaceImpl.0.2.5\lib\net45\Dapplo.InterfaceImpl.dll True - - ..\packages\Dapplo.Log.1.0.21\lib\net45\Dapplo.Log.dll + + ..\packages\Dapplo.Log.1.0.22\lib\net45\Dapplo.Log.dll True ..\packages\Dapplo.Log.Facade.0.5.4\lib\net45\Dapplo.Log.Facade.dll True - - ..\packages\Dapplo.Log.Loggers.1.0.21\lib\net45\Dapplo.Log.Loggers.dll + + ..\packages\Dapplo.Log.Loggers.1.0.22\lib\net45\Dapplo.Log.Loggers.dll True - - ..\packages\Dapplo.Utils.0.1.122\lib\net45\Dapplo.Utils.dll + + ..\packages\Dapplo.Utils.1.0.128\lib\net45\Dapplo.Utils.dll True @@ -94,6 +94,7 @@ ..\packages\MahApps.Metro.IconPacks.1.6.0\lib\net45\MahApps.Metro.IconPacks.dll True + @@ -112,10 +113,12 @@ ..\packages\System.Reactive.Linq.3.1.0\lib\net45\System.Reactive.Linq.dll True + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll True + ..\packages\MahApps.Metro.1.3.0\lib\net45\System.Windows.Interactivity.dll True diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/ViewModels/WizardStep2ViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/ViewModels/WizardStep2ViewModel.cs index 7913b0d4..6864ec38 100644 --- a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/ViewModels/WizardStep2ViewModel.cs +++ b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/ViewModels/WizardStep2ViewModel.cs @@ -30,7 +30,6 @@ using Dapplo.CaliburnMicro.Demo.Languages; using Dapplo.CaliburnMicro.Extensions; using Dapplo.CaliburnMicro.Wizard; -using Dapplo.Utils.Extensions; #endregion @@ -54,7 +53,7 @@ public override void Initialize() { // automatically update the DisplayName _displayNameUpdater = WizardTranslations.CreateBinding(this, nameof(IWizardTranslations.TitleStep2)); - ParentWizard.OnPropertyChanged(s => IsEnabled = ParentWizard.IsStep2Enabled, nameof(WizardExampleViewModel.IsStep2Enabled)); + ParentWizard.OnPropertyChanged(nameof(WizardExampleViewModel.IsStep2Enabled)).Subscribe(s => IsEnabled = ParentWizard.IsStep2Enabled); } public override void Terminate() diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/ViewModels/WizardStep3ViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/ViewModels/WizardStep3ViewModel.cs index 1868e2fb..abd446f8 100644 --- a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/ViewModels/WizardStep3ViewModel.cs +++ b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/ViewModels/WizardStep3ViewModel.cs @@ -30,7 +30,7 @@ using Dapplo.CaliburnMicro.Demo.Languages; using Dapplo.CaliburnMicro.Extensions; using Dapplo.CaliburnMicro.Wizard; -using Dapplo.Utils.Extensions; + #endregion namespace Dapplo.CaliburnMicro.Demo.UseCases.Wizard.ViewModels @@ -53,8 +53,7 @@ public override void Initialize() // automatically update the DisplayName _displayNameUpdater = WizardTranslations.CreateBinding(this, nameof(IWizardTranslations.TitleStep3)); IsVisible = false; - ParentWizard.OnPropertyChanged(s => IsVisible = ParentWizard.IsStep3Visible, nameof(WizardExampleViewModel.IsStep3Visible)); - + ParentWizard.OnPropertyChanged(nameof(WizardExampleViewModel.IsStep3Visible)).Subscribe(s => IsVisible = ParentWizard.IsStep3Visible); } public override void Terminate() diff --git a/Dapplo.CaliburnMicro.Demo/packages.config b/Dapplo.CaliburnMicro.Demo/packages.config index a432a4e1..d3b80cfb 100644 --- a/Dapplo.CaliburnMicro.Demo/packages.config +++ b/Dapplo.CaliburnMicro.Demo/packages.config @@ -2,13 +2,13 @@ - - - - + + + + - - + + diff --git a/Dapplo.CaliburnMicro.Metro/Dapplo.CaliburnMicro.Metro.csproj b/Dapplo.CaliburnMicro.Metro/Dapplo.CaliburnMicro.Metro.csproj index 95703133..09248702 100644 --- a/Dapplo.CaliburnMicro.Metro/Dapplo.CaliburnMicro.Metro.csproj +++ b/Dapplo.CaliburnMicro.Metro/Dapplo.CaliburnMicro.Metro.csproj @@ -47,27 +47,31 @@ ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll True - - ..\packages\Dapplo.Log.1.0.21\lib\net45\Dapplo.Log.dll + + ..\packages\Dapplo.Log.1.0.22\lib\net45\Dapplo.Log.dll True ..\packages\Dapplo.Log.Facade.0.5.4\lib\net45\Dapplo.Log.Facade.dll True - - ..\packages\Dapplo.Utils.0.1.122\lib\net45\Dapplo.Utils.dll + + ..\packages\Dapplo.Utils.1.0.128\lib\net45\Dapplo.Utils.dll True ..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll True + + + + ..\packages\MahApps.Metro.1.3.0\lib\net45\System.Windows.Interactivity.dll True diff --git a/Dapplo.CaliburnMicro.Metro/packages.config b/Dapplo.CaliburnMicro.Metro/packages.config index a374587c..6401fde7 100644 --- a/Dapplo.CaliburnMicro.Metro/packages.config +++ b/Dapplo.CaliburnMicro.Metro/packages.config @@ -2,8 +2,8 @@ - + - + \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.NotifyIconWpf/Dapplo.CaliburnMicro.NotifyIconWpf.csproj b/Dapplo.CaliburnMicro.NotifyIconWpf/Dapplo.CaliburnMicro.NotifyIconWpf.csproj index 6f6b29f2..404723e2 100644 --- a/Dapplo.CaliburnMicro.NotifyIconWpf/Dapplo.CaliburnMicro.NotifyIconWpf.csproj +++ b/Dapplo.CaliburnMicro.NotifyIconWpf/Dapplo.CaliburnMicro.NotifyIconWpf.csproj @@ -47,32 +47,36 @@ ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll True - - ..\packages\Dapplo.Addons.0.3.87\lib\net45\Dapplo.Addons.dll + + ..\packages\Dapplo.Addons.0.3.88\lib\net45\Dapplo.Addons.dll True - - ..\packages\Dapplo.Log.1.0.21\lib\net45\Dapplo.Log.dll + + ..\packages\Dapplo.Log.1.0.22\lib\net45\Dapplo.Log.dll True ..\packages\Dapplo.Log.Facade.0.5.4\lib\net45\Dapplo.Log.Facade.dll True - - ..\packages\Dapplo.Utils.0.1.122\lib\net45\Dapplo.Utils.dll + + ..\packages\Dapplo.Utils.1.0.128\lib\net45\Dapplo.Utils.dll True ..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net45\Hardcodet.Wpf.TaskbarNotification.dll True + + + + ..\packages\Caliburn.Micro.3.0.1\lib\net45\System.Windows.Interactivity.dll True diff --git a/Dapplo.CaliburnMicro.NotifyIconWpf/packages.config b/Dapplo.CaliburnMicro.NotifyIconWpf/packages.config index 3a0718f7..67a1790b 100644 --- a/Dapplo.CaliburnMicro.NotifyIconWpf/packages.config +++ b/Dapplo.CaliburnMicro.NotifyIconWpf/packages.config @@ -2,9 +2,9 @@ - - + + - + \ No newline at end of file diff --git a/Dapplo.CaliburnMicro/Dapplo.CaliburnMicro.csproj b/Dapplo.CaliburnMicro/Dapplo.CaliburnMicro.csproj index d5926dcb..34fe7759 100644 --- a/Dapplo.CaliburnMicro/Dapplo.CaliburnMicro.csproj +++ b/Dapplo.CaliburnMicro/Dapplo.CaliburnMicro.csproj @@ -47,36 +47,28 @@ ..\packages\Caliburn.Micro.3.0.1\lib\net45\Caliburn.Micro.Platform.Core.dll True - - ..\packages\Dapplo.Addons.0.3.87\lib\net45\Dapplo.Addons.dll + + ..\packages\Dapplo.Addons.0.3.88\lib\net45\Dapplo.Addons.dll True - - ..\packages\Dapplo.Addons.Bootstrapper.0.3.87\lib\net45\Dapplo.Addons.Bootstrapper.dll + + ..\packages\Dapplo.Addons.Bootstrapper.0.3.88\lib\net45\Dapplo.Addons.Bootstrapper.dll True - - ..\packages\Dapplo.Config.0.3.54\lib\net45\Dapplo.Config.dll + + ..\packages\Dapplo.Config.0.4.2\lib\net45\Dapplo.Config.dll True - - ..\packages\Dapplo.InterfaceImpl.0.1.37\lib\net45\Dapplo.InterfaceImpl.dll + + ..\packages\Dapplo.InterfaceImpl.0.2.5\lib\net45\Dapplo.InterfaceImpl.dll True - - ..\packages\Dapplo.Log.1.0.21\lib\net45\Dapplo.Log.dll + + ..\packages\Dapplo.Log.1.0.22\lib\net45\Dapplo.Log.dll True - - ..\packages\Dapplo.Log.Facade.0.5.4\lib\net45\Dapplo.Log.Facade.dll - True - - - ..\packages\Dapplo.Utils.0.1.122\lib\net45\Dapplo.Utils.dll - True - - - ..\packages\MahApps.Metro.IconPacks.1.6.0\lib\net45\MahApps.Metro.IconPacks.dll + + ..\packages\Dapplo.Utils.1.0.128\lib\net45\Dapplo.Utils.dll True @@ -86,8 +78,6 @@ - - ..\packages\System.Reactive.Core.3.1.0\lib\net45\System.Reactive.Core.dll True @@ -100,17 +90,12 @@ ..\packages\System.Reactive.Linq.3.1.0\lib\net45\System.Reactive.Linq.dll True - - ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - True - ..\packages\Caliburn.Micro.3.0.1\lib\net45\System.Windows.Interactivity.dll True - @@ -123,6 +108,8 @@ + + diff --git a/Dapplo.CaliburnMicro/Extensions/HaveDisplayNameExtensions.cs b/Dapplo.CaliburnMicro/Extensions/HaveDisplayNameExtensions.cs index 831150ac..cec011f7 100644 --- a/Dapplo.CaliburnMicro/Extensions/HaveDisplayNameExtensions.cs +++ b/Dapplo.CaliburnMicro/Extensions/HaveDisplayNameExtensions.cs @@ -60,7 +60,7 @@ public NameBinding(IObservable> observabl /// /// All bindings are stored here - /// + /// tran public CompositeDisposable Disposables { get; } /// diff --git a/Dapplo.CaliburnMicro/Extensions/IniSectionExtensions.cs b/Dapplo.CaliburnMicro/Extensions/IniSectionExtensions.cs new file mode 100644 index 00000000..d8024db9 --- /dev/null +++ b/Dapplo.CaliburnMicro/Extensions/IniSectionExtensions.cs @@ -0,0 +1,126 @@ +#region Dapplo 2016 - GNU Lesser General Public License + +// Dapplo - building blocks for .NET applications +// Copyright (C) 2016 Dapplo +// +// For more information see: http://dapplo.net/ +// Dapplo repositories are hosted on GitHub: https://github.com/dapplo +// +// This file is part of Dapplo.CaliburnMicro +// +// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Dapplo.CaliburnMicro is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have a copy of the GNU Lesser General Public License +// along with Dapplo.CaliburnMicro. If not, see . + +#endregion + +using System; +using System.Reactive.Linq; +using Dapplo.Config.Ini; + +namespace Dapplo.CaliburnMicro.Extensions +{ + /// + /// Supply an extension to simplify the usage of IIniSection.OnLoaded / IIniSection.OnSaved / IIniSection.OnSaving / IIniSection.Reset + /// + public static class IniSectionExtensions + { + /// + /// Automatically call the update action when the Reset fires + /// If the is called on a DI object, make sure it's available. + /// When using MEF, it would be best to call this from IPartImportsSatisfiedNotification.OnImportsSatisfied + /// + /// IIniSection + /// Action to call on events, argument is the IniSectionEventArgs + /// an IDisposable, calling Dispose on this will stop everything + public static IDisposable OnReset(this IIniSection iniSection, Action eventAction) + { + if (iniSection == null) + { + throw new ArgumentNullException(nameof(iniSection)); + } + if (eventAction == null) + { + throw new ArgumentNullException(nameof(eventAction)); + } + var observable = Observable.FromEventPattern, IniSectionEventArgs>(h => iniSection.Reset += h, h => iniSection.Reset -= h); + return observable.Subscribe(pce => eventAction(pce.EventArgs)); + } + + /// + /// Automatically call the update action when the Loaded fires + /// If the is called on a DI object, make sure it's available. + /// When using MEF, it would be best to call this from IPartImportsSatisfiedNotification.OnImportsSatisfied + /// + /// IIniSection + /// Action to call on events, argument is the IniSectionEventArgs + /// an IDisposable, calling Dispose on this will stop everything + public static IDisposable OnLoaded(this IIniSection iniSection, Action eventAction) + { + if (iniSection == null) + { + throw new ArgumentNullException(nameof(iniSection)); + } + if (eventAction == null) + { + throw new ArgumentNullException(nameof(eventAction)); + } + var observable = Observable.FromEventPattern, IniSectionEventArgs>(h => iniSection.Loaded += h, h => iniSection.Loaded -= h); + return observable.Subscribe(pce => eventAction(pce.EventArgs)); + } + + /// + /// Automatically call the update action when the Saved fires + /// If the is called on a DI object, make sure it's available. + /// When using MEF, it would be best to call this from IPartImportsSatisfiedNotification.OnImportsSatisfied + /// + /// IIniSection + /// Action to call on events, argument is the IniSectionEventArgs + /// an IDisposable, calling Dispose on this will stop everything + public static IDisposable OnSaved(this IIniSection iniSection, Action eventAction) + { + if (iniSection == null) + { + throw new ArgumentNullException(nameof(iniSection)); + } + if (eventAction == null) + { + throw new ArgumentNullException(nameof(eventAction)); + } + var observable = Observable.FromEventPattern, IniSectionEventArgs>(h => iniSection.Saved += h, h => iniSection.Saved -= h); + return observable.Subscribe(pce => eventAction(pce.EventArgs)); + } + + /// + /// Automatically call the update action when the Saving fires + /// If the is called on a DI object, make sure it's available. + /// When using MEF, it would be best to call this from IPartImportsSatisfiedNotification.OnImportsSatisfied + /// + /// IIniSection + /// Action to call on events, argument is the IniSectionEventArgs + /// an IDisposable, calling Dispose on this will stop everything + public static IDisposable OnSaving(this IIniSection iniSection, Action eventAction) + { + if (iniSection == null) + { + throw new ArgumentNullException(nameof(iniSection)); + } + if (eventAction == null) + { + throw new ArgumentNullException(nameof(eventAction)); + } + var observable = Observable.FromEventPattern, IniSectionEventArgs>(h => iniSection.Saving += h, h => iniSection.Saving -= h); + return observable.Subscribe(pce => eventAction(pce.EventArgs)); + } + } + +} diff --git a/Dapplo.CaliburnMicro/Extensions/LanguageChangedExtensions.cs b/Dapplo.CaliburnMicro/Extensions/LanguageChangedExtensions.cs new file mode 100644 index 00000000..d8187b7a --- /dev/null +++ b/Dapplo.CaliburnMicro/Extensions/LanguageChangedExtensions.cs @@ -0,0 +1,71 @@ +#region Dapplo 2016 - GNU Lesser General Public License + +// Dapplo - building blocks for .NET applications +// Copyright (C) 2016 Dapplo +// +// For more information see: http://dapplo.net/ +// Dapplo repositories are hosted on GitHub: https://github.com/dapplo +// +// This file is part of Dapplo.Config +// +// Dapplo.Config is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Dapplo.Config is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have a copy of the GNU Lesser General Public License +// along with Dapplo.Config. If not, see . + +#endregion + +#region Usings + +using System; +using System.Reactive.Linq; +using Dapplo.Config.Language; + +#endregion + +namespace Dapplo.CaliburnMicro.Extensions +{ + /// + /// Supply an extension to simplify the usage of ILanguage.LanguageChanged + /// + public static class LanguageChangedExtensions + { + /// + /// Automatically call the update action when the LanguageChanged fires + /// If the is called on a DI object, make sure it's available. + /// When using MEF, it would be best to call this from IPartImportsSatisfiedNotification.OnImportsSatisfied + /// + /// ILanguage + /// Action to call on active and update, the argument is the property name + /// default the action is run when defining, specify false if this is not wanted + /// an IDisposable, calling Dispose on this will stop everything + public static IDisposable OnLanguageChanged(this ILanguage language, Action updateAction, bool run = true) + { + if (language == null) + { + throw new ArgumentNullException(nameof(language)); + } + if (updateAction == null) + { + throw new ArgumentNullException(nameof(updateAction)); + } + if (run) + { + updateAction(language); + } + var observable = Observable.FromEventPattern, EventArgs>( + h => language.LanguageChanged += h, + h => language.LanguageChanged -= h); + + return observable.Subscribe(pce => updateAction(pce.Sender as ILanguage)); + } + } +} \ No newline at end of file diff --git a/Dapplo.CaliburnMicro/packages.config b/Dapplo.CaliburnMicro/packages.config index 9bbcb099..24d2e291 100644 --- a/Dapplo.CaliburnMicro/packages.config +++ b/Dapplo.CaliburnMicro/packages.config @@ -2,50 +2,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - \ No newline at end of file