feat: update window height feat content

dev_without_third_libraries
DESKTOP-3BO4HSG\ksat 2 years ago
parent 97fb16a567
commit 2abb3edb9b

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

@ -16,7 +16,7 @@
Topmost="True" Topmost="True"
Deactivated="Window_Deactivated" Deactivated="Window_Deactivated"
WindowStyle="None" WindowStyle="None"
Height="450" SizeToContent="Height"
Width="400" Width="400"
Icon="/Images/translate.ico"> Icon="/Images/translate.ico">
<Window.DataContext> <Window.DataContext>
@ -84,22 +84,38 @@
BorderThickness="1" BorderThickness="1"
CornerRadius="4" CornerRadius="4"
Margin="5"> Margin="5">
<TextBox x:Name="TextBoxInput" <Grid>
Background="Transparent" <TextBox x:Name="TextBoxInput"
BorderBrush="{x:Null}" Background="Transparent"
Margin="5" BorderBrush="{x:Null}"
BorderThickness="0" Margin="5,5,5,35"
FontSize="18" BorderThickness="0"
TextWrapping="Wrap" FontSize="16"
AcceptsReturn="True" MinHeight="80"
VerticalContentAlignment="Top" MaxHeight="200"
HorizontalScrollBarVisibility="Disabled" TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" AcceptsReturn="True"
Text="{Binding InputTxt,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"> VerticalContentAlignment="Top"
<TextBox.InputBindings> HorizontalScrollBarVisibility="Disabled"
<KeyBinding Command="{Binding TranslateCmd}" Key="Enter" /> VerticalScrollBarVisibility="Auto"
</TextBox.InputBindings> Text="{Binding InputTxt,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
</TextBox> <TextBox.InputBindings>
<KeyBinding Command="{Binding TranslateCmd}" Key="Enter" />
</TextBox.InputBindings>
</TextBox>
<Button Cursor="Hand"
Margin="5,0,0,5"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Command="{Binding CopyInputCmd}">
<Image Source="/Images/copy2.png"/>
<hc:FloatingBlock.ContentTemplate>
<DataTemplate>
<TextBlock Text="已复制" />
</DataTemplate>
</hc:FloatingBlock.ContentTemplate>
</Button>
</Grid>
</Border> </Border>
</Grid> </Grid>
@ -116,8 +132,8 @@
Style="{StaticResource ComboBox.Small}" Style="{StaticResource ComboBox.Small}"
ItemsSource="{Binding InputCombo}" ItemsSource="{Binding InputCombo}"
SelectedItem="{Binding InputComboSelected}" /> SelectedItem="{Binding InputComboSelected}" />
<Separator Margin="20,0"/>
<Label Content="目标语言:" <Label Content="目标语言:"
Margin="10,0"
Background="Transparent" Background="Transparent"
BorderThickness="0" /> BorderThickness="0" />
<ComboBox x:Name="OutCombo" <ComboBox x:Name="OutCombo"
@ -125,7 +141,7 @@
Style="{StaticResource ComboBox.Small}" Style="{StaticResource ComboBox.Small}"
ItemsSource="{Binding OutputCombo}" ItemsSource="{Binding OutputCombo}"
SelectedItem="{Binding OutputComboSelected}" /> SelectedItem="{Binding OutputComboSelected}" />
<Button Margin="10,0,0,0" <!--<Button Margin="10,0,0,0"
Cursor="Hand" Cursor="Hand"
Command="{Binding CopyResultCmd}"> Command="{Binding CopyResultCmd}">
<Image Source="/Images/copy.png" /> <Image Source="/Images/copy.png" />
@ -134,7 +150,7 @@
<TextBlock Text="已复制" /> <TextBlock Text="已复制" />
</DataTemplate> </DataTemplate>
</hc:FloatingBlock.ContentTemplate> </hc:FloatingBlock.ContentTemplate>
</Button> </Button>-->
</StackPanel> </StackPanel>
<!--output--> <!--output-->
@ -149,19 +165,65 @@
CornerRadius="4" CornerRadius="4"
Margin="5" Margin="5"
Height="{Binding ElementName=Output, Path=Height}"> Height="{Binding ElementName=Output, Path=Height}">
<hc:TextBox x:Name="TextBoxOutput" <Grid>
hc:InfoElement.Placeholder="翻译" <hc:TextBox x:Name="TextBoxOutput"
Background="Transparent" hc:InfoElement.Placeholder="翻译结果"
BorderBrush="{x:Null}" Background="Transparent"
BorderThickness="0" BorderBrush="{x:Null}"
IsReadOnly="True" BorderThickness="0"
Margin="5" IsReadOnly="True"
FontSize="18" Margin="5,5,5,35"
TextWrapping="Wrap" MaxHeight="400"
VerticalContentAlignment="Top" FontSize="16"
HorizontalScrollBarVisibility="Disabled" TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" VerticalContentAlignment="Top"
Text="{Binding OutputTxt}"/> HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
Text="{Binding OutputTxt}"/>
<StackPanel Orientation="Horizontal"
Margin="5,0,0,5">
<!--普通复制-->
<Button Cursor="Hand"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
ToolTip="普通"
Command="{Binding CopyResultCmd}">
<Image Source="/Images/copy2.png"/>
<hc:FloatingBlock.ContentTemplate>
<DataTemplate>
<TextBlock Text="已复制" />
</DataTemplate>
</hc:FloatingBlock.ContentTemplate>
</Button>
<!--蛇形复制-->
<Button Cursor="Hand"
Margin="5,0,5,0"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
ToolTip="蛇形"
Command="{Binding CopySnakeResultCmd}">
<Image Source="/Images/copy2.png"/>
<hc:FloatingBlock.ContentTemplate>
<DataTemplate>
<TextBlock Text="已复制" />
</DataTemplate>
</hc:FloatingBlock.ContentTemplate>
</Button>
<!--驼峰复制-->
<Button Cursor="Hand"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
ToolTip="驼峰"
Command="{Binding CopyHumpResultCmd}">
<Image Source="/Images/copy2.png"/>
<hc:FloatingBlock.ContentTemplate>
<DataTemplate>
<TextBlock Text="已复制" />
</DataTemplate>
</hc:FloatingBlock.ContentTemplate>
</Button>
</StackPanel>
</Grid>
</Border> </Border>
</Grid> </Grid>
</Grid> </Grid>

@ -70,6 +70,16 @@ namespace STranslate.Properties {
} }
} }
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap copy2 {
get {
object obj = ResourceManager.GetObject("copy2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
/// </summary> /// </summary>

@ -121,6 +121,9 @@
<data name="copy" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\copy.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\images\copy.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="copy2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\copy2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="crossword" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="crossword" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\images\crossword.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\images\crossword.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>

@ -157,6 +157,9 @@
<Resource Include="Images\translate.ico"> <Resource Include="Images\translate.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource> </Resource>
<Resource Include="Images\copy2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Content Include="STranslate.yml"> <Content Include="STranslate.yml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

@ -26,6 +26,14 @@ namespace STranslate.ViewModel
//TODO: fix no config //TODO: fix no config
config = ConfigUtil.ReadConfig(ConfigPath); config = ConfigUtil.ReadConfig(ConfigPath);
//复制输入
CopyInputCmd = new RelayCommand((_) =>
{
return string.IsNullOrEmpty(InputTxt) ? false : true;
}, (_) =>
{
Clipboard.SetText(InputTxt);
});
//复制翻译结果 //复制翻译结果
CopyResultCmd = new RelayCommand((_) => CopyResultCmd = new RelayCommand((_) =>
{ {
@ -82,15 +90,12 @@ namespace STranslate.ViewModel
} }
OutputTxt = translateResp; OutputTxt = translateResp;
var splitList = translateResp.Split(' ').ToList(); var splitList = OutputTxt.Split(' ').ToList();
if (splitList.Count > 1) if (splitList.Count > 1)
{ {
SnakeRet = GenSnakeString(splitList); //SnakeRet = GenSnakeString(splitList);
HumpRet = GenHumpString(splitList); //HumpRet = GenHumpString(splitList);
} }
System.Diagnostics.Debug.Print(SnakeRet);
System.Diagnostics.Debug.Print(HumpRet);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -104,7 +109,7 @@ namespace STranslate.ViewModel
/// <returns></returns> /// <returns></returns>
private string GenSnakeString(List<string> req) private string GenSnakeString(List<string> req)
{ {
//Alarm statistics //TODO: 构造时间过长
var ret = string.Empty; var ret = string.Empty;
req.ForEach(x => req.ForEach(x =>
@ -121,6 +126,7 @@ namespace STranslate.ViewModel
private string GenHumpString(List<string> req) private string GenHumpString(List<string> req)
{ {
//TODO: I'm your father 出错情况 //TODO: I'm your father 出错情况
//TODO: 构造出错
var ret = string.Empty; var ret = string.Empty;
var arr = req.ToArray(); var arr = req.ToArray();
ret += arr[0].Substring(0, 1).ToLower() + arr[0].Substring(1); ret += arr[0].Substring(0, 1).ToLower() + arr[0].Substring(1);
@ -136,12 +142,15 @@ namespace STranslate.ViewModel
#region Params #region Params
public ICommand TranslateCmd { get; private set; } public ICommand TranslateCmd { get; private set; }
public ICommand CopyInputCmd { get; private set; }
public ICommand CopyResultCmd { get; private set; } public ICommand CopyResultCmd { get; private set; }
public ICommand CopySnakeResultCmd { get; private set; } public ICommand CopySnakeResultCmd { get; private set; }
public ICommand CopyHumpResultCmd { get; private set; } public ICommand CopyHumpResultCmd { get; private set; }
public string SnakeRet { get; set; } private string _SnakeRet;
public string HumpRet { get; set; } public string SnakeRet { get => _SnakeRet; set => UpdateProperty(ref _SnakeRet, value); }
private string _HumpRet;
public string HumpRet { get => _HumpRet; set => UpdateProperty(ref _HumpRet, value); }
private string _InputTxt; private string _InputTxt;
public string InputTxt { get => _InputTxt; set => UpdateProperty(ref _InputTxt, value); } public string InputTxt { get => _InputTxt; set => UpdateProperty(ref _InputTxt, value); }

Loading…
Cancel
Save