diff options
Diffstat (limited to 'JVDesktop')
| -rw-r--r-- | JVDesktop/App.axaml | 17 | ||||
| -rw-r--r-- | JVDesktop/App.axaml.cs | 11 | ||||
| -rw-r--r-- | JVDesktop/JVDesktop.csproj | 37 | ||||
| -rw-r--r-- | JVDesktop/Program.cs | 6 | ||||
| -rw-r--r-- | JVDesktop/ViewLocator.cs | 2 | ||||
| -rw-r--r-- | JVDesktop/ViewModels/DashboardViewModel.cs (renamed from JVDesktop/ViewModels/MainWindowViewModel.cs) | 10 | ||||
| -rw-r--r-- | JVDesktop/ViewModels/ViewModel.cs | 7 | ||||
| -rw-r--r-- | JVDesktop/ViewModels/ViewModelBase.cs | 7 | ||||
| -rw-r--r-- | JVDesktop/Views/DashboardView.axaml | 63 | ||||
| -rw-r--r-- | JVDesktop/Views/DashboardView.axaml.cs | 15 | ||||
| -rw-r--r-- | JVDesktop/Views/MainWindow.axaml | 23 | ||||
| -rw-r--r-- | JVDesktop/Views/MainWindow.axaml.cs | 11 | ||||
| -rw-r--r-- | JVDesktop/app.manifest | 4 |
13 files changed, 132 insertions, 81 deletions
diff --git a/JVDesktop/App.axaml b/JVDesktop/App.axaml index 4d268d0..1bebd8d 100644 --- a/JVDesktop/App.axaml +++ b/JVDesktop/App.axaml @@ -1,15 +1,16 @@ -<Application xmlns="https://github.com/avaloniaui" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - x:Class="JVDesktop.App" - xmlns:local="using:JVDesktop" - RequestedThemeVariant="Default"> - <!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. --> +<Application + xmlns="https://github.com/avaloniaui" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + x:Class="JVDesktop.App" + xmlns:local="using:JVDesktop" + RequestedThemeVariant="Default" +> <Application.DataTemplates> - <local:ViewLocator/> + <local:ViewLocator /> </Application.DataTemplates> <Application.Styles> - <FluentTheme /> + <SimpleTheme /> </Application.Styles> </Application> diff --git a/JVDesktop/App.axaml.cs b/JVDesktop/App.axaml.cs index 4c26724..a2ba079 100644 --- a/JVDesktop/App.axaml.cs +++ b/JVDesktop/App.axaml.cs @@ -1,11 +1,10 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Data.Core; using Avalonia.Data.Core.Plugins; using System.Linq; using Avalonia.Markup.Xaml; -using JVDesktop.ViewModels; using JVDesktop.Views; +using JVDesktop.ViewModels; namespace JVDesktop; @@ -20,12 +19,10 @@ public partial class App : Application { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - // Avoid duplicate validations from both Avalonia and the CommunityToolkit. - // More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins DisableAvaloniaDataAnnotationValidation(); - desktop.MainWindow = new MainWindow + desktop.MainWindow = new DashboardView { - DataContext = new MainWindowViewModel(), + DataContext = new DashboardViewModel(), }; } @@ -34,11 +31,9 @@ public partial class App : Application private void DisableAvaloniaDataAnnotationValidation() { - // Get an array of plugins to remove var dataValidationPluginsToRemove = BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray(); - // remove each entry found foreach (var plugin in dataValidationPluginsToRemove) { BindingPlugins.DataValidators.Remove(plugin); diff --git a/JVDesktop/JVDesktop.csproj b/JVDesktop/JVDesktop.csproj index e103899..2940b03 100644 --- a/JVDesktop/JVDesktop.csproj +++ b/JVDesktop/JVDesktop.csproj @@ -5,24 +5,39 @@ <Nullable>enable</Nullable> <BuiltInComInteropSupport>true</BuiltInComInteropSupport> <ApplicationManifest>app.manifest</ApplicationManifest> - <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> + <AvaloniaUseCompiledBindingsByDefault + >true</AvaloniaUseCompiledBindingsByDefault> + <BaseOutputPath>..\.Temp\Debug\</BaseOutputPath> + <OutDir>$(OutputPath)</OutDir> + <AppendTargetFrameworkToOutputPath + >false</AppendTargetFrameworkToOutputPath> + <AppendRuntimeIdentifierToOutputPath + >false</AppendRuntimeIdentifierToOutputPath> </PropertyGroup> <ItemGroup> - <Folder Include="Models\"/> - <AvaloniaResource Include="Assets\**"/> + <Folder Include="Models\" /> + <AvaloniaResource Include="Assets\**" /> </ItemGroup> <ItemGroup> - <PackageReference Include="Avalonia" Version="11.3.4"/> - <PackageReference Include="Avalonia.Desktop" Version="11.3.4"/> - <PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.4"/> - <PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.4"/> - <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> + <PackageReference Include="Avalonia" Version="11.3.4" /> + <PackageReference Include="Avalonia.Desktop" Version="11.3.4" /> + <PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.4" /> <PackageReference Include="Avalonia.Diagnostics" Version="11.3.4"> - <IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets> - <PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets> + <IncludeAssets + Condition="'$(Configuration)' != 'Debug'" + >None</IncludeAssets> + <PrivateAssets + Condition="'$(Configuration)' != 'Debug'" + >All</PrivateAssets> </PackageReference> - <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1"/> + <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference + Include="..\CommandLineWrapper\CommandLineWrapper.csproj" + /> </ItemGroup> </Project> diff --git a/JVDesktop/Program.cs b/JVDesktop/Program.cs index 8d39a63..850598c 100644 --- a/JVDesktop/Program.cs +++ b/JVDesktop/Program.cs @@ -1,18 +1,14 @@ -using Avalonia; +using Avalonia; using System; namespace JVDesktop; sealed 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<App>() .UsePlatformDetect() diff --git a/JVDesktop/ViewLocator.cs b/JVDesktop/ViewLocator.cs index 6015998..57507a5 100644 --- a/JVDesktop/ViewLocator.cs +++ b/JVDesktop/ViewLocator.cs @@ -25,6 +25,6 @@ public class ViewLocator : IDataTemplate public bool Match(object? data) { - return data is ViewModelBase; + return data is ViewModel; } } diff --git a/JVDesktop/ViewModels/MainWindowViewModel.cs b/JVDesktop/ViewModels/DashboardViewModel.cs index 4dd12b4..5ae7d95 100644 --- a/JVDesktop/ViewModels/MainWindowViewModel.cs +++ b/JVDesktop/ViewModels/DashboardViewModel.cs @@ -1,15 +1,15 @@ -using System; -using System.Windows.Input; +using System; using CommunityToolkit.Mvvm.Input; namespace JVDesktop.ViewModels; -public class MainWindowViewModel : ViewModelBase +public partial class DashboardViewModel : ViewModel { public string Greeting => "Welcome to Avalonia!"; - public ICommand ButtonClickCommand { get; } = new RelayCommand(() => + [RelayCommand] + private void ButtonClick() { Console.WriteLine("Button clicked"); - }); + } } diff --git a/JVDesktop/ViewModels/ViewModel.cs b/JVDesktop/ViewModels/ViewModel.cs new file mode 100644 index 0000000..c1c5055 --- /dev/null +++ b/JVDesktop/ViewModels/ViewModel.cs @@ -0,0 +1,7 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace JVDesktop.ViewModels; + +public class ViewModel : ObservableObject +{ +} diff --git a/JVDesktop/ViewModels/ViewModelBase.cs b/JVDesktop/ViewModels/ViewModelBase.cs deleted file mode 100644 index bd3dbd8..0000000 --- a/JVDesktop/ViewModels/ViewModelBase.cs +++ /dev/null @@ -1,7 +0,0 @@ -using CommunityToolkit.Mvvm.ComponentModel; - -namespace JVDesktop.ViewModels; - -public class ViewModelBase : ObservableObject -{ -} diff --git a/JVDesktop/Views/DashboardView.axaml b/JVDesktop/Views/DashboardView.axaml new file mode 100644 index 0000000..553754f --- /dev/null +++ b/JVDesktop/Views/DashboardView.axaml @@ -0,0 +1,63 @@ +<Window + xmlns="https://github.com/avaloniaui" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:vm="using:JVDesktop.ViewModels" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="d" + d:DesignWidth="800" + d:DesignHeight="550" + x:Class="JVDesktop.Views.DashboardView" + x:DataType="vm:DashboardViewModel" + Icon="/Assets/avalonia-logo.ico" + Title="JVDesktop" + Width="800" + Height="550" + MinWidth="550" + MinHeight="400" + WindowStartupLocation="CenterScreen" + ExtendClientAreaToDecorationsHint="True" +> + + <Design.DataContext> + <vm:DashboardViewModel /> + </Design.DataContext> + + <Grid RowDefinitions="65,*,32"> + + <!-- Header --> + <Border Grid.Row="0" Background="#424242" PointerPressed="MoveWindow"> + <TextBlock + Text="Header" + HorizontalAlignment="Center" + VerticalAlignment="Center" + /> + </Border> + + <!-- Content --> + <Border Grid.Row="1" Background="Black"> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock + Text="{Binding Greeting}" + HorizontalAlignment="Center" + VerticalAlignment="Center" + /> + <Button + Content="Click" + Command="{Binding ButtonClickCommand}" + Margin="0,10,0,0" + /> + </StackPanel> + </Border> + + <!-- Footer --> + <Border Grid.Row="2" Background="#424242"> + <TextBlock + Text="Footer" + HorizontalAlignment="Center" + VerticalAlignment="Center" + /> + </Border> + </Grid> + +</Window> diff --git a/JVDesktop/Views/DashboardView.axaml.cs b/JVDesktop/Views/DashboardView.axaml.cs new file mode 100644 index 0000000..ae58263 --- /dev/null +++ b/JVDesktop/Views/DashboardView.axaml.cs @@ -0,0 +1,15 @@ +using Avalonia.Controls; +using Avalonia.Input; + +namespace JVDesktop.Views; + +public partial class DashboardView : Window +{ + public DashboardView() => InitializeComponent(); + + private void MoveWindow(object sender, PointerPressedEventArgs e) + { + if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) + BeginMoveDrag(e); + } +} diff --git a/JVDesktop/Views/MainWindow.axaml b/JVDesktop/Views/MainWindow.axaml deleted file mode 100644 index 13f20c4..0000000 --- a/JVDesktop/Views/MainWindow.axaml +++ /dev/null @@ -1,23 +0,0 @@ -<Window xmlns="https://github.com/avaloniaui" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:vm="using:JVDesktop.ViewModels" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="JVDesktop.Views.MainWindow" - x:DataType="vm:MainWindowViewModel" - Icon="/Assets/avalonia-logo.ico" - Title="JVDesktop"> - - <Design.DataContext> - <!-- This only sets the DataContext for the previewer in an IDE, - to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) --> - <vm:MainWindowViewModel/> - </Design.DataContext> - - <Grid> - <TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/> - <Button Content="Click" Command="{Binding ButtonClickCommand}"/> - </Grid> - -</Window> diff --git a/JVDesktop/Views/MainWindow.axaml.cs b/JVDesktop/Views/MainWindow.axaml.cs deleted file mode 100644 index 37f530e..0000000 --- a/JVDesktop/Views/MainWindow.axaml.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Avalonia.Controls; - -namespace JVDesktop.Views; - -public partial class MainWindow : Window -{ - public MainWindow() - { - InitializeComponent(); - } -}
\ No newline at end of file diff --git a/JVDesktop/app.manifest b/JVDesktop/app.manifest index 85ade99..25cb8eb 100644 --- a/JVDesktop/app.manifest +++ b/JVDesktop/app.manifest @@ -1,9 +1,9 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> <!-- This manifest is used on Windows only. Don't remove it as it might cause problems with window transparency and embedded controls. For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests --> - <assemblyIdentity version="1.0.0.0" name="JVDesktop.Desktop"/> + <assemblyIdentity version="1.0.0.0" name="JVDesktop.Desktop" /> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> |
