Csharp/C Sharp by API/System.Windows.Forms/SystemInformation — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:10, 26 мая 2010

SystemInformation.ArrangeDirection

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
          Console.WriteLine(SystemInformation.ArrangeDirection);
     }
}


SystemInformation.ArrangeStartingPosition

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
          Console.WriteLine(SystemInformation.ArrangeStartingPosition);
     }
}


SystemInformation.ArrangeStartingPosition(all System Information

  

using System;
using System.Drawing;
using System.Windows.Forms;
class SysInfoStrings
{
     public static string[] Values
     {
          get 
          { 
              return new string[] 
              {
              SystemInformation.ArrangeDirection.ToString(),
              SystemInformation.ArrangeStartingPosition.ToString(),
              SystemInformation.BootMode.ToString(),
              SystemInformation.Border3DSize.ToString(),
              SystemInformation.BorderSize.ToString(),
              SystemInformation.CaptionButtonSize.ToString(),
              SystemInformation.CaptionHeight.ToString(),
              SystemInformation.ruputerName,
              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.MenuFont.ToString(),
              SystemInformation.MenuHeight.ToString(),
              SystemInformation.MidEastEnabled.ToString(),
              SystemInformation.MinimizedWindowSize.ToString(),
              SystemInformation.MinimizedWindowSpacingSize.ToString(),
              SystemInformation.MinimumWindowSize.ToString(),
              SystemInformation.MinWindowTrackSize.ToString(),
              SystemInformation.MonitorCount.ToString(),
              SystemInformation.MonitorsSameDisplayFormat.ToString(),
              SystemInformation.MouseButtons.ToString(),
              SystemInformation.MouseButtonsSwapped.ToString(),
              SystemInformation.MousePresent.ToString(),
              SystemInformation.MouseWheelPresent.ToString(),
              SystemInformation.MouseWheelScrollLines.ToString(),
              SystemInformation.NativeMouseWheelSupport.ToString(),
              SystemInformation.Network.ToString(),
              SystemInformation.PenWindows.ToString(),
              SystemInformation.PrimaryMonitorMaximizedWindowSize.ToString(),
              SystemInformation.PrimaryMonitorSize.ToString(),
              SystemInformation.RightAlignedMenus.ToString(),
              SystemInformation.Secure.ToString(),
              SystemInformation.ShowSounds.ToString(),
              SystemInformation.SmallIconSize.ToString(),
              SystemInformation.ToolWindowCaptionButtonSize.ToString(),
              SystemInformation.ToolWindowCaptionHeight.ToString(),
              SystemInformation.UserDomainName,
              SystemInformation.UserInteractive.ToString(),
              SystemInformation.UserName,
              SystemInformation.VerticalScrollBarArrowHeight.ToString(),
              SystemInformation.VerticalScrollBarThumbHeight.ToString(),
              SystemInformation.VerticalScrollBarWidth.ToString(),
              SystemInformation.VirtualScreen.ToString(),
              SystemInformation.WorkingArea.ToString(),
              };
          }    
     }
}


SystemInformation.BootMode

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
          Console.WriteLine(SystemInformation.BootMode);
     }
}


SystemInformation.Border3DSize

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
          Console.WriteLine(SystemInformation.Border3DSize);
     }
}


SystemInformation.BorderSize

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
   
          Console.WriteLine(SystemInformation.BorderSize);
     }
}


SystemInformation.CaptionButtonSize

  

using System;
using System.Drawing;
using System.Windows.Forms;
   
class BetterDialog: Form
{
     public static void Main()
     {
          Application.Run(new BetterDialog());
     }
     public BetterDialog()
     {
          Menu = new MainMenu();
          Menu.MenuItems.Add("&Dialog!", new EventHandler(MenuOnClick));
     }
     void MenuOnClick(object obj, EventArgs ea)
     {
          BetterDialogBox dlg = new BetterDialogBox();
          DialogResult    dr  = dlg.ShowDialog();
   
          Console.WriteLine(dr);
     }
}
class BetterDialogBox: Form
{
     public BetterDialogBox()
     {
          Text = "Better Dialog Box";
   
          FormBorderStyle = FormBorderStyle.FixedDialog;
          ControlBox      = false;
          MaximizeBox     = false;
          MinimizeBox     = false;
          ShowInTaskbar   = false;
          StartPosition   = FormStartPosition.Manual;
          Location        = ActiveForm.Location + 
                            SystemInformation.CaptionButtonSize +
                            SystemInformation.FrameBorderSize;
   
          Button btn = new Button();
          btn.Parent   = this;
          btn.Text     = "OK";
          btn.Location = new Point(50, 50);
          btn.Size     = new Size (10 * Font.Height, 2 * Font.Height);
          btn.DialogResult = DialogResult.OK;
   
          AcceptButton = btn;
   
          btn = new Button();
          btn.Parent   = this;
          btn.Text     = "Cancel";
          btn.Location = new Point(50, 100);
          btn.Size     = new Size (10 * Font.Height, 2 * Font.Height);
          btn.DialogResult = DialogResult.Cancel;
   
          CancelButton = btn;
     }
}


SystemInformation.CaptionHeight

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
          Console.WriteLine(SystemInformation.CaptionHeight);
     }
}


SystemInformation.ComputerName

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
   
          Console.WriteLine(SystemInformation.ruputerName);
     }
}


SystemInformation.CursorSize

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
   
          Console.WriteLine(SystemInformation.CursorSize);
   
     }
}


SystemInformation.DbcsEnabled

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class MainClass{
     public static void Main()
     {
   
          Console.WriteLine(SystemInformation.DbcsEnabled);
     }
}


SystemInformation.DoubleClickSize

  
using System;
using System.Drawing;
using System.Windows.Forms;
public class MainClass{
  static void Main() 
  {
    Console.WriteLine("DoubleClickSize"+ SystemInformation.DoubleClickSize.ToString());
    Console.WriteLine("DoubleClickTime"+SystemInformation.DoubleClickTime.ToString());
    Console.WriteLine("MouseButtons"+SystemInformation.MouseButtons.ToString());
    Console.WriteLine("MouseButtonsSwapped"+SystemInformation.MouseButtonsSwapped.ToString());
    Console.WriteLine("MousePresent"+SystemInformation.MousePresent.ToString());
    Console.WriteLine("MouseWheelPresent"+SystemInformation.MouseWheelPresent.ToString());
    Console.WriteLine("MouseWheelScrollLines"+SystemInformation.MouseWheelScrollLines.ToString());
    Console.WriteLine("NativeMouseWheelSupport"+SystemInformation.NativeMouseWheelSupport.ToString());
  }
}


SystemInformation.DoubleClickTime

  
using System;
using System.Drawing;
using System.Windows.Forms;
public class MainClass{
  static void Main() 
  {
    Console.WriteLine("DoubleClickSize"+ SystemInformation.DoubleClickSize.ToString());
    Console.WriteLine("DoubleClickTime"+SystemInformation.DoubleClickTime.ToString());
    Console.WriteLine("MouseButtons"+SystemInformation.MouseButtons.ToString());
    Console.WriteLine("MouseButtonsSwapped"+SystemInformation.MouseButtonsSwapped.ToString());
    Console.WriteLine("MousePresent"+SystemInformation.MousePresent.ToString());
    Console.WriteLine("MouseWheelPresent"+SystemInformation.MouseWheelPresent.ToString());
    Console.WriteLine("MouseWheelScrollLines"+SystemInformation.MouseWheelScrollLines.ToString());
    Console.WriteLine("NativeMouseWheelSupport"+SystemInformation.NativeMouseWheelSupport.ToString());
  }
}


SystemInformation.FrameBorderSize

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class BetterDialog: Form
{
     public static void Main()
     {
          Application.Run(new BetterDialog());
     }
     public BetterDialog()
     {
          Menu = new MainMenu();
          Menu.MenuItems.Add("&Dialog!", new EventHandler(MenuOnClick));
     }
     void MenuOnClick(object obj, EventArgs ea)
     {
          BetterDialogBox dlg = new BetterDialogBox();
          DialogResult    dr  = dlg.ShowDialog();
   
          Console.WriteLine(dr);
     }
}
class BetterDialogBox: Form
{
     public BetterDialogBox()
     {
          Text = "Better Dialog Box";
   
          FormBorderStyle = FormBorderStyle.FixedDialog;
          ControlBox      = false;
          MaximizeBox     = false;
          MinimizeBox     = false;
          ShowInTaskbar   = false;
          StartPosition   = FormStartPosition.Manual;
          Location        = ActiveForm.Location + 
                            SystemInformation.CaptionButtonSize +
                            SystemInformation.FrameBorderSize;
   
          Button btn = new Button();
          btn.Parent   = this;
          btn.Text     = "OK";
          btn.Location = new Point(50, 50);
          btn.Size     = new Size (10 * Font.Height, 2 * Font.Height);
          btn.DialogResult = DialogResult.OK;
   
          AcceptButton = btn;
   
          btn = new Button();
          btn.Parent   = this;
          btn.Text     = "Cancel";
          btn.Location = new Point(50, 100);
          btn.Size     = new Size (10 * Font.Height, 2 * Font.Height);
          btn.DialogResult = DialogResult.Cancel;
   
          CancelButton = btn;
     }
}


SystemInformation.MouseButtons

  
using System;
using System.Drawing;
using System.Windows.Forms;
public class MainClass{
  static void Main() 
  {
    Console.WriteLine("DoubleClickSize"+ SystemInformation.DoubleClickSize.ToString());
    Console.WriteLine("DoubleClickTime"+SystemInformation.DoubleClickTime.ToString());
    Console.WriteLine("MouseButtons"+SystemInformation.MouseButtons.ToString());
    Console.WriteLine("MouseButtonsSwapped"+SystemInformation.MouseButtonsSwapped.ToString());
    Console.WriteLine("MousePresent"+SystemInformation.MousePresent.ToString());
    Console.WriteLine("MouseWheelPresent"+SystemInformation.MouseWheelPresent.ToString());
    Console.WriteLine("MouseWheelScrollLines"+SystemInformation.MouseWheelScrollLines.ToString());
    Console.WriteLine("NativeMouseWheelSupport"+SystemInformation.NativeMouseWheelSupport.ToString());
  }
}


SystemInformation.MouseButtonsSwapped

  
using System;
using System.Drawing;
using System.Windows.Forms;
public class MainClass{
  static void Main() 
  {
    Console.WriteLine("DoubleClickSize"+ SystemInformation.DoubleClickSize.ToString());
    Console.WriteLine("DoubleClickTime"+SystemInformation.DoubleClickTime.ToString());
    Console.WriteLine("MouseButtons"+SystemInformation.MouseButtons.ToString());
    Console.WriteLine("MouseButtonsSwapped"+SystemInformation.MouseButtonsSwapped.ToString());
    Console.WriteLine("MousePresent"+SystemInformation.MousePresent.ToString());
    Console.WriteLine("MouseWheelPresent"+SystemInformation.MouseWheelPresent.ToString());
    Console.WriteLine("MouseWheelScrollLines"+SystemInformation.MouseWheelScrollLines.ToString());
    Console.WriteLine("NativeMouseWheelSupport"+SystemInformation.NativeMouseWheelSupport.ToString());
  }
}


SystemInformation.MousePresent

  
using System;
using System.Drawing;
using System.Windows.Forms;
public class MainClass{
  static void Main() 
  {
    Console.WriteLine("DoubleClickSize"+ SystemInformation.DoubleClickSize.ToString());
    Console.WriteLine("DoubleClickTime"+SystemInformation.DoubleClickTime.ToString());
    Console.WriteLine("MouseButtons"+SystemInformation.MouseButtons.ToString());
    Console.WriteLine("MouseButtonsSwapped"+SystemInformation.MouseButtonsSwapped.ToString());
    Console.WriteLine("MousePresent"+SystemInformation.MousePresent.ToString());
    Console.WriteLine("MouseWheelPresent"+SystemInformation.MouseWheelPresent.ToString());
    Console.WriteLine("MouseWheelScrollLines"+SystemInformation.MouseWheelScrollLines.ToString());
    Console.WriteLine("NativeMouseWheelSupport"+SystemInformation.NativeMouseWheelSupport.ToString());
  }
}


SystemInformation.MouseWheelPresent

  
using System;
using System.Drawing;
using System.Windows.Forms;
public class MainClass{
  static void Main() 
  {
    Console.WriteLine("DoubleClickSize"+ SystemInformation.DoubleClickSize.ToString());
    Console.WriteLine("DoubleClickTime"+SystemInformation.DoubleClickTime.ToString());
    Console.WriteLine("MouseButtons"+SystemInformation.MouseButtons.ToString());
    Console.WriteLine("MouseButtonsSwapped"+SystemInformation.MouseButtonsSwapped.ToString());
    Console.WriteLine("MousePresent"+SystemInformation.MousePresent.ToString());
    Console.WriteLine("MouseWheelPresent"+SystemInformation.MouseWheelPresent.ToString());
    Console.WriteLine("MouseWheelScrollLines"+SystemInformation.MouseWheelScrollLines.ToString());
    Console.WriteLine("NativeMouseWheelSupport"+SystemInformation.NativeMouseWheelSupport.ToString());
  }
}


SystemInformation.MouseWheelScrollLines

  
using System;
using System.Drawing;
using System.Windows.Forms;
public class MainClass{
  static void Main() 
  {
    Console.WriteLine("DoubleClickSize"+ SystemInformation.DoubleClickSize.ToString());
    Console.WriteLine("DoubleClickTime"+SystemInformation.DoubleClickTime.ToString());
    Console.WriteLine("MouseButtons"+SystemInformation.MouseButtons.ToString());
    Console.WriteLine("MouseButtonsSwapped"+SystemInformation.MouseButtonsSwapped.ToString());
    Console.WriteLine("MousePresent"+SystemInformation.MousePresent.ToString());
    Console.WriteLine("MouseWheelPresent"+SystemInformation.MouseWheelPresent.ToString());
    Console.WriteLine("MouseWheelScrollLines"+SystemInformation.MouseWheelScrollLines.ToString());
    Console.WriteLine("NativeMouseWheelSupport"+SystemInformation.NativeMouseWheelSupport.ToString());
  }
}


SystemInformation.NativeMouseWheelSupport

  
using System;
using System.Drawing;
using System.Windows.Forms;
public class MainClass{
  static void Main() 
  {
    Console.WriteLine("DoubleClickSize"+ SystemInformation.DoubleClickSize.ToString());
    Console.WriteLine("DoubleClickTime"+SystemInformation.DoubleClickTime.ToString());
    Console.WriteLine("MouseButtons"+SystemInformation.MouseButtons.ToString());
    Console.WriteLine("MouseButtonsSwapped"+SystemInformation.MouseButtonsSwapped.ToString());
    Console.WriteLine("MousePresent"+SystemInformation.MousePresent.ToString());
    Console.WriteLine("MouseWheelPresent"+SystemInformation.MouseWheelPresent.ToString());
    Console.WriteLine("MouseWheelScrollLines"+SystemInformation.MouseWheelScrollLines.ToString());
    Console.WriteLine("NativeMouseWheelSupport"+SystemInformation.NativeMouseWheelSupport.ToString());
  }
}


SystemInformation.PrimaryMonitor

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class ScribbleWithBitmap: Form
{
     bool     bTracking;
     Point    ptLast;
     Bitmap   bitmap;
     Graphics grfxBm;
   
     public static void Main()
     {
          Application.Run(new ScribbleWithBitmap());
     }
     public ScribbleWithBitmap()
     {
          Text = "Scribble with Bitmap";
          Size size = SystemInformation.PrimaryMonitorMaximizedWindowSize;
          bitmap = new Bitmap(size.Width, size.Height);
   
          grfxBm = Graphics.FromImage(bitmap);
          grfxBm.Clear(BackColor);
     }
     protected override void OnMouseDown(MouseEventArgs mea)
     {
          if (mea.Button != MouseButtons.Left)
               return;
   
          ptLast = new Point(mea.X, mea.Y);
          bTracking = true;
     }
     protected override void OnMouseMove(MouseEventArgs mea)
     {
          if (!bTracking)
               return;
   
          Point ptNew = new Point(mea.X, mea.Y);
          
          Pen pen = new Pen(ForeColor);
          Graphics grfx = CreateGraphics();
          grfx.DrawLine(pen, ptLast, ptNew);
          grfx.Dispose();
   
          grfxBm.DrawLine(pen, ptLast, ptNew);
   
          ptLast = ptNew;
     }
     protected override void OnMouseUp(MouseEventArgs mea)
     {
          bTracking = false;
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics grfx = pea.Graphics;
          grfx.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
     }
}


SystemInformation.PrimaryMonitorMaximizedWindowSize

  
using System;
using System.Drawing;
using System.Windows.Forms;
   
class ScribbleWithBitmap: Form
{
     bool     bTracking;
     Point    ptLast;
     Bitmap   bitmap;
     Graphics grfxBm;
   
     public static void Main()
     {
          Application.Run(new ScribbleWithBitmap());
     }
     public ScribbleWithBitmap()
     {
          Size size = SystemInformation.PrimaryMonitorMaximizedWindowSize;
          bitmap = new Bitmap(size.Width, size.Height);
   
          grfxBm = Graphics.FromImage(bitmap);
          grfxBm.Clear(BackColor);
     }
     protected override void OnMouseDown(MouseEventArgs mea)
     {
          if (mea.Button != MouseButtons.Left)
               return;
   
          ptLast = new Point(mea.X, mea.Y);
          bTracking = true;
     }
     protected override void OnMouseMove(MouseEventArgs mea)
     {
          if (!bTracking)
               return;
   
          Point ptNew = new Point(mea.X, mea.Y);
          
          Pen pen = new Pen(ForeColor);
          Graphics grfx = CreateGraphics();
          grfx.DrawLine(pen, ptLast, ptNew);
          grfx.Dispose();
   
          grfxBm.DrawLine(pen, ptLast, ptNew);
   
          ptLast = ptNew;
     }
     protected override void OnMouseUp(MouseEventArgs mea)
     {
          bTracking = false;
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics grfx = pea.Graphics;
          grfx.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
     }
}