using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Reflection;
using System.IO;

namespace iSTP_Core
{
    /// <summary>
    /// Show all information from ReleaseNotes.txt
    /// </summary>
    public partial class AboutDlg : Form
    {
        public AboutDlg()
        {
            InitializeComponent();
        }

        private void AboutDlg_Load(object sender, EventArgs e)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            var descriptionAttribute = assembly
                                      .GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)
                                      .OfType<AssemblyDescriptionAttribute>()
                                      .FirstOrDefault();
            Description_lbl.Text = descriptionAttribute.Description;
            AppName_lbl.Text = typeof(AboutDlg).Assembly.GetName().Name;
            AppVersion_lbl.Text = typeof(AboutDlg).Assembly.GetName().Version.ToString();
            var copyrightAttribute = assembly
                                      .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)
                                      .OfType<AssemblyCopyrightAttribute>()
                                      .FirstOrDefault();
            Copyright_lbl.Text = copyrightAttribute.Copyright;

            
            try
            {
                string resource = "iSTP_Core.ReleaseNotes.txt";
                Stream rns = assembly.GetManifestResourceStream(resource);
                ChangeList_txt.LoadFile(rns, RichTextBoxStreamType.PlainText);
            }
            catch
            {
                MessageBox.Show("Error accessing resources!");
            }
        }
    }
}