按键示例

using System;
using   System.Drawing ;
using  System.Windows.Forms ;

namespace WindowsProgram
{
 /// <summary>
 /// Class3 的摘要说明。
 /// </summary>
  class SysteKeyBoard:SystemInforList
 {
  public SysteKeyBoard()
  {
   Text="Syste Key Board";
   ResizeRedraw=true;
   
  }
  static void Main(string[] args)
  {
   Application.Run(new SysteKeyBoard());
  }
  protected override void OnKeyDown(KeyEventArgs  kea)
  {  Point pt=AutoScrollPosition;
     pt.X =-pt.X ;
     pt.Y=-pt.Y ;
   switch(kea.KeyCode)
   {case Keys.Right:
    if((kea.Modifiers&Keys.Control)==Keys.Control)
     pt.X += ClientSize.Width ;
     else
     pt.X+=Font.Height ;
     break;
    case Keys.Left :
    if((kea.Modifiers&Keys.Control)==Keys.Control)
     pt.X -= ClientSize.Width ;
    else
     pt.X-=Font.Height ;
     break;
    case Keys.Down:pt.Y+=Font.Height ;break;
    case Keys.Up:pt.Y-=Font.Height ;break;
    case Keys.PageDown:
     pt.Y+=ClientSize.Height ;break;
    case Keys.PageUp :
     pt.Y -=ClientSize.Height ;break;
    case Keys.Home:pt= Point.Empty ;break;
    case Keys.End :pt.Y=1000000;break;
   }
   AutoScrollPosition=pt;
   //Invalidate();
  }
 }
}

using System;
using   System.Drawing ;
using  System.Windows.Forms ;
namespace WindowsProgram
{
 /// <summary>
 /// Class2 的摘要说明。
 /// </summary>
 public class SysInfoString
 {
  public SysInfoString()
  {
  }
  public  static string []  lables
  {
   get
   {
    return new  string[]
    {"ArrangeStartingPosition",
     "ArrangeStartingPosition",
     "BootMode",
     "Border3DSize",
     "BorderSize",
     "CaptionButtonSize",
     "CaptionHeight",
     "ComputerName",
     "CursorSize",
     "DbcsEnabled",
     "DebugOS",
     "DoubleClickSize",
     "DoubleClickTime",
     "DragFullWindows",
     "DragSize",
     "FixedFrameBorderSize",
     "FrameBorderSize",
     "HighContrast",
     "HorizontalScrollBarArrowWidth",
     "HorizontalScrollBarHeight",
     "HorizontalScrollBarThumbWidth",
     "IconSize",
     "IconSpacingSize",
     "KanjiWindowHeight",
     "MaxWindowTrackSize",
     "MenuButtonSize",
     "MenuCheckSize",
     "MenuHeight",
     "MidEastEnabled",
     "MinimumWindowSize"     
    };
   }
  }
  public static  float MaxLableWidth(Graphics grfx,Font font)
  {
    return MaxWidth(lables,grfx,font);
  }
  public static int Count
  {get
   {return lables.Length; }
  }
  static float MaxWidth(string[]  astr,Graphics grfx,Font  font)
  {float fMax=0;
   foreach(string  str in  astr)
     fMax=Math.Max(fMax,grfx.MeasureString(str,font).Width);
   return  fMax;
  }
  public static string[] values
  {
   get
   {
    return new  string[]
    {  SystemInformation.ArrangeStartingPosition.ToString(),
       SystemInformation.ArrangeStartingPosition.ToString(),
     SystemInformation.BootMode.ToString(),
     SystemInformation.Border3DSize.ToString(),
     SystemInformation.BorderSize.ToString(),
     SystemInformation.CaptionButtonSize.ToString(),
     SystemInformation.CaptionHeight.ToString(),
     SystemInformation.ComputerName.ToString(),
     SystemInformation.CursorSize.ToString(),
     SystemInformation.DbcsEnabled.ToString(),
     SystemInformation.DebugOS.ToString(),
     SystemInformation.DoubleClickSize.ToString(),
     SystemInformation.DoubleClickTime.ToString(),
     SystemInformation.DragFullWindows.ToString(),
     SystemInformation.DragSize.ToString(),
     SystemInformation.FixedFrameBorderSize.ToString(),
     SystemInformation.FrameBorderSize.ToString(),
     SystemInformation.HighContrast.ToString(),
     SystemInformation.HorizontalScrollBarArrowWidth.ToString(),
     SystemInformation.HorizontalScrollBarHeight.ToString(),
     SystemInformation.HorizontalScrollBarThumbWidth.ToString(),
     SystemInformation.IconSize.ToString(),
     SystemInformation.IconSpacingSize.ToString(),
     SystemInformation.KanjiWindowHeight.ToString(),
     SystemInformation.MaxWindowTrackSize.ToString(),
     SystemInformation.MenuButtonSize.ToString(),
     SystemInformation.MenuCheckSize.ToString(),
     SystemInformation.MenuHeight.ToString(),
     SystemInformation.MidEastEnabled.ToString(),
     SystemInformation.MinimumWindowSize.ToString()
     
    };
   }
  }
 }
}
using System;
using   System.Drawing ;
using  System.Windows.Forms ;
namespace WindowsProgram

 class SystemInforList:Form
 { 
     readonly  float  cxCol;
     readonly  int  cySpace;
  //[STAThread]
  /*static void Main(string[] args)
  {
   Application.Run(new SystemInforList());
  }*/
  public  SystemInforList()
  {  Text="System  Information  List";
           BackColor=SystemColors.Window ;
     ForeColor=SystemColors.WindowText;
     Graphics  grfx=CreateGraphics();
     SizeF  sizef=grfx.MeasureString(" ",Font);
     cxCol=sizef.Width +SysInfoString.MaxLableWidth(grfx,Font);
     cySpace=Font.Height ;
     AutoScroll=true;

   AutoScrollMinSize=new Size((int)Math.Ceiling(cxCol+SysInfoString.MaxLableWidth(grfx,Font)),
    (int)Math.Ceiling(cySpace*SysInfoString.Count));
     grfx.Dispose();
  
    
    
  }
  protected override void OnPaint(PaintEventArgs e)
  {
   Graphics grs=e.Graphics ;
   Brush brush=new SolidBrush(ForeColor);
   int iCount=SysInfoString.Count;
   string[]  astrLable=SysInfoString.lables;
   string[]  astrValues=SysInfoString.values;
   for(int i=0;i<iCount;i++)
   {
    grs.DrawString(astrLable[i],Font,brush,0,i*cySpace);
    grs.DrawString(astrValues[i],Font,brush,cxCol,i*cySpace);

   }
   
  }

  private void InitializeComponent()
  {
   //
   // SystemInforList
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(292, 273);
   this.Name = "SystemInforList";
   this.Load += new System.EventHandler(this.SystemInforList_Load);

  }

  private void SystemInforList_Load(object sender, System.EventArgs e)
  {
  
  }

 }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值