feat(desktop): add opacity and compact mode

This commit is contained in:
Anna 2020-11-12 21:18:49 -05:00
parent 93dec93a34
commit c169c8099f
6 changed files with 103 additions and 27 deletions

View File

@ -10,6 +10,13 @@
<local:UShortConverter x:Key="UShortConverter" />
<local:UIntConverter x:Key="UIntConverter" />
<local:SenderPlayerConverter x:Key="SenderPlayerConverter" />
<local:NotConverter x:Key="NotConverter" />
<local:BoolToVisibility x:Key="BoolToVisibilityConverter"
TrueValue="Visible"
FalseValue="Collapsed" />
<local:BoolToVisibility x:Key="InverseBoolToVisibilityConverter"
TrueValue="Collapsed"
FalseValue="Visible" />
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources AccentColor="#02ccee" />

View File

@ -24,35 +24,35 @@
<TabItem Header="Window">
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<CheckBox Grid.Row="0"
Grid.Column="0"
Content="Always on top"
IsChecked="{Binding Config.AlwaysOnTop}"
Checked="AlwaysOnTop_Checked"
Unchecked="AlwaysOnTop_Unchecked" />
<TextBox Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Left"
PreviewTextInput="NumericInputFilter"
Text="{Binding Config.FontSize, Converter={StaticResource DoubleConverter}}"
ui:ControlHelper.Header="Log font size"
Width="200" />
<TextBox Grid.Row="2"
Grid.Column="0"
ui:ControlHelper.Header="Messages to store locally"
HorizontalAlignment="Left"
PreviewTextInput="NumericInputFilter"
Text="{Binding Config.LocalBacklogMessages, Converter={StaticResource UIntConverter}}"
Width="200" />
<StackPanel>
<CheckBox Content="Always on top"
IsChecked="{Binding Config.AlwaysOnTop}"
Checked="AlwaysOnTop_Checked"
Unchecked="AlwaysOnTop_Unchecked" />
<CheckBox Content="Compact mode"
IsChecked="{Binding Config.CompactMode}" />
<Slider ui:ControlHelper.Header="Opacity"
Value="{Binding Config.Opacity}"
Minimum=".3"
Maximum="1" />
<TextBox HorizontalAlignment="Left"
PreviewTextInput="NumericInputFilter"
Text="{Binding Config.FontSize, Converter={StaticResource DoubleConverter}}"
ui:ControlHelper.Header="Log font size"
Width="200" />
<TextBox ui:ControlHelper.Header="Messages to store locally"
HorizontalAlignment="Left"
PreviewTextInput="NumericInputFilter"
Text="{Binding Config.LocalBacklogMessages, Converter={StaticResource UIntConverter}}"
Width="200" />
</StackPanel>
<Button Grid.Row="4"
<Button Grid.Row="2"
HorizontalAlignment="Right"
Click="Save_Click">
Save

View File

@ -34,7 +34,7 @@ namespace XIVChat_Desktop {
get => this.fontSize;
set {
this.fontSize = value;
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.FontSize)));
this.OnPropertyChanged(nameof(this.FontSize));
}
}
@ -42,6 +42,30 @@ namespace XIVChat_Desktop {
public uint LocalBacklogMessages { get; set; } = 10_000;
private double opacity = 1.0;
public double Opacity {
get => this.opacity;
set {
this.opacity = value;
this.OnPropertyChanged(nameof(this.Opacity));
}
}
private bool compactMode;
public bool CompactMode {
get => this.compactMode;
set {
this.compactMode = value;
this.OnPropertyChanged(nameof(this.CompactMode));
}
}
private void OnPropertyChanged(string propName) {
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
}
#region io
private static string FilePath() => Path.Join(

View File

@ -1,7 +1,10 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using XIVChatCommon;
namespace XIVChat_Desktop {
@ -71,4 +74,31 @@ namespace XIVChat_Desktop {
throw new NotImplementedException();
}
}
public class NotConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return !((bool)value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return !((bool)value);
}
}
public abstract class BoolMapper<T> : IValueConverter {
public T TrueValue { get; set; } = default!;
public T FalseValue { get; set; } = default!;
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return (bool)value ? this.TrueValue : this.FalseValue;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
var val = (T)value;
return EqualityComparer<T>.Default.Equals(val, this.TrueValue);
}
}
public class BoolToVisibility : BoolMapper<Visibility> {
}
}

View File

@ -7,11 +7,15 @@
xmlns:cc="clr-namespace:XIVChat_Desktop.Controls"
xmlns:ui="http://schemas.modernwpf.com/2019"
ui:WindowHelper.UseModernWindowStyle="True"
ui:TitleBar.ExtendViewIntoTitleBar="{Binding App.Config.CompactMode}"
mc:Ignorable="d"
Title="XIVChat for Windows"
Height="450"
Width="800"
x:Name="Main"
WindowStyle="None"
AllowsTransparency="True"
Opacity="{Binding App.Config.Opacity}"
Icon="/Resources/logo.ico"
d:DataContext="{d:DesignInstance local:MainWindow}">
<Grid>
@ -21,7 +25,8 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Menu Grid.Row="0">
<MenuItem Header="XIVChat">
<MenuItem Header="XIVChat"
WindowChrome.IsHitTestVisibleInChrome="{Binding App.Config.CompactMode}">
<MenuItem Header="Connect"
Click="Connect_Click"
IsEnabled="{Binding App.Disconnected, UpdateSourceTrigger=PropertyChanged}" />
@ -38,8 +43,12 @@
Click="Licence_Click" />
<MenuItem Header="Configuration"
Click="Configuration_Click" />
<Separator />
<MenuItem Header="Exit"
Click="Exit_Click" />
</MenuItem>
<MenuItem Header="Tabs">
<MenuItem Header="Tabs"
WindowChrome.IsHitTestVisibleInChrome="{Binding App.Config.CompactMode}">
<MenuItem Header="Manage"
Click="ManageTabs_Click" />
</MenuItem>
@ -117,7 +126,8 @@
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
<StatusBar Grid.Row="2">
<StatusBar Grid.Row="2"
Visibility="{Binding App.Config.CompactMode, Converter={StaticResource InverseBoolToVisibilityConverter}}">
<StatusBarItem x:Name="LoggedInAs"
Content="Not logged in" />
<Separator x:Name="LoggedInAsSeparator"

View File

@ -189,5 +189,10 @@ namespace XIVChat_Desktop {
private void Licence_Click(object sender, RoutedEventArgs e) {
new LicenceWindow(this, false).Show();
}
private void Exit_Click(object sender, RoutedEventArgs e) {
this.Close();
this.App.Shutdown();
}
}
}