/* This file is part of AHD Subtitles Maker Professional
   A program can create and edit subtitles

   Copyright © Ala I Hadid 2009 - 2012

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Reflection;
using System.Resources;
namespace AHD.SM.Forms
{
    public partial class Frm_AboutASM : Form
    {
        public Frm_AboutASM(string version)
        {
            InitializeComponent();
            ResourceManager resources = new ResourceManager("AHD.SM.Forms.LanguageResources.Resource",
            Assembly.GetExecutingAssembly());

            label_version.Text = resources.GetString("Version") + ": " + version;
            richTextBox2.Rtf = Properties.Resources.CREDIT;

            //components
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string[] files = Directory.GetFiles(directory, "*", SearchOption.AllDirectories);
            int i = 0;
            foreach (string file in files)
            {
                if (Path.GetExtension(file).ToLower() == ".exe" || Path.GetExtension(file).ToLower() == ".dll")
                {
                    try
                    {
                        imageList1.Images.Add(Icon.ExtractAssociatedIcon(file));
                        Assembly assembly = Assembly.LoadFile(file);
                        ListViewItem item = new ListViewItem();
                        item.Text = Path.GetFileName(file);
                        //version
                        item.SubItems.Add(assembly.GetName().Version.ToString());
                        //copyright
                        object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
                        if (attributes.Length == 0)
                        {
                            item.SubItems.Add("");
                        }
                        else
                            item.SubItems.Add(((AssemblyCopyrightAttribute)attributes[0]).Copyright);
                        //description
                        attributes = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
                        if (attributes.Length == 0)
                        {
                            item.SubItems.Add("");
                        }
                        else
                            item.SubItems.Add(((AssemblyDescriptionAttribute)attributes[0]).Description);

                        item.ImageIndex = i;
                        listView1.Items.Add(item);
                        i++;
                    }
                    catch { }
                   
                }
            }
        }

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

       

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://barnamenevisjavan.com");
        }

        private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("https://www.facebook.com/mahdidvb");
        }

        
    }
}
