From b209bf67bf987c59c7a5d7ba20fa94b2e7fc0906 Mon Sep 17 00:00:00 2001 From: Protiguous Date: Fri, 12 Mar 2021 15:25:12 -0700 Subject: [PATCH 1/3] Updated to .NET 4.8. --- .../App.config | 10 +-- .../Program.cs | 14 ++-- .../Properties/Resources.Designer.cs | 68 ++++++++----------- .../Properties/Settings.Designer.cs | 22 +++--- ...eactiveUI.Winforms.Samples.Bindings.csproj | 37 +++------- .../ViewModels/MainViewModel.cs | 38 +++++------ .../Views/MainView.cs | 43 ++++++------ .../packages.config | 13 ---- .../App.config | 10 +-- .../Program.cs | 14 ++-- .../Properties/Resources.Designer.cs | 68 ++++++++----------- .../Properties/Settings.Designer.cs | 22 +++--- ...eactiveUI.Winforms.Samples.Commands.csproj | 38 +++-------- .../ViewModels/MainViewModel.cs | 61 ++++++++--------- .../Views/MainView.cs | 32 +++++---- .../packages.config | 13 ---- .../App.config | 10 +-- .../Bootstrapper.cs | 16 ++--- .../Program.cs | 12 ++-- .../Properties/Resources.Designer.cs | 26 +++---- .../Properties/Settings.Designer.cs | 10 +-- ...ReactiveUI.Winforms.Samples.Routing.csproj | 36 ++-------- .../ViewModels/AboutViewModel.cs | 20 +++--- .../ViewModels/ContactViewModel.cs | 20 +++--- .../ViewModels/HomeViewModel.cs | 20 +++--- .../ViewModels/ShellViewModel.cs | 67 +++++++++--------- .../Views/AboutView.cs | 25 ++++--- .../Views/ContactView.cs | 25 ++++--- .../Views/HomeView.cs | 25 ++++--- .../Views/ShellView.cs | 32 +++++---- .../packages.config | 13 ---- 31 files changed, 366 insertions(+), 494 deletions(-) delete mode 100644 ReactiveUI.Winforms.Samples.Bindings/packages.config delete mode 100644 ReactiveUI.Winforms.Samples.Commands/packages.config delete mode 100644 ReactiveUI.Winforms.Samples.Routing/packages.config diff --git a/ReactiveUI.Winforms.Samples.Bindings/App.config b/ReactiveUI.Winforms.Samples.Bindings/App.config index 7fa5b2d..8441b75 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/App.config +++ b/ReactiveUI.Winforms.Samples.Bindings/App.config @@ -1,14 +1,14 @@ - + - + - - + + - \ No newline at end of file + diff --git a/ReactiveUI.Winforms.Samples.Bindings/Program.cs b/ReactiveUI.Winforms.Samples.Bindings/Program.cs index 02c957b..bfaafa3 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/Program.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/Program.cs @@ -1,13 +1,13 @@ -using ReactiveUI.Winforms.Samples.Bindings.Views; -using System; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Bindings +namespace ReactiveUI.Winforms.Samples.Bindings { - static class Program + using Views; + using System; + using System.Windows.Forms; + + public static class Program { [STAThread] - static void Main() + public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/ReactiveUI.Winforms.Samples.Bindings/Properties/Resources.Designer.cs b/ReactiveUI.Winforms.Samples.Bindings/Properties/Resources.Designer.cs index 9942908..6c83573 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/Properties/Resources.Designer.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/Properties/Resources.Designer.cs @@ -1,69 +1,61 @@ //------------------------------------------------------------------------------ // -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion: 4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn -// der Code neu generiert wird. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ -namespace ReactiveUI.Winforms.Samples.Bindings.Properties -{ - - +namespace ReactiveUI.Winforms.Samples.Bindings.Properties { + using System; + + /// - /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse - // über ein Tool wie ResGen oder Visual Studio automatisch generiert. - // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// - /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ReactiveUI.Winforms.Samples.Bindings.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// - /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/ReactiveUI.Winforms.Samples.Bindings/Properties/Settings.Designer.cs b/ReactiveUI.Winforms.Samples.Bindings/Properties/Settings.Designer.cs index c617512..3984058 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/Properties/Settings.Designer.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/Properties/Settings.Designer.cs @@ -8,21 +8,17 @@ // //------------------------------------------------------------------------------ -namespace ReactiveUI.Winforms.Samples.Bindings.Properties -{ - - +namespace ReactiveUI.Winforms.Samples.Bindings.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/ReactiveUI.Winforms.Samples.Bindings/ReactiveUI.Winforms.Samples.Bindings.csproj b/ReactiveUI.Winforms.Samples.Bindings/ReactiveUI.Winforms.Samples.Bindings.csproj index 366f4e4..7b9ede1 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/ReactiveUI.Winforms.Samples.Bindings.csproj +++ b/ReactiveUI.Winforms.Samples.Bindings/ReactiveUI.Winforms.Samples.Bindings.csproj @@ -8,9 +8,10 @@ WinExe ReactiveUI.Winforms.Samples.Bindings ReactiveUI.Winforms.Samples.Bindings - v4.6.1 + v4.8 512 true + AnyCPU @@ -37,35 +38,8 @@ - - ..\packages\ReactiveUI.8.0.1\lib\net461\ReactiveUI.dll - - - ..\packages\ReactiveUI.WinForms.8.0.1\lib\net461\ReactiveUI.Winforms.dll - - - ..\packages\Splat.4.0.0\lib\net461\Splat.dll - - - ..\packages\System.Drawing.Primitives.4.3.0\lib\net45\System.Drawing.Primitives.dll - - - ..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll - - - ..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll - - - ..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll - - - ..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll - - - ..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll - @@ -92,11 +66,11 @@ True Resources.resx + True MainView.cs - SettingsSingleFileGenerator Settings.Designer.cs @@ -110,5 +84,10 @@ + + + 13.2.2 + + \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Bindings/ViewModels/MainViewModel.cs b/ReactiveUI.Winforms.Samples.Bindings/ViewModels/MainViewModel.cs index 1e34624..c50edff 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/ViewModels/MainViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/ViewModels/MainViewModel.cs @@ -1,37 +1,37 @@ -using System; - -namespace ReactiveUI.Winforms.Samples.Bindings.ViewModels +namespace ReactiveUI.Winforms.Samples.Bindings.ViewModels { - public class MainViewModel : ReactiveObject + using System; + + public class MainViewModel : ReactiveObject { - private string _applicationTitle; - private string _valueOne; - private long _valueTwo; + private String _applicationTitle; + private String _valueOne; + private Int64 _valueTwo; public MainViewModel() { // Set properties - ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Bindings"; - ValueOne = "Type somthing"; - ValueTwo = DateTime.Now.Date.ToFileTime(); + this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Bindings"; + this.ValueOne = "Type somthing"; + this.ValueTwo = DateTime.Now.Date.ToFileTime(); } - public string ApplicationTitle + public String ApplicationTitle { - get => _applicationTitle; - set => this.RaiseAndSetIfChanged(ref _applicationTitle, value); + get => this._applicationTitle; + set => this.RaiseAndSetIfChanged(ref this._applicationTitle, value); } - public string ValueOne + public String ValueOne { - get => _valueOne; - set => this.RaiseAndSetIfChanged(ref _valueOne, value); + get => this._valueOne; + set => this.RaiseAndSetIfChanged(ref this._valueOne, value); } - public long ValueTwo + public Int64 ValueTwo { - get => _valueTwo; - set => this.RaiseAndSetIfChanged(ref _valueTwo, value); + get => this._valueTwo; + set => this.RaiseAndSetIfChanged(ref this._valueTwo, value); } } } diff --git a/ReactiveUI.Winforms.Samples.Bindings/Views/MainView.cs b/ReactiveUI.Winforms.Samples.Bindings/Views/MainView.cs index ccf8a12..964a6fd 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/Views/MainView.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/Views/MainView.cs @@ -1,38 +1,41 @@ -using ReactiveUI.Winforms.Samples.Bindings.ViewModels; -using System; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Bindings.Views +namespace ReactiveUI.Winforms.Samples.Bindings.Views { - public partial class MainView : Form, IViewFor + using ViewModels; + using System; + using System.Windows.Forms; + + public partial class MainView : Form, IViewFor { public MainView() { - InitializeComponent(); + this.InitializeComponent(); + + var _ = this.WhenActivated(d => { + if ( d is null ) { + return; + } - this.WhenActivated(d => - { - // One way bind from viewmodel to view - d(this.OneWayBind(ViewModel, vm => vm.ApplicationTitle, v => v.Text)); + // One way bind from viewmodel to view + d( this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text ) ); // Two way bind for input (textbox) and one way bind for output (label) - d(this.Bind(ViewModel, vm => vm.ValueOne, v => v.tbInputOne.Text)); - d(this.OneWayBind(ViewModel, vm => vm.ValueOne, v => v.lOutputOne.Text)); + d( this.Bind( this.ViewModel, vm => vm.ValueOne, v => v.tbInputOne.Text ) ); + d( this.OneWayBind( this.ViewModel, vm => vm.ValueOne, v => v.lOutputOne.Text ) ); // Two way bind for input (textbox) with convert and one way bind for output (label) - d(this.Bind(ViewModel, vm => vm.ValueTwo, v => v.dtpInputTwo.Value, t => DateTime.FromFileTime(t), dt => dt.ToFileTime())); - d(this.OneWayBind(ViewModel, vm => vm.ValueTwo, v => v.lOutputTwo.Text)); - }); + d( this.Bind( this.ViewModel, vm => vm.ValueTwo, v => v.dtpInputTwo.Value, DateTime.FromFileTime, dt => dt.ToFileTime() ) ); + d( this.OneWayBind( this.ViewModel, vm => vm.ValueTwo, v => v.lOutputTwo.Text ) ); + }); - ViewModel = new MainViewModel(); + this.ViewModel = new MainViewModel(); } public MainViewModel ViewModel { get; set; } - object IViewFor.ViewModel + Object IViewFor.ViewModel { - get => ViewModel; - set => ViewModel = (MainViewModel)value; + get => this.ViewModel; + set => this.ViewModel = (MainViewModel)value; } } } diff --git a/ReactiveUI.Winforms.Samples.Bindings/packages.config b/ReactiveUI.Winforms.Samples.Bindings/packages.config deleted file mode 100644 index 60139cd..0000000 --- a/ReactiveUI.Winforms.Samples.Bindings/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Commands/App.config b/ReactiveUI.Winforms.Samples.Commands/App.config index 7fa5b2d..8441b75 100644 --- a/ReactiveUI.Winforms.Samples.Commands/App.config +++ b/ReactiveUI.Winforms.Samples.Commands/App.config @@ -1,14 +1,14 @@ - + - + - - + + - \ No newline at end of file + diff --git a/ReactiveUI.Winforms.Samples.Commands/Program.cs b/ReactiveUI.Winforms.Samples.Commands/Program.cs index 7a08802..73bc5f2 100644 --- a/ReactiveUI.Winforms.Samples.Commands/Program.cs +++ b/ReactiveUI.Winforms.Samples.Commands/Program.cs @@ -1,13 +1,13 @@ -using ReactiveUI.Winforms.Samples.Commands.Views; -using System; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Commands +namespace ReactiveUI.Winforms.Samples.Commands { - static class Program + using Views; + using System; + using System.Windows.Forms; + + public static class Program { [STAThread] - static void Main() + public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/ReactiveUI.Winforms.Samples.Commands/Properties/Resources.Designer.cs b/ReactiveUI.Winforms.Samples.Commands/Properties/Resources.Designer.cs index 6d991f7..105a962 100644 --- a/ReactiveUI.Winforms.Samples.Commands/Properties/Resources.Designer.cs +++ b/ReactiveUI.Winforms.Samples.Commands/Properties/Resources.Designer.cs @@ -1,69 +1,61 @@ //------------------------------------------------------------------------------ // -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion: 4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn -// der Code neu generiert wird. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ -namespace ReactiveUI.Winforms.Samples.Commands.Properties -{ - - +namespace ReactiveUI.Winforms.Samples.Commands.Properties { + using System; + + /// - /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse - // über ein Tool wie ResGen oder Visual Studio automatisch generiert. - // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// - /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ReactiveUI.Winforms.Samples.Commands.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// - /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/ReactiveUI.Winforms.Samples.Commands/Properties/Settings.Designer.cs b/ReactiveUI.Winforms.Samples.Commands/Properties/Settings.Designer.cs index 2b5feb5..534fc27 100644 --- a/ReactiveUI.Winforms.Samples.Commands/Properties/Settings.Designer.cs +++ b/ReactiveUI.Winforms.Samples.Commands/Properties/Settings.Designer.cs @@ -8,21 +8,17 @@ // //------------------------------------------------------------------------------ -namespace ReactiveUI.Winforms.Samples.Commands.Properties -{ - - +namespace ReactiveUI.Winforms.Samples.Commands.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj b/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj index 50d65f5..a604f3c 100644 --- a/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj +++ b/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj @@ -8,9 +8,10 @@ WinExe ReactiveUI.Winforms.Samples.Commands ReactiveUI.Winforms.Samples.Commands - v4.6.1 + v4.8 512 true + AnyCPU @@ -37,34 +38,7 @@ - - ..\packages\ReactiveUI.8.0.1\lib\net461\ReactiveUI.dll - - - ..\packages\ReactiveUI.WinForms.8.0.1\lib\net461\ReactiveUI.Winforms.dll - - - ..\packages\Splat.4.0.0\lib\net461\Splat.dll - - - ..\packages\System.Drawing.Primitives.4.3.0\lib\net45\System.Drawing.Primitives.dll - - - ..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll - - - ..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll - - - ..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll - - - ..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll - - - ..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll - @@ -90,11 +64,11 @@ True Resources.resx + True MainView.cs - SettingsSingleFileGenerator Settings.Designer.cs @@ -108,6 +82,10 @@ - + + + 13.2.2 + + \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Commands/ViewModels/MainViewModel.cs b/ReactiveUI.Winforms.Samples.Commands/ViewModels/MainViewModel.cs index 4eacca1..92597b0 100644 --- a/ReactiveUI.Winforms.Samples.Commands/ViewModels/MainViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Commands/ViewModels/MainViewModel.cs @@ -1,55 +1,50 @@ -using System.Reactive.Linq; -using System.Windows; - -namespace ReactiveUI.Winforms.Samples.Commands.ViewModels +namespace ReactiveUI.Winforms.Samples.Commands.ViewModels { - public class MainViewModel : ReactiveObject + + using System; + using System.Reactive; + using System.Reactive.Linq; + using System.Windows; + + public class MainViewModel : ReactiveObject { - private string _applicationTitle; - private string _withCanExecuteParameter; + private String _applicationTitle; + private String _withCanExecuteParameter; public MainViewModel() { // Set properties - ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Commands"; + this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Commands"; // Create parameterless command - ParameterlessCommand = ReactiveCommand.Create(Parameterless); + this.ParameterlessCommand = ReactiveCommand.Create( this.Parameterless); // Create command with parameter - WithParameterCommand = ReactiveCommand.Create(WithParameter); + this.WithParameterCommand = ReactiveCommand.Create( this.WithParameter); // Create command with can execute - WithCanExecuteCommand = ReactiveCommand.Create(WithCanExecute, - this.WhenAnyValue(vm => vm.WithCanExecuteParameter).Select(s => string.IsNullOrEmpty(s) == false)); + this.WithCanExecuteCommand = ReactiveCommand.Create( this.WithCanExecute, + this.WhenAnyValue(vm => vm.WithCanExecuteParameter).Select(s => String.IsNullOrEmpty(s) == false)); } - public string ApplicationTitle + public String ApplicationTitle { - get => _applicationTitle; - set => this.RaiseAndSetIfChanged(ref _applicationTitle, value); + get => this._applicationTitle; + set => this.RaiseAndSetIfChanged(ref this._applicationTitle, value); } - public string WithCanExecuteParameter + public String WithCanExecuteParameter { - get => _withCanExecuteParameter; - set => this.RaiseAndSetIfChanged(ref _withCanExecuteParameter, value); + get => this._withCanExecuteParameter; + set => this.RaiseAndSetIfChanged(ref this._withCanExecuteParameter, value); } - public ReactiveCommand ParameterlessCommand { get; } - public ReactiveCommand WithParameterCommand { get; } - public ReactiveCommand WithCanExecuteCommand { get; } + public ReactiveCommand ParameterlessCommand { get; } + public ReactiveCommand WithParameterCommand { get; } + public ReactiveCommand WithCanExecuteCommand { get; } - private void Parameterless() - { - MessageBox.Show("You pressed the button!", ApplicationTitle, MessageBoxButton.OK); - } + private void Parameterless() => MessageBox.Show("You pressed the button!", this.ApplicationTitle, MessageBoxButton.OK); - private void WithParameter(string message) - { - MessageBox.Show(message, ApplicationTitle, MessageBoxButton.OK); - } + private void WithParameter(String message) => MessageBox.Show(message, this.ApplicationTitle, MessageBoxButton.OK); + + private void WithCanExecute() => MessageBox.Show( this.WithCanExecuteParameter, this.ApplicationTitle, MessageBoxButton.OK); - private void WithCanExecute() - { - MessageBox.Show(WithCanExecuteParameter, ApplicationTitle, MessageBoxButton.OK); - } } } diff --git a/ReactiveUI.Winforms.Samples.Commands/Views/MainView.cs b/ReactiveUI.Winforms.Samples.Commands/Views/MainView.cs index ec0c127..be23bf3 100644 --- a/ReactiveUI.Winforms.Samples.Commands/Views/MainView.cs +++ b/ReactiveUI.Winforms.Samples.Commands/Views/MainView.cs @@ -1,38 +1,40 @@ -using ReactiveUI.Winforms.Samples.Commands.ViewModels; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Commands.Views +namespace ReactiveUI.Winforms.Samples.Commands.Views { - public partial class MainView : Form, IViewFor + + using System; + using ViewModels; + using System.Windows.Forms; + + public partial class MainView : Form, IViewFor { public MainView() { - InitializeComponent(); + this.InitializeComponent(); this.WhenActivated(d => { // Bind properties - d(this.OneWayBind(ViewModel, vm => vm.ApplicationTitle, v => v.Text)); + d(this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text)); // Bind property for command with can execute - d(this.Bind(ViewModel, vm => vm.WithCanExecuteParameter, v => v.tbWithCanExecuteParameter.Text)); + d(this.Bind( this.ViewModel, vm => vm.WithCanExecuteParameter, v => v.tbWithCanExecuteParameter.Text)); // Bind parameterless command - d(this.BindCommand(ViewModel, vm => vm.ParameterlessCommand, v => v.btParameterless)); + d(this.BindCommand( this.ViewModel, vm => vm.ParameterlessCommand, v => v.btParameterless)); // Bind command with parameter - d(this.BindCommand(ViewModel, vm => vm.WithParameterCommand, v => v.btWithParameter, this.WhenAnyValue(v => v.tbParameter.Text))); + d(this.BindCommand( this.ViewModel, vm => vm.WithParameterCommand, v => v.btWithParameter, this.WhenAnyValue(v => v.tbParameter.Text))); // Bind command with can execute - d(this.BindCommand(ViewModel, vm => vm.WithCanExecuteCommand, v => v.btWithCanExecute)); + d(this.BindCommand( this.ViewModel, vm => vm.WithCanExecuteCommand, v => v.btWithCanExecute)); }); - ViewModel = new MainViewModel(); + this.ViewModel = new MainViewModel(); } public MainViewModel ViewModel { get; set; } - object IViewFor.ViewModel + Object IViewFor.ViewModel { - get => ViewModel; - set => ViewModel = (MainViewModel)value; + get => this.ViewModel; + set => this.ViewModel = (MainViewModel)value; } } } diff --git a/ReactiveUI.Winforms.Samples.Commands/packages.config b/ReactiveUI.Winforms.Samples.Commands/packages.config deleted file mode 100644 index 60139cd..0000000 --- a/ReactiveUI.Winforms.Samples.Commands/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/App.config b/ReactiveUI.Winforms.Samples.Routing/App.config index 7fa5b2d..8441b75 100644 --- a/ReactiveUI.Winforms.Samples.Routing/App.config +++ b/ReactiveUI.Winforms.Samples.Routing/App.config @@ -1,14 +1,14 @@ - + - + - - + + - \ No newline at end of file + diff --git a/ReactiveUI.Winforms.Samples.Routing/Bootstrapper.cs b/ReactiveUI.Winforms.Samples.Routing/Bootstrapper.cs index 1789f30..b684c2c 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Bootstrapper.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Bootstrapper.cs @@ -1,15 +1,15 @@ -using ReactiveUI.Winforms.Samples.Routing.ViewModels; -using ReactiveUI.Winforms.Samples.Routing.Views; -using Splat; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Routing +namespace ReactiveUI.Winforms.Samples.Routing { - public class Bootstrapper + using ViewModels; + using Views; + using Splat; + using System.Windows.Forms; + + public class Bootstrapper { public Bootstrapper() { - ConfigureServices(); + this.ConfigureServices(); } private void ConfigureServices() diff --git a/ReactiveUI.Winforms.Samples.Routing/Program.cs b/ReactiveUI.Winforms.Samples.Routing/Program.cs index 1a3a6d6..88b53f3 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Program.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Program.cs @@ -1,12 +1,12 @@ -using System; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Routing +namespace ReactiveUI.Winforms.Samples.Routing { - static class Program + using System; + using System.Windows.Forms; + + public static class Program { [STAThread] - static void Main() + public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/ReactiveUI.Winforms.Samples.Routing/Properties/Resources.Designer.cs b/ReactiveUI.Winforms.Samples.Routing/Properties/Resources.Designer.cs index 1ed45a8..3dce100 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Properties/Resources.Designer.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,13 +13,13 @@ namespace ReactiveUI.Winforms.Samples.Routing.Properties { /// - /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert - // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. - // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -33,7 +33,7 @@ internal Resources() { } /// - /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal Resources() { } /// - /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { diff --git a/ReactiveUI.Winforms.Samples.Routing/Properties/Settings.Designer.cs b/ReactiveUI.Winforms.Samples.Routing/Properties/Settings.Designer.cs index 9cd50e7..ff56b7f 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Properties/Settings.Designer.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Properties/Settings.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -12,7 +12,7 @@ namespace ReactiveUI.Winforms.Samples.Routing.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.6.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/ReactiveUI.Winforms.Samples.Routing/ReactiveUI.Winforms.Samples.Routing.csproj b/ReactiveUI.Winforms.Samples.Routing/ReactiveUI.Winforms.Samples.Routing.csproj index c30f786..64f9c54 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ReactiveUI.Winforms.Samples.Routing.csproj +++ b/ReactiveUI.Winforms.Samples.Routing/ReactiveUI.Winforms.Samples.Routing.csproj @@ -8,9 +8,10 @@ WinExe ReactiveUI.Winforms.Samples.Routing ReactiveUI.Winforms.Samples.Routing - v4.6.1 + v4.8 512 true + AnyCPU @@ -37,36 +38,9 @@ - - ..\packages\ReactiveUI.8.0.1\lib\net461\ReactiveUI.dll - - - ..\packages\ReactiveUI.WinForms.8.0.1\lib\net461\ReactiveUI.Winforms.dll - - - ..\packages\Splat.4.0.0\lib\net461\Splat.dll - - - ..\packages\System.Drawing.Primitives.4.3.0\lib\net45\System.Drawing.Primitives.dll - - - ..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll - - - ..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll - - - ..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll - - - ..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll - - - ..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll - @@ -127,7 +101,6 @@ ShellView.cs - SettingsSingleFileGenerator Settings.Designer.cs @@ -141,5 +114,10 @@ + + + 13.2.2 + + \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/ViewModels/AboutViewModel.cs b/ReactiveUI.Winforms.Samples.Routing/ViewModels/AboutViewModel.cs index 01302f1..110617f 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ViewModels/AboutViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Routing/ViewModels/AboutViewModel.cs @@ -1,21 +1,21 @@ namespace ReactiveUI.Winforms.Samples.Routing.ViewModels { - public class AboutViewModel : ReactiveObject, IRoutableViewModel + + using System; + + public class AboutViewModel : ReactiveObject, IRoutableViewModel { - private string _viewTitle; + private String _viewTitle; - public AboutViewModel() - { - ViewTitle = "About View"; - } + public AboutViewModel() => this.ViewTitle = "About View"; - public string ViewTitle + public String ViewTitle { - get => _viewTitle; - set => this.RaiseAndSetIfChanged(ref _viewTitle, value); + get => this._viewTitle; + set => this.RaiseAndSetIfChanged(ref this._viewTitle, value); } public IScreen HostScreen { get; protected set; } - public string UrlPathSegment { get; protected set; } + public String UrlPathSegment { get; protected set; } } } diff --git a/ReactiveUI.Winforms.Samples.Routing/ViewModels/ContactViewModel.cs b/ReactiveUI.Winforms.Samples.Routing/ViewModels/ContactViewModel.cs index 15fd167..2123a2b 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ViewModels/ContactViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Routing/ViewModels/ContactViewModel.cs @@ -1,21 +1,21 @@ namespace ReactiveUI.Winforms.Samples.Routing.ViewModels { - public class ContactViewModel : ReactiveObject, IRoutableViewModel + + using System; + + public class ContactViewModel : ReactiveObject, IRoutableViewModel { - private string _viewTitle; + private String _viewTitle; - public ContactViewModel() - { - ViewTitle = "Contact View"; - } + public ContactViewModel() => this.ViewTitle = "Contact View"; - public string ViewTitle + public String ViewTitle { - get => _viewTitle; - set => this.RaiseAndSetIfChanged(ref _viewTitle, value); + get => this._viewTitle; + set => this.RaiseAndSetIfChanged(ref this._viewTitle, value); } public IScreen HostScreen { get; protected set; } - public string UrlPathSegment { get; protected set; } + public String UrlPathSegment { get; protected set; } } } diff --git a/ReactiveUI.Winforms.Samples.Routing/ViewModels/HomeViewModel.cs b/ReactiveUI.Winforms.Samples.Routing/ViewModels/HomeViewModel.cs index 27ad9ca..e32f15c 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ViewModels/HomeViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Routing/ViewModels/HomeViewModel.cs @@ -1,21 +1,21 @@ namespace ReactiveUI.Winforms.Samples.Routing.ViewModels { - public class HomeViewModel : ReactiveObject, IRoutableViewModel + + using System; + + public class HomeViewModel : ReactiveObject, IRoutableViewModel { - private string _viewTitle; + private String _viewTitle; - public HomeViewModel() - { - ViewTitle = "Home View"; - } + public HomeViewModel() => this.ViewTitle = "Home View"; - public string ViewTitle + public String ViewTitle { - get => _viewTitle; - set => this.RaiseAndSetIfChanged(ref _viewTitle, value); + get => this._viewTitle; + set => this.RaiseAndSetIfChanged(ref this._viewTitle, value); } public IScreen HostScreen { get; protected set; } - public string UrlPathSegment { get; protected set; } + public String UrlPathSegment { get; protected set; } } } diff --git a/ReactiveUI.Winforms.Samples.Routing/ViewModels/ShellViewModel.cs b/ReactiveUI.Winforms.Samples.Routing/ViewModels/ShellViewModel.cs index c47bf32..34a2cda 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ViewModels/ShellViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Routing/ViewModels/ShellViewModel.cs @@ -1,24 +1,25 @@ -using System; - -namespace ReactiveUI.Winforms.Samples.Routing.ViewModels +namespace ReactiveUI.Winforms.Samples.Routing.ViewModels { - public class ShellViewModel : ReactiveObject, IScreen + using System; + using System.Reactive; + + public class ShellViewModel : ReactiveObject, IScreen { - private string _applicationTitle; + private String _applicationTitle; public ShellViewModel() { // Create router for IScreen - Router = new RoutingState(); + this.Router = new RoutingState(); // Set properties - ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Routing"; + this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Routing"; // Create commands - ShowHomeCommand = ReactiveCommand.Create(ShowHome); - ShowAboutCommand = ReactiveCommand.Create(ShowAbout); - ShowContactCommand = ReactiveCommand.Create(ShowContact); - GoBackCommand = ReactiveCommand.Create(GoBack, Router.NavigateBack.CanExecute); + this.ShowHomeCommand = ReactiveCommand.Create( this.ShowHome); + this.ShowAboutCommand = ReactiveCommand.Create( this.ShowAbout); + this.ShowContactCommand = ReactiveCommand.Create( this.ShowContact); + this.GoBackCommand = ReactiveCommand.Create( this.GoBack, this.Router.NavigateBack.CanExecute); // Navigate to HomeViewModel and reset NavigationStack (shows HomeView at application start) - Router + var _ = this.Router .NavigateAndReset .Execute(new HomeViewModel()) .Subscribe(); @@ -26,21 +27,21 @@ public ShellViewModel() public RoutingState Router { get; } - public string ApplicationTitle + public String ApplicationTitle { - get => _applicationTitle; - set => this.RaiseAndSetIfChanged(ref _applicationTitle, value); + get => this._applicationTitle; + set => this.RaiseAndSetIfChanged(ref this._applicationTitle, value); } - public ReactiveCommand ShowHomeCommand { get; } - public ReactiveCommand ShowAboutCommand { get; } - public ReactiveCommand ShowContactCommand { get; } - public ReactiveCommand GoBackCommand { get; } + public ReactiveCommand ShowHomeCommand { get; } + public ReactiveCommand ShowAboutCommand { get; } + public ReactiveCommand ShowContactCommand { get; } + public ReactiveCommand GoBackCommand { get; } private void ShowHome() { // Navigate to HomeViewModel - Router + var _ = this.Router .Navigate .Execute(new HomeViewModel()) .Subscribe(); @@ -49,31 +50,31 @@ private void ShowHome() private void ShowAbout() { // Navigate to AboutViewModel - Router - .Navigate - .Execute(new AboutViewModel()) - .Subscribe(); + var _ = this.Router + .Navigate + .Execute(new AboutViewModel()) + .Subscribe(); } private void ShowContact() { // Navigate to ContactViewModel - Router - .Navigate - .Execute(new ContactViewModel()) - .Subscribe(); + var _ = this.Router + .Navigate + .Execute(new ContactViewModel()) + .Subscribe(); } private void GoBack() { // Navigate back in NavigationStack // Note: You have to check the count to prevent an ArgumentOutOfRangeException or navigate to empty - if (Router.NavigationStack.Count > 0) + if ( this.Router.NavigationStack.Count > 0) { - Router - .NavigateBack - .Execute() - .Subscribe(); + var _ = this.Router + .NavigateBack + .Execute() + .Subscribe(); } } } diff --git a/ReactiveUI.Winforms.Samples.Routing/Views/AboutView.cs b/ReactiveUI.Winforms.Samples.Routing/Views/AboutView.cs index ed6c230..bd276f8 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Views/AboutView.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Views/AboutView.cs @@ -1,26 +1,25 @@ -using ReactiveUI.Winforms.Samples.Routing.ViewModels; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Routing.Views +namespace ReactiveUI.Winforms.Samples.Routing.Views { - public partial class AboutView : UserControl, IViewFor + using ViewModels; + using System.Windows.Forms; + + using System; + + public partial class AboutView : UserControl, IViewFor { public AboutView() { - InitializeComponent(); + this.InitializeComponent(); - this.WhenActivated(d => - { - d(this.OneWayBind(ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)); - }); + var _ = this.WhenActivated(d => d?.Invoke(this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)) ); } public AboutViewModel ViewModel { get; set; } - object IViewFor.ViewModel + Object IViewFor.ViewModel { - get => ViewModel; - set => ViewModel = (AboutViewModel)value; + get => this.ViewModel; + set => this.ViewModel = (AboutViewModel)value; } } } diff --git a/ReactiveUI.Winforms.Samples.Routing/Views/ContactView.cs b/ReactiveUI.Winforms.Samples.Routing/Views/ContactView.cs index 10f05f2..9eda0ac 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Views/ContactView.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Views/ContactView.cs @@ -1,26 +1,25 @@ -using ReactiveUI.Winforms.Samples.Routing.ViewModels; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Routing.Views +namespace ReactiveUI.Winforms.Samples.Routing.Views { - public partial class ContactView : UserControl, IViewFor + using ViewModels; + using System.Windows.Forms; + + using System; + + public partial class ContactView : UserControl, IViewFor { public ContactView() { - InitializeComponent(); + this.InitializeComponent(); - this.WhenActivated(d => - { - d(this.OneWayBind(ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)); - }); + var _ = this.WhenActivated(d => d?.Invoke(this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)) ); } public ContactViewModel ViewModel { get; set; } - object IViewFor.ViewModel + Object IViewFor.ViewModel { - get => ViewModel; - set => ViewModel = (ContactViewModel)value; + get => this.ViewModel; + set => this.ViewModel = (ContactViewModel)value; } } } diff --git a/ReactiveUI.Winforms.Samples.Routing/Views/HomeView.cs b/ReactiveUI.Winforms.Samples.Routing/Views/HomeView.cs index 925b476..f8199d3 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Views/HomeView.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Views/HomeView.cs @@ -1,26 +1,25 @@ -using ReactiveUI.Winforms.Samples.Routing.ViewModels; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Routing.Views +namespace ReactiveUI.Winforms.Samples.Routing.Views { - public partial class HomeView : UserControl, IViewFor + using ViewModels; + using System.Windows.Forms; + + using System; + + public partial class HomeView : UserControl, IViewFor { public HomeView() { - InitializeComponent(); + this.InitializeComponent(); - this.WhenActivated(d => - { - d(this.OneWayBind(ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)); - }); + var _ = this.WhenActivated(d => d?.Invoke(this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)) ); } public HomeViewModel ViewModel { get; set; } - object IViewFor.ViewModel + Object IViewFor.ViewModel { - get => ViewModel; - set => ViewModel = (HomeViewModel)value; + get => this.ViewModel; + set => this.ViewModel = (HomeViewModel)value; } } } diff --git a/ReactiveUI.Winforms.Samples.Routing/Views/ShellView.cs b/ReactiveUI.Winforms.Samples.Routing/Views/ShellView.cs index e8aa332..b2bd82c 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Views/ShellView.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Views/ShellView.cs @@ -1,9 +1,11 @@ -using ReactiveUI.Winforms.Samples.Routing.ViewModels; -using System.Windows.Forms; - -namespace ReactiveUI.Winforms.Samples.Routing.Views +namespace ReactiveUI.Winforms.Samples.Routing.Views { - public partial class ShellView : Form, IViewFor + using ViewModels; + using System.Windows.Forms; + + using System; + + public partial class ShellView : Form, IViewFor { /* * To see the RoutedControlHost in the Designer you have to create it manually in the ShellView.Designer.cs @@ -36,30 +38,30 @@ public partial class ShellView : Form, IViewFor public ShellView() { - InitializeComponent(); + this.InitializeComponent(); this.WhenActivated(b => { // Bind router - b(this.OneWayBind(ViewModel, vm => vm.Router, v => v.routedControlHost.Router)); + b(this.OneWayBind( this.ViewModel, vm => vm.Router, v => v.routedControlHost.Router)); // Bind properties - b(this.OneWayBind(ViewModel, vm => vm.ApplicationTitle, v => v.Text)); + b(this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text)); // Bind commands - b(this.BindCommand(ViewModel, vm => vm.ShowHomeCommand, v => v.btHome)); - b(this.BindCommand(ViewModel, vm => vm.ShowAboutCommand, v => v.btAbout)); - b(this.BindCommand(ViewModel, vm => vm.ShowContactCommand, v => v.btContact)); - b(this.BindCommand(ViewModel, vm => vm.GoBackCommand, v => v.btGoBack)); + b(this.BindCommand( this.ViewModel, vm => vm.ShowHomeCommand, v => v.btHome)); + b(this.BindCommand( this.ViewModel, vm => vm.ShowAboutCommand, v => v.btAbout)); + b(this.BindCommand( this.ViewModel, vm => vm.ShowContactCommand, v => v.btContact)); + b(this.BindCommand( this.ViewModel, vm => vm.GoBackCommand, v => v.btGoBack)); }); } public ShellViewModel ViewModel { get; set; } - object IViewFor.ViewModel + Object IViewFor.ViewModel { - get => ViewModel; - set => ViewModel = (ShellViewModel)value; + get => this.ViewModel; + set => this.ViewModel = (ShellViewModel)value; } } } diff --git a/ReactiveUI.Winforms.Samples.Routing/packages.config b/ReactiveUI.Winforms.Samples.Routing/packages.config deleted file mode 100644 index 60139cd..0000000 --- a/ReactiveUI.Winforms.Samples.Routing/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file From 09786d648a1ead90028c4b8abf504276abdd29d5 Mon Sep 17 00:00:00 2001 From: Protiguous Date: Mon, 15 Mar 2021 06:30:20 -0600 Subject: [PATCH 2/3] Tweaked a few more things. --- .../App.config | 25 +-- .../Program.cs | 29 ++-- .../Properties/AssemblyInfo.cs | 25 ++- ...eactiveUI.Winforms.Samples.Bindings.csproj | 30 ++++ .../ViewModels/MainViewModel.cs | 73 +++++---- .../Views/MainView.cs | 81 +++++----- .../App.config | 25 +-- .../Program.cs | 29 ++-- .../Properties/AssemblyInfo.cs | 25 ++- ...eactiveUI.Winforms.Samples.Commands.csproj | 1 + .../ViewModels/MainViewModel.cs | 93 ++++++----- .../Views/MainView.cs | 85 +++++----- .../App.config | 25 +-- .../Bootstrapper.cs | 71 ++++---- .../Program.cs | 31 ++-- .../Properties/AssemblyInfo.cs | 25 ++- ...ReactiveUI.Winforms.Samples.Routing.csproj | 1 + .../ViewModels/AboutViewModel.cs | 32 ++-- .../ViewModels/ContactViewModel.cs | 32 ++-- .../ViewModels/HomeViewModel.cs | 32 ++-- .../ViewModels/ShellViewModel.cs | 152 +++++++++--------- .../Views/AboutView.cs | 44 ++--- .../Views/ContactView.cs | 38 ++--- .../Views/HomeView.cs | 38 ++--- .../Views/ShellView.cs | 83 +++++----- 25 files changed, 597 insertions(+), 528 deletions(-) diff --git a/ReactiveUI.Winforms.Samples.Bindings/App.config b/ReactiveUI.Winforms.Samples.Bindings/App.config index 8441b75..60bd416 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/App.config +++ b/ReactiveUI.Winforms.Samples.Bindings/App.config @@ -1,14 +1,15 @@ + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Bindings/Program.cs b/ReactiveUI.Winforms.Samples.Bindings/Program.cs index bfaafa3..28b6db7 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/Program.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/Program.cs @@ -1,17 +1,18 @@ -namespace ReactiveUI.Winforms.Samples.Bindings -{ - using Views; +namespace ReactiveUI.Winforms.Samples.Bindings { + using System; using System.Windows.Forms; + using Views; + + public static class Program { + + [STAThread] + public static void Main() { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault( false ); + Application.Run( new MainView() ); + } + + } - public static class Program - { - [STAThread] - public static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new MainView()); - } - } -} +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Bindings/Properties/AssemblyInfo.cs b/ReactiveUI.Winforms.Samples.Bindings/Properties/AssemblyInfo.cs index e97a69f..ab21c9a 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/Properties/AssemblyInfo.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/Properties/AssemblyInfo.cs @@ -1,17 +1,14 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("ReactiveUI.Winforms.Samples.Bindings")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ReactiveUI.Winforms.Samples")] -[assembly: AssemblyCopyright("Copyright © Asesjix 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("e72f085f-4227-4563-a3ad-07a630239df5")] - -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyTitle( "ReactiveUI.Winforms.Samples.Bindings" )] +[assembly: AssemblyDescription( "" )] +[assembly: AssemblyConfiguration( "" )] +[assembly: AssemblyCompany( "" )] +[assembly: AssemblyProduct( "ReactiveUI.Winforms.Samples" )] +[assembly: AssemblyCopyright( "Copyright © Asesjix 2018" )] +[assembly: AssemblyTrademark( "" )] +[assembly: AssemblyCulture( "" )] +[assembly: ComVisible( false )] +[assembly: Guid( "e72f085f-4227-4563-a3ad-07a630239df5" )] +[assembly: AssemblyVersion( "1.0.0.0" )] \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Bindings/ReactiveUI.Winforms.Samples.Bindings.csproj b/ReactiveUI.Winforms.Samples.Bindings/ReactiveUI.Winforms.Samples.Bindings.csproj index 7b9ede1..9ffb256 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/ReactiveUI.Winforms.Samples.Bindings.csproj +++ b/ReactiveUI.Winforms.Samples.Bindings/ReactiveUI.Winforms.Samples.Bindings.csproj @@ -12,6 +12,21 @@ 512 true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -22,6 +37,9 @@ DEBUG;TRACE prompt 4 + MinimumRecommendedRules.ruleset + false + false AnyCPU @@ -89,5 +107,17 @@ 13.2.2 + + + False + Microsoft .NET Framework 4.8 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Bindings/ViewModels/MainViewModel.cs b/ReactiveUI.Winforms.Samples.Bindings/ViewModels/MainViewModel.cs index c50edff..03d0f0d 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/ViewModels/MainViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/ViewModels/MainViewModel.cs @@ -1,37 +1,40 @@ -namespace ReactiveUI.Winforms.Samples.Bindings.ViewModels -{ +namespace ReactiveUI.Winforms.Samples.Bindings.ViewModels { + using System; - public class MainViewModel : ReactiveObject - { - private String _applicationTitle; - private String _valueOne; - private Int64 _valueTwo; - - public MainViewModel() - { - // Set properties - this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Bindings"; - this.ValueOne = "Type somthing"; - this.ValueTwo = DateTime.Now.Date.ToFileTime(); - } - - public String ApplicationTitle - { - get => this._applicationTitle; - set => this.RaiseAndSetIfChanged(ref this._applicationTitle, value); - } - - public String ValueOne - { - get => this._valueOne; - set => this.RaiseAndSetIfChanged(ref this._valueOne, value); - } - - public Int64 ValueTwo - { - get => this._valueTwo; - set => this.RaiseAndSetIfChanged(ref this._valueTwo, value); - } - } -} + public class MainViewModel : ReactiveObject { + + private String _applicationTitle; + + private String _valueOne; + + private Int64 _valueTwo; + + public MainViewModel() { + // Set properties + this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Bindings"; + this.ValueOne = "Type somthing"; + this.ValueTwo = DateTime.Now.Date.ToFileTime(); + } + + public String ApplicationTitle { + get => this._applicationTitle; + + set => this.RaiseAndSetIfChanged( ref this._applicationTitle, value ); + } + + public String ValueOne { + get => this._valueOne; + + set => this.RaiseAndSetIfChanged( ref this._valueOne, value ); + } + + public Int64 ValueTwo { + get => this._valueTwo; + + set => this.RaiseAndSetIfChanged( ref this._valueTwo, value ); + } + + } + +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Bindings/Views/MainView.cs b/ReactiveUI.Winforms.Samples.Bindings/Views/MainView.cs index 964a6fd..988b8ba 100644 --- a/ReactiveUI.Winforms.Samples.Bindings/Views/MainView.cs +++ b/ReactiveUI.Winforms.Samples.Bindings/Views/MainView.cs @@ -1,41 +1,46 @@ -namespace ReactiveUI.Winforms.Samples.Bindings.Views -{ - using ViewModels; +namespace ReactiveUI.Winforms.Samples.Bindings.Views { + using System; using System.Windows.Forms; + using ViewModels; + + public partial class MainView : Form, IViewFor { + + public MainView() { + this.InitializeComponent(); + + var _ = this.WhenActivated( d => { + if ( d is null ) { + return; + } + + if ( this.ViewModel is null ) { + return; + } + + // One way bind from viewmodel to view + d( this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text ) ); + + // Two way bind for input (textbox) and one way bind for output (label) + d( this.Bind( this.ViewModel, vm => vm.ValueOne, v => v.tbInputOne.Text ) ); + d( this.OneWayBind( this.ViewModel, vm => vm.ValueOne, v => v.lOutputOne.Text ) ); + + // Two way bind for input (textbox) with convert and one way bind for output (label) + d( this.Bind( this.ViewModel, vm => vm.ValueTwo, v => v.dtpInputTwo.Value, DateTime.FromFileTime, dt => dt.ToFileTime() ) ); + d( this.OneWayBind( this.ViewModel, vm => vm.ValueTwo, v => v.lOutputTwo.Text ) ); + } ); + + this.ViewModel = new MainViewModel(); + } + + public MainViewModel ViewModel { get; set; } + + Object IViewFor.ViewModel { + get => this.ViewModel; + + set => this.ViewModel = ( MainViewModel ) value; + } + + } - public partial class MainView : Form, IViewFor - { - public MainView() - { - this.InitializeComponent(); - - var _ = this.WhenActivated(d => { - if ( d is null ) { - return; - } - - // One way bind from viewmodel to view - d( this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text ) ); - - // Two way bind for input (textbox) and one way bind for output (label) - d( this.Bind( this.ViewModel, vm => vm.ValueOne, v => v.tbInputOne.Text ) ); - d( this.OneWayBind( this.ViewModel, vm => vm.ValueOne, v => v.lOutputOne.Text ) ); - - // Two way bind for input (textbox) with convert and one way bind for output (label) - d( this.Bind( this.ViewModel, vm => vm.ValueTwo, v => v.dtpInputTwo.Value, DateTime.FromFileTime, dt => dt.ToFileTime() ) ); - d( this.OneWayBind( this.ViewModel, vm => vm.ValueTwo, v => v.lOutputTwo.Text ) ); - }); - - this.ViewModel = new MainViewModel(); - } - - public MainViewModel ViewModel { get; set; } - - Object IViewFor.ViewModel - { - get => this.ViewModel; - set => this.ViewModel = (MainViewModel)value; - } - } -} +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Commands/App.config b/ReactiveUI.Winforms.Samples.Commands/App.config index 8441b75..60bd416 100644 --- a/ReactiveUI.Winforms.Samples.Commands/App.config +++ b/ReactiveUI.Winforms.Samples.Commands/App.config @@ -1,14 +1,15 @@ + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Commands/Program.cs b/ReactiveUI.Winforms.Samples.Commands/Program.cs index 73bc5f2..1a7009d 100644 --- a/ReactiveUI.Winforms.Samples.Commands/Program.cs +++ b/ReactiveUI.Winforms.Samples.Commands/Program.cs @@ -1,17 +1,18 @@ -namespace ReactiveUI.Winforms.Samples.Commands -{ - using Views; +namespace ReactiveUI.Winforms.Samples.Commands { + using System; using System.Windows.Forms; + using Views; + + public static class Program { + + [STAThread] + public static void Main() { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault( false ); + Application.Run( new MainView() ); + } + + } - public static class Program - { - [STAThread] - public static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new MainView()); - } - } -} +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Commands/Properties/AssemblyInfo.cs b/ReactiveUI.Winforms.Samples.Commands/Properties/AssemblyInfo.cs index fd31ad5..6f7d32d 100644 --- a/ReactiveUI.Winforms.Samples.Commands/Properties/AssemblyInfo.cs +++ b/ReactiveUI.Winforms.Samples.Commands/Properties/AssemblyInfo.cs @@ -1,17 +1,14 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("ReactiveUI.Winforms.Samples.Commands")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ReactiveUI.Winforms.Samples")] -[assembly: AssemblyCopyright("Copyright © Asesjix 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("e72f085f-4227-4563-a3ad-07a630239df5")] - -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyTitle( "ReactiveUI.Winforms.Samples.Commands" )] +[assembly: AssemblyDescription( "" )] +[assembly: AssemblyConfiguration( "" )] +[assembly: AssemblyCompany( "" )] +[assembly: AssemblyProduct( "ReactiveUI.Winforms.Samples" )] +[assembly: AssemblyCopyright( "Copyright © Asesjix 2018" )] +[assembly: AssemblyTrademark( "" )] +[assembly: AssemblyCulture( "" )] +[assembly: ComVisible( false )] +[assembly: Guid( "e72f085f-4227-4563-a3ad-07a630239df5" )] +[assembly: AssemblyVersion( "1.0.0.0" )] \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj b/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj index a604f3c..a2098b3 100644 --- a/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj +++ b/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj @@ -22,6 +22,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU diff --git a/ReactiveUI.Winforms.Samples.Commands/ViewModels/MainViewModel.cs b/ReactiveUI.Winforms.Samples.Commands/ViewModels/MainViewModel.cs index 92597b0..f94d6e2 100644 --- a/ReactiveUI.Winforms.Samples.Commands/ViewModels/MainViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Commands/ViewModels/MainViewModel.cs @@ -1,50 +1,55 @@ -namespace ReactiveUI.Winforms.Samples.Commands.ViewModels -{ +namespace ReactiveUI.Winforms.Samples.Commands.ViewModels { using System; using System.Reactive; using System.Reactive.Linq; using System.Windows; - public class MainViewModel : ReactiveObject - { - private String _applicationTitle; - private String _withCanExecuteParameter; - - public MainViewModel() - { - // Set properties - this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Commands"; - // Create parameterless command - this.ParameterlessCommand = ReactiveCommand.Create( this.Parameterless); - // Create command with parameter - this.WithParameterCommand = ReactiveCommand.Create( this.WithParameter); - // Create command with can execute - this.WithCanExecuteCommand = ReactiveCommand.Create( this.WithCanExecute, - this.WhenAnyValue(vm => vm.WithCanExecuteParameter).Select(s => String.IsNullOrEmpty(s) == false)); - } - - public String ApplicationTitle - { - get => this._applicationTitle; - set => this.RaiseAndSetIfChanged(ref this._applicationTitle, value); - } - - public String WithCanExecuteParameter - { - get => this._withCanExecuteParameter; - set => this.RaiseAndSetIfChanged(ref this._withCanExecuteParameter, value); - } - - public ReactiveCommand ParameterlessCommand { get; } - public ReactiveCommand WithParameterCommand { get; } - public ReactiveCommand WithCanExecuteCommand { get; } - - private void Parameterless() => MessageBox.Show("You pressed the button!", this.ApplicationTitle, MessageBoxButton.OK); - - private void WithParameter(String message) => MessageBox.Show(message, this.ApplicationTitle, MessageBoxButton.OK); - - private void WithCanExecute() => MessageBox.Show( this.WithCanExecuteParameter, this.ApplicationTitle, MessageBoxButton.OK); - - } -} + public class MainViewModel : ReactiveObject { + + private String _applicationTitle; + + private String _withCanExecuteParameter; + + public MainViewModel() { + // Set properties + this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Commands"; + + // Create parameterless command + this.ParameterlessCommand = ReactiveCommand.Create( this.Parameterless ); + + // Create command with parameter + this.WithParameterCommand = ReactiveCommand.Create( this.WithParameter ); + + // Create command with can execute + this.WithCanExecuteCommand = ReactiveCommand.Create( this.WithCanExecute, + this.WhenAnyValue( vm => vm.WithCanExecuteParameter )?.Select( s => String.IsNullOrEmpty( s ) == false ) ); + } + + public String ApplicationTitle { + get => this._applicationTitle; + + set => this.RaiseAndSetIfChanged( ref this._applicationTitle, value ); + } + + public String WithCanExecuteParameter { + get => this._withCanExecuteParameter; + + set => this.RaiseAndSetIfChanged( ref this._withCanExecuteParameter, value ); + } + + public ReactiveCommand ParameterlessCommand { get; } + + public ReactiveCommand WithParameterCommand { get; } + + public ReactiveCommand WithCanExecuteCommand { get; } + + private void Parameterless() => MessageBox.Show( "You pressed the button!", this.ApplicationTitle, MessageBoxButton.OK ); + + private void WithParameter( String message ) => MessageBox.Show( message, this.ApplicationTitle, MessageBoxButton.OK ); + + private void WithCanExecute() => MessageBox.Show( this.WithCanExecuteParameter, this.ApplicationTitle, MessageBoxButton.OK ); + + } + +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Commands/Views/MainView.cs b/ReactiveUI.Winforms.Samples.Commands/Views/MainView.cs index be23bf3..5b7e766 100644 --- a/ReactiveUI.Winforms.Samples.Commands/Views/MainView.cs +++ b/ReactiveUI.Winforms.Samples.Commands/Views/MainView.cs @@ -1,40 +1,53 @@ -namespace ReactiveUI.Winforms.Samples.Commands.Views -{ +namespace ReactiveUI.Winforms.Samples.Commands.Views { using System; - using ViewModels; using System.Windows.Forms; + using ViewModels; + + public partial class MainView : Form, IViewFor { + + public MainView() { + this.InitializeComponent(); + + var _ = this.WhenActivated( d => { + if ( d is null ) { + return; + } + + if ( this.ViewModel is null ) { + return; + } + + // Bind properties + d( this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text ) ); + + // Bind property for command with can execute + d( this.Bind( this.ViewModel, vm => vm.WithCanExecuteParameter, v => v.tbWithCanExecuteParameter.Text ) ); + + // Bind parameterless command + d( this.BindCommand( this.ViewModel, vm => vm.ParameterlessCommand, v => v.btParameterless ) ); + + // Bind command with parameter + var anyValue = this.WhenAnyValue( v => v.tbParameter.Text ); + if ( anyValue != null ) { + d( this.BindCommand( this.ViewModel, vm => vm.WithParameterCommand, v => v.btWithParameter, anyValue ) ); + } + + // Bind command with can execute + d( this.BindCommand( this.ViewModel, vm => vm.WithCanExecuteCommand, v => v.btWithCanExecute ) ); + } ); + + this.ViewModel = new MainViewModel(); + } + + public MainViewModel ViewModel { get; set; } + + Object IViewFor.ViewModel { + get => this.ViewModel; + + set => this.ViewModel = ( MainViewModel ) value; + } + + } - public partial class MainView : Form, IViewFor - { - public MainView() - { - this.InitializeComponent(); - - this.WhenActivated(d => - { - // Bind properties - d(this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text)); - // Bind property for command with can execute - d(this.Bind( this.ViewModel, vm => vm.WithCanExecuteParameter, v => v.tbWithCanExecuteParameter.Text)); - - // Bind parameterless command - d(this.BindCommand( this.ViewModel, vm => vm.ParameterlessCommand, v => v.btParameterless)); - // Bind command with parameter - d(this.BindCommand( this.ViewModel, vm => vm.WithParameterCommand, v => v.btWithParameter, this.WhenAnyValue(v => v.tbParameter.Text))); - // Bind command with can execute - d(this.BindCommand( this.ViewModel, vm => vm.WithCanExecuteCommand, v => v.btWithCanExecute)); - }); - - this.ViewModel = new MainViewModel(); - } - - public MainViewModel ViewModel { get; set; } - - Object IViewFor.ViewModel - { - get => this.ViewModel; - set => this.ViewModel = (MainViewModel)value; - } - } -} +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/App.config b/ReactiveUI.Winforms.Samples.Routing/App.config index 8441b75..60bd416 100644 --- a/ReactiveUI.Winforms.Samples.Routing/App.config +++ b/ReactiveUI.Winforms.Samples.Routing/App.config @@ -1,14 +1,15 @@ + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/Bootstrapper.cs b/ReactiveUI.Winforms.Samples.Routing/Bootstrapper.cs index b684c2c..57b5003 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Bootstrapper.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Bootstrapper.cs @@ -1,36 +1,41 @@ -namespace ReactiveUI.Winforms.Samples.Routing -{ +namespace ReactiveUI.Winforms.Samples.Routing { + + using System.Windows.Forms; + using Splat; using ViewModels; using Views; - using Splat; - using System.Windows.Forms; - public class Bootstrapper - { - public Bootstrapper() - { - this.ConfigureServices(); - } - - private void ConfigureServices() - { - // Register views - Locator.CurrentMutable.Register(() => new ShellView(), typeof(IViewFor)); - Locator.CurrentMutable.Register(() => new HomeView(), typeof(IViewFor)); - Locator.CurrentMutable.Register(() => new AboutView(), typeof(IViewFor)); - Locator.CurrentMutable.Register(() => new ContactView(), typeof(IViewFor)); - } - - public void Run() - { - // Create ShellViewModel and register as IScreen - var viewModel = new ShellViewModel(); - Locator.CurrentMutable.RegisterConstant(viewModel, typeof(IScreen)); - // Resolve view for ShellViewModel - var view = ViewLocator.Current.ResolveView(viewModel); - view.ViewModel = viewModel; - // Run application - Application.Run((Form)view); - } - } -} + public class Bootstrapper { + + public Bootstrapper() => this.ConfigureServices(); + + private void ConfigureServices() { + // Register views + if ( Locator.CurrentMutable is null ) { + return; + } + + Locator.CurrentMutable.Register( () => new ShellView(), typeof( IViewFor ) ); + Locator.CurrentMutable.Register( () => new HomeView(), typeof( IViewFor ) ); + Locator.CurrentMutable.Register( () => new AboutView(), typeof( IViewFor ) ); + Locator.CurrentMutable.Register( () => new ContactView(), typeof( IViewFor ) ); + } + + public void Run() { + // Create ShellViewModel and register as IScreen + var viewModel = new ShellViewModel(); + Locator.CurrentMutable.RegisterConstant( viewModel, typeof( IScreen ) ); + + // Resolve view for ShellViewModel + var view = ViewLocator.Current.ResolveView( viewModel ); + if ( view != null ) { + view.ViewModel = viewModel; + + // Run application + Application.Run( ( Form ) view ); + } + } + + } + +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/Program.cs b/ReactiveUI.Winforms.Samples.Routing/Program.cs index 88b53f3..bd113e8 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Program.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Program.cs @@ -1,19 +1,20 @@ -namespace ReactiveUI.Winforms.Samples.Routing -{ +namespace ReactiveUI.Winforms.Samples.Routing { + using System; using System.Windows.Forms; - public static class Program - { - [STAThread] - public static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + public static class Program { + + [STAThread] + public static void Main() { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault( false ); + + // Create and run Bootstrapper + var bootstrapper = new Bootstrapper(); + bootstrapper.Run(); + } + + } - // Create and run Bootstrapper - var bootstrapper = new Bootstrapper(); - bootstrapper.Run(); - } - } -} +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/Properties/AssemblyInfo.cs b/ReactiveUI.Winforms.Samples.Routing/Properties/AssemblyInfo.cs index 05803e4..7d00772 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Properties/AssemblyInfo.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Properties/AssemblyInfo.cs @@ -1,17 +1,14 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("ReactiveUI.Winforms.Samples.Routing")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ReactiveUI.Winforms.Samples")] -[assembly: AssemblyCopyright("Copyright © Asesjix 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("e72f085f-4227-4563-a3ad-07a630239df5")] - -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyTitle( "ReactiveUI.Winforms.Samples.Routing" )] +[assembly: AssemblyDescription( "" )] +[assembly: AssemblyConfiguration( "" )] +[assembly: AssemblyCompany( "" )] +[assembly: AssemblyProduct( "ReactiveUI.Winforms.Samples" )] +[assembly: AssemblyCopyright( "Copyright © Asesjix 2018" )] +[assembly: AssemblyTrademark( "" )] +[assembly: AssemblyCulture( "" )] +[assembly: ComVisible( false )] +[assembly: Guid( "e72f085f-4227-4563-a3ad-07a630239df5" )] +[assembly: AssemblyVersion( "1.0.0.0" )] \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/ReactiveUI.Winforms.Samples.Routing.csproj b/ReactiveUI.Winforms.Samples.Routing/ReactiveUI.Winforms.Samples.Routing.csproj index 64f9c54..6998292 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ReactiveUI.Winforms.Samples.Routing.csproj +++ b/ReactiveUI.Winforms.Samples.Routing/ReactiveUI.Winforms.Samples.Routing.csproj @@ -22,6 +22,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU diff --git a/ReactiveUI.Winforms.Samples.Routing/ViewModels/AboutViewModel.cs b/ReactiveUI.Winforms.Samples.Routing/ViewModels/AboutViewModel.cs index 110617f..5dc68f2 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ViewModels/AboutViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Routing/ViewModels/AboutViewModel.cs @@ -1,21 +1,23 @@ -namespace ReactiveUI.Winforms.Samples.Routing.ViewModels -{ +namespace ReactiveUI.Winforms.Samples.Routing.ViewModels { using System; - public class AboutViewModel : ReactiveObject, IRoutableViewModel - { - private String _viewTitle; + public class AboutViewModel : ReactiveObject, IRoutableViewModel { - public AboutViewModel() => this.ViewTitle = "About View"; + private String _viewTitle; - public String ViewTitle - { - get => this._viewTitle; - set => this.RaiseAndSetIfChanged(ref this._viewTitle, value); - } + public AboutViewModel() => this.ViewTitle = "About View"; - public IScreen HostScreen { get; protected set; } - public String UrlPathSegment { get; protected set; } - } -} + public String ViewTitle { + get => this._viewTitle; + + set => this.RaiseAndSetIfChanged( ref this._viewTitle, value ); + } + + public IScreen HostScreen { get; protected set; } + + public String UrlPathSegment { get; protected set; } + + } + +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/ViewModels/ContactViewModel.cs b/ReactiveUI.Winforms.Samples.Routing/ViewModels/ContactViewModel.cs index 2123a2b..548c152 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ViewModels/ContactViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Routing/ViewModels/ContactViewModel.cs @@ -1,21 +1,23 @@ -namespace ReactiveUI.Winforms.Samples.Routing.ViewModels -{ +namespace ReactiveUI.Winforms.Samples.Routing.ViewModels { using System; - public class ContactViewModel : ReactiveObject, IRoutableViewModel - { - private String _viewTitle; + public class ContactViewModel : ReactiveObject, IRoutableViewModel { - public ContactViewModel() => this.ViewTitle = "Contact View"; + private String _viewTitle; - public String ViewTitle - { - get => this._viewTitle; - set => this.RaiseAndSetIfChanged(ref this._viewTitle, value); - } + public ContactViewModel() => this.ViewTitle = "Contact View"; - public IScreen HostScreen { get; protected set; } - public String UrlPathSegment { get; protected set; } - } -} + public String ViewTitle { + get => this._viewTitle; + + set => this.RaiseAndSetIfChanged( ref this._viewTitle, value ); + } + + public IScreen HostScreen { get; protected set; } + + public String UrlPathSegment { get; protected set; } + + } + +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/ViewModels/HomeViewModel.cs b/ReactiveUI.Winforms.Samples.Routing/ViewModels/HomeViewModel.cs index e32f15c..6fac99c 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ViewModels/HomeViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Routing/ViewModels/HomeViewModel.cs @@ -1,21 +1,23 @@ -namespace ReactiveUI.Winforms.Samples.Routing.ViewModels -{ +namespace ReactiveUI.Winforms.Samples.Routing.ViewModels { using System; - public class HomeViewModel : ReactiveObject, IRoutableViewModel - { - private String _viewTitle; + public class HomeViewModel : ReactiveObject, IRoutableViewModel { - public HomeViewModel() => this.ViewTitle = "Home View"; + private String _viewTitle; - public String ViewTitle - { - get => this._viewTitle; - set => this.RaiseAndSetIfChanged(ref this._viewTitle, value); - } + public HomeViewModel() => this.ViewTitle = "Home View"; - public IScreen HostScreen { get; protected set; } - public String UrlPathSegment { get; protected set; } - } -} + public String ViewTitle { + get => this._viewTitle; + + set => this.RaiseAndSetIfChanged( ref this._viewTitle, value ); + } + + public IScreen HostScreen { get; protected set; } + + public String UrlPathSegment { get; protected set; } + + } + +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/ViewModels/ShellViewModel.cs b/ReactiveUI.Winforms.Samples.Routing/ViewModels/ShellViewModel.cs index 34a2cda..809125a 100644 --- a/ReactiveUI.Winforms.Samples.Routing/ViewModels/ShellViewModel.cs +++ b/ReactiveUI.Winforms.Samples.Routing/ViewModels/ShellViewModel.cs @@ -1,81 +1,77 @@ -namespace ReactiveUI.Winforms.Samples.Routing.ViewModels -{ +namespace ReactiveUI.Winforms.Samples.Routing.ViewModels { + using System; using System.Reactive; - public class ShellViewModel : ReactiveObject, IScreen - { - private String _applicationTitle; - - public ShellViewModel() - { - // Create router for IScreen - this.Router = new RoutingState(); - // Set properties - this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Routing"; - // Create commands - this.ShowHomeCommand = ReactiveCommand.Create( this.ShowHome); - this.ShowAboutCommand = ReactiveCommand.Create( this.ShowAbout); - this.ShowContactCommand = ReactiveCommand.Create( this.ShowContact); - this.GoBackCommand = ReactiveCommand.Create( this.GoBack, this.Router.NavigateBack.CanExecute); - // Navigate to HomeViewModel and reset NavigationStack (shows HomeView at application start) - var _ = this.Router - .NavigateAndReset - .Execute(new HomeViewModel()) - .Subscribe(); - } - - public RoutingState Router { get; } - - public String ApplicationTitle - { - get => this._applicationTitle; - set => this.RaiseAndSetIfChanged(ref this._applicationTitle, value); - } - - public ReactiveCommand ShowHomeCommand { get; } - public ReactiveCommand ShowAboutCommand { get; } - public ReactiveCommand ShowContactCommand { get; } - public ReactiveCommand GoBackCommand { get; } - - private void ShowHome() - { - // Navigate to HomeViewModel - var _ = this.Router - .Navigate - .Execute(new HomeViewModel()) - .Subscribe(); - } - - private void ShowAbout() - { - // Navigate to AboutViewModel - var _ = this.Router - .Navigate - .Execute(new AboutViewModel()) - .Subscribe(); - } - - private void ShowContact() - { - // Navigate to ContactViewModel - var _ = this.Router - .Navigate - .Execute(new ContactViewModel()) - .Subscribe(); - } - - private void GoBack() - { - // Navigate back in NavigationStack - // Note: You have to check the count to prevent an ArgumentOutOfRangeException or navigate to empty - if ( this.Router.NavigationStack.Count > 0) - { - var _ = this.Router - .NavigateBack - .Execute() - .Subscribe(); - } - } - } -} + public class ShellViewModel : ReactiveObject, IScreen { + + private String _applicationTitle; + + public ShellViewModel() { + // Create router for IScreen + this.Router = new RoutingState(); + + // Set properties + this.ApplicationTitle = "ReactiveUI Winforms Samples by Asesjix - Routing"; + + // Create commands + this.ShowHomeCommand = ReactiveCommand.Create( this.ShowHome ); + this.ShowAboutCommand = ReactiveCommand.Create( this.ShowAbout ); + this.ShowContactCommand = ReactiveCommand.Create( this.ShowContact ); + this.GoBackCommand = ReactiveCommand.Create( this.GoBack, this.Router?.NavigateBack.CanExecute ); + + // Navigate to HomeViewModel and reset NavigationStack (shows HomeView at application start) + var _ = this.Router?.NavigateAndReset.Execute( new HomeViewModel() ).Subscribe(); + } + + public String ApplicationTitle { + get => this._applicationTitle; + + set => this.RaiseAndSetIfChanged( ref this._applicationTitle, value ); + } + + public ReactiveCommand ShowHomeCommand { get; } + + public ReactiveCommand ShowAboutCommand { get; } + + public ReactiveCommand ShowContactCommand { get; } + + public ReactiveCommand GoBackCommand { get; } + + public RoutingState Router { get; } + + /// + /// Navigate to HomeViewModel + /// + private void ShowHome() { + var _ = this.Router?.Navigate.Execute( new HomeViewModel() ).Subscribe(); + } + + /// + /// Navigate to AboutViewModel + /// + private void ShowAbout() { + var _ = this.Router?.Navigate.Execute( new AboutViewModel() ).Subscribe(); + } + + /// + /// Navigate to ContactViewModel + /// + private void ShowContact() { + var _ = this.Router?.Navigate.Execute( new ContactViewModel() ).Subscribe(); + } + + /// + /// Navigate back in NavigationStack + /// + private void GoBack() { + // Note: You have to check the count to prevent an ArgumentOutOfRangeException or navigate to empty + var router = this.Router; + if ( router?.NavigationStack.Count > 0 ) { + var _ = router.NavigateBack.Execute().Subscribe(); + } + } + + } + +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/Views/AboutView.cs b/ReactiveUI.Winforms.Samples.Routing/Views/AboutView.cs index bd276f8..ee28259 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Views/AboutView.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Views/AboutView.cs @@ -1,25 +1,25 @@ -namespace ReactiveUI.Winforms.Samples.Routing.Views -{ - using ViewModels; - using System.Windows.Forms; +namespace ReactiveUI.Winforms.Samples.Routing.Views { using System; + using System.Windows.Forms; + using ViewModels; + + public partial class AboutView : UserControl, IViewFor { + + public AboutView() { + this.InitializeComponent(); + + var _ = this.WhenActivated( d => d?.Invoke( this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text ) ) ); + } + + public AboutViewModel ViewModel { get; set; } + + Object IViewFor.ViewModel { + get => this.ViewModel; + + set => this.ViewModel = ( AboutViewModel ) value; + } + + } - public partial class AboutView : UserControl, IViewFor - { - public AboutView() - { - this.InitializeComponent(); - - var _ = this.WhenActivated(d => d?.Invoke(this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)) ); - } - - public AboutViewModel ViewModel { get; set; } - - Object IViewFor.ViewModel - { - get => this.ViewModel; - set => this.ViewModel = (AboutViewModel)value; - } - } -} +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/Views/ContactView.cs b/ReactiveUI.Winforms.Samples.Routing/Views/ContactView.cs index 9eda0ac..c2b9504 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Views/ContactView.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Views/ContactView.cs @@ -1,25 +1,25 @@ -namespace ReactiveUI.Winforms.Samples.Routing.Views -{ - using ViewModels; - using System.Windows.Forms; +namespace ReactiveUI.Winforms.Samples.Routing.Views { using System; + using System.Windows.Forms; + using ViewModels; + + public partial class ContactView : UserControl, IViewFor { + + public ContactView() { + this.InitializeComponent(); + + var _ = this.WhenActivated( d => d?.Invoke( this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text ) ) ); + } + + public ContactViewModel ViewModel { get; set; } - public partial class ContactView : UserControl, IViewFor - { - public ContactView() - { - this.InitializeComponent(); + Object IViewFor.ViewModel { + get => this.ViewModel; - var _ = this.WhenActivated(d => d?.Invoke(this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)) ); - } + set => this.ViewModel = ( ContactViewModel ) value; + } - public ContactViewModel ViewModel { get; set; } + } - Object IViewFor.ViewModel - { - get => this.ViewModel; - set => this.ViewModel = (ContactViewModel)value; - } - } -} +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/Views/HomeView.cs b/ReactiveUI.Winforms.Samples.Routing/Views/HomeView.cs index f8199d3..46c29cc 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Views/HomeView.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Views/HomeView.cs @@ -1,25 +1,25 @@ -namespace ReactiveUI.Winforms.Samples.Routing.Views -{ - using ViewModels; - using System.Windows.Forms; +namespace ReactiveUI.Winforms.Samples.Routing.Views { using System; + using System.Windows.Forms; + using ViewModels; + + public partial class HomeView : UserControl, IViewFor { + + public HomeView() { + this.InitializeComponent(); + + var _ = this.WhenActivated( d => d?.Invoke( this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text ) ) ); + } + + public HomeViewModel ViewModel { get; set; } - public partial class HomeView : UserControl, IViewFor - { - public HomeView() - { - this.InitializeComponent(); + Object IViewFor.ViewModel { + get => this.ViewModel; - var _ = this.WhenActivated(d => d?.Invoke(this.OneWayBind( this.ViewModel, vm => vm.ViewTitle, v => v.lViewTitle.Text)) ); - } + set => this.ViewModel = ( HomeViewModel ) value; + } - public HomeViewModel ViewModel { get; set; } + } - Object IViewFor.ViewModel - { - get => this.ViewModel; - set => this.ViewModel = (HomeViewModel)value; - } - } -} +} \ No newline at end of file diff --git a/ReactiveUI.Winforms.Samples.Routing/Views/ShellView.cs b/ReactiveUI.Winforms.Samples.Routing/Views/ShellView.cs index b2bd82c..5bc0995 100644 --- a/ReactiveUI.Winforms.Samples.Routing/Views/ShellView.cs +++ b/ReactiveUI.Winforms.Samples.Routing/Views/ShellView.cs @@ -1,22 +1,21 @@ -namespace ReactiveUI.Winforms.Samples.Routing.Views -{ - using ViewModels; - using System.Windows.Forms; +namespace ReactiveUI.Winforms.Samples.Routing.Views { using System; + using System.Windows.Forms; + using ViewModels; - public partial class ShellView : Form, IViewFor - { - /* + public partial class ShellView : Form, IViewFor { + + /* * To see the RoutedControlHost in the Designer you have to create it manually in the ShellView.Designer.cs - * + * * private void InitializeComponent() * { * this.routedControlHost = new ReactiveUI.Winforms.RoutedControlHost(); * ... - * // + * // * // routedControlHost - * // + * // * this.routedControlHost.DefaultContent = null; * this.routedControlHost.Location = new System.Drawing.Point(3, 55); * this.routedControlHost.Name = "routedControlHost"; @@ -25,43 +24,51 @@ public partial class ShellView : Form, IViewFor * this.routedControlHost.TabIndex = 4; * this.routedControlHost.ViewLocator = null; * ... - * // + * // * // ShellView * // * ... * this.Controls.Add(this.routedControlHost); * } - * + * * private RoutedControlHost routedControlHost; - * + * */ - public ShellView() - { - this.InitializeComponent(); + public ShellView() { + this.InitializeComponent(); + + var _ = this.WhenActivated( action => { + if ( action is null ) { + return; + } + + if ( this.ViewModel is null ) { + return; + } + + // Bind router + action( this.OneWayBind( this.ViewModel, vm => vm.Router, v => v.routedControlHost.Router ) ); + + // Bind properties + action( this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text ) ); + + // Bind commands + action( this.BindCommand( this.ViewModel, vm => vm.ShowHomeCommand, v => v.btHome ) ); + action( this.BindCommand( this.ViewModel, vm => vm.ShowAboutCommand, v => v.btAbout ) ); + action( this.BindCommand( this.ViewModel, vm => vm.ShowContactCommand, v => v.btContact ) ); + action( this.BindCommand( this.ViewModel, vm => vm.GoBackCommand, v => v.btGoBack ) ); + } ); + } + + public ShellViewModel ViewModel { get; set; } - this.WhenActivated(b => - { - // Bind router - b(this.OneWayBind( this.ViewModel, vm => vm.Router, v => v.routedControlHost.Router)); + Object IViewFor.ViewModel { + get => this.ViewModel; - // Bind properties - b(this.OneWayBind( this.ViewModel, vm => vm.ApplicationTitle, v => v.Text)); + set => this.ViewModel = ( ShellViewModel ) value; + } - // Bind commands - b(this.BindCommand( this.ViewModel, vm => vm.ShowHomeCommand, v => v.btHome)); - b(this.BindCommand( this.ViewModel, vm => vm.ShowAboutCommand, v => v.btAbout)); - b(this.BindCommand( this.ViewModel, vm => vm.ShowContactCommand, v => v.btContact)); - b(this.BindCommand( this.ViewModel, vm => vm.GoBackCommand, v => v.btGoBack)); - }); - } - - public ShellViewModel ViewModel { get; set; } + } - Object IViewFor.ViewModel - { - get => this.ViewModel; - set => this.ViewModel = (ShellViewModel)value; - } - } -} +} \ No newline at end of file From 437eedc16d658156b952246c34420339c947df3d Mon Sep 17 00:00:00 2001 From: Protiguous Date: Mon, 15 Mar 2021 09:05:36 -0600 Subject: [PATCH 3/3] Updated gitignore. --- .gitignore | 309 ++++++++++++++++-- ...eactiveUI.Winforms.Samples.Commands.csproj | 4 +- 2 files changed, 288 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 3c4efe2..5718aef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,172 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/jetbrains,visualstudio,rider,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=jetbrains,visualstudio,rider,visualstudiocode + +### JetBrains ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### JetBrains Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Rider ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff + +# Sensitive or high-churn files + +# Gradle + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake + +# Mongo Explorer plugin + +# File-based project format + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +# Editor-based Rest Client + +# Android studio 3.1+ serialized cache file + +### VisualStudioCode ### +.vscode/* +!.vscode/tasks.json +!.vscode/launch.json +*.code-workspace + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### VisualStudio ### ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files +*.rsuser *.suo *.user *.userosscache @@ -10,6 +175,9 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# Mono auto generated files +mono_crash.* + # Build results [Dd]ebug/ [Dd]ebugPublic/ @@ -17,42 +185,60 @@ [Rr]eleases/ x64/ x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ +[Ll]ogs/ -# Visual Studio 2015 cache/options directory +# Generated files + +# Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ +# Visual Studio 2017 auto generated files +Generated\ Files/ + # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -# NUNIT +# NUnit *.VisualState.xml TestResult.xml +nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c -# DNX +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core project.lock.json project.fragment.lock.json artifacts/ +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio *_i.c *_p.c -*_i.h +*_h.h *.ilk *.meta *.obj +*.iobj *.pch *.pdb +*.ipdb *.pgc *.pgd *.rsp @@ -62,6 +248,7 @@ artifacts/ *.tlh *.tmp *.tmp_proj +*_wpftmp.csproj *.log *.vspscc *.vssscc @@ -90,6 +277,9 @@ ipch/ *.vspx *.sap +# Visual Studio Trace Files +*.e2e + # TFS 2012 Local Workspace $tf/ @@ -101,15 +291,23 @@ _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user -# JustCode is a .NET coding add-in -.JustCode - # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*[.json, .xml, .info] + +# Visual Studio code coverage results +*.coverage +*.coveragexml + # NCrunch _NCrunch_* .*crunch*.local.xml @@ -141,9 +339,9 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings +# Note: Comment the next line if you want to checkin your web deploy settings, # but database connection strings (with potential passwords) will be unencrypted -#*.pubxml +*.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to @@ -153,13 +351,15 @@ PublishScripts/ # NuGet Packages *.nupkg +# NuGet Symbol Packages +*.snupkg # The packages folder can be ignored because of Package Restore -**/packages/* +**/[Pp]ackages/* # except build/, which is used as an MSBuild target. -!**/packages/build/ +!**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignoreable files +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets @@ -176,12 +376,15 @@ AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt +*.appx +*.appxbundle +*.appxupload # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache -!*.[Cc]ache/ +!?*.[Cc]ache/ # Others ClientBin/ @@ -192,9 +395,12 @@ ClientBin/ *.jfm *.pfx *.publishsettings -node_modules/ orleans.codegen.cs +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ @@ -209,15 +415,22 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak # SQL Server files *.mdf *.ldf +*.ndf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ @@ -227,6 +440,7 @@ FakesAssemblies/ # Node.js Tools for Visual Studio .ntvs_analysis.dat +node_modules/ # Visual Studio 6 build log *.plg @@ -234,6 +448,9 @@ FakesAssemblies/ # Visual Studio 6 workspace options file *.opt +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts @@ -249,13 +466,61 @@ paket-files/ # FAKE - F# Make .fake/ -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ +# CodeRush personal settings +.cr/personal # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc \ No newline at end of file +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# End of https://www.toptal.com/developers/gitignore/api/jetbrains,visualstudio,rider,visualstudiocode +Librainian/obj/x64/Debug/net5.0-windows/Librainian.AssemblyInfo.cs +Librainian/obj/x64/Debug/net5.0-windows/Librainian.AssemblyInfoInputs.cache +Librainian/obj/x64/Debug/net5.0-windows/Librainian.csproj.CoreCompileInputs.cache +Librainian/obj/x64/Debug/net5.0-windows/Librainian.csprojAssemblyReference.cache +Librainian/obj/x64/Release/net5.0-windows/Librainian.AssemblyInfo.cs +Librainian/obj/x64/Release/net5.0-windows/Librainian.AssemblyInfoInputs.cache +Librainian/obj/x64/Release/net5.0-windows/Librainian.csprojAssemblyReference.cache diff --git a/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj b/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj index a2098b3..96b8ac6 100644 --- a/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj +++ b/ReactiveUI.Winforms.Samples.Commands/ReactiveUI.Winforms.Samples.Commands.csproj @@ -70,6 +70,7 @@ MainView.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -80,9 +81,6 @@ True - - - 13.2.2