Пример #1
0
        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.");
            }
        }
Пример #2
0
 private void PreviewPanel_MouseUp(object sender, MouseEventArgs e)
 {
     Drag.EndDrag();
     CommitCorrection();
     Drag.Init();
     PreviewPanel.Invalidate();
 }
Пример #3
0
        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();
        }
Пример #4
0
 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();
 }
Пример #5
0
        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();
        }
Пример #6
0
        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();
        }
Пример #7
0
        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();
        }
Пример #8
0
 private void ReInitButton_Click(object sender, EventArgs e)
 {
     ClearCorrection();
     PreviewPanel.Invalidate();
 }
Пример #9
0
 private void imageButton1_Click(object sender, EventArgs e)
 {
     ClearCurrentLaserCorrection();
     PreviewPanel.Invalidate();
 }
Пример #10
0
 private void imageButton2_Click(object sender, EventArgs e)
 {
     Drag.Init();
     PreviewPanel.Invalidate();
 }
Пример #11
0
 private void PreviewPanel_SizeChanged(object sender, EventArgs e)
 {
     PreviewPanel.Invalidate();
 }