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"
Deactivated="Window_Deactivated"
WindowStyle="None"
Height="450"
SizeToContent="Height"
Width="400"
Icon="/Images/translate.ico">
<Window.DataContext>
@ -84,12 +84,15 @@
BorderThickness="1"
CornerRadius="4"
Margin="5">
<Grid>
<TextBox x:Name="TextBoxInput"
Background="Transparent"
BorderBrush="{x:Null}"
Margin="5"
Margin="5,5,5,35"
BorderThickness="0"
FontSize="18"
FontSize="16"
MinHeight="80"
MaxHeight="200"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalContentAlignment="Top"
@ -100,6 +103,19 @@
<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>
</Grid>
@ -116,8 +132,8 @@
Style="{StaticResource ComboBox.Small}"
ItemsSource="{Binding InputCombo}"
SelectedItem="{Binding InputComboSelected}" />
<Separator Margin="20,0"/>
<Label Content="目标语言:"
Margin="10,0"
Background="Transparent"
BorderThickness="0" />
<ComboBox x:Name="OutCombo"
@ -125,7 +141,7 @@
Style="{StaticResource ComboBox.Small}"
ItemsSource="{Binding OutputCombo}"
SelectedItem="{Binding OutputComboSelected}" />
<Button Margin="10,0,0,0"
<!--<Button Margin="10,0,0,0"
Cursor="Hand"
Command="{Binding CopyResultCmd}">
<Image Source="/Images/copy.png" />
@ -134,7 +150,7 @@
<TextBlock Text="已复制" />
</DataTemplate>
</hc:FloatingBlock.ContentTemplate>
</Button>
</Button>-->
</StackPanel>
<!--output-->
@ -149,19 +165,65 @@
CornerRadius="4"
Margin="5"
Height="{Binding ElementName=Output, Path=Height}">
<Grid>
<hc:TextBox x:Name="TextBoxOutput"
hc:InfoElement.Placeholder="翻译"
hc:InfoElement.Placeholder="翻译结果"
Background="Transparent"
BorderBrush="{x:Null}"
BorderThickness="0"
IsReadOnly="True"
Margin="5"
FontSize="18"
Margin="5,5,5,35"
MaxHeight="400"
FontSize="16"
TextWrapping="Wrap"
VerticalContentAlignment="Top"
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>
</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>
/// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
/// </summary>

@ -121,6 +121,9 @@
<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>
</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">
<value>..\images\crossword.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

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

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

Loading…
Cancel
Save