C#ウィンドウフォームアプリケーションデザイン
このシリーズの最後の記事は、今後ブログ投稿として表示されません。
記事ディレクトリ
序文
流行のため、3年生に入るとともに、彼は研究と研究で忙しい。大学院入学試験を受けることを目標に、長い時間がかかりました。私の記事を穴に読んだ皆さん、最初に申し訳ありません。たくさんのシリーズを作り、たくさんの計画を立てたいのですが、すべてがあまりにも早く変更されました。(当初、私は2年生のレビューと審査の昨年などの一連の計画を今学期にプッシュすることを計画しました。さらに、今学期にさまざまな専門的な認知インターンシップを行います)したがって、その後の一連の更新の一部は非常に遅いか、ほとんど更新されません。時間を計画した後、毎週末更新することにしました。週末は他の目的のために保存し、他の時間は勉強や試験に集中します。私は毎週月曜日にそれをするように努めています。確認する必要があると感じた場合は確認できます。更新の強度は以前ほど良くなく、以前の青写真は実現できません。要するに、皆さんのご支援に感謝します。
以下はこの記事のテキストです
一つは、テトリスの実現
テトリスは比較的古典的なゲームで、プレイしたことがなくても聞いたことがあると思いますが、一部のショーではテトリスのプレイ方法が変わり、より楽しくなりました。今、あなたの小さな頭を動かして、一緒に簡単なテトリスゲームを書いてください。
第二に、ステップ
1.機能コードの一部
主な機能コードは次のとおりです。
namespace Tetris
{
partial class frmMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#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.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
this.label4 = new System.Windows.Forms.Label();
this.btnStop = new System.Windows.Forms.Button();
this.btnStart = new System.Windows.Forms.Button();
this.lblScore = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.pbNextBlock = new System.Windows.Forms.PictureBox();
this.pbMain = new System.Windows.Forms.PictureBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.musicPlayer = new AxWMPLib.AxWindowsMediaPlayer();
((System.ComponentModel.ISupportInitialize)(this.pbNextBlock)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbMain)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.musicPlayer)).BeginInit();
this.SuspendLayout();
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(228, 263);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(107, 12);
this.label4.TabIndex = 17;
this.label4.Text = "请选择速度(1-9):";
//
// btnStop
//
this.btnStop.Location = new System.Drawing.Point(230, 391);
this.btnStop.Name = "btnStop";
this.btnStop.Size = new System.Drawing.Size(119, 23);
this.btnStop.TabIndex = 16;
this.btnStop.Text = "暂停游戏";
this.btnStop.UseVisualStyleBackColor = true;
this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
//
// btnStart
//
this.btnStart.Location = new System.Drawing.Point(228, 340);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(121, 23);
this.btnStart.TabIndex = 15;
this.btnStart.Text = "开始游戏";
this.btnStart.UseVisualStyleBackColor = true;
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
// lblScore
//
this.lblScore.AutoSize = true;
this.lblScore.Location = new System.Drawing.Point(299, 224);
this.lblScore.Name = "lblScore";
this.lblScore.Size = new System.Drawing.Size(11, 12);
this.lblScore.TabIndex = 13;
this.lblScore.Text = "0";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(228, 224);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 12;
this.label2.Text = "你的得分:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.Black;
this.label1.Location = new System.Drawing.Point(228, 39);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 12);
this.label1.TabIndex = 11;
this.label1.Text = "即将出场的是:";
//
// pbNextBlock
//
this.pbNextBlock.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.pbNextBlock.Location = new System.Drawing.Point(257, 65);
this.pbNextBlock.Name = "pbNextBlock";
this.pbNextBlock.Size = new System.Drawing.Size(120, 120);
this.pbNextBlock.TabIndex = 10;
this.pbNextBlock.TabStop = false;
this.pbNextBlock.Paint += new System.Windows.Forms.PaintEventHandler(this.pbNextBlock_Paint);
//
// pbMain
//
this.pbMain.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pbMain.Location = new System.Drawing.Point(12, 12);
this.pbMain.Name = "pbMain";
this.pbMain.Size = new System.Drawing.Size(210, 420);
this.pbMain.TabIndex = 9;
this.pbMain.TabStop = false;
this.pbMain.Paint += new System.Windows.Forms.PaintEventHandler(this.pbMain_Paint);
//
// timer1
//
this.timer1.Interval = 200;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"});
this.comboBox1.Location = new System.Drawing.Point(230, 293);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 20);
this.comboBox1.TabIndex = 14;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// musicPlayer
//
this.musicPlayer.Enabled = true;
this.musicPlayer.Location = new System.Drawing.Point(341, 263);
this.musicPlayer.Name = "musicPlayer";
this.musicPlayer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("musicPlayer.OcxState")));
this.musicPlayer.Size = new System.Drawing.Size(10, 12);
this.musicPlayer.TabIndex = 18;
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(386, 445);
this.Controls.Add(this.musicPlayer);
this.Controls.Add(this.label4);
this.Controls.Add(this.btnStop);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.lblScore);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.pbNextBlock);
this.Controls.Add(this.pbMain);
this.KeyPreview = true;
this.Name = "frmMain";
this.Text = "俄罗斯方块";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.frmMain_KeyDown);
((System.ComponentModel.ISupportInitialize)(this.pbNextBlock)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pbMain)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.musicPlayer)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button btnStop;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.Label lblScore;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.PictureBox pbNextBlock;
private System.Windows.Forms.PictureBox pbMain;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.ComboBox comboBox1;
private AxWMPLib.AxWindowsMediaPlayer musicPlayer;
}
}
2.説明(コードを分析するときに使用されます)
グリッドの状態を判断する。
図面のみ(イベントを描く)ペイント、描画時に有効であることができる
マップ[ハング、嘘] == 1つの//グラフィック
マップ[ハング、嘘] == 2 //境界線を
境界線の色が変更された場合
、他の//その他
は3つの境界
を描画しますfor(int hang = 0; hang <map.getlength(0); hang ++)
//左境界
マップ[hang、0] = 2;
//右境界
マップ[hang、mapgetlength(1) -1] = 2
3.さて、ショーは終わりました
はい、ねえ。コードは書かれていましたが、前学期だったので忘れ物が多かったです。そして、vs2019をアンインストールしました。このコードは、すべての人が学習して使用できるように、全体としてのみ作成できます。そのため、スクリーンショットを表示する方法はありません。申し訳ありません。
4.まとめ
この例では、5つのフォームを作成する必要があります。全体的な方法とプロセスについては、前に更新したC#のサンプルアプリケーションを参照してください。これは、ウォーターシリーズの最後のアップデートでもあります。プラットフォームにソースコードをアップロードしますので、フォローすれば無料でダウンロードできます。コード内のさまざまな属性と実行後の効果は、必要に応じて変更できます。具体的な方法や内容については、以前書いたものを参考にしてください。将来的には、ほとんどの主要プロジェクトへのリンクを直接投稿して、誰もがダウンロードできるようにします。もちろん、必要なドキュメントにコメントすることもできます。前の内容をゆっくり整理していきます。
ポータル1.簡単な計算機の実装
ポータル2.学生システム管理システム
ポータル3.ミニゲームデザイン
ポータル4.数学テスト
ポータル4.C#フォームアプリケーションの基本(第1期)
その他はホームページにあります。見てみな。
それがあなたに役立つなら、あなたはフォロー、いいね、そしてお気に入りにすることができます。ご不明な点がございましたら、以下にメッセージを残すか、非公開でチャットしてください。ご協力ありがとうございました
ソースコードをダウンロードするには、ここをクリックしてください。C#はTetrisを実装します
隠れたメリット:最近、組立言語を見直しています。一部の電子書籍はあなたと共有されています。組立言語の関連コンテンツは、次の号でも更新される可能性があります。
1.組立言語(第3版)清華大学プレスリンク:
抽出コード:g2pb
ここをクリックしてダウンロードしてください。
2. People's Posts and Telecommunications Pressが発行したマイクロコンピューターの原理とインターフェース技術
抽出コード:yfaj、
ここをクリックしてダウンロードしてください。
3.アセンブリ言語コンパイラemu8086(中国語版)
ダウンロードするには、ここをクリックしてください。
抽出コード:7jpa