private void ImportButton_Click(object sender, EventArgs e) { try { if (ImportFileDialog.ShowDialog() != DialogResult.OK) { return; } Texture = new Bitmap(ImportFileDialog.FileName); if (Texture != null) { BaseZoom = Math.Min((float)PreviewPanel.ClientSize.Width / Texture.Width, (float)PreviewPanel.ClientSize.Height / Texture.Height); PropertiesTextBox.Text = "[" + Texture.PixelFormat + "] " + Texture.Width + " x " + Texture.Height; ExportButton.Enabled = true; } else { ExportButton.Enabled = false; } RepairOffset(); PreviewPanel.Invalidate(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error: Can not import texture."); } }
private void PreviewPanel_MouseUp(object sender, MouseEventArgs e) { Drag.EndDrag(); CommitCorrection(); Drag.Init(); PreviewPanel.Invalidate(); }
private void PreviewPanel_MouseWheel(object sender, MouseEventArgs e) { float OldZoom = Zoom; if (e.Delta > 0) { Zoom *= 2.0f; } if (e.Delta < 0) { Zoom /= 2.0f; } if (BaseZoom * Zoom < 0.01f) { Zoom = OldZoom; } if (BaseZoom * Zoom > 100.0f) { Zoom = OldZoom; } RepairOffset(); PreviewPanel.Invalidate(); }
private void LaserComboBox_SelectedIndexChanged(object sender, EventArgs e) { this.CommitCorrection(); CurrentLaserIndex = this.LaserComboBox.Items.Count == 0 ? -1 : this.LaserComboBox.SelectedIndex; if (loading) { return; } LoadFromSettings(); PreviewPanel.Invalidate(); }
private void TextureForm_Resize(object sender, EventArgs e) { if (Texture != null) { BaseZoom = Math.Min((float)PreviewPanel.ClientSize.Width / Texture.Width, (float)PreviewPanel.ClientSize.Height / Texture.Height); } RepairOffset(); PreviewPanel.Invalidate(); }
private void PreviewPanel_MouseMove(object sender, MouseEventArgs e) { if (!MouseHold) { return; } OffsetX += e.Location.X - MousePt.X; OffsetY += e.Location.Y - MousePt.Y; RepairOffset(); MousePt = e.Location; PreviewPanel.Invalidate(); }
public BitmapForm(Bitmap bitmap = null) { InitializeComponent(); PreviewPanel.MouseWheel += PreviewPanel_MouseWheel; Texture = bitmap; MouseHold = false; MousePt = new PointF(); OffsetX = PreviewPanel.ClientSize.Width / 2; OffsetY = PreviewPanel.ClientSize.Height / 2; Zoom = 1.0f; BaseZoom = 1.0f; if (Texture != null) { BaseZoom = Math.Min((float)PreviewPanel.ClientSize.Width / Texture.Width, (float)PreviewPanel.ClientSize.Height / Texture.Height); PropertiesTextBox.Text = "[" + Texture.PixelFormat + "] " + Texture.Width + " x " + Texture.Height; ExportButton.Enabled = true; } else { ExportButton.Enabled = false; } typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, PreviewPanel, new object[] { true }); RepairOffset(); PreviewPanel.Invalidate(); }
private void ReInitButton_Click(object sender, EventArgs e) { ClearCorrection(); PreviewPanel.Invalidate(); }
private void imageButton1_Click(object sender, EventArgs e) { ClearCurrentLaserCorrection(); PreviewPanel.Invalidate(); }
private void imageButton2_Click(object sender, EventArgs e) { Drag.Init(); PreviewPanel.Invalidate(); }
private void PreviewPanel_SizeChanged(object sender, EventArgs e) { PreviewPanel.Invalidate(); }