Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
增加源文本显示选项
Browse files Browse the repository at this point in the history
  • Loading branch information
Isayama-Kagura committed Aug 10, 2022
1 parent 03bc4fe commit 452e7c4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
7 changes: 7 additions & 0 deletions TsubakiTranslator/BasicLibrary/WindowConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public WindowConfig()
TranslateWindowTransparency = 165;
SourceTextColor = Colors.BurlyWood;
TranslatedTextColor = Colors.WhiteSmoke;
SourceTextVisibility = "Auto";
}

private double mainWindowWidth;
Expand All @@ -30,6 +31,7 @@ public WindowConfig()
private int translateWindowTransparency;
private Color sourceTextColor;
private Color translatedTextColor;
private string sourceTextVisibility;


public double MainWindowWidth
Expand Down Expand Up @@ -91,5 +93,10 @@ public Color TranslatedTextColor
set => SetProperty(ref translatedTextColor, value);
}

public string SourceTextVisibility
{
get => sourceTextVisibility;
set => SetProperty(ref sourceTextVisibility, value);
}
}
}
3 changes: 1 addition & 2 deletions TsubakiTranslator/TranslateWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
Topmost="{Binding TranslateWindowTopmost, Mode=TwoWay}"
MaxWidth="{StaticResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}"
MaxHeight="{StaticResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}"
Closing="On_TranslateWindow_Closing" MouseEnter="TranslateWindow_MouseEnter"
MinHeight="100" MinWidth="400" MouseLeave="TranslateWindow_MouseLeave"
Closing="On_TranslateWindow_Closing" MinHeight="100" MinWidth="400"
MouseLeftButtonDown="Window_MouseLeftButtonDown">

<!--窗口可改变尺寸-->
Expand Down
15 changes: 15 additions & 0 deletions TsubakiTranslator/TranslateWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ private void Init()
}
this.Background = new SolidColorBrush(Color.FromArgb((byte)App.WindowConfig.TranslateWindowTransparency, 0, 0, 0));

switch (App.WindowConfig.SourceTextVisibility)
{
case "Visible":
TranslatedResultDisplay.SourceText.Visibility = Visibility.Visible;
break;
case "Auto":
this.MouseEnter += TranslateWindow_MouseEnter;
this.MouseLeave += TranslateWindow_MouseLeave;
break;
case "Collapsed":
TranslatedResultDisplay.SourceText.Visibility = Visibility.Collapsed;
break;
}


//TTS
if (App.TranslateAPIConfig.TTSIsEnabled)
{
Expand Down
15 changes: 14 additions & 1 deletion TsubakiTranslator/WinStylePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,21 @@
SelectedValue="{Binding TranslatedTextColor, Mode=TwoWay}"
materialDesign:HintAssist.Hint="翻译文本颜色"/>
</DockPanel>



<Separator Style="{StaticResource MaterialDesignSeparator}"/>

<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
Margin="20 10 20 10" Text="源文本显示"/>

<ListBox Style="{StaticResource MaterialDesignChoiceChipOutlineListBox}"
SelectedValue="{Binding SourceTextVisibility, Mode=TwoWay}"
SelectedValuePath="Tag">
<ListBoxItem Content="可见" Tag="Visible" Margin="10,0,0,0" />
<ListBoxItem Content="变动" Tag="Auto" IsSelected="True"/>
<ListBoxItem Content="隐藏" Tag="Collapsed" />
</ListBox>

</StackPanel>


Expand Down

0 comments on commit 452e7c4

Please sign in to comment.