diff --git a/.gitignore b/.gitignore index dfcfd56..1626ee1 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,57 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ + + +################# +## Rider +################# +.idea + +################# +## VS Code +################# +.vscode/ + +################# +## Cake +################# +tools/* +!tools/packages.config +.nuget +artifacts/ +nuget +Avalonia.XBuild.sln +project.lock.json +.idea/* + + +################## +## BenchmarkDotNet +################## +BenchmarkDotNet.Artifacts/ + +dirs.sln + + +################## +# Xcode +################## +Index/ +Logs/ +ModuleCache.noindex/ +Build/Intermediates.noindex/ +build-intermediate +obj-Direct2D1/ +obj-Skia/ + +################## +# Vim +################## +.vim +coc-settings.json +.ccls-cache +.ccls +*.map +src/Web/Avalonia.Web.Blazor/wwwroot/*.js +src/Web/Avalonia.Web.Blazor/Interop/Typescript/*.js \ No newline at end of file diff --git a/Ursa.sln b/Ursa.sln new file mode 100644 index 0000000..cf9d8ce --- /dev/null +++ b/Ursa.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa", "src\Ursa\Ursa.csproj", "{14E5B6D1-E3ED-41D7-9664-37ABE3B22558}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.Demo", "demo\Ursa.Demo\Ursa.Demo.csproj", "{407A91FD-A88B-459B-8DCE-8C6AA98279FE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ursa.Themes.Semi", "src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj", "{53B5F277-3AEB-4661-ACAE-15CFFF2ED800}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {14E5B6D1-E3ED-41D7-9664-37ABE3B22558}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {14E5B6D1-E3ED-41D7-9664-37ABE3B22558}.Debug|Any CPU.Build.0 = Debug|Any CPU + {14E5B6D1-E3ED-41D7-9664-37ABE3B22558}.Release|Any CPU.ActiveCfg = Release|Any CPU + {14E5B6D1-E3ED-41D7-9664-37ABE3B22558}.Release|Any CPU.Build.0 = Release|Any CPU + {407A91FD-A88B-459B-8DCE-8C6AA98279FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {407A91FD-A88B-459B-8DCE-8C6AA98279FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {407A91FD-A88B-459B-8DCE-8C6AA98279FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {407A91FD-A88B-459B-8DCE-8C6AA98279FE}.Release|Any CPU.Build.0 = Release|Any CPU + {53B5F277-3AEB-4661-ACAE-15CFFF2ED800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {53B5F277-3AEB-4661-ACAE-15CFFF2ED800}.Debug|Any CPU.Build.0 = Debug|Any CPU + {53B5F277-3AEB-4661-ACAE-15CFFF2ED800}.Release|Any CPU.ActiveCfg = Release|Any CPU + {53B5F277-3AEB-4661-ACAE-15CFFF2ED800}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/demo/Ursa.Demo/App.axaml b/demo/Ursa.Demo/App.axaml new file mode 100644 index 0000000..004d33b --- /dev/null +++ b/demo/Ursa.Demo/App.axaml @@ -0,0 +1,9 @@ + + + + + diff --git a/demo/Ursa.Demo/App.axaml.cs b/demo/Ursa.Demo/App.axaml.cs new file mode 100644 index 0000000..990010b --- /dev/null +++ b/demo/Ursa.Demo/App.axaml.cs @@ -0,0 +1,33 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Data.Core; +using Avalonia.Data.Core.Plugins; +using Avalonia.Markup.Xaml; +using Ursa.Demo.ViewModels; +using Ursa.Demo.Views; + +namespace Ursa.Demo; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + // Line below is needed to remove Avalonia data validation. + // Without this line you will get duplicate validations from both Avalonia and CT + ExpressionObserver.DataValidators.RemoveAll(x => x is DataAnnotationsValidationPlugin); + desktop.MainWindow = new MainWindow + { + DataContext = new MainWindowViewModel(), + }; + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Assets/avalonia-logo.ico b/demo/Ursa.Demo/Assets/avalonia-logo.ico new file mode 100644 index 0000000..da8d49f Binary files /dev/null and b/demo/Ursa.Demo/Assets/avalonia-logo.ico differ diff --git a/demo/Ursa.Demo/Program.cs b/demo/Ursa.Demo/Program.cs new file mode 100644 index 0000000..66ec68f --- /dev/null +++ b/demo/Ursa.Demo/Program.cs @@ -0,0 +1,20 @@ +using Avalonia; +using System; + +namespace Ursa.Demo; + +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. + [STAThread] + 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(); +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Roots.xml b/demo/Ursa.Demo/Roots.xml new file mode 100644 index 0000000..43bb5f4 --- /dev/null +++ b/demo/Ursa.Demo/Roots.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/demo/Ursa.Demo/Ursa.Demo.csproj b/demo/Ursa.Demo/Ursa.Demo.csproj new file mode 100644 index 0000000..81079f9 --- /dev/null +++ b/demo/Ursa.Demo/Ursa.Demo.csproj @@ -0,0 +1,29 @@ + + + WinExe + net6.0 + enable + true + app.manifest + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/Ursa.Demo/ViewLocator.cs b/demo/Ursa.Demo/ViewLocator.cs new file mode 100644 index 0000000..2a2e3cf --- /dev/null +++ b/demo/Ursa.Demo/ViewLocator.cs @@ -0,0 +1,27 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Ursa.Demo.ViewModels; + +namespace Ursa.Demo; + +public class ViewLocator : IDataTemplate +{ + public IControl Build(object data) + { + var name = data.GetType().FullName!.Replace("ViewModel", "View"); + var type = Type.GetType(name); + + if (type != null) + { + return (Control)Activator.CreateInstance(type)!; + } + + return new TextBlock { Text = "Not Found: " + name }; + } + + public bool Match(object data) + { + return data is ViewModelBase; + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/MainWindowViewModel.cs b/demo/Ursa.Demo/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..9ac0155 --- /dev/null +++ b/demo/Ursa.Demo/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,6 @@ +namespace Ursa.Demo.ViewModels; + +public class MainWindowViewModel : ViewModelBase +{ + public string Greeting => "Welcome to Avalonia!"; +} \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/ViewModelBase.cs b/demo/Ursa.Demo/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..de083dd --- /dev/null +++ b/demo/Ursa.Demo/ViewModels/ViewModelBase.cs @@ -0,0 +1,7 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace Ursa.Demo.ViewModels; + +public class ViewModelBase : ObservableObject +{ +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Views/MainWindow.axaml b/demo/Ursa.Demo/Views/MainWindow.axaml new file mode 100644 index 0000000..d0ef4cb --- /dev/null +++ b/demo/Ursa.Demo/Views/MainWindow.axaml @@ -0,0 +1,26 @@ + + + + + + + + +