public void SourceTextBox_KeyPress(object sender, KeyPressEventArgs e) { try { if (InHouseRadioButton.Checked) { if ((e.KeyChar >= 48 && e.KeyChar <= 57) || e.KeyChar == 8) { e.Handled = false; } else { MessageBox.Show("Please enter a number.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); SourceTextBox.Clear(); e.Handled = true; } } else { if (e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back || e.KeyChar == (char)Keys.Space)) { e.Handled = true; base.OnKeyPress(e); MessageBox.Show("Please enter a Letter.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); SourceTextBox.Clear(); } } } catch (Exception) { MessageBox.Show("Incorrect datatype for part source.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void Clear_Click(object sender, RoutedEventArgs e) { string cmd = (sender as Button).CommandParameter.ToString(); switch (cmd) { case "ClearInput": { SourceTextBox.Clear(); } break; case "ClearResult": { ResultTextBox.Clear(); } break; default: break; } }
private void OutsourcedRadioButton_CheckedChanged(object sender, EventArgs e) { CompanyMachineToggle.Text = "Company Name"; IsOutsourced = true; SourceTextBox.Clear(); }
private void InHouseRadioButton_CheckedChanged(object sender, EventArgs e) { CompanyMachineToggle.Text = "Machine ID"; IsOutsourced = false; SourceTextBox.Clear(); }
private void SelectSourceButton_Click(object sender, EventArgs e) { string fileName; using (var op = new OpenFileDialog { Filter = Consts.BitmapImportFilter }) { if (op.ShowDialog() != DialogResult.OK) { return; } fileName = op.FileName; } try { if (m_originalBitmap != null) { m_originalBitmap.Dispose(); } m_originalBitmap = BitmapProcessor.LoadBitmapFromFile(fileName); if (m_originalBitmap.Width > 2048 || m_originalBitmap.Height > 2048) { if (m_monochromeBitmap != null) { m_monochromeBitmap.Dispose(); m_monochromeBitmap = null; } SourceTextBox.Clear(); ResizeContainerPanel.Enabled = false; ConversionContainerPanel.Enabled = false; m_doNotUpdateMonochrome = true; NewWidthUpDown.Value = m_width = (int)NewWidthUpDown.Minimum; NewHeightUpDown.Value = m_height = (int)NewHeightUpDown.Minimum; m_doNotUpdateMonochrome = false; ImagePreviewSurface.Invalidate(); OkButton.Enabled = false; InfoBox.Show("Selected images is too big. Choose an image that has dimension lower than 2048x2048."); } else { SourceTextBox.Text = fileName; ConversionContainerPanel.Enabled = true; if (m_importMode) { NewWidthUpDown.Value = m_width = m_desireWidth; NewHeightUpDown.Value = m_height = m_desireHeight; } else { ResizeContainerPanel.Enabled = true; m_doNotUpdateMonochrome = true; NewWidthUpDown.Value = m_width = m_originalBitmap.Width; NewHeightUpDown.Value = m_height = m_originalBitmap.Height; m_doNotUpdateMonochrome = false; } CreateMonochromeBitmap(); ImagePreviewSurface.Invalidate(); OkButton.Enabled = true; } } catch (Exception ex) { InfoBox.Show("An error occured during opening image file!\n" + ex.Message); } }
private void SourceTextBox_MouseDown(object sender, MouseEventArgs e) { SourceTextBox.DoDragDrop(SourceTextBox.Text, DragDropEffects.Move); SourceTextBox.Clear(); }