Skip to content

Commit

Permalink
Merge pull request #61 from Milkitic/develop
Browse files Browse the repository at this point in the history
better support for navbar
  • Loading branch information
Milkitic committed Nov 15, 2020
2 parents 4547fb5 + 44f8ee0 commit e630bc9
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 3 deletions.
1 change: 1 addition & 0 deletions OsuPlayer.Common/Configuration/GeneralSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class GeneralSection
public string CustomSongsPath { get; set; } = Path.Combine(Domain.CurrentPath, "Songs");
public bool? ExitWhenClosed { get; set; } = null;
public bool FirstOpen { get; set; } = true;
public bool IsNavigationCollapsed { get; set; }
public Point? MiniLastPosition { get; set; }
public Rectangle? MiniWorkingArea { get; set; }
}
Expand Down
49 changes: 49 additions & 0 deletions OsuPlayer.Wpf/Converters/GetOutlinedTextConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;

namespace Milky.OsuPlayer.Converters
{
class GetOutlinedTextConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string s)
{
string result = null;
var split = s.Split(' ');
if (split.Length > 1)
{
result = (split[0].Substring(0, 1) + split[1].Substring(0, 1)).ToUpper();
}
else if (split.Length > 0)
{
if (split[0].Length > 1)
{
result = split[0].Substring(0, 2);
}
else
result = split[0].Substring(0, 1);
}

if (result == null) return null;
if (result.All(k => k >= 32 && k <= 255))
{
return result;
}
else
{
return result.Substring(0, 1);
}
}

return null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
1 change: 1 addition & 0 deletions OsuPlayer.Wpf/OsuPlayer.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\GetOutlinedTextConverter.cs" />
<Compile Include="Converters\LocalizedFontFamilyConverter.cs" />
<Compile Include="Converters\RoundedNumberConverter.cs" />
<Compile Include="Utils\CompoundUtil.cs" />
Expand Down
1 change: 1 addition & 0 deletions OsuPlayer.Wpf/Styles/ConverterDictionary.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
<converters:Multi_ListViewSelectAndScrollConverter x:Key="Multi_ListViewSelectAndScrollConverter" />
<converters:LocalizedFontFamilyConverter x:Key="LocalizedFontFamilyConverter" />
<converters:RoundedNumberConverter x:Key="RoundedNumberConverter" />
<converters:GetOutlinedTextConverter x:Key="GetOutlinedTextConverter" />
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
<Setter Property="MouseOverIconColor" Value="#DC498D" />
<Setter Property="TargetPageSingleton" Value="True" />
<Setter Property="Scope" Value="Nav" />
<!--<Setter Property="UseLayoutRounding" Value="True" />-->
<Setter Property="SnapsToDevicePixels" Value="True" />
</Style>
<Style
x:Key="ConfigSwitchRadio"
Expand Down
4 changes: 4 additions & 0 deletions OsuPlayer.Wpf/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Milky.OsuPlayer.Presentation.Interaction;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Milky.OsuPlayer.Common.Configuration;

namespace Milky.OsuPlayer.ViewModels
{
Expand Down Expand Up @@ -34,6 +35,7 @@ public bool IsNavigationCollapsed
get => _isNavigationCollapsed;
set
{
if (_isNavigationCollapsed == value) return;
_isNavigationCollapsed = value;
OnPropertyChanged();
}
Expand Down Expand Up @@ -68,6 +70,8 @@ public ICommand CollapseCommand
Execute.OnUiThread(() =>
{
IsNavigationCollapsed = !IsNavigationCollapsed;
AppSettings.Default.General.IsNavigationCollapsed = IsNavigationCollapsed;
AppSettings.SaveDefault();
});
});
}
Expand Down
40 changes: 37 additions & 3 deletions OsuPlayer.Wpf/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,6 @@
VerticalAlignment="Center"
CheckedIconColor="#4090A0"
Content="{Binding Name}"
IconSize="18"
IconTemplate="{StaticResource CollectionTempl}"
Style="{StaticResource OsuSwitchRadio}"
TargetFrameControl="MainFrame"
TargetPageData="{Binding Id}"
TargetPageSingleton="False"
Expand All @@ -251,6 +248,43 @@
<Binding RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</radioButtonComponent:SwitchRadio.Tag>
<radioButtonComponent:SwitchRadio.Style>
<Style BasedOn="{StaticResource OsuSwitchRadio}" TargetType="radioButtonComponent:SwitchRadio">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.IsNavigationCollapsed, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" Value="False">
<Setter Property="IconTemplate" Value="{StaticResource CollectionTempl}" />
<Setter Property="IconSize" Value="18" />
</DataTrigger>
<!--<Setter Property="MouseOverBackground" Value="White" />
<Setter Property="MouseOverForeground" Value="#303030" />
<Setter Property="MouseOverIconColor" Value="#DC498D" />-->
<DataTrigger Binding="{Binding Path=DataContext.IsNavigationCollapsed, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" Value="True">
<Setter Property="IconTemplate">
<Setter.Value>
<ControlTemplate>
<Border
Width="40"
Height="40"
Background="{TemplateBinding Foreground}"
CornerRadius="20">
<Label
Margin="1,0.5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{Binding Name, Converter={StaticResource GetOutlinedTextConverter}}"
FontSize="22"
FontWeight="Bold"
Foreground="#303030" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="-2,0,0,1" />
<Setter Property="IconSize" Value="20" />
</DataTrigger>
</Style.Triggers>
</Style>
</radioButtonComponent:SwitchRadio.Style>
</radioButtonComponent:SwitchRadio>
</ControlTemplate>
<Style TargetType="{x:Type ListViewItem}">
Expand Down
1 change: 1 addition & 0 deletions OsuPlayer.Wpf/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public MainWindow()
{
InitializeComponent();
ViewModel = (MainWindowViewModel)DataContext;
ViewModel.IsNavigationCollapsed = AppSettings.Default.General.IsNavigationCollapsed;
LyricWindow = new LyricWindow(this);
if (AppSettings.Default.Lyric.EnableLyric)
LyricWindow.Show();
Expand Down

0 comments on commit e630bc9

Please sign in to comment.