Fix some visual stuff

This commit is contained in:
Nguyen Duy
2024-05-09 07:07:08 +07:00
parent 93ebbd21d8
commit 66ded645d1
4 changed files with 28 additions and 22 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Languages/vi.xaml"/>
<ResourceDictionary Source="Languages/en.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
+2 -2
View File
@@ -86,7 +86,7 @@
</Label.Style>
</Label>
</StackPanel>
<TextBlock FontSize="14" Margin="5" Cursor="Hand" MouseDown="TextBlock_MouseDown" MouseUp="ChangeLanguage">
<TextBlock FontSize="14" Margin="5" Cursor="Hand" MouseDown="LanguageText_MouseEvent" MouseUp="LanguageText_MouseEvent" HorizontalAlignment="Left">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="White" />
@@ -123,7 +123,7 @@
<MenuItem Header="{DynamicResource t_fallback_display}" IsCheckable="True" IsChecked="{Binding Path=(local:Config.FallbackDisplay), Mode=TwoWay}" />
<MenuItem Header="{DynamicResource t_keep_screen_on}" IsCheckable="True" IsChecked="{Binding Path=(local:Config.KeepScreenOn), Mode=TwoWay}" />
<Separator />
<MenuItem Header="{DynamicResource t_check_for_update}" x:Name="xMICheckUpdate" Click="CheckUpdate" />
<MenuItem Header="{DynamicResource t_check_for_update}" Click="CheckUpdate" />
<Separator />
<MenuItem Header="{DynamicResource t_exit}" Click="ExitApp" />
</ContextMenu>
+22 -19
View File
@@ -24,6 +24,13 @@ namespace ParsecVDisplay
xDisplays.Children.Clear();
xNoDisplay.Visibility = Visibility.Hidden;
// setup tray context menu
ContextMenu.DataContext = this;
ContextMenu.Resources = App.Current.Resources;
Tray.Init(this, ContextMenu);
ContextMenu = null;
}
protected override void OnSourceInitialized(EventArgs e)
@@ -61,11 +68,11 @@ namespace ParsecVDisplay
{
Loaded -= Window_Loaded;
CheckUpdate(null, null);
if (App.Silent)
Hide();
CheckUpdate(null, null);
var defaultLang = Config.Language;
foreach (var item in App.Languages)
{
@@ -88,12 +95,6 @@ namespace ParsecVDisplay
xLanguageMenu.Items.Add(mi);
}
ContextMenu.DataContext = this;
ContextMenu.Resources = App.Current.Resources;
Tray.Init(this, ContextMenu);
ContextMenu = null;
ParsecVDD.DisplayChanged += DisplayChanged;
ParsecVDD.Invalidate();
}
@@ -200,9 +201,12 @@ namespace ParsecVDisplay
private async void CheckUpdate(object sender, RoutedEventArgs e)
{
var oldText = xMICheckUpdate.Header;
xMICheckUpdate.Header = "Checking for update...";
xMICheckUpdate.IsEnabled = false;
MenuItem menuItem = null;
if (sender is MenuItem)
{
menuItem = sender as MenuItem;
menuItem.IsEnabled = false;
}
var newVersion = await Updater.CheckUpdate();
if (!string.IsNullOrEmpty(newVersion))
@@ -222,19 +226,18 @@ namespace ParsecVDisplay
App.NAME, MessageBoxButton.OK, MessageBoxImage.Information);
}
xMICheckUpdate.Header = oldText;
xMICheckUpdate.IsEnabled = true;
if (menuItem != null)
{
menuItem.IsEnabled = true;
}
}
private void ChangeLanguage(object sender, MouseButtonEventArgs e)
private void LanguageText_MouseEvent(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
(sender as TextBlock).ContextMenu.IsOpen = true;
}
private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
if (e.LeftButton == MouseButtonState.Released)
(sender as TextBlock).ContextMenu.IsOpen = true;
}
}
}
+3
View File
@@ -43,6 +43,9 @@
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<StartupObject>ParsecVDisplay.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />