Skip to content

Commit

Permalink
HttpProxyBox: 验证用户输入
Browse files Browse the repository at this point in the history
  • Loading branch information
imba-tjd committed Feb 14, 2023
1 parent bb3d3d1 commit a368b5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<StackPanel Margin="20,36,0,0">
<hc:ComboBox Name="FirstTransCombox" Width="380" hc:InfoElement.TitleWidth="140" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="{StaticResource GeneralTransSettingsPage_FirstTranslator}" hc:Poptip.HitMode="None" hc:Poptip.IsOpen="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}" hc:Poptip.Content="{StaticResource GeneralTransSettingsPage_TransSourceHint}" hc:Poptip.Placement="Top" SelectionChanged="FirstTransCombox_SelectionChanged" HorizontalAlignment="Left"/>
<hc:ComboBox Name="SecondTransCombox" Margin="0,10,0,0" Width="380" hc:InfoElement.TitleWidth="140" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="{StaticResource GeneralTransSettingsPage_SecondTranslator}" hc:Poptip.HitMode="None" hc:Poptip.IsOpen="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}" hc:Poptip.Content="{StaticResource GeneralTransSettingsPage_TransSourceHint}" hc:Poptip.Placement="Top" SelectionChanged="SecondTransCombox_SelectionChanged" HorizontalAlignment="Left"/>
<hc:TextBox Margin="0,10,0,0" Width="480" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="{StaticResource GeneralTransSettingsPage_HttpProxy}" Name="HttpProxyBox" hc:InfoElement.ShowClearButton="True" TextChanged="HttpProxyBox_TextChanged" HorizontalAlignment="Left"/>
<hc:TextBox Margin="0,10,0,0" Width="480" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="{StaticResource GeneralTransSettingsPage_HttpProxy}" Name="HttpProxyBox" hc:InfoElement.ShowClearButton="True" LostFocus="HttpProxyBox_LostFocus" HorizontalAlignment="Left"/>

<hc:NumericUpDown Name="TransLimitBox" Minimum="1" Margin="0,10,0,0" Width="380" Style="{StaticResource NumericUpDownExtend}" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.TitleWidth="140" hc:InfoElement.Title="{StaticResource GeneralTransSettingsPage_Translimit}" HorizontalAlignment="Left"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ private void EachRowTransCheckBox_Click(object sender, RoutedEventArgs e)
Common.appSettings.EachRowTrans = EachRowTransCheckBox.IsChecked ?? false;
}

private void HttpProxyBox_TextChanged(object sender, TextChangedEventArgs e)
private void HttpProxyBox_LostFocus(object sender, RoutedEventArgs e)
{
Common.appSettings.HttpProxy = HttpProxyBox.Text;
string text = HttpProxyBox.Text.Trim();
try { new Uri(text); }
catch (UriFormatException) { HandyControl.Controls.Growl.Error("Proxy url unsupported."); return; };
Common.appSettings.HttpProxy = text;
}

private void TransLimitBox_ValueChanged(object sender, HandyControl.Data.FunctionEventArgs<double> e)
Expand Down

0 comments on commit a368b5f

Please sign in to comment.