Пример #1
0
        private void PanoramaPictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (PanoramaPictureBox.Capture)
                {
                    int dx = e.X - lastX;
                    int dy = e.Y - lastY;
                    currentX += dx;
                    currentY += dy;
                    lastX     = e.X;
                    lastY     = e.Y;

                    if (currentY > 0)
                    {
                        currentY = 0;
                    }
                    else if (currentY < -(img.Height * PbDpiY / ImgDpiY - PanoramaPictureBox.Height))
                    {
                        currentY = -(img.Height * PbDpiY / ImgDpiY - PanoramaPictureBox.Height);
                    }
                    if (2 * img.Width * PbDpiX / ImgDpiX - Math.Abs(currentX) < PanoramaPictureBox.Width) //Формула контроля расстояния до крайней правой точки второго изображения от правой границы области просмотра.
                    {
                        currentX += img.Width * PbDpiX / ImgDpiX;
                    }
                    if (img.Width * PbDpiX / ImgDpiX - currentX - PanoramaPictureBox.Width < -PanoramaPictureBox.Width)
                    {
                        currentX -= img.Width * PbDpiX / ImgDpiX;
                    }

                    PanoramaPictureBox.Invalidate();
                }
            }
        }
Пример #2
0
        private void ClearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            img.Dispose();
            img = new Bitmap(@"Panoramas\Sample.png");

            ImgDpiX = Convert.ToInt32(img.HorizontalResolution);
            ImgDpiY = Convert.ToInt32(img.VerticalResolution);

            currentX = -(img.Width * PbDpiX / ImgDpiX - PanoramaPictureBox.Width) / 2;
            currentY = -(img.Height * PbDpiY / ImgDpiY - PanoramaPictureBox.Height) / 2;

            PanoramaNameLabel.Text = Program.LocaleLabelsMF[0];

            PanoramaPictureBox.Invalidate();
        }
Пример #3
0
        private void OpenPanoramaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (PanoramaOpenFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            Bitmap NewImage = new Bitmap(PanoramaOpenFileDialog.FileName);

            if (NewImage.Width < StandardPanoramaSize.Width || NewImage.Height < StandardPanoramaSize.Height)
            {
                if (Program.ResizeImage)
                {
                    img = new Bitmap(NewImage, StandardPanoramaSize.Width, StandardPanoramaSize.Height);
                }
                else
                {
                    MessageBox.Show(Program.LocaleMessageBoxes[1], Program.LocaleMessageBoxes[0], MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }
            else
            {
                img = NewImage;
            }


            ImgDpiX = Convert.ToInt32(img.HorizontalResolution);
            ImgDpiY = Convert.ToInt32(img.VerticalResolution);

            currentX = -(img.Width * PbDpiX / ImgDpiX - PanoramaPictureBox.Width) / 2;
            currentY = -(img.Height * PbDpiY / ImgDpiY - PanoramaPictureBox.Height) / 2;

            PanoramaNameLabel.Text = PanoramaOpenFileDialog.SafeFileName;

            PanoramaPictureBox.Invalidate();
        }