private void closeEmUp(object sender, EventArgs e) { closeTimer.Stop(); previousOpenedField.Close(); previousOpenedField = null; closedFields++; (closeTimer.Tag as ClosableField)?.Close(); closedFields++; }
private void CloseFieldsRoutine(ClosableField currentOpenedField) { if (currentOpenedField == null) { return; } closeTimer.Tag = currentOpenedField; closeTimer.Start(); this.Parent.Text = closedFields.ToString(); }
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(); } } } } }