Skip to content

Commit 2a7ce6e

Browse files
committed
Responsive UI. Issue #28
1 parent 1954e20 commit 2a7ce6e

File tree

10 files changed

+72
-35
lines changed

10 files changed

+72
-35
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Avalonia.Data.Converters;
2+
using System;
3+
using System.Globalization;
4+
5+
namespace Avalonia86.Converters;
6+
7+
/// <summary>
8+
/// Usage:
9+
///
10+
/// <Window.Resources>
11+
/// <local:HeightToIsVisibleConverter x:Key="HeightToIsVisibleConverter"/>
12+
/// </Window.Resources>
13+
///
14+
/// Then:
15+
/// <local:MyUserControl IsVisible = "{Binding #MainWindow.Height,
16+
/// Converter={StaticResource HeightToIsVisibleConverter},
17+
/// ConverterParameter = 500}" />
18+
/// </summary>
19+
public class HeightToIsVisibleConverter : IValueConverter
20+
{
21+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
22+
{
23+
if (value is double height && double.TryParse(parameter?.ToString(), out double threshold))
24+
{
25+
return height >= threshold;
26+
}
27+
return true;
28+
}
29+
30+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
31+
=> throw new NotImplementedException();
32+
}

Avalonia86/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333

34-
[assembly: AssemblyVersion("1.3.5.0")]
35-
[assembly: AssemblyFileVersion("1.3.5.0")]
34+
[assembly: AssemblyVersion("1.3.6.0")]
35+
[assembly: AssemblyFileVersion("1.3.6.0")]

Avalonia86/Themes/CustomCtrls.axaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<!-- Colors used on dialog buttons -->
1717
<SolidColorBrush x:Key="DlgBtnBackground" Color="#e1e1e1" />
18-
<SolidColorBrush x:Key="DlgBtnBoarderBrush" Color="#adadad" />
18+
<SolidColorBrush x:Key="DlgBtnBorderBrush" Color="#adadad" />
1919

2020
<!-- Colors used on data tables -->
2121
<SolidColorBrush x:Key="GridRowBackground" Color="White"/>
@@ -35,7 +35,7 @@
3535

3636
<!-- Colors used on dialog buttons -->
3737
<SolidColorBrush x:Key="DlgBtnBackground" Color="#111111" />
38-
<SolidColorBrush x:Key="DlgBtnBoarderBrush" Color="#adadad" />
38+
<SolidColorBrush x:Key="DlgBtnBorderBrush" Color="#adadad" />
3939

4040
<!-- Colors used on data tables -->
4141
<SolidColorBrush x:Key="GridRowBackground" Color="Black"/>
@@ -65,8 +65,8 @@
6565
<Setter Property="Template">
6666
<ControlTemplate>
6767
<DockPanel>
68-
<!-- The way we get rid of the boarder below the selected tab is by slightly overdrawing the ItemsPresenter over the ContentPresenter,
69-
then not drawing the lower boarder on TabItem. ZIndex is key here. -->
68+
<!-- The way we get rid of the border below the selected tab is by slightly overdrawing the ItemsPresenter over the ContentPresenter,
69+
then not drawing the lower border on TabItem. ZIndex is key here. -->
7070
<ItemsPresenter Name="PART_ItemsPresenter"
7171
ItemsPanel="{TemplateBinding ItemsPanel}"
7272
DockPanel.Dock="Top"
@@ -88,8 +88,8 @@
8888
<Setter Property="Template">
8989
<ControlTemplate>
9090
<DockPanel>
91-
<!-- The way we get rid of the boarder below the selected tab is by slightly overdrawing the ItemsPresenter over the ContentPresenter,
92-
then not drawing the lower boarder on TabItem. ZIndex is key here. -->
91+
<!-- The way we get rid of the border below the selected tab is by slightly overdrawing the ItemsPresenter over the ContentPresenter,
92+
then not drawing the lower border on TabItem. ZIndex is key here. -->
9393
<ItemsPresenter Name="PART_ItemsPresenter"
9494
ItemsPanel="{TemplateBinding ItemsPanel}"
9595
DockPanel.Dock="Top"

Avalonia86/Views/dlgAddExe.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<Window.Styles>
1414
<Style Selector="Button">
1515
<Setter Property="Background" Value="{DynamicResource DlgBtnBackground}"/>
16-
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBoarderBrush}"/>
16+
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBorderBrush}"/>
1717
<Setter Property="BorderThickness" Value="1"/>
1818
</Style>
1919

Avalonia86/Views/dlgAddVM.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343
<Window.Styles>
4444
<Style Selector="Button">
4545
<Setter Property="Background" Value="{DynamicResource DlgBtnBackground}"/>
46-
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBoarderBrush}"/>
46+
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBorderBrush}"/>
4747
<Setter Property="BorderThickness" Value="1"/>
4848
</Style>
4949

5050
<Style Selector="Border#Acorn">
5151
<Setter Property="Background" Value="{DynamicResource DlgBtnBackground}"/>
52-
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBoarderBrush}"/>
52+
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBorderBrush}"/>
5353
<Setter Property="BorderThickness" Value="1"/>
5454
</Style>
5555

Avalonia86/Views/dlgCloneVM.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<Window.Styles>
1616
<Style Selector="Button">
1717
<Setter Property="Background" Value="{DynamicResource DlgBtnBackground}"/>
18-
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBoarderBrush}"/>
18+
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBorderBrush}"/>
1919
<Setter Property="BorderThickness" Value="1"/>
2020
</Style>
2121

Avalonia86/Views/dlgEditVM.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<Window.Styles>
2929
<Style Selector="Button">
3030
<Setter Property="Background" Value="{DynamicResource DlgBtnBackground}"/>
31-
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBoarderBrush}"/>
31+
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBorderBrush}"/>
3232
<Setter Property="BorderThickness" Value="1"/>
3333
</Style>
3434

Avalonia86/Views/dlgSettings.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<Window.Styles>
2525
<Style Selector="Button">
2626
<Setter Property="Background" Value="{DynamicResource DlgBtnBackground}"/>
27-
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBoarderBrush}"/>
27+
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBorderBrush}"/>
2828
<Setter Property="BorderThickness" Value="1"/>
2929
</Style>
3030

Avalonia86/Views/dlgUpdater.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<Window.Styles>
2020
<Style Selector="Button">
2121
<Setter Property="Background" Value="{DynamicResource DlgBtnBackground}"/>
22-
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBoarderBrush}"/>
22+
<Setter Property="BorderBrush" Value="{DynamicResource DlgBtnBorderBrush}"/>
2323
<Setter Property="BorderThickness" Value="1"/>
2424
</Style>
2525

Avalonia86/Views/frmMain.axaml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
x:Class="Avalonia86.Views.frmMain"
1414
Icon="/Assets/86Box-gray.ico"
1515
Opened="Main_OnOpened"
16-
Closing="Window_OnClosing">
16+
Closing="Window_OnClosing"
17+
x:Name="MainWindow">
1718
<Design.DataContext>
1819
<vm:MainModel/>
1920
</Design.DataContext>
@@ -102,6 +103,7 @@
102103

103104
<conv:BitmapAssetValueConverter x:Key="variableImage"/>
104105
<conv:StatusToColorConverter x:Key="colorConv"/>
106+
<conv:HeightToIsVisibleConverter x:Key="HeightToIsVisible" />
105107
</Window.Resources>
106108
<!--
107109
UI Structur
@@ -382,7 +384,7 @@
382384
<ColumnDefinition Width="10"><!-- Where we put the "Grip resizer" dots --></ColumnDefinition>
383385
</Grid.ColumnDefinitions>
384386
<Grid.RowDefinitions>
385-
<RowDefinition Height="1"><!-- Used to create a thin boarder over the status bar --></RowDefinition>
387+
<RowDefinition Height="1"><!-- Used to create a thin border over the status bar --></RowDefinition>
386388
<RowDefinition Height="18"></RowDefinition>
387389
</Grid.RowDefinitions>
388390
<Rectangle Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Height="1" Fill="{DynamicResource statusbar_LineBrush}"/>
@@ -630,23 +632,26 @@
630632
</StackPanel>
631633
<Rectangle Fill="Transparent" />
632634
</DockPanel>
633-
<Grid DockPanel.Dock="Bottom" ColumnDefinitions="*, *" RowDefinitions="*, *, *, *" Margin="0,0,0,2">
634-
<TextBlock Grid.Row="0" Grid.Column="0" Text="VM Age"/>
635-
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Machine.SinceCreated, TargetNullValue='Unknown', Mode=OneWay}" HorizontalAlignment="Right"/>
636-
<TextBlock Grid.Row="1" Grid.Column="0" Text="Uptime"/>
637-
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Machine.Uptime.Short, Mode=OneWay}" HorizontalAlignment="Right" ToolTip.Placement="Top">
638-
<ToolTip.Tip>
639-
<StackPanel Orientation="Horizontal">
640-
<TextBlock>Total uptime: </TextBlock>
641-
<TextBlock Margin="5, 0, 0, 0" Text="{Binding Machine.Uptime.Full, Mode=OneWay}" />
642-
</StackPanel>
643-
</ToolTip.Tip>
644-
</TextBlock>
645-
<TextBlock Grid.Row="2" Grid.Column="0" Text="Play count"/>
646-
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Machine.RunCount, Mode=OneWay}" HorizontalAlignment="Right"/>
647-
<TextBlock Grid.Row="3" Grid.Column="0" Text="Disk usage"/>
648-
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding Machine.VMSize, TargetNullValue='Calculating...', Mode=OneWay}" HorizontalAlignment="Right"/>
649-
</Grid>
635+
<StackPanel DockPanel.Dock="Bottom">
636+
<view:ctrlInformation Height="200" DataContext="{Binding Machine, Mode=OneWay}" IsVisible = "{Binding #MainWindow.Height, Converter={StaticResource HeightToIsVisible}, ConverterParameter = 600}" />
637+
<Grid ColumnDefinitions="*, *" RowDefinitions="*, *, *, *" Margin="0,0,0,2">
638+
<TextBlock Grid.Row="0" Grid.Column="0" Text="VM Age"/>
639+
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Machine.SinceCreated, TargetNullValue='Unknown', Mode=OneWay}" HorizontalAlignment="Right"/>
640+
<TextBlock Grid.Row="1" Grid.Column="0" Text="Uptime"/>
641+
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Machine.Uptime.Short, Mode=OneWay}" HorizontalAlignment="Right" ToolTip.Placement="Top">
642+
<ToolTip.Tip>
643+
<StackPanel Orientation="Horizontal">
644+
<TextBlock>Total uptime: </TextBlock>
645+
<TextBlock Margin="5, 0, 0, 0" Text="{Binding Machine.Uptime.Full, Mode=OneWay}" />
646+
</StackPanel>
647+
</ToolTip.Tip>
648+
</TextBlock>
649+
<TextBlock Grid.Row="2" Grid.Column="0" Text="Play count"/>
650+
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Machine.RunCount, Mode=OneWay}" HorizontalAlignment="Right"/>
651+
<TextBlock Grid.Row="3" Grid.Column="0" Text="Disk usage"/>
652+
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding Machine.VMSize, TargetNullValue='Calculating...', Mode=OneWay}" HorizontalAlignment="Right"/>
653+
</Grid>
654+
</StackPanel>
650655
<Border BorderBrush="#a0a0a0" BorderThickness="1, 1, 0, 0" Margin="0, 0, 0, 8">
651656
<Grid>
652657
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="(None)" />
@@ -657,7 +662,7 @@
657662
</DockPanel>
658663
</TabItem>
659664
<TabItem Header="Information" Theme="{StaticResource CustomTabItm}">
660-
<view:ctrlInformation DataContext="{Binding Machine, Mode=OneWay}"></view:ctrlInformation>
665+
<view:ctrlInformation DataContext="{Binding Machine, Mode=OneWay}" />
661666
</TabItem>
662667
</TabControl>
663668
</Grid>

0 commit comments

Comments
 (0)