/*
* User: Administrator
* Date: Time:
*/
UsingSystem;
UsingSystem. windows;
UsingSystem. Windows. input;
Namespace Wpftest
{
/// <Summary>
/// Description of cxywin.
/// </Summary>
Public Class Cxywin: Window
{
Public Cxywin ()
{
Title = " Grow and shrink Test " ;
Windowstartuplocation = Windowstartuplocation. centerscreen;
Height = 400 ;
Width = 400 ;
This . Windowstyle = Windowstyle. threedborderwindow; // Display control buttons
// This. resizemode = resizemode. noresize; // Disable resize
This . Windowstate = Windowstate. maximized; // Window status
}
Protected Override Void Ontextinput (textcompositioneventargs E)
{
// The entered string is displayed on the title bar.
Base . Ontextinput (E );
If (E. Text = " \ B " && Title. Length > 0 ) // Delete characters when character rollback
{
Title = Title. substring ( 0 , Title. Length - 1 );
}
Else If ( ! Char . Iscontrol (E. Text [ 0 ])
{
Title = Title + E. Text;
}
}
Protected Override Void Onkeydown (keyeventargs E)
{
Base . Onkeydown (E );
// Adjust the position of the window to add moreCodeResize the form
If (E. Key = Key. UP)
{
Left -= Width * 0.05 ;
Top -= Height * 0.05 ;
}
If (E. Key = Key. down)
{
Left + = Width * 0.05 ;
Top + = Height * 0.05 ;
}
}
}
}