diff --git a/MusicDecrypto.Avalonia/App.axaml b/MusicDecrypto.Avalonia/App.axaml index d5054b1..96528ca 100644 --- a/MusicDecrypto.Avalonia/App.axaml +++ b/MusicDecrypto.Avalonia/App.axaml @@ -1,48 +1,64 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MusicDecrypto.Avalonia/Controls/MatchDialogContent.axaml b/MusicDecrypto.Avalonia/Controls/MatchDialogContent.axaml index 164f84c..8722a08 100644 --- a/MusicDecrypto.Avalonia/Controls/MatchDialogContent.axaml +++ b/MusicDecrypto.Avalonia/Controls/MatchDialogContent.axaml @@ -1,11 +1,12 @@ + d:DesignWidth="800" d:DesignHeight="450" + mc:Ignorable="d"> - + diff --git a/MusicDecrypto.Avalonia/Controls/MatchDialogContent.axaml.cs b/MusicDecrypto.Avalonia/Controls/MatchDialogContent.axaml.cs index 013cbca..d2a8106 100644 --- a/MusicDecrypto.Avalonia/Controls/MatchDialogContent.axaml.cs +++ b/MusicDecrypto.Avalonia/Controls/MatchDialogContent.axaml.cs @@ -9,9 +9,4 @@ public MatchDialogContent() { InitializeComponent(); } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } } diff --git a/MusicDecrypto.Avalonia/Controls/OptionsDisplayItem.axaml b/MusicDecrypto.Avalonia/Controls/OptionsDisplayItem.axaml deleted file mode 100644 index b53bc89..0000000 --- a/MusicDecrypto.Avalonia/Controls/OptionsDisplayItem.axaml +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/MusicDecrypto.Avalonia/Controls/OptionsDisplayItem.axaml.cs b/MusicDecrypto.Avalonia/Controls/OptionsDisplayItem.axaml.cs deleted file mode 100644 index dc2721c..0000000 --- a/MusicDecrypto.Avalonia/Controls/OptionsDisplayItem.axaml.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using System.Windows.Input; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.Primitives; -using Avalonia.Input; -using Avalonia.Interactivity; -using FluentIcons.FluentAvalonia; -using MusicDecrypto.Avalonia.Helpers; - -namespace MusicDecrypto.Avalonia.Controls; - -public class OptionsDisplayItem : TemplatedControl -{ - public static readonly StyledProperty HeaderProperty = - AvaloniaProperty.Register(nameof(Header)); - - public static readonly StyledProperty DescriptionProperty = - AvaloniaProperty.Register(nameof(Description)); - - public static readonly StyledProperty IconProperty = - AvaloniaProperty.Register(nameof(Icon)); - - public static readonly StyledProperty ActionButtonProperty = - AvaloniaProperty.Register(nameof(ActionButton)); - - public static readonly StyledProperty NavigatesProperty = - AvaloniaProperty.Register(nameof(Navigates)); - - public static readonly StyledProperty NavigationCommandProperty = - AvaloniaProperty.Register(nameof(NavigationCommand)); - - public static readonly StyledProperty ExpandsProperty = - AvaloniaProperty.Register(nameof(Expands)); - - public static readonly StyledProperty ContentProperty = - ContentControl.ContentProperty.AddOwner(); - - public static readonly DirectProperty IsExpandedProperty = - Expander.IsExpandedProperty.AddOwner(x => x.IsExpanded, - (x, v) => x.IsExpanded = v); - - public static readonly StyledProperty LinksProprerty = - AvaloniaProperty.Register(nameof(Links)); - - public static readonly StyledProperty HrefProprerty = - AvaloniaProperty.Register(nameof(Href)); - - public string Header - { - get => GetValue(HeaderProperty); - set => SetValue(HeaderProperty, value); - } - - public string Description - { - get => GetValue(DescriptionProperty); - set => SetValue(DescriptionProperty, value); - } - - public SymbolIcon Icon - { - get => GetValue(IconProperty); - set => SetValue(IconProperty, value); - } - - public IControl ActionButton - { - get => GetValue(ActionButtonProperty); - set => SetValue(ActionButtonProperty, value); - } - - public bool Navigates - { - get => GetValue(NavigatesProperty); - set => SetValue(NavigatesProperty, value); - } - - public ICommand NavigationCommand - { - get => GetValue(NavigationCommandProperty); - set => SetValue(NavigationCommandProperty, value); - } - - public bool Expands - { - get => GetValue(ExpandsProperty); - set => SetValue(ExpandsProperty, value); - } - - public bool IsExpanded - { - get => _isExpanded; - set => SetAndRaise(IsExpandedProperty, ref _isExpanded, value); - } - - public object Content - { - get => GetValue(ContentProperty); - set => SetValue(ContentProperty, value); - } - - public bool Links - { - get => GetValue(LinksProprerty); - set => SetValue(LinksProprerty, value); - } - - public string Href - { - get => GetValue(HrefProprerty); - set => SetValue(HrefProprerty, value); - } - - public static readonly RoutedEvent NavigationRequestedEvent = - RoutedEvent.Register(nameof(NavigationRequested), RoutingStrategies.Bubble); - - public event EventHandler NavigationRequested - { - add => AddHandler(NavigationRequestedEvent, value); - remove => RemoveHandler(NavigationRequestedEvent, value); - } - - protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) - { - base.OnPropertyChanged(change); - - if (change.Property == NavigatesProperty) - { - if (Expands || Links) - throw new InvalidOperationException("Navigating control cannot Expand or Link"); - - PseudoClasses.Set(":navigates", change.NewValue.GetValueOrDefault()); - } - else if (change.Property == ExpandsProperty) - { - if (Navigates || Links) - throw new InvalidOperationException("Expanding control cannot Navigate or Link"); - - PseudoClasses.Set(":expands", change.NewValue.GetValueOrDefault()); - } - else if (change.Property == LinksProprerty) - { - if (Expands || Navigates) - throw new InvalidOperationException("Linking control cannot Expand or Link"); - - PseudoClasses.Set(":links", change.NewValue.GetValueOrDefault()); - } - else if (change.Property == IsExpandedProperty) - { - PseudoClasses.Set(":expanded", change.NewValue.GetValueOrDefault()); - } - else if (change.Property == IconProperty) - { - PseudoClasses.Set(":icon", change.NewValue.GetValueOrDefault() is not null); - } - } - - protected override void OnApplyTemplate(TemplateAppliedEventArgs e) - { - base.OnApplyTemplate(e); - - _layoutRoot = e.NameScope.Find("LayoutRoot"); - _layoutRoot.PointerPressed += OnLayoutRootPointerPressed; - _layoutRoot.PointerReleased += OnLayoutRootPointerReleased; - _layoutRoot.PointerCaptureLost += OnLayoutRootPointerCaptureLost; - } - - private void OnLayoutRootPointerPressed(object? sender, PointerPressedEventArgs e) - { - if (e.GetCurrentPoint(this).Properties.PointerUpdateKind == PointerUpdateKind.LeftButtonPressed) - { - _isPressed = true; - PseudoClasses.Set(":pressed", true); - } - } - - private void OnLayoutRootPointerReleased(object? sender, PointerReleasedEventArgs e) - { - var pt = e.GetCurrentPoint(this); - if (_isPressed && pt.Properties.PointerUpdateKind == PointerUpdateKind.LeftButtonReleased) - { - _isPressed = false; - - PseudoClasses.Set(":pressed", false); - - if (Expands) IsExpanded = !IsExpanded; - else if (Navigates) - { - RaiseEvent(new RoutedEventArgs(NavigationRequestedEvent, this)); - NavigationCommand?.Execute(null); - } - else if (Links) UrlHelper.OpenLink(Href); - } - } - - private void OnLayoutRootPointerCaptureLost(object? sender, PointerCaptureLostEventArgs e) - { - _isPressed = false; - PseudoClasses.Set(":pressed", false); - } - - private bool _isPressed; - private bool _isExpanded; - private Border? _layoutRoot; -} diff --git a/MusicDecrypto.Avalonia/Controls/UrlTextBlock.axaml b/MusicDecrypto.Avalonia/Controls/UrlTextBlock.axaml index 042bdec..3620e11 100644 --- a/MusicDecrypto.Avalonia/Controls/UrlTextBlock.axaml +++ b/MusicDecrypto.Avalonia/Controls/UrlTextBlock.axaml @@ -6,13 +6,16 @@ + + + + + + diff --git a/MusicDecrypto.Avalonia/Controls/UrlTextBlock.axaml.cs b/MusicDecrypto.Avalonia/Controls/UrlTextBlock.axaml.cs index 67b70b5..19bf345 100644 --- a/MusicDecrypto.Avalonia/Controls/UrlTextBlock.axaml.cs +++ b/MusicDecrypto.Avalonia/Controls/UrlTextBlock.axaml.cs @@ -11,16 +11,15 @@ public partial class UrlTextBlock : TemplatedControl private StackPanel? _layoutRoot; private bool _isPressed; - public static readonly StyledProperty TextProperty = - AvaloniaProperty.Register(nameof(Text)); - public static readonly StyledProperty HrefProperty = - AvaloniaProperty.Register(nameof(Href)); + public static readonly StyledProperty TextProperty = + AvaloniaProperty.Register(nameof(Text)); + public static readonly StyledProperty HrefProperty = + AvaloniaProperty.Register(nameof(Href)); - public string _text = string.Empty; public string Text { - get => _text; - set => SetAndRaise(TextProperty, ref _text, value); + get => GetValue(TextProperty); + set => SetValue(TextProperty, value); } public string Href diff --git a/MusicDecrypto.Avalonia/MusicDecrypto.Avalonia.csproj b/MusicDecrypto.Avalonia/MusicDecrypto.Avalonia.csproj index b3b0214..2f99828 100644 --- a/MusicDecrypto.Avalonia/MusicDecrypto.Avalonia.csproj +++ b/MusicDecrypto.Avalonia/MusicDecrypto.Avalonia.csproj @@ -14,11 +14,11 @@ - - - + + + - + @@ -35,4 +35,3 @@ - \ No newline at end of file diff --git a/MusicDecrypto.Avalonia/Pages/HomePage.axaml b/MusicDecrypto.Avalonia/Pages/HomePage.axaml index 715bd2d..4c2bcbe 100644 --- a/MusicDecrypto.Avalonia/Pages/HomePage.axaml +++ b/MusicDecrypto.Avalonia/Pages/HomePage.axaml @@ -1,11 +1,12 @@ + d:DesignWidth="800" d:DesignHeight="450" + mc:Ignorable="d"> @@ -14,12 +15,13 @@ + Theme="{StaticResource FluentSubtitleTextBlockStyle}" + Opacity=".25" IsVisible="{Binding IsEmpty}"> Drag and drop here or use the button above. - + - - - - - + + + + + - - - - - - - - - + - + + + + + - - - + + + + + + - - - + - + + Text="MusicDecrypto" IsHitTestVisible="False" /> - + Orientation="Horizontal" Margin="6" Spacing="6"> + - + diff --git a/MusicDecrypto.Avalonia/Views/MainView.axaml.cs b/MusicDecrypto.Avalonia/Views/MainView.axaml.cs index 5191035..dd5f713 100644 --- a/MusicDecrypto.Avalonia/Views/MainView.axaml.cs +++ b/MusicDecrypto.Avalonia/Views/MainView.axaml.cs @@ -1,10 +1,9 @@ -using System; using Avalonia; using Avalonia.Controls; using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; -using FluentAvalonia.Core.ApplicationModel; +using Avalonia.Platform.Storage; using FluentAvalonia.UI.Controls; +using FluentAvalonia.UI.Windowing; using MusicDecrypto.Avalonia.Pages; using MusicDecrypto.Avalonia.ViewModels; @@ -12,80 +11,55 @@ namespace MusicDecrypto.Avalonia.Views; public partial class MainView : UserControl { - private Window? _parent; + private Window? _window; private Frame? _frameView; - private FluentAvalonia.UI.Controls.Button? _openFilesButton; - private FluentAvalonia.UI.Controls.Button? _settingsButton; + private Button? _openFilesButton; + private Button? _settingsButton; public MainView() { InitializeComponent(); } - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); - _parent = (Window)e.Root; - _parent.Opened += OnParentWindowsOpened; + _window = e.Root as Window; _frameView = this.FindControl("FrameView"); - _frameView.Navigate(typeof(HomePage)); - - _openFilesButton = this.FindControl("OpenFilesButton"); - _openFilesButton.Click += OnOpenFilesButtonClickAsync; - - _settingsButton = this.FindControl("SettingsButton"); - _settingsButton.Click += OnSettingsButtonClick; + _frameView?.Navigate(typeof(HomePage)); + _openFilesButton = this.FindControl