dev_split_view_vm
DESKTOP-3BO4HSG\ksat 2 years ago
parent cbcee3eb0a
commit 980d3e36b8

@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:STranslate.ViewModel"
xmlns:tb="http://www.hardcodet.net/taskbar"
mc:Ignorable="d"
Name="Mwin"
Background="Transparent"
@ -23,6 +24,21 @@
<Window.DataContext>
<vm:MainVM />
</Window.DataContext>
<Window.Resources>
<ContextMenu x:Key="TrayMenu">
<MenuItem Header="输入翻译"
Command="{Binding InputTranslateCmd}"/>
<Separator />
<MenuItem Header="显示主界面"
Command="{Binding ShowMainWinCmd}"/>
<MenuItem Header="开机自启"
IsChecked="{Binding IsStartup}"
Command="{Binding StartupCmd}"/>
<Separator />
<MenuItem Header="退出"
Command="{Binding ExitCmd}"/>
</ContextMenu>
</Window.Resources>
<Border Style="{DynamicResource BorderMainStyle}">
<Grid>
@ -33,7 +49,17 @@
<RowDefinition Height="7*" />
</Grid.RowDefinitions>
<!--header-->
<!--tray-->
<tb:TaskbarIcon x:Name="myNotifyIcon"
Visibility="{Binding IsVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"
ToolTipText="STranslate"
ContextMenu="{StaticResource TrayMenu}"
LeftClickCommand="{Binding ShowMainWinCmd}"
IconSource="/Images/translate.ico">
</tb:TaskbarIcon>
<!--header-->
<Grid x:Name="Header">
<Button x:Name="TopmostBtn"
Template="{DynamicResource ButtonTemplateUnTopmost}"

@ -22,7 +22,7 @@ namespace STranslate
InitView();
InitialTray();
//InitialTray();
//if (HotKeys.InputTranslate.Conflict || HotKeys.CrosswordTranslate.Conflict || HotKeys.ScreenShotTranslate.Conflict)
//{

@ -56,6 +56,9 @@
<ApplicationIcon>Images\translate.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Hardcodet.NotifyIcon.Wpf, Version=1.1.0.0, Culture=neutral, PublicKeyToken=682384a853a08aad, processorArchitecture=MSIL">
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.1.0\lib\net472\Hardcodet.NotifyIcon.Wpf.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>

@ -1,5 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--引入字体文件-->
<Style x:Key="IconStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="/STranslate;component/Images/#iconfont"/>
</Style>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/STranslate;component/Style/Dark/DictionaryButtonDark.xaml"/>

@ -2,6 +2,8 @@
xmlns:model="clr-namespace:STranslate.Model"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<model:VisibilityConverter x:Key="String2VisibilityConverter"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<Style x:Key="BorderMainStyle"
TargetType="Border">
<Setter Property="Background" Value="#2e323a"/>

@ -2,6 +2,8 @@
xmlns:model="clr-namespace:STranslate.Model"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<model:VisibilityConverter x:Key="String2VisibilityConverter"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<Style x:Key="BorderMainStyle"
TargetType="Border">
<Setter Property="Background" Value="#ffffff"/>

@ -29,6 +29,45 @@ namespace STranslate.ViewModel
InputCombo = LanguageEnumDict.Keys.ToList();
OutputCombo = LanguageEnumDict.Keys.ToList();
#region 托盘程序
//运行前检查是否开机自启
IsStartup = StartupHelper.IsStartup();
//输入翻译
InputTranslateCmd = new RelayCommand((_) => true, (_) =>
{
InputTxt = string.Empty;
OutputTxt = string.Empty;
SnakeRet = string.Empty;
SmallHumpRet = string.Empty;
LargeHumpRet = string.Empty;
IdentifyLanguage = string.Empty;
//view操作
});
//显示主界面
ShowMainWinCmd = new RelayCommand((_) => true, (_) =>
{
//view操作
});
//开机自启
StartupCmd = new RelayCommand((_) => true, (_) =>
{
if (StartupHelper.IsStartup()) StartupHelper.UnSetStartup();
else StartupHelper.SetStartup();
IsStartup = StartupHelper.IsStartup();
});
//退出App
ExitCmd = new RelayCommand((_) => true, (_) =>
{
IsVisibility = false;
Dispose();
Environment.Exit(0);
});
#endregion
//source speak
SourceSpeakCmd = new RelayCommand((_) => true, (_) =>
{
@ -260,6 +299,20 @@ namespace STranslate.ViewModel
public ICommand CopySmallHumpResultCmd { get; private set; }
public ICommand CopyLargeHumpResultCmd { get; private set; }
public ICommand ThemeConvertCmd { get; private set; }
//托盘程序
public ICommand InputTranslateCmd { get; private set; }
public ICommand ShowMainWinCmd { get; private set; }
public ICommand StartupCmd { get; private set; }
public ICommand ExitCmd { get; private set; }
/// <summary>
/// 是否开机自启
/// </summary>
private bool _IsStartup;
public bool IsStartup { get => _IsStartup; set => UpdateProperty(ref _IsStartup, value); }
private bool _IsVisibility = true;
public bool IsVisibility { get => _IsVisibility; set => UpdateProperty(ref _IsVisibility, value); }
/// <summary>
/// 全局配置文件

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Hardcodet.NotifyIcon.Wpf" version="1.1.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net48" />
</packages>
Loading…
Cancel
Save