// On "Ok" button private void okButton_Click(object sender, System.EventArgs e) { try { // get new image size int width = Math.Max(1, Math.Min(5000, int.Parse(widthBox.Text))); int height = Math.Max(1, Math.Min(5000, int.Parse(heightBox.Text))); // create appropriate filter switch (methodCombo.SelectedIndex) { case 0: filter = new ResizeNearestNeighbor(width, height); break; case 1: filter = new ResizeBilinear(width, height); break; case 2: filter = new ResizeBicubic(width, height); break; } // close the dialog this.DialogResult = DialogResult.OK; this.Close( ); } catch (Exception) { MessageBox.Show(this, "Incorrect values are entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// On "Ok" button private void okButton_Click( object sender, System.EventArgs e ) { try { // get new image size int width = Math.Max( 1, Math.Min( 5000, int.Parse( widthBox.Text ) ) ); int height = Math.Max( 1, Math.Min( 5000, int.Parse( heightBox.Text ) ) ); // create appropriate filter switch ( methodCombo.SelectedIndex ) { case 0: filter = new ResizeNearestNeighbor( width, height ); break; case 1: filter = new ResizeBilinear( width, height ); break; case 2: filter = new ResizeBicubic( width, height ); break; } // close the dialog this.DialogResult = DialogResult.OK; this.Close( ); } catch ( Exception ) { MessageBox.Show( this, "Incorrect values are entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } }