diff --git a/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj b/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj index 87f03fea..05ea8133 100644 --- a/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj +++ b/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj @@ -63,24 +63,18 @@ - - ..\packages\Caliburn.Micro.3.0.1\lib\net45\System.Windows.Interactivity.dll True - - - - - + diff --git a/Dapplo.CaliburnMicro.Demo.Addon/Languages/IAddonTranslations.cs b/Dapplo.CaliburnMicro.Demo.Addon/Languages/IAddonTranslations.cs index 24f4210f..c599f1e3 100644 --- a/Dapplo.CaliburnMicro.Demo.Addon/Languages/IAddonTranslations.cs +++ b/Dapplo.CaliburnMicro.Demo.Addon/Languages/IAddonTranslations.cs @@ -26,12 +26,15 @@ #endregion -namespace Dapplo.CaliburnMicro.Demo.Languages +namespace Dapplo.CaliburnMicro.Demo.Addon.Languages { [Language("Addon1")] public interface IAddonTranslations : ILanguage, INotifyPropertyChanged { [DefaultValue("Blub")] string Addon { get; } + + [DefaultValue("Can't touch me")] + string NotSelectableAddon { get; } } } \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/AddonSettingsViewModel.cs b/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/AddonSettingsViewModel.cs index f563e9cd..3599d250 100644 --- a/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/AddonSettingsViewModel.cs +++ b/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/AddonSettingsViewModel.cs @@ -23,16 +23,18 @@ using System.ComponentModel.Composition; using Caliburn.Micro; -using Dapplo.CaliburnMicro.Demo.Interfaces; +using Dapplo.CaliburnMicro.Configuration; +using Dapplo.CaliburnMicro.Demo.Addon.Languages; using Dapplo.CaliburnMicro.Demo.Languages; +using Dapplo.CaliburnMicro.Demo.UseCases.Configuration; using Dapplo.Utils.Extensions; #endregion namespace Dapplo.CaliburnMicro.Demo.Addon.ViewModels { - [Export(typeof(ISettingsControl))] - public class AddonSettingsViewModel : Screen, ISettingsControl, IPartImportsSatisfiedNotification + [Export(typeof(IConfigScreen))] + public sealed class AddonSettingsViewModel : ConfigScreen, IPartImportsSatisfiedNotification { [Import] public IAddonTranslations AddonTranslations { get; set; } @@ -51,7 +53,10 @@ public void OnImportsSatisfied() public void DoSomething() { - EventAggregator.PublishOnUIThread("Addon clicked"); + EventAggregator.PublishOnUIThread("Addon button clicked"); } + + public override int ParentId { get; } = (int)ConfigIds.Addons; + public override int Id { get; } = (int) (ConfigIds.Addons + 1); } } \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/NotSelectableConfigViewModel.cs b/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/NotSelectableConfigViewModel.cs new file mode 100644 index 00000000..db6d5e24 --- /dev/null +++ b/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/NotSelectableConfigViewModel.cs @@ -0,0 +1,55 @@ +// Dapplo - building blocks for desktop 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 . + +#region using + +using System.ComponentModel.Composition; +using Caliburn.Micro; +using Dapplo.CaliburnMicro.Configuration; +using Dapplo.CaliburnMicro.Demo.Addon.Languages; +using Dapplo.CaliburnMicro.Demo.Languages; +using Dapplo.CaliburnMicro.Demo.UseCases.Configuration; +using Dapplo.Utils.Extensions; + +#endregion + +namespace Dapplo.CaliburnMicro.Demo.Addon.ViewModels +{ + [Export(typeof(IConfigScreen))] + public sealed class NotSelectableConfigViewModel : ConfigScreen, IPartImportsSatisfiedNotification + { + [Import] + public IAddonTranslations AddonTranslations { get; set; } + + public void OnImportsSatisfied() + { + IsEnabled = false; + // automatically update the DisplayName + AddonTranslations.OnPropertyChanged(e => + { + DisplayName = AddonTranslations.NotSelectableAddon; + }, nameof(IAddonTranslations.NotSelectableAddon)); + } + + public override int ParentId { get; } = (int)ConfigIds.Addons; + public override int Id { get; } = (int)(ConfigIds.Addons + 2); + } +} \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj b/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj index 9ecc0f4c..bfd24559 100644 --- a/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj +++ b/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj @@ -107,7 +107,7 @@ - + @@ -116,11 +116,14 @@ + + + - + - + @@ -181,7 +184,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -189,7 +192,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/Dapplo.CaliburnMicro.Demo/Interfaces/ISettingsControl.cs b/Dapplo.CaliburnMicro.Demo/Languages/IConfigTranslations.cs similarity index 80% rename from Dapplo.CaliburnMicro.Demo/Interfaces/ISettingsControl.cs rename to Dapplo.CaliburnMicro.Demo/Languages/IConfigTranslations.cs index 73b8bb8f..df7d1c85 100644 --- a/Dapplo.CaliburnMicro.Demo/Interfaces/ISettingsControl.cs +++ b/Dapplo.CaliburnMicro.Demo/Languages/IConfigTranslations.cs @@ -21,13 +21,17 @@ #region using -using Caliburn.Micro; +using System.ComponentModel; +using Dapplo.Config.Language; #endregion -namespace Dapplo.CaliburnMicro.Demo.Interfaces +namespace Dapplo.CaliburnMicro.Demo.Languages { - public interface ISettingsControl : IHaveDisplayName + [Language("Config")] + public interface IConfigTranslations : ILanguage, INotifyPropertyChanged { + string Ui { get; } + string Addons { get; } } } \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.Demo/Languages/language-de-DE.xml b/Dapplo.CaliburnMicro.Demo/Languages/language-de-DE.xml index 9995d8ce..22841be7 100644 --- a/Dapplo.CaliburnMicro.Demo/Languages/language-de-DE.xml +++ b/Dapplo.CaliburnMicro.Demo/Languages/language-de-DE.xml @@ -8,6 +8,10 @@ Einstellungen Sprache ändern + + Benutzeroberfläche + Erweiterungen + Benutzername Paswort diff --git a/Dapplo.CaliburnMicro.Demo/Languages/language-en-US.xml b/Dapplo.CaliburnMicro.Demo/Languages/language-en-US.xml index f979b298..d8afbece 100644 --- a/Dapplo.CaliburnMicro.Demo/Languages/language-en-US.xml +++ b/Dapplo.CaliburnMicro.Demo/Languages/language-en-US.xml @@ -8,6 +8,10 @@ Settings Change language + + User interface + Addons + Username Password diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ConfigIds.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ConfigIds.cs new file mode 100644 index 00000000..65b108b2 --- /dev/null +++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ConfigIds.cs @@ -0,0 +1,48 @@ +#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 + +namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration +{ + /// + /// Used to make it possible to add a ConfigScreen to a well defined parent node + /// + public enum ConfigIds + { + /// + /// The root ID + /// + Root = 0, + + /// + /// UI related config screens should have this as parent + /// + Ui = 100, + + /// + /// Config screens from addons should have this as parent + /// + Addons = 200 + } +} \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/AddonConfigNodeViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/AddonConfigNodeViewModel.cs new file mode 100644 index 00000000..8be83f89 --- /dev/null +++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/AddonConfigNodeViewModel.cs @@ -0,0 +1,56 @@ +// Dapplo - building blocks for desktop 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 . + +#region using + +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Threading.Tasks; +using Caliburn.Micro; +using Dapplo.CaliburnMicro.Configuration; +using Dapplo.CaliburnMicro.Demo.Languages; +using Dapplo.CaliburnMicro.Demo.Models; +using Dapplo.Config.Language; +using Dapplo.Utils.Extensions; + +#endregion + +namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration.ViewModels +{ + [Export(typeof(IConfigScreen))] + public sealed class AddonConfigNodeViewModel : ConfigScreen, IPartImportsSatisfiedNotification + { + [Import] + public IConfigTranslations ConfigTranslations { get; set; } + + public void OnImportsSatisfied() + { + // automatically update the DisplayName + ConfigTranslations.OnPropertyChanged(pcEvent => + { + DisplayName = ConfigTranslations.Addons; + }, nameof(IConfigTranslations.Addons)); + CanActivate = false; + } + + public override int Id { get; } = (int) ConfigIds.Addons; + } +} \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/SettingsViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/ConfigViewModel.cs similarity index 86% rename from Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/SettingsViewModel.cs rename to Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/ConfigViewModel.cs index 2cf68595..d47d13ce 100644 --- a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/SettingsViewModel.cs +++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/ConfigViewModel.cs @@ -25,7 +25,7 @@ using System.ComponentModel.Composition; using System.Threading.Tasks; using Caliburn.Micro; -using Dapplo.CaliburnMicro.Demo.Interfaces; +using Dapplo.CaliburnMicro.Configuration; using Dapplo.CaliburnMicro.Demo.Languages; using Dapplo.CaliburnMicro.Demo.Models; using Dapplo.CaliburnMicro.Demo.ViewModels; @@ -43,12 +43,15 @@ namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration.ViewModels /// It is a conductor where one item is active. /// [Export] - public class SettingsViewModel : Conductor.Collection.OneActive, IPartImportsSatisfiedNotification + public class ConfigViewModel : Config, IPartImportsSatisfiedNotification { private static readonly LogSource Log = new LogSource(); [Import] - private ICoreTranslations CoreTranslations { get; set; } + public ICoreTranslations CoreTranslations { get; set; } + + [Import] + public IConfigTranslations ConfigTranslations { get; set; } [Import] private CredentialsViewModel CredentialsVm { get; set; } @@ -66,7 +69,7 @@ public class SettingsViewModel : Conductor.Collection.OneActiv /// Get all settings controls, these are the items that are displayed. /// [ImportMany] - private IEnumerable SettingsControls { get; set; } + public override IEnumerable ConfigScreens { get; set; } /// /// Used to show a "normal" dialog @@ -85,7 +88,7 @@ public class SettingsViewModel : Conductor.Collection.OneActiv /// And will make sure that the selected item is made visible. /// /// - public void ActivateChildView(ISettingsControl view) + public void ActivateChildView(IConfigScreen view) { ActivateItem(view); } @@ -108,14 +111,6 @@ public async Task Dialog() await Dialogcoordinator.ShowMessageAsync(this, "Message from VM", "MVVM based dialogs!"); } - protected override void OnActivate() - { - base.OnActivate(); - // Add all the imported settings controls - // TODO: Sort them for a tree view, somehow... - Items.AddRange(SettingsControls); - } - public void OnImportsSatisfied() { // automatically update the DisplayName diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageSettingsViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageConfigViewModel.cs similarity index 89% rename from Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageSettingsViewModel.cs rename to Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageConfigViewModel.cs index bab1a74c..c5cb5ca1 100644 --- a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageSettingsViewModel.cs +++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageConfigViewModel.cs @@ -25,7 +25,7 @@ using System.ComponentModel.Composition; using System.Threading.Tasks; using Caliburn.Micro; -using Dapplo.CaliburnMicro.Demo.Interfaces; +using Dapplo.CaliburnMicro.Configuration; using Dapplo.CaliburnMicro.Demo.Languages; using Dapplo.CaliburnMicro.Demo.Models; using Dapplo.Config.Language; @@ -35,8 +35,8 @@ namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration.ViewModels { - [Export(typeof(ISettingsControl))] - public class LanguageSettingsViewModel : Screen, ISettingsControl, IPartImportsSatisfiedNotification + [Export(typeof(IConfigScreen))] + public sealed class LanguageConfigViewModel : ConfigScreen, IPartImportsSatisfiedNotification { public IDictionary AvailableLanguages => LanguageLoader.Current.AvailableLanguages; @@ -74,5 +74,9 @@ public async Task ChangeLanguage() EventAggregator.PublishOnUIThread($"Changing to language: {DemoConfiguration.Language}"); await LanguageLoader.Current.ChangeLanguageAsync(DemoConfiguration.Language).ConfigureAwait(false); } + + public override int ParentId { get; } = (int)ConfigIds.Ui; + + public override int Id { get; } = (int) ConfigIds.Ui + 1; } } \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/UiConfigNodeViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/UiConfigNodeViewModel.cs new file mode 100644 index 00000000..11cea4ee --- /dev/null +++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/UiConfigNodeViewModel.cs @@ -0,0 +1,56 @@ +// Dapplo - building blocks for desktop 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 . + +#region using + +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Threading.Tasks; +using Caliburn.Micro; +using Dapplo.CaliburnMicro.Configuration; +using Dapplo.CaliburnMicro.Demo.Languages; +using Dapplo.CaliburnMicro.Demo.Models; +using Dapplo.Config.Language; +using Dapplo.Utils.Extensions; + +#endregion + +namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration.ViewModels +{ + [Export(typeof(IConfigScreen))] + public sealed class UiConfigNodeViewModel : ConfigScreen, IPartImportsSatisfiedNotification + { + [Import] + public IConfigTranslations ConfigTranslations { get; set; } + + public void OnImportsSatisfied() + { + // automatically update the DisplayName + ConfigTranslations.OnPropertyChanged(pcEvent => + { + DisplayName = ConfigTranslations.Ui; + }, nameof(IConfigTranslations.Ui)); + CanActivate = false; + } + + public override int Id { get; } = (int) ConfigIds.Ui; + } +} \ No newline at end of file diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/SettingsView.xaml b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/ConfigView.xaml similarity index 50% rename from Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/SettingsView.xaml rename to Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/ConfigView.xaml index dce5599a..cba71767 100644 --- a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/SettingsView.xaml +++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/ConfigView.xaml @@ -1,10 +1,13 @@ - + Width="500" Height="400"> + + +