public static MaskResult MaskForm_Execute() { var result = new MaskResult(); using (MaskaForm form = new MaskaForm()) { form.okButton.DialogResult = DialogResult.OK; form.cancelButton.DialogResult = DialogResult.Cancel; form.smallRadio.Checked = true; while (true) { result.Result = form.ShowDialog(); if (result.Result == DialogResult.OK) { if (!CheckText_Error(form)) { var cnt = GetAll(form, typeof(TextBox)); int z = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { string pole = "textBox" + z; foreach (var arg in cnt) { if (arg.Name == pole) { result.MaskaTable[i, j] = int.Parse(arg.Text); z++; break; } } } } result.Size = form.smallRadio.Checked ? 3 : 5; return(result); } else { MessageBox.Show("Błędna wartość pola, znak \"-\" powinien znajdować się na początku!", "", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } } if (result.Result == DialogResult.Cancel) { return(result); } } } }
private static bool CheckText_Error(MaskaForm form) { var cnt = GetAll(form, typeof(TextBox)); foreach (var arg in cnt) { if (arg.Text.LastIndexOf("-") > 0) { return(true); } } return(false); }
private void maskaToolStripMenuItem_Click(object sender, EventArgs e) { progressBar1.Visible = false; if (obiektObrazek != null && KopiaPictureBox.Image != null) { var result = MaskaForm.MaskForm_Execute(); if (result.Result == DialogResult.OK) { obiektObrazek.AddOperation_toList(obiektObrazek.Kopia); obiektObrazek.Kopia = Tools.PerformMaska(obiektObrazek.Kopia, result.MaskaTable, result.Size); Bitmap obrazek1 = Tools.Zoom(new Bitmap(obiektObrazek.Kopia), zoomFactor); KopiaPictureBox.Size = obrazek1.Size; KopiaPictureBox.Image = obrazek1; Center(); } } }