Form1.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace Hanoi
{
    public partial class Form1 : Form
    {
        int PlateMargin = 10;
        int MaxPlateWidth, MinPlateWidth = 50;

        int PlateNumber = 5;
        int PlateHeight, MaxPlateHeight = 30;
        int dRadius, dRadiusMax = 15;//盘子半径差
        Label[] Plate = null;
        Stack<int>[] stack = new Stack<int>[3];
        bool isMoving = false;
        public Form1()
        {
            InitializeComponent();

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            btnStop.Enabled = btnReset.Enabled = false;
            stack[0] = new Stack<int>();
            stack[1] = new Stack<int>();
            stack[2] = new Stack<int>();
            MaxPlateWidth = (lblFloor.Width - PlateMargin * 2) / 3;
            lblA.Left = (int)(lblFloor.Left + PlateMargin + 1.0 * MaxPlateWidth / 2 - lblA.Width / 2.0);
            lblB.Left = (int)(lblFloor.Left + PlateMargin + 3.0 * MaxPlateWidth / 2 - lblB.Width / 2.0);
            lblC.Left = (int)(lblFloor.Left + PlateMargin + 5.0 * MaxPlateWidth / 2 - lblA.Width / 2.0);
            CreatePlate();
            initRun();
        }

        //运行前的初始化工作
        private void initRun()
        {
            stack[0].Clear();
            stack[1].Clear();
            stack[2].Clear();
            for (int i = 0; i < PlateNumber; ++i)
            {
                Plate[i].Left = lblFloor.Left + PlateMargin + i * dRadius;
                Plate[i].Top = lblFloor.Top - (PlateHeight - 1) * (i + 1);
                stack[0].Push(i);
            }
        }

        //动态创建盘子、设置其属性,并显示在窗体上
        private void CreatePlate()
        {
后面还有 182 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。