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