⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formmain.cs

📁 windows mobile 开发实例wi ndows mobile 开发实例
💻 CS
📖 第 1 页 / 共 2 页
字号:
//-----------------------------------------------------------------------------
// Code from _Programming the .NET Compact Framework with C#_
// and _Programming the .NET Compact Framework with VB_
// (c) Copyright 2002-2004 Paul Yao and David Durant. 
// All rights reserved.
//-----------------------------------------------------------------------------

using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;

namespace LifeGame
{
   /// <summary>
   /// Summary description for Form1.
   /// </summary>
   public class FormMain : System.Windows.Forms.Form
   {
      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.ComponentModel.Container components = null;

      #region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
         this.mnuMain = new System.Windows.Forms.MainMenu();
         this.panelCells = new System.Windows.Forms.Panel();
         this.btnStartStop = new System.Windows.Forms.Button();
         // 
         // btnStartStop
         // 
         this.btnStartStop.Location = new System.Drawing.Point(344, 240);
         this.btnStartStop.Text = "S&tart";
         this.btnStartStop.Click += new System.EventHandler(this.mnuStartStop_Click);
         // 
         // FormMain
         // 
         this.ClientSize = new System.Drawing.Size(506, 301);
         this.Menu = this.mnuMain;
         this.Text = "Life Game";
         this.Closing += new System.ComponentModel.CancelEventHandler(this.FormMain_Closing);
         this.Load += new System.EventHandler(this.FormMain_Load);

      }
      #endregion

      #region Properties
		
      //	The LifeMain object.  It contains,
      //		and runs, the Life Game; and it
      //		supplies the control needed to
      //		display the game.
      private LifeMain refLifeMain;

      //	"Game is running" indicator.
      private bool boolRun = false;
		
      #endregion

      #region Controls
      private System.Windows.Forms.Panel panelCells;
      private System.Windows.Forms.Button btnStartStop;
      private LifeGame.LifeControl facadeLifeGame;

      private System.Windows.Forms.MainMenu mnuMain;

      private System.Windows.Forms.MenuItem mnuFile;
      private System.Windows.Forms.MenuItem mnuStartStop;
      private System.Windows.Forms.MenuItem mnuExit;

      private System.Windows.Forms.MenuItem mnuPattern;
      private System.Windows.Forms.MenuItem mnuEmpty;
      private System.Windows.Forms.MenuItem mnuReset;
      private System.Windows.Forms.MenuItem mnuManual;

      private System.Windows.Forms.MenuItem mnuCheckers;
      private System.Windows.Forms.MenuItem mnuBoard;
      private System.Windows.Forms.MenuItem mnuSelfFix;
      private System.Windows.Forms.MenuItem mnuSelfDestruct;

      private System.Windows.Forms.MenuItem mnuLines;
      private System.Windows.Forms.MenuItem mnuDiagonal;
      private System.Windows.Forms.MenuItem mnuVertical;
      private System.Windows.Forms.MenuItem mnuFlawedVertical;

      private System.Windows.Forms.MenuItem mnuGliders;
      private System.Windows.Forms.MenuItem mnuGlider;
      private System.Windows.Forms.MenuItem mnuGliderMate;
      private System.Windows.Forms.MenuItem mnuGliderPump;

      private System.Windows.Forms.MenuItem mnuSmalls;
      private System.Windows.Forms.MenuItem mnuFiveCell;
      private System.Windows.Forms.MenuItem mnuSixCell;
      private System.Windows.Forms.MenuItem mnuEightCell;
      private System.Windows.Forms.MenuItem mnuTenCell;
         
      private System.Windows.Forms.MenuItem mnuSpeed;
      private System.Windows.Forms.MenuItem mnuFastest;
      private System.Windows.Forms.MenuItem mnuFast;
      private System.Windows.Forms.MenuItem mnuFaster;
      private System.Windows.Forms.MenuItem mnuSpeedNormal;
      private System.Windows.Forms.MenuItem mnuSlower;
      private System.Windows.Forms.MenuItem mnuSlow;
      private System.Windows.Forms.MenuItem mnuSlowest;

      private System.Windows.Forms.MenuItem mnuZoom;
      private System.Windows.Forms.MenuItem mnuInnest;
      private System.Windows.Forms.MenuItem mnuIn;
      private System.Windows.Forms.MenuItem mnuSizeNormal;
      private System.Windows.Forms.MenuItem mnuOut;
      private System.Windows.Forms.MenuItem mnuOutest;

      private System.Windows.Forms.MenuItem mnuAbout;
      #endregion
		
      #region System Methods

      public FormMain()
      {
         //
         // Required for Windows Form Designer support
         //
         InitializeComponent();
      }

      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      protected override void Dispose( bool disposing )
      {
         if( disposing )
         {
            if (components != null) 
            {
               components.Dispose();
            }
         }
         base.Dispose( disposing );
      }

      #endregion

      #region Initialization

      /// <summary>
      /// The main entry point for the application.
      /// </summary>

      static void Main() 
      {
         Application.Run(new FormMain());
      }

      private void FormMain_Load(object sender, System.EventArgs e)
      {
         InitLifeGame();
         InitMenus();
         WindowState = FormWindowState.Maximized;
         PositionControls();
      }

      private void InitLifeGame()
      {
         //	Create a new LifeMain object.
         refLifeMain = new LifeMain();

         //	Specify the delegate function to be notified
         //		when a new generation has been calculated.
         refLifeMain.NextGenReady += new LifeMain.deleNextGenReady( LifeMain_NextGenReady );
			
         //	Specify the delegate function to be notified
         //		when a static state has been reached.
         refLifeMain.StableStateReached += new LifeMain.deleStableStateReached( LifeMain_StableStateReached );

         //	Get the display control from the LifeGame 
         //		object.  Make it visible.  Specify a
         //		click event for it.  Add it to the form.
         facadeLifeGame = refLifeMain.refFacade;
         facadeLifeGame.Visible = true;
         facadeLifeGame.MouseUp += new System.Windows.Forms.MouseEventHandler(this.facadeLifeGame_MouseUp);
         this.Controls.Add( this.facadeLifeGame );
      }

      private void PositionControls()
      {
         //	Postion controls on form.
         facadeLifeGame.BackColor = Color.Tan;
         utilGUI.SetBounds(facadeLifeGame,
            ClientRectangle.Left,
            ClientRectangle.Top,
            (ClientRectangle.Width < ClientRectangle.Height) ? ClientRectangle.Width : ClientRectangle.Height,
            (ClientRectangle.Width < ClientRectangle.Height) ? ClientRectangle.Width : ClientRectangle.Height);

         utilGUI.SetBounds(panelCells,
            facadeLifeGame.Width,
            (ClientRectangle.Height / 4) * 2,
            ClientRectangle.Width - facadeLifeGame.Width,
            ClientRectangle.Height / 4);

         btnStartStop.Enabled = mnuStartStop.Enabled = false;
      }

      #endregion

      #region Menu Initialization

      private void InitMenus()
      {
         this.mnuFile = new System.Windows.Forms.MenuItem();
         this.mnuStartStop = new System.Windows.Forms.MenuItem();
         this.mnuExit = new System.Windows.Forms.MenuItem();
         this.mnuPattern = new System.Windows.Forms.MenuItem();
         this.mnuEmpty = new System.Windows.Forms.MenuItem();
         this.mnuReset = new System.Windows.Forms.MenuItem();
         this.mnuManual = new System.Windows.Forms.MenuItem();
         this.mnuSmalls = new System.Windows.Forms.MenuItem();
         this.mnuFiveCell = new System.Windows.Forms.MenuItem();
         this.mnuSixCell = new System.Windows.Forms.MenuItem();
         this.mnuEightCell = new System.Windows.Forms.MenuItem();
         this.mnuTenCell = new System.Windows.Forms.MenuItem();
         this.mnuSpeed = new System.Windows.Forms.MenuItem();
         this.mnuFastest = new System.Windows.Forms.MenuItem();
         this.mnuFast = new System.Windows.Forms.MenuItem();
         this.mnuFaster = new System.Windows.Forms.MenuItem();
         this.mnuSpeedNormal = new System.Windows.Forms.MenuItem();
         this.mnuSlower = new System.Windows.Forms.MenuItem();
         this.mnuSlow = new System.Windows.Forms.MenuItem();
         this.mnuSlowest = new System.Windows.Forms.MenuItem();
         this.mnuZoom = new System.Windows.Forms.MenuItem();
         this.mnuInnest = new System.Windows.Forms.MenuItem();
         this.mnuIn = new System.Windows.Forms.MenuItem();
         this.mnuSizeNormal = new System.Windows.Forms.MenuItem();
         this.mnuOut = new System.Windows.Forms.MenuItem();
         this.mnuOutest = new System.Windows.Forms.MenuItem();
         this.mnuLines = new System.Windows.Forms.MenuItem();
         this.mnuDiagonal = new System.Windows.Forms.MenuItem();
         this.mnuVertical = new System.Windows.Forms.MenuItem();
         this.mnuFlawedVertical = new System.Windows.Forms.MenuItem();
         this.mnuCheckers = new System.Windows.Forms.MenuItem();
         this.mnuBoard = new System.Windows.Forms.MenuItem();
         this.mnuSelfFix = new System.Windows.Forms.MenuItem();
         this.mnuSelfDestruct = new System.Windows.Forms.MenuItem();
         this.mnuGliders = new System.Windows.Forms.MenuItem();
         this.mnuGlider = new System.Windows.Forms.MenuItem();
         this.mnuGliderMate = new System.Windows.Forms.MenuItem();
         this.mnuGliderPump = new System.Windows.Forms.MenuItem();
         this.mnuAbout = new System.Windows.Forms.MenuItem();
         // 
         // mnuMain
         // 
         this.mnuMain.MenuItems.Add(this.mnuFile);
         this.mnuMain.MenuItems.Add(this.mnuPattern);
         this.mnuMain.MenuItems.Add(this.mnuSpeed);
         this.mnuMain.MenuItems.Add(this.mnuZoom);
         // 
         // mnuFile
         // 
         this.mnuFile.MenuItems.Add(this.mnuStartStop);
         this.mnuFile.MenuItems.Add(this.mnuExit);
         this.mnuFile.Text = "File";
         // 
         // mnuStartStop
         // 
         this.mnuStartStop.Text = "S&tart";
         this.mnuStartStop.Click += new System.EventHandler(this.mnuStartStop_Click);
         // 
         // mnuExit
         // 
         this.mnuExit.Text = "E&xit";
         this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
         // 
         // mnuPattern
         // 
         this.mnuPattern.MenuItems.Add(this.mnuEmpty);
         this.mnuPattern.MenuItems.Add(this.mnuReset);
         this.mnuPattern.MenuItems.Add(this.mnuManual);
         this.mnuPattern.MenuItems.Add(this.mnuSmalls);
         this.mnuPattern.MenuItems.Add(this.mnuLines);
         this.mnuPattern.MenuItems.Add(this.mnuCheckers);
         this.mnuPattern.MenuItems.Add(this.mnuGliders);
         this.mnuPattern.Text = "Pattern";
         // 
         // mnuEmpty
         // 
         this.mnuEmpty.Text = "Empty";
         this.mnuEmpty.Click += new System.EventHandler(this.mnuPatterns_Click);
         // 
         // mnuReset
         // 
         this.mnuReset.Text = "Reset";
         this.mnuReset.Click += new System.EventHandler(this.mnuReset_Click);
         // 
         // mnuManual
         // 
         this.mnuManual.Text = "Manual";
         this.mnuManual.Click += new System.EventHandler(this.mnuManual_Click);
         // 
         // mnuSmalls
         // 
         this.mnuSmalls.MenuItems.Add(this.mnuFiveCell);
         this.mnuSmalls.MenuItems.Add(this.mnuSixCell);
         this.mnuSmalls.MenuItems.Add(this.mnuEightCell);
         this.mnuSmalls.MenuItems.Add(this.mnuTenCell);
         this.mnuSmalls.Text = "Smalls";
         // 
         // mnuFiveCell
         // 
         this.mnuFiveCell.Text = "Five Cell";
         this.mnuFiveCell.Click += new System.EventHandler(this.mnuPatterns_Click);
         // 
         // mnuSixCell
         // 
         this.mnuSixCell.Text = "Six Cell";
         this.mnuSixCell.Click += new System.EventHandler(this.mnuPatterns_Click);
         // 
         // mnuEightCell
         // 
         this.mnuEightCell.Text = "Eight Cell";
         this.mnuEightCell.Click += new System.EventHandler(this.mnuPatterns_Click);
         // 
         // mnuTenCell
         // 
         this.mnuTenCell.Text = "Ten Cell";
         this.mnuTenCell.Click += new System.EventHandler(this.mnuPatterns_Click);
         // 
         // mnuSpeed
         // 
         this.mnuSpeed.MenuItems.Add(this.mnuFastest);
         this.mnuSpeed.MenuItems.Add(this.mnuFast);
         this.mnuSpeed.MenuItems.Add(this.mnuFaster);
         this.mnuSpeed.MenuItems.Add(this.mnuSpeedNormal);
         this.mnuSpeed.MenuItems.Add(this.mnuSlower);
         this.mnuSpeed.MenuItems.Add(this.mnuSlow);
         this.mnuSpeed.MenuItems.Add(this.mnuSlowest);
         this.mnuSpeed.Text = "Speed";
         // 
         // mnuFastest
         // 
         this.mnuFastest.Text = "Fastest";
         this.mnuFastest.Click += new System.EventHandler(this.mnuSpeed_Click);
         // 
         // mnuFast
         // 
         this.mnuFast.Text = "Fast";
         this.mnuFast.Click += new System.EventHandler(this.mnuSpeed_Click);
         // 
         // mnuFaster
         // 
         this.mnuFaster.Text = "Faster";
         this.mnuFaster.Click += new System.EventHandler(this.mnuSpeed_Click);
         // 
         // mnuSpeedNormal

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -