using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace Azyobuzi.Twirunrun
{
    public partial class PictureViewer : Form
    {
        public PictureViewer()
        {
            InitializeComponent();
        }

        private void PictureViewer_Load(object sender, EventArgs e)
        {
            checkBox1.Checked = Settings.Instance.PictureViewerAutoSize;
            Settings.Instance.ViewerForm.Restore(this);

            checkBox1_CheckedChanged(checkBox1, EventArgs.Empty);
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            Settings.Instance.PictureViewerAutoSize = checkBox1.Checked;
            if (checkBox1.Checked)
            {
                PictureBox.SizeMode = PictureBoxSizeMode.Zoom;
                PictureBox.Dock = DockStyle.Fill;
            }
            else
            {
                PictureBox.Dock = DockStyle.None;
                PictureBox.SizeMode = PictureBoxSizeMode.AutoSize;
            }
        }
        
        private void PictureViewer_BoundsChanged(object sender, EventArgs e)
        {
            if (WindowState == FormWindowState.Normal)
                Settings.Instance.ViewerForm = FormSettings.FromForm(this);
            Settings.Instance.ViewerForm.WindowState = this.WindowState;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
