dev_split_view_vm
DESKTOP-3BO4HSG\ksat 2 years ago
parent 1740c9b6fa
commit faa13358fd

@ -1,11 +1,12 @@
<Window <Window x:Class="STranslate.MainWindow"
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" xmlns:local="clr-namespace:STranslate"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d" mc:Ignorable="d"
x:Name="Mwin" x:Name="Mwin"
Background="Transparent" Background="Transparent"
@ -135,16 +136,26 @@
<ComboBox x:Name="InCombo" <ComboBox x:Name="InCombo"
Style="{DynamicResource cmbstyle}" Style="{DynamicResource cmbstyle}"
ItemsSource="{Binding InputCombo}" ItemsSource="{Binding InputCombo}"
SelectionChanged="SelectionChanged" SelectedItem="{Binding InputComboSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
SelectedItem="{Binding InputComboSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> <i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectLangChangedCmd}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Separator Margin="20,0"/> <Separator Margin="20,0"/>
<TextBlock Text="目标语言: " <TextBlock Text="目标语言: "
Style="{DynamicResource MidStyle}"/> Style="{DynamicResource MidStyle}"/>
<ComboBox x:Name="OutCombo" <ComboBox x:Name="OutCombo"
Style="{DynamicResource cmbstyle}" Style="{DynamicResource cmbstyle}"
ItemsSource="{Binding OutputCombo}" ItemsSource="{Binding OutputCombo}"
SelectionChanged="SelectionChanged" SelectedItem="{Binding OutputComboSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
SelectedItem="{Binding OutputComboSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> <i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectLangChangedCmd}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel> </StackPanel>
<!--output--> <!--output-->

@ -80,14 +80,5 @@ namespace STranslate
this.Hide(); this.Hide();
} }
} }
private void SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (!string.IsNullOrEmpty(vm?.InputTxt))
{
vm.IdentifyLanguage = string.Empty;
_ = vm?.Translate();
}
}
} }
} }

@ -59,6 +59,9 @@
<Reference Include="Hardcodet.NotifyIcon.Wpf, Version=1.1.0.0, Culture=neutral, PublicKeyToken=682384a853a08aad, processorArchitecture=MSIL"> <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> <HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.1.0\lib\net472\Hardcodet.NotifyIcon.Wpf.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <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> <HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
@ -68,6 +71,9 @@
<Reference Include="System.Speech" /> <Reference Include="System.Speech" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -200,6 +206,5 @@
<EmbedInteropTypes>True</EmbedInteropTypes> <EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference> </COMReference>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

@ -92,6 +92,16 @@ namespace STranslate.ViewModel
} }
}); });
//切换语言
SelectLangChangedCmd = new RelayCommand((_) => true, (_) =>
{
if (!string.IsNullOrEmpty(InputTxt))
{
IdentifyLanguage = string.Empty;
_ = Translate();
}
});
#endregion #endregion
#region Common #region Common
@ -376,6 +386,7 @@ namespace STranslate.ViewModel
public ICommand ExitCmd { get; private set; } public ICommand ExitCmd { get; private set; }
public ICommand TopmostCmd { get; private set; } public ICommand TopmostCmd { get; private set; }
public ICommand EscCmd { get; private set; } public ICommand EscCmd { get; private set; }
public ICommand SelectLangChangedCmd { get; private set; }
/// <summary> /// <summary>
/// 是否开机自启 /// 是否开机自启

@ -2,4 +2,5 @@
<packages> <packages>
<package id="Hardcodet.NotifyIcon.Wpf" version="1.1.0" targetFramework="net48" /> <package id="Hardcodet.NotifyIcon.Wpf" version="1.1.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net48" /> <package id="Newtonsoft.Json" version="13.0.2" targetFramework="net48" />
<package id="System.Windows.Interactivity.WPF" version="2.0.20525" targetFramework="net48" />
</packages> </packages>
Loading…
Cancel
Save