Example #1
0
        private void RotateImage(int degrees)
        {
            if (!m_imageStates.TryGetValue(m_imageFileName, out var state))
            {
                state = new ImageState();
                m_imageStates.Add(m_imageFileName, state);
            }

            state.Rotation += degrees;

            while (state.Rotation >= 360)
            {
                state.Rotation -= 360;
            }

            if (degrees > 0)
            {
                ImageBoxControl.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
            }
            else
            {
                ImageBoxControl.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
            }

            ImageBoxControl.ZoomToFit();
        }
Example #2
0
        private void SetImage(string imageDirectory, string imageFileName, int currentIndex, int maxIndex)
        {
            m_imageDirectory   = imageDirectory;
            m_imageFileName    = imageFileName;
            m_currentFileIndex = currentIndex + 1;
            m_maxFileIndex     = maxIndex;

            var oldImage = ImageBoxControl.Image;

            if (imageFileName != null)
            {
                if (imageFileName == "CLIPBOARD")
                {
                    ImageBoxControl.Image = Clipboard.GetImage();
                    ImageBoxControl.Text  = null;
                }
                else
                {
                    try
                    {
                        var image = ImageLoader.Load(imageFileName);
                        LoadUserRotationState(imageFileName, image);
                        ImageBoxControl.Image = image;
                        ImageBoxControl.Text  = null;
                    }
                    catch (Exception e)
                    {
                        ImageBoxControl.Image = null;
                        ImageBoxControl.Text  = e.Message;
                        m_currentFileIndex    = 0;
                    }
                }
            }
            else
            {
                ImageBoxControl.Image = null;
                ImageBoxControl.Text  = "No File";
                m_currentFileIndex    = 0;
            }

            if (oldImage != null)
            {
                oldImage.Dispose();
            }

            ImageBoxControl.ZoomToFit();

            UpdateTitle();
        }
Example #3
0
        private void FullScreen(bool fullScreen)
        {
            if (fullScreen)
            {
                this.FormBorderStyle = FormBorderStyle.None;
                this.WindowState     = FormWindowState.Maximized;
                ImageBoxControl.ZoomToFit();
            }
            else
            {
                this.WindowState     = FormWindowState.Normal;
                this.FormBorderStyle = FormBorderStyle.Sizable;
            }

            m_isFullScreen = fullScreen;
        }
Example #4
0
        private void LoadUserRotationState(string fileName, Image image)
        {
            if (m_imageStates.TryGetValue(fileName, out var state))
            {
                switch (state.Rotation)
                {
                case 90:
                    image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    break;

                case 180:
                    image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                    break;

                case 270:
                    image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    break;
                }

                ImageBoxControl.ZoomToFit();
            }
        }
Example #5
0
        private void ImageForm_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Left:
            case Keys.PageUp:
            case Keys.Up:
                PreviousFile();
                break;

            case Keys.Right:
            case Keys.PageDown:
            case Keys.Down:
                NextFile();
                break;

            case Keys.Space:
                if (e.Shift)
                {
                    PreviousFile();
                }
                else
                {
                    NextFile();
                }
                break;

            case Keys.Home:
                FirstFile();
                break;

            case Keys.End:
                LastFile();
                break;

            case Keys.R:
                if (e.Shift)
                {
                    RotateImage(-90);
                }
                else
                {
                    RotateImage(90);
                }
                ImageBoxControl.ZoomToFit();
                break;

            case Keys.G:
                m_windowManager.OpenRangerWindow(m_imageDirectory);
                break;

            case Keys.F11:
                FullScreen(!m_isFullScreen);
                break;

            case Keys.Escape:
                if (m_isFullScreen)
                {
                    FullScreen(false);
                }
                else
                {
                    Close();
                }
                break;
            }
        }
Example #6
0
 private void fitToScreenToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ImageBoxControl.ZoomToFit();
 }