using Apewer.Surface;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Apewer.Tray
{
    class MainForm : Form
    {

        private void InitializeComponent()
        {
            SuspendLayout();
            AutoScaleMode = AutoScaleMode.None;
            StartPosition = FormStartPosition.CenterScreen;
            ClientSize = new Size(900, 600);
            Font = FormsUtility.DefaultFont;
            Text = "MainForm";
            ResumeLayout(false);
        }

        public MainForm()
        {
            Load += (s, e) => Init();
        }

        ListBox _listbox;

        void Init()
        {
            Padding = new Padding(30, 30, 30, 30);

            _listbox = new ListBox();
            _listbox.Dock = DockStyle.Fill;
            Controls.Add(_listbox);

            Resize += (s, e) => Log(nameof(Resize), Width, Height);
            ResizeBegin += (s, e) => Log(nameof(ResizeBegin), Width, Height);
            ResizeEnd += (s, e) => Log(nameof(ResizeEnd), Width, Height);

            Paint += (s, e) => Log(nameof(ResizeBegin), $"X={e.ClipRectangle.X}", $"Y={e.ClipRectangle.Y}", $"Width={e.ClipRectangle.Width}", $"X={e.ClipRectangle.Height}");
        }

        void Log(params object[] segs)
        {
            var text = TextUtility.Join("|", segs);
            Logger.Write(text);
            if (_listbox != null)
            {
                _listbox.Items.Add(text);
                _listbox.TopIndex = _listbox.Items.Count - (int)(_listbox.Height / _listbox.ItemHeight);
            }
        }

    }

}