Skip to content

Commit

Permalink
TransLimitBox: 修复数据保存问题
Browse files Browse the repository at this point in the history
  • Loading branch information
imba-tjd committed Jan 18, 2022
1 parent e70d4e5 commit 59572bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<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: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" ValueChanged="TransLimitBox_ValueChanged"/>
<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"/>

<CheckBox Name="EachRowTransCheckBox" Margin="0,10,0,0" Content="{StaticResource GeneralTransSettingsPage_EachRowTransCheckBox}" IsChecked="True" hc:InfoElement.Title="{StaticResource GeneralTransSettingsPage_SecondTranslator}" hc:Poptip.HitMode="None" hc:Poptip.IsOpen="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}" hc:Poptip.Content="{StaticResource GeneralTransSettingsPage_EachRowTransHint}" hc:Poptip.Placement="Right" Click="EachRowTransCheckBox_Click" HorizontalAlignment="Left"/>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public TranslatorGeneralSettingsPage()
EachRowTransCheckBox.IsChecked = Convert.ToBoolean(Common.appSettings.EachRowTrans);

TransLimitBox.Value = Common.appSettings.TransLimitNums;
// 给TransLimitBox添加Minimum后,初始化它时就会触发一次ValueChanged,导致Settings被设为1,因此只能从设置中读取数据后再添加事件处理函数
TransLimitBox.ValueChanged += TransLimitBox_ValueChanged;
}

private void FirstTransCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand All @@ -51,11 +53,11 @@ private void SecondTransCombox_SelectionChanged(object sender, SelectionChangedE
private void EachRowTransCheckBox_Click(object sender, RoutedEventArgs e)
{
Common.appSettings.EachRowTrans = Convert.ToString(EachRowTransCheckBox.IsChecked);
}

private void TransLimitBox_ValueChanged(object sender, HandyControl.Data.FunctionEventArgs<double> e)
{
Common.appSettings.TransLimitNums = (int)TransLimitBox.Value;
}
}

private void TransLimitBox_ValueChanged(object sender, HandyControl.Data.FunctionEventArgs<double> e)
{
Common.appSettings.TransLimitNums = (int)TransLimitBox.Value;
}
}
}

0 comments on commit 59572bd

Please sign in to comment.