dev_split_view_vm
DESKTOP-3BO4HSG\ksat 2 years ago
parent 7c8363b531
commit f3992b2f19

@ -1,12 +1,13 @@
<Window x:Class="STranslate.MainWindow" <Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:STranslate.ViewModel" xmlns:vm="clr-namespace:STranslate.ViewModel"
xmlns:tb="http://www.hardcodet.net/taskbar" xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:STranslate" x:Class="STranslate.MainWindow"
mc:Ignorable="d" mc:Ignorable="d"
Name="Mwin" x:Name="Mwin"
Background="Transparent" Background="Transparent"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
MouseLeftButtonDown="Window_MouseLeftButtonDown" MouseLeftButtonDown="Window_MouseLeftButtonDown"
@ -20,7 +21,7 @@
SizeToContent="Height" SizeToContent="Height"
Width="400" Width="400"
Icon="/Images/translate.ico"> Icon="/Images/translate.ico">
<Window.Resources> <Window.Resources>
<ContextMenu x:Key="TrayMenu"> <ContextMenu x:Key="TrayMenu">
<MenuItem Header="输入翻译" <MenuItem Header="输入翻译"
@ -37,7 +38,7 @@
</ContextMenu> </ContextMenu>
</Window.Resources> </Window.Resources>
<Border Style="{DynamicResource BorderMainStyle}"> <Border Style="{DynamicResource BorderMainStyle}">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -52,11 +53,9 @@
ToolTipText="STranslate" ToolTipText="STranslate"
ContextMenu="{StaticResource TrayMenu}" ContextMenu="{StaticResource TrayMenu}"
DoubleClickCommand="{Binding InputTranslateCmd}" DoubleClickCommand="{Binding InputTranslateCmd}"
IconSource="/Images/translate.ico"> IconSource="/Images/translate.ico"/>
</tb:TaskbarIcon>
<!--header--> <!--header-->
<Grid x:Name="Header"> <Grid x:Name="Header">
<Button x:Name="TopmostBtn" <Button x:Name="TopmostBtn"
Template="{DynamicResource ButtonTemplateUnTopmost}" Template="{DynamicResource ButtonTemplateUnTopmost}"
@ -75,7 +74,7 @@
DisplayMemberPath="Name" DisplayMemberPath="Name"
HorizontalAlignment="Right"/> HorizontalAlignment="Right"/>
</Grid> </Grid>
<!--input--> <!--input-->
<Grid x:Name="Input" <Grid x:Name="Input"
Grid.Row="1" Grid.Row="1"
@ -86,7 +85,7 @@
<Grid> <Grid>
<TextBox x:Name="TextBoxInput" <TextBox x:Name="TextBoxInput"
Style="{DynamicResource TextBoxInputStyle}" Style="{DynamicResource TextBoxInputStyle}"
Text="{Binding InputTxt,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"> Text="{Binding InputTxt, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings> <TextBox.InputBindings>
<KeyBinding Command="{Binding TranslateCmd}" Key="Enter" /> <KeyBinding Command="{Binding TranslateCmd}" Key="Enter" />
</TextBox.InputBindings> </TextBox.InputBindings>
@ -95,13 +94,13 @@
Margin="10,5" Margin="10,5"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">
<Button Template="{DynamicResource ButtonTemplateSpeak}" <Button Template="{DynamicResource ButtonTemplateSpeak}"
Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding InputTxt, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding SourceSpeakCmd}"/> Command="{Binding SourceSpeakCmd}"/>
<Button Template="{DynamicResource ButtonTemplate}" <Button Template="{DynamicResource ButtonTemplate}"
Visibility="{Binding InputTxt,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding InputTxt, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyInputCmd}"/> Command="{Binding CopyInputCmd}"/>
<Border Style="{DynamicResource LanguageMarkBorderStyle}" <Border Style="{DynamicResource LanguageMarkBorderStyle}"
Visibility="{Binding IdentifyLanguage,Converter={StaticResource String2VisibilityConverter}}"> Visibility="{Binding IdentifyLanguage, Converter={StaticResource String2VisibilityConverter}}">
<StackPanel Margin="5,2" <StackPanel Margin="5,2"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock Text="识别为 " <TextBlock Text="识别为 "
@ -114,7 +113,7 @@
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>
<!--mid--> <!--mid-->
<StackPanel x:Name="MidArea" <StackPanel x:Name="MidArea"
Grid.Row="2" Grid.Row="2"
@ -126,7 +125,7 @@
Style="{DynamicResource cmbstyle}" Style="{DynamicResource cmbstyle}"
ItemsSource="{Binding InputCombo}" ItemsSource="{Binding InputCombo}"
SelectionChanged="SelectionChanged" SelectionChanged="SelectionChanged"
SelectedItem="{Binding InputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> SelectedItem="{Binding InputComboSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Separator Margin="20,0"/> <Separator Margin="20,0"/>
<TextBlock Text="目标语言: " <TextBlock Text="目标语言: "
Style="{DynamicResource MidStyle}"/> Style="{DynamicResource MidStyle}"/>
@ -134,9 +133,9 @@
Style="{DynamicResource cmbstyle}" Style="{DynamicResource cmbstyle}"
ItemsSource="{Binding OutputCombo}" ItemsSource="{Binding OutputCombo}"
SelectionChanged="SelectionChanged" SelectionChanged="SelectionChanged"
SelectedItem="{Binding OutputComboSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> SelectedItem="{Binding OutputComboSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel> </StackPanel>
<!--output--> <!--output-->
<Grid x:Name="Output" <Grid x:Name="Output"
Margin="10,0,10,10" Margin="10,0,10,10"
@ -144,7 +143,7 @@
<!--输出框--> <!--输出框-->
<Border x:Name="BorderOutput" <Border x:Name="BorderOutput"
Style="{DynamicResource BorderInOutputStyle}" Style="{DynamicResource BorderInOutputStyle}"
Height="{Binding ElementName=Output, Path=Height}"> Height="{Binding Height, ElementName=Output}">
<Grid> <Grid>
<TextBox x:Name="TextBoxOutput" <TextBox x:Name="TextBoxOutput"
Style="{DynamicResource TextBoxOutputStyle}" Style="{DynamicResource TextBoxOutputStyle}"
@ -153,25 +152,25 @@
Margin="10,5" Margin="10,5"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">
<Button Template="{DynamicResource ButtonTemplateSpeak}" <Button Template="{DynamicResource ButtonTemplateSpeak}"
Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding OutputTxt, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding TargetSpeakCmd}"/> Command="{Binding TargetSpeakCmd}"/>
<!--普通复制--> <!--普通复制-->
<Button Template="{DynamicResource ButtonTemplate}" <Button Template="{DynamicResource ButtonTemplate}"
Visibility="{Binding OutputTxt,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding OutputTxt, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyResultCmd}"/> Command="{Binding CopyResultCmd}"/>
<!--蛇形复制--> <!--蛇形复制-->
<Button Margin="5,0" <Button Margin="5,0"
Template="{DynamicResource ButtonTemplateSnakeCopy}" Template="{DynamicResource ButtonTemplateSnakeCopy}"
Visibility="{Binding SnakeRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding SnakeRet, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopySnakeResultCmd}"/> Command="{Binding CopySnakeResultCmd}"/>
<!--小驼峰复制--> <!--小驼峰复制-->
<Button Template="{DynamicResource ButtonTemplateSmallHumpCopy}" <Button Template="{DynamicResource ButtonTemplateSmallHumpCopy}"
Visibility="{Binding SmallHumpRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding SmallHumpRet, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopySmallHumpResultCmd}"/> Command="{Binding CopySmallHumpResultCmd}"/>
<!--大驼峰复制--> <!--大驼峰复制-->
<Button Margin="5,0" <Button Margin="5,0"
Template="{DynamicResource ButtonTemplateLargeHumpCopy}" Template="{DynamicResource ButtonTemplateLargeHumpCopy}"
Visibility="{Binding LargeHumpRet,Converter={StaticResource String2VisibilityConverter}}" Visibility="{Binding LargeHumpRet, Converter={StaticResource String2VisibilityConverter}}"
Command="{Binding CopyLargeHumpResultCmd}"/> Command="{Binding CopyLargeHumpResultCmd}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>

@ -20,7 +20,7 @@ namespace STranslate
DataContext = new MainVM(this); DataContext = new MainVM(this);
vm = (MainVM)DataContext; vm = (MainVM)DataContext;
//if (HotKeys.InputTranslate.Conflict || HotKeys.CrosswordTranslate.Conflict || HotKeys.ScreenShotTranslate.Conflict) //if (HotKeys.InputTranslate.Conflict || HotKeys.CrosswordTranslate.Conflict || HotKeys.ScreenShotTranslate.Conflict)
//{ //{
// MessageBox.Show("全局快捷键有冲突,请您到设置中重新设置"); // MessageBox.Show("全局快捷键有冲突,请您到设置中重新设置");

@ -17,10 +17,10 @@ namespace STranslate.ViewModel
{ {
public class MainVM : BaseVM, IDisposable public class MainVM : BaseVM, IDisposable
{ {
private MainWindow mainwin;
public MainVM(Window win) public MainVM(Window win)
{ {
mainwin = (MainWindow)win; _Mainwin = (MainWindow)win;
OpenMainWin(); OpenMainWin();
if (!ReadConfig()) if (!ReadConfig())
@ -139,8 +139,8 @@ namespace STranslate.ViewModel
/// </summary> /// </summary>
public void OpenMainWin() public void OpenMainWin()
{ {
mainwin.Show(); _Mainwin.Show();
mainwin.Activate(); _Mainwin.Activate();
//TODO: add textbox focus //TODO: add textbox focus
} }
public void InputTranslate() public void InputTranslate()
@ -353,6 +353,7 @@ namespace STranslate.ViewModel
private bool _IsVisibility = true; private bool _IsVisibility = true;
public bool IsVisibility { get => _IsVisibility; set => UpdateProperty(ref _IsVisibility, value); } public bool IsVisibility { get => _IsVisibility; set => UpdateProperty(ref _IsVisibility, value); }
private MainWindow _Mainwin;
/// <summary> /// <summary>
/// 全局配置文件 /// 全局配置文件

Loading…
Cancel
Save