コード例 #1
0
ファイル: MemoryGrid.cs プロジェクト: PajLe/memory-game
 private void closeEmUp(object sender, EventArgs e)
 {
     closeTimer.Stop();
     previousOpenedField.Close();
     previousOpenedField = null;
     closedFields++;
     (closeTimer.Tag as ClosableField)?.Close();
     closedFields++;
 }
コード例 #2
0
ファイル: MemoryGrid.cs プロジェクト: PajLe/memory-game
        private void CloseFieldsRoutine(ClosableField currentOpenedField)
        {
            if (currentOpenedField == null)
            {
                return;
            }

            closeTimer.Tag = currentOpenedField;
            closeTimer.Start();
            this.Parent.Text = closedFields.ToString();
        }
コード例 #3
0
ファイル: MemoryGrid.cs プロジェクト: PajLe/memory-game
        private void Field_Click(object sender, EventArgs e)
        {
            if (closeTimer.Enabled)
            {
                closeEmUp(closeTimer, null);
            }

            Field fld = sender as Field;

            if (fld == null)
            {
                return;
            }

            if (fld.Open())
            {
                Application.DoEvents();
                closedFields--;
                this.Parent.Text = closedFields.ToString();
                BeginAndEndHandle();
                if (previousOpenedField == null)
                {
                    previousOpenedField = fld as ClosableField;
                }
                else
                {
                    if (!previousOpenedField.OpenImage.Tag.Equals(fld.OpenImage.Tag))
                    {
                        CloseFieldsRoutine(fld as ClosableField);
                    }
                    else // we found a pair
                    {
                        previousOpenedField = null;
                        pairCount--;
                        if (pairCount == 0)
                        {
                            OpenAllFields();
                        }
                    }
                }
            }
        }