Example #1
0
        public Game(int lvl)
        {
            InitializeComponent();
            DoubleBuffered = true;

            HintUsed = true;
            HintTimeLeft = 30;
            HintTimer = new Timer();
            HintTimer.Interval = 1000;
            HintTimer.Tick += new EventHandler(HintTimerTick);

            HintTimer.Start();

            Constants = new Constants();

            InitializeLevel(lvl);

            Paint += new PaintEventHandler(OnPaint);
        }
        public SelectLevel()
        {
            InitializeComponent();
            DoubleBuffered = true;

            Constants = new Constants();
            levels = new List<Label>();

            //Properties.Settings.Default.Level = 50;
            //Properties.Settings.Default.Save();

            maxLevel = Properties.Settings.Default.Level;

            float y = 50;

            for (int i = 0; i < Constants.LevelMatrices.Count; i++)
            {
                int rows =  i / 10;
                int cols = i % 10;

                int jumpOffset = 0;

                if (rows % 2 != 0)
                {
                    jumpOffset = 30;
                }

                float x = 50 + jumpOffset;

                int countLvl = i + 1;

                Label lbl = new Label();
                lbl = new Label();
                lbl.Click += new EventHandler(Play);
                lbl.Location = new Point((int)x + 60 * cols, (int)y + 50 * rows);
                lbl.TextAlign = ContentAlignment.MiddleCenter;

                if (i < maxLevel)
                {
                    lbl.Image = Resources.filled;
                }
                else if (i == maxLevel)
                {
                    lbl.Image = Resources.selected;
                }
                else
                {
                    lbl.Image = Resources.free;
                }

                lbl.Height = 50;
                lbl.Width = 50;
                lbl.Text = countLvl + "";
                lbl.Font = new Font("Calibri", 10);
                lbl.ForeColor = Color.Black;
                lbl.Tag = i;
                lbl.Cursor = Cursors.Hand;
                lbl.BackColor = Color.Transparent;

                levels.Add(lbl);
                Controls.Add(lbl);
            }

            y += 48;
        }