Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
87df99a758
3 files changed
+22
-8
No files matched your search
@@ -65,7 +65,7 @@ namespace DyeingComputer.View
|
||||
{
|
||||
InputBox frm = new InputBox();
|
||||
frm.Accept += new EventHandler(InputBox_accept);
|
||||
frm.Show();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
void InputBox_accept(object sender, EventArgs e)//新建按钮窗口返回
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:DyeingComputer.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="InputBox" Height="200" Width="400">
|
||||
<Grid>
|
||||
<TextBox x:Name="Boxx" HorizontalAlignment="Left" Height="36" Margin="39,31,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="319"/>
|
||||
<Button Content="Button" HorizontalAlignment="Left" Height="35" Margin="58,104,0,0" VerticalAlignment="Top" Width="96" Click="YES_Click"/>
|
||||
<Button Content="Button" HorizontalAlignment="Left" Height="35" Margin="158,104,0,0" VerticalAlignment="Top" Width="96" Click="NO_Click"/>
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ResizeMode ="NoResize"
|
||||
Title="SUNLIGHT 838"
|
||||
Height="150" Width="400">
|
||||
<Grid FocusManager.FocusedElement="{Binding ElementName=Boxx}">
|
||||
<TextBox x:Name="Boxx" Height="40" Margin="20,10,20,0" VerticalAlignment="Top" FontSize="26"
|
||||
MaxLines="1" BorderThickness="3,3,3,3" ClipToBounds="True"/>
|
||||
<Button Content="YES" HorizontalAlignment="Left" Height="35" Margin="50,70,0,5" VerticalAlignment="Bottom" Width="80" Click="YES_Click"/>
|
||||
<Button Content="NO" HorizontalAlignment="Right" Height="35" Margin="0,70,50,5" VerticalAlignment="Bottom" Width="80" Click="NO_Click"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -22,6 +22,8 @@ namespace DyeingComputer.Windows
|
||||
public InputBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
FocusManager.SetFocusedElement(Boxx, Boxx);
|
||||
}
|
||||
|
||||
public string InputValue
|
||||
@@ -39,17 +41,25 @@ namespace DyeingComputer.Windows
|
||||
public event EventHandler Accept;
|
||||
|
||||
private void YES_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var input = Boxx.Text.TrimStart(); //去除字符串前空格
|
||||
if (input.Length == 0) //字长度不等于0有效
|
||||
{
|
||||
Boxx.Focus(); //聚焦元素
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Accept != null)
|
||||
{
|
||||
Accept(this, EventArgs.Empty);
|
||||
}
|
||||
this.Close(); //为了测试效果,点击Done以后先不关闭窗口
|
||||
this.Close(); //关闭窗口
|
||||
}
|
||||
}
|
||||
|
||||
private void NO_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close(); //为了测试效果,点击Done以后先不关闭窗口
|
||||
this.Close(); //关闭窗口
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user