示例#1
0
        private void zoomOutContextMenuItem_Click(object sender, EventArgs e)
        {
            if (fractalStack.Count > 0)
            {
                FractalContext fc = fractalStack.Pop();
                if (fractalStack.Count == 0)
                {
                    zoomOutMenuItem.Enabled        = false;
                    zoomOutContextMenuItem.Enabled = false;
                    zoomOutToolbarButton.Enabled   = false;
                }
                xstart = fc.Xstart;
                ystart = fc.Ystart;
                xend   = fc.Xend;
                yend   = fc.Yend;
                xzoom  = fc.Xzoom;
                yzoom  = fc.Yzoom;
                bitmap = fc.Bitmap;

                pictureBox.Image = bitmap;

                graphics = Graphics.FromImage(pictureBox.Image);
                DoMandelbrot();
            }
        }
示例#2
0
        private void pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            int mouse_selection_height, mouse_selection_width;

            if (mouseLeftPressed)
            {
                mouseLeftPressed = false;
                if (action)
                {
                    mouse_x_end = e.X;
                    mouse_y_end = e.Y;
                    if (mouse_x_start > mouse_x_end)
                    {
                        int temp = mouse_x_start;
                        mouse_x_start = mouse_x_end;
                        mouse_x_end   = temp;
                    }
                    if (mouse_y_start > mouse_y_end)
                    {
                        int temp = mouse_y_start;
                        mouse_y_start = mouse_y_end;
                        mouse_y_end   = temp;
                    }
                    mouse_selection_width  = (mouse_x_end - mouse_x_start);
                    mouse_selection_height = (mouse_y_end - mouse_y_start);
                    if ((mouse_selection_width < 2) && (mouse_selection_height < 2))
                    {
                        zoomInContextMenuItem_Click(sender, e);
                    }
                    else
                    {
                        FractalContext fc = new FractalContext(bitmap, xstart, ystart, xend, yend, xzoom, yzoom);
                        fractalStack.Push(fc);
                        zoomOutMenuItem.Enabled        = true;
                        zoomOutContextMenuItem.Enabled = true;
                        zoomOutToolbarButton.Enabled   = true;

                        if (((float)mouse_selection_width > (float)mouse_selection_height * xy))
                        {
                            mouse_y_end = (int)((float)mouse_y_start + (float)mouse_selection_width / xy);
                        }
                        else
                        {
                            mouse_x_end = (int)((float)mouse_x_start + (float)mouse_selection_height * xy);
                        }
                        xend    = xstart + xzoom * (double)mouse_x_end;
                        yend    = ystart + yzoom * (double)mouse_y_end;
                        xstart += xzoom * (double)mouse_x_start;
                        ystart += yzoom * (double)mouse_y_start;
                    }
                    xzoom = (xend - xstart) / (double)canvasWidth;
                    yzoom = (yend - ystart) / (double)canvasHeight;
                    DoMandelbrot();

                    isRectangle = false;
                    pictureBox.Invalidate();
                    pictureBox.Refresh();
                }
            }
        }
示例#3
0
        private void zoomInContextMenuItem_Click(object sender, EventArgs e)
        {
            FractalContext fc = new FractalContext(bitmap, xstart, ystart, xend, yend, xzoom, yzoom);

            fractalStack.Push(fc);
            zoomOutMenuItem.Enabled        = true;
            zoomOutContextMenuItem.Enabled = true;
            zoomOutToolbarButton.Enabled   = true;
            mouse_x_start = lastMouseRelativePosition.X - 10;
            mouse_x_end   = lastMouseRelativePosition.X + 10;
            mouse_y_start = lastMouseRelativePosition.Y - 10;
            mouse_y_end   = lastMouseRelativePosition.Y - 10;
            int mouse_selection_width  = (mouse_x_end - mouse_x_start);
            int mouse_selection_height = (mouse_y_end - mouse_y_start);

            if (((float)mouse_selection_width > (float)mouse_selection_height * xy))
            {
                mouse_y_end = (int)((float)mouse_y_start + (float)mouse_selection_width / xy);
            }
            else
            {
                mouse_x_end = (int)((float)mouse_x_start + (float)mouse_selection_height * xy);
            }

            xzoom = (xend - xstart) / (double)canvasWidth * 1000;
            yzoom = (yend - ystart) / (double)canvasHeight * 1000;

            xend    = xstart + xzoom * (double)mouse_x_end;
            yend    = ystart + yzoom * (double)mouse_y_end;
            xstart += xzoom * (double)mouse_x_start;
            ystart += yzoom * (double)mouse_y_start;



            DoMandelbrot();
            isRectangle = false;
            pictureBox.Invalidate();
            pictureBox.Refresh();
        }