diff --git a/Nuclex.Windows.Forms (net-4.0).csproj b/Nuclex.Windows.Forms (net-4.0).csproj index 05bbbb0..6552027 100644 --- a/Nuclex.Windows.Forms (net-4.0).csproj +++ b/Nuclex.Windows.Forms (net-4.0).csproj @@ -59,6 +59,12 @@ + + UserControl + + + ProgressSpinner.cs + @@ -102,6 +108,9 @@ WindowManager.cs + + ProgressSpinner.cs + ProgressReporterForm.cs Designer @@ -143,7 +152,7 @@ - {2F487C4D-8E06-496F-BCD5-7119B18C78D8} + {2f487c4d-8e06-496f-bcd5-7119b18c78d8} Nuclex.Support.Transactions %28net-4.0%29 @@ -158,7 +167,6 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Source/ViewModels/MultiPageViewModel.cs b/Source/ViewModels/MultiPageViewModel.cs new file mode 100644 index 0000000..55af961 --- /dev/null +++ b/Source/ViewModels/MultiPageViewModel.cs @@ -0,0 +1,71 @@ +#region CPL License +/* +Nuclex Framework +Copyright (C) 2002-2019 Nuclex Development Labs + +This library is free software; you can redistribute it and/or +modify it under the terms of the IBM Common Public License as +published by the IBM Corporation; either version 1.0 of the +License, or (at your option) any later version. + +This library 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 +IBM Common Public License for more details. + +You should have received a copy of the IBM Common Public +License along with this library +*/ +#endregion + +using System; + +using Nuclex.Support; + +namespace Nuclex.Windows.Forms.ViewModels { + + /// Base class for view models that have multiple child view models + /// Enum type by which pages can be indicated + public abstract class MultiPageViewModel : Observable + where TPageEnumeration : IEquatable { + + /// Initializes a new multi-page view model + /// + /// Window manager the view model uses to create child views + /// + /// + /// Whether child view models will be kept alive and reused + /// + public MultiPageViewModel(IWindowManager windowManager, bool cachePageViewModels = false) { + this.windowManager = windowManager; + } + + /// Child page that is currently being displayed by the view model + public TPageEnumeration ActivePage { + get { return this.activePage; } + set { + if(!this.activePage.Equals(value)) { + this.activePage = value; + OnPropertyChanged(nameof(ActivePage)); + } + } + } + + /// Windowmanager that can create view models and display other views + protected IWindowManager WindowManager { + get { return this.windowManager; } + } + + /// Creates a view model for the specified page + /// Page for which a view model will be created + /// The view model for the specified page + protected abstract object createViewModelForPage(TPageEnumeration page); + + /// Page that is currently active in the multi-page view model + private TPageEnumeration activePage; + /// Window manager that can be used to display other views + private IWindowManager windowManager; + + } + +} // namespace Nuclex.Windows.Forms.ViewModels