From ff685bb5d80a5d82432eba0c5c8f5665351fe7f8 Mon Sep 17 00:00:00 2001 From: Simon G Date: Tue, 6 Apr 2021 13:05:51 +0200 Subject: [PATCH] - add solution --- .idea/.idea.Mystify.dir/.idea/.gitignore | 13 ++ .idea/.idea.Mystify.dir/.idea/encodings.xml | 4 + .idea/.idea.Mystify.dir/.idea/indexLayout.xml | 8 ++ .idea/.idea.Mystify.dir/.idea/vcs.xml | 6 + .idea/.idea.Mystify/.idea/encodings.xml | 4 + .idea/.idea.Mystify/.idea/workspace.xml | 117 ++++++++++++++++++ Mystify.sln | 16 +++ Mystify/.gitignore | 8 ++ Mystify/App.axaml | 12 ++ Mystify/App.axaml.cs | 26 ++++ Mystify/Mystify.csproj | 20 +++ Mystify/Program.cs | 21 ++++ Mystify/ViewLocator.cs | 25 ++++ Mystify/ViewModels/MainWindowViewModel.cs | 11 ++ Mystify/ViewModels/ViewModelBase.cs | 22 ++++ Mystify/Views/MainWindow.axaml | 17 +++ Mystify/Views/MainWindow.axaml.cs | 19 +++ MystifyTempIcon.ico | Bin 0 -> 397 bytes 18 files changed, 349 insertions(+) create mode 100644 .idea/.idea.Mystify.dir/.idea/.gitignore create mode 100644 .idea/.idea.Mystify.dir/.idea/encodings.xml create mode 100644 .idea/.idea.Mystify.dir/.idea/indexLayout.xml create mode 100644 .idea/.idea.Mystify.dir/.idea/vcs.xml create mode 100644 .idea/.idea.Mystify/.idea/encodings.xml create mode 100644 .idea/.idea.Mystify/.idea/workspace.xml create mode 100644 Mystify.sln create mode 100644 Mystify/.gitignore create mode 100644 Mystify/App.axaml create mode 100644 Mystify/App.axaml.cs create mode 100644 Mystify/Mystify.csproj create mode 100644 Mystify/Program.cs create mode 100644 Mystify/ViewLocator.cs create mode 100644 Mystify/ViewModels/MainWindowViewModel.cs create mode 100644 Mystify/ViewModels/ViewModelBase.cs create mode 100644 Mystify/Views/MainWindow.axaml create mode 100644 Mystify/Views/MainWindow.axaml.cs create mode 100644 MystifyTempIcon.ico diff --git a/.idea/.idea.Mystify.dir/.idea/.gitignore b/.idea/.idea.Mystify.dir/.idea/.gitignore new file mode 100644 index 0000000..ab24303 --- /dev/null +++ b/.idea/.idea.Mystify.dir/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/.idea.Mystify.iml +/modules.xml +/contentModel.xml +/projectSettingsUpdater.xml +# Datasource local storage ignored files +/../../../../../../../:\Workspace\Testprojekte\Mystify\.idea\.idea.Mystify.dir\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.Mystify.dir/.idea/encodings.xml b/.idea/.idea.Mystify.dir/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.Mystify.dir/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.Mystify.dir/.idea/indexLayout.xml b/.idea/.idea.Mystify.dir/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.Mystify.dir/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Mystify.dir/.idea/vcs.xml b/.idea/.idea.Mystify.dir/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.Mystify.dir/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Mystify/.idea/encodings.xml b/.idea/.idea.Mystify/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.Mystify/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.Mystify/.idea/workspace.xml b/.idea/.idea.Mystify/.idea/workspace.xml new file mode 100644 index 0000000..4977869 --- /dev/null +++ b/.idea/.idea.Mystify/.idea/workspace.xml @@ -0,0 +1,117 @@ + + + + Mystify/Mystify.csproj + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1617702838043 + + + + + + + + + + + + + \ No newline at end of file diff --git a/Mystify.sln b/Mystify.sln new file mode 100644 index 0000000..41c639a --- /dev/null +++ b/Mystify.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mystify", "Mystify\Mystify.csproj", "{87373A7B-B012-4E47-A875-0F189DE731E7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {87373A7B-B012-4E47-A875-0F189DE731E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87373A7B-B012-4E47-A875-0F189DE731E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87373A7B-B012-4E47-A875-0F189DE731E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87373A7B-B012-4E47-A875-0F189DE731E7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Mystify/.gitignore b/Mystify/.gitignore new file mode 100644 index 0000000..a0d6a36 --- /dev/null +++ b/Mystify/.gitignore @@ -0,0 +1,8 @@ +.idea/ +.vscode/ +.vs/ + +bin/ +obj/ + +*.user \ No newline at end of file diff --git a/Mystify/App.axaml b/Mystify/App.axaml new file mode 100644 index 0000000..2ee6a9c --- /dev/null +++ b/Mystify/App.axaml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/Mystify/App.axaml.cs b/Mystify/App.axaml.cs new file mode 100644 index 0000000..c41cba2 --- /dev/null +++ b/Mystify/App.axaml.cs @@ -0,0 +1,26 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using Mystify.ViewModels; +using Mystify.Views; + +namespace Mystify +{ + public class App : Application + { + public override void Initialize() => AvaloniaXamlLoader.Load(this); + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow + { + DataContext = new MainWindowViewModel(), + }; + } + + base.OnFrameworkInitializationCompleted(); + } + } +} \ No newline at end of file diff --git a/Mystify/Mystify.csproj b/Mystify/Mystify.csproj new file mode 100644 index 0000000..eb317c5 --- /dev/null +++ b/Mystify/Mystify.csproj @@ -0,0 +1,20 @@ + + + WinExe + net5.0 + enable + + + + + + + + + + + + + + + diff --git a/Mystify/Program.cs b/Mystify/Program.cs new file mode 100644 index 0000000..7b3427d --- /dev/null +++ b/Mystify/Program.cs @@ -0,0 +1,21 @@ +using Avalonia; +using Avalonia.ReactiveUI; + +namespace Mystify +{ + class Program + { + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .LogToTrace() + .UseReactiveUI(); + } +} diff --git a/Mystify/ViewLocator.cs b/Mystify/ViewLocator.cs new file mode 100644 index 0000000..3b30d66 --- /dev/null +++ b/Mystify/ViewLocator.cs @@ -0,0 +1,25 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Mystify.ViewModels; + +namespace Mystify +{ + public class ViewLocator : IDataTemplate + { + public bool SupportsRecycling => false; + + public IControl Build(object data) + { + string name = data.GetType().FullName!.Replace("ViewModel", "View"); + Type? type = Type.GetType(name); + + if (type != null) + return (Control) Activator.CreateInstance(type)!; + + return new TextBlock { Text = "Not Found: " + name }; + } + + public bool Match(object data) => data is ViewModelBase; + } +} \ No newline at end of file diff --git a/Mystify/ViewModels/MainWindowViewModel.cs b/Mystify/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..209befc --- /dev/null +++ b/Mystify/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Mystify.ViewModels +{ + public class MainWindowViewModel : ViewModelBase + { + public string Greeting => "Welcome to Avalonia!"; + } +} diff --git a/Mystify/ViewModels/ViewModelBase.cs b/Mystify/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..a8f7322 --- /dev/null +++ b/Mystify/ViewModels/ViewModelBase.cs @@ -0,0 +1,22 @@ +using System; +using System.Linq.Expressions; +using System.Reflection; +using Avalonia.Controls; +using ReactiveUI; + +namespace Mystify.ViewModels +{ + public class ViewModelBase : ReactiveObject + { + protected bool IsInDesignMode => Design.IsDesignMode; + protected void RaisePropertyChanged(string propertyName) => ((IReactiveObject) this).RaisePropertyChanged(propertyName); + protected void RaisePropertyChanged(Expression> propertyExpression) + { + if (propertyExpression.Body is not MemberExpression body) + throw new ArgumentException("Invalid argument.", nameof(propertyExpression)); + + PropertyInfo propertyInfo = body.Member as PropertyInfo ?? throw new ArgumentException("Argument is not a property.", nameof(propertyExpression)); + ((IReactiveObject) this).RaisePropertyChanged(propertyInfo.Name); + } + } +} diff --git a/Mystify/Views/MainWindow.axaml b/Mystify/Views/MainWindow.axaml new file mode 100644 index 0000000..f37d5d9 --- /dev/null +++ b/Mystify/Views/MainWindow.axaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/Mystify/Views/MainWindow.axaml.cs b/Mystify/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..aaa4006 --- /dev/null +++ b/Mystify/Views/MainWindow.axaml.cs @@ -0,0 +1,19 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Mystify.Views +{ + public class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif + } + + private void InitializeComponent() => AvaloniaXamlLoader.Load(this); + } +} \ No newline at end of file diff --git a/MystifyTempIcon.ico b/MystifyTempIcon.ico new file mode 100644 index 0000000000000000000000000000000000000000..bd650fe83366ef253cafd2b378c57147d0540acd GIT binary patch literal 397 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmUKs7M+SzC{oH>NS%G|oWRD45dJguM!v-tY$DUh!@P+6=(yLU`z6LcLCBs@Y8vBJ&@uo z@Q5r1(g|SvA=~LZkkRky;uw-~@9lL*z6J#zm%yw&|EIn_)#}T$;^@YY``0EIiE(dX zWAHMwx^VZe!NoIE9+#hvj?WTfS|RAr%aE0QtvgBny{-J)&$dss9T>JwDV@={IUw{Y z^PG3gd-us5HML&--W@D+{!Zt6t$0SJ6-)23udCX1{>`cI28OIn^$M@wgzRHt2~cj3 zVq|!5-|XI013#PNHHUysQ!R0gC`m~yNwrEYN(E93Mg~TPx&|h?24*1!mR80lR)!YZ n1_o9J2A)%%#Gz=&%}>cptHiCr;$+Mtpaup{S3j3^P6