zoukankan      html  css  js  c++  java
  • 写的wpf的第一个窗口类

    /*  
     * User: Administrator
     * Date: 2007-11-16 Time: 14:54
     
    */

    using System;
    using System.Windows;
    using System.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;//显示控件按钮
                
    //this.ResizeMode= ResizeMode.NoResize;//禁止resize
                this.WindowState= WindowState.Maximized;//窗口状态
            }
            
            
    protected override void OnTextInput(TextCompositionEventArgs e)
            {
                
    //在输入字符串时,显示输入的字符串在标题栏上
                base.OnTextInput(e);
                
    if(e.Text=="\b" && Title.Length>0)//回退字符时删除字符
                {
                    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);
                
    //调整窗口的位置,可以多加代码调整窗体的大小
                 
                
    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;
                }
         
            }
            
        }
    }
  • 相关阅读:
    LeetCode 121. Best Time to Buy and Sell Stock
    LeetCode 221. Maximal Square
    LeetCode 152. Maximum Product Subarray
    LeetCode 53. Maximum Subarray
    LeetCode 91. Decode Ways
    LeetCode 64. Minimum Path Sum
    LeetCode 264. Ugly Number II
    LeetCode 263. Ugly Number
    LeetCode 50. Pow(x, n)
    LeetCode 279. Perfect Squares
  • 原文地址:https://www.cnblogs.com/sunbingzibo/p/961701.html
Copyright © 2011-2022 走看看