using System;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;
using NotepadEnhanced.Helpers;

namespace NotepadEnhanced.GUI.Forms
{
    public partial class AboutForm : Form
    {
        public AboutForm()
        {
            InitializeComponent();
            lblVersion.Text +=  " " + Application.ProductVersion;
            btnLogoLink.Location = new Point(this.Width + btnLogoLink.Width, btnLogoLink.Location.Y);
            tmrAnimate.Start();
        }

        private void btnLogo_Click(object sender, EventArgs e)
        {
            GotoAdress(Properties.Resources.DeveloperWebSite);
        }

        private void tmrAnimate_Tick(object sender, EventArgs e)
        {
            if (btnLogoLink.Location.X <= this.Width - btnLogoLink.Width - 24)
            {
                tmrAnimate.Stop();
            }
            else
            {
                int xPos = btnLogoLink.Location.X - 1;
                btnLogoLink.Location = new Point(xPos, btnLogoLink.Location.Y);
            }
        }

        private void linkEmail_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            GotoAdress("mailto:" + Properties.Resources.DeveloperEmail);
        }

        private static void GotoAdress(string adress)
        {
            try
            {
                Process.Start(adress);
            }
            catch (Exception ex)
            {
                MsgBox.Show(ex.Message);
            }
        }
    }
}
