Skip to content

Commit

Permalink
More simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Mar 22, 2024
1 parent 69b6dbe commit ac779ea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
7 changes: 4 additions & 3 deletions YoutubeExplode.Demo.Gui/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
<!-- Expander -->
<Style Selector="Expander">
<Setter Property="materialAssists:ShadowAssist.ShadowDepth" Value="Depth1" />
</Style>
<Style Selector="Expander LayoutTransformControl#PART_ToggleTransform">
<Setter Property="Cursor" Value="Hand" />

<Style Selector="^ LayoutTransformControl#PART_ToggleTransform">
<Setter Property="Cursor" Value="Hand" />
</Style>
</Style>
</Application.Styles>
</Application>
4 changes: 2 additions & 2 deletions YoutubeExplode.Demo.Gui/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class App : Application

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
desktop.MainWindow = new MainWindow();
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime)
desktopLifetime.MainWindow = new MainWindow();

base.OnFrameworkInitializationCompleted();

Expand Down
12 changes: 6 additions & 6 deletions YoutubeExplode.Demo.Gui/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
xmlns:materialControls="clr-namespace:Material.Styles.Controls;assembly=Material.Styles"
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:viewModels="clr-namespace:YoutubeExplode.Demo.Gui.ViewModels"
x:Name="Root"
Title="YoutubeExplode Demo"
Width="720"
Height="620"
Icon="/favicon.ico"
Loaded="Root_OnLoaded"
Loaded="Window_OnLoaded"
WindowStartupLocation="CenterScreen">
<Window.DataContext>
<viewModels:MainViewModel />
</Window.DataContext>

<DockPanel>
<!-- Header -->
<StackPanel
Expand Down Expand Up @@ -251,7 +251,7 @@
<Button
Padding="4"
VerticalAlignment="Center"
Command="{Binding DataContext.DownloadStreamCommand, ElementName=Root}"
Command="{Binding $parent[Window].DataContext.DownloadStreamCommand}"
CommandParameter="{Binding}"
Theme="{DynamicResource MaterialFlatButton}">
<materialIcons:MaterialIcon
Expand Down Expand Up @@ -292,7 +292,7 @@
<Button
Padding="4"
VerticalAlignment="Center"
Command="{Binding DataContext.DownloadStreamCommand, ElementName=Root}"
Command="{Binding $parent[Window].DataContext.DownloadStreamCommand}"
CommandParameter="{Binding}"
Theme="{DynamicResource MaterialFlatButton}">
<materialIcons:MaterialIcon
Expand Down Expand Up @@ -333,7 +333,7 @@
<Button
Padding="4"
VerticalAlignment="Center"
Command="{Binding DataContext.DownloadStreamCommand, ElementName=Root}"
Command="{Binding $parent[Window].DataContext.DownloadStreamCommand}"
CommandParameter="{Binding}"
Theme="{DynamicResource MaterialFlatButton}">
<materialIcons:MaterialIcon
Expand Down Expand Up @@ -384,7 +384,7 @@
<Button
Padding="4"
VerticalAlignment="Center"
Command="{Binding DataContext.DownloadClosedCaptionTrackCommand, ElementName=Root}"
Command="{Binding $parent[Window].DataContext.DownloadClosedCaptionTrackCommand}"
CommandParameter="{Binding}"
Theme="{DynamicResource MaterialFlatButton}">
<materialIcons:MaterialIcon
Expand Down
15 changes: 13 additions & 2 deletions YoutubeExplode.Demo.Gui/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
using Avalonia.Controls;
using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using YoutubeExplode.Demo.Gui.ViewModels;

namespace YoutubeExplode.Demo.Gui.Views;

public partial class MainWindow : Window
{
public MainWindow() => InitializeComponent();

private void Root_OnLoaded(object? sender, RoutedEventArgs args) => QueryTextBox.Focus();
public new MainViewModel DataContext
{
get =>
(MainViewModel)(
base.DataContext ?? throw new InvalidOperationException("DataContext is not set.")
);
set => base.DataContext = value;
}

private void Window_OnLoaded(object? sender, RoutedEventArgs args) => QueryTextBox.Focus();
}

0 comments on commit ac779ea

Please sign in to comment.