chore: remove topmost view int viewmodel

dev_ocr_translate
DESKTOP-3BO4HSG\ksat 2 years ago
parent 1ac7c152e2
commit 5c76a1df83

@ -46,7 +46,8 @@
Key="T" Key="T"
Command="{Binding TopmostCmd}"/> Command="{Binding TopmostCmd}"/>
<KeyBinding Key="Esc" <KeyBinding Key="Esc"
Command="{Binding EscCmd}"/> Command="{Binding EscCmd}"
CommandParameter="{Binding ElementName=TopmostBtn, Mode=OneWay}"/>
</Window.InputBindings> </Window.InputBindings>
@ -80,6 +81,7 @@
<Grid x:Name="Header"> <Grid x:Name="Header">
<Button x:Name="TopmostBtn" <Button x:Name="TopmostBtn"
Command="{Binding TopmostCmd}" Command="{Binding TopmostCmd}"
CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}}"
Template="{DynamicResource ButtonTemplateUnTopmost}"/> Template="{DynamicResource ButtonTemplateUnTopmost}"/>
<Button Width="auto" <Button Width="auto"
Template="{DynamicResource ButtonTemplateTheme}" Template="{DynamicResource ButtonTemplateTheme}"

@ -61,33 +61,31 @@ namespace STranslate.ViewModel
}); });
//置顶 //置顶
TopmostCmd = new RelayCommand((_) => true, (_) => TopmostCmd = new RelayCommand((_) => true, (o) =>
{ {
var button = o as System.Windows.Controls.Button;
if (IsTopmost) if (IsTopmost)
{ {
(Mainwin.FindName("TopmostBtn") as System.Windows.Controls.Button) button.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _UnTopmostTemplateName);
.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _UnTopmostTemplateName);
} }
else else
{ {
(Mainwin.FindName("TopmostBtn") as System.Windows.Controls.Button) button.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _TopmostTemplateName);
.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _TopmostTemplateName);
} }
IsTopmost = !IsTopmost; IsTopmost = !IsTopmost;
}); });
//ESC //ESC
EscCmd = new RelayCommand((_) => true, (_) => EscCmd = new RelayCommand((_) => true, (o) =>
{ {
Mainwin.Hide();
//取消置顶 //取消置顶
if (IsTopmost) if (IsTopmost)
{ {
(Mainwin.FindName("TopmostBtn") as System.Windows.Controls.Button) (o as System.Windows.Controls.Button)
.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _UnTopmostTemplateName); .SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _UnTopmostTemplateName);
IsTopmost = !IsTopmost; IsTopmost = !IsTopmost;
} }
Mainwin.Hide();
}); });
//切换语言 //切换语言

Loading…
Cancel
Save