using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace WSDDBBrowser
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : MetroWindow
    {
        public MainWindow()
        {
            InitializeComponent();

            App.MetroWindow = this;
            this.frame.Content = new PgMain();


            Title = GetTitle();
        }
        string GetTitle() 
        {
            //显示版本号
            Assembly asm = Assembly.GetAssembly(this.GetType());

            AssemblyProductAttribute asmproduct = (AssemblyProductAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyProductAttribute));
            Version version = asm.GetName().Version;

            string version_str = string.Format("v{0}.{1}.{2}", version.Major, version.Minor, version.Build);
            string location = asm.Location;
            string buliddt;
            if (!string.IsNullOrEmpty(location))
            {
                buliddt = System.IO.File.GetLastWriteTime(location).ToString("yyyyMMdd");
            }
            else
            {
                buliddt = "";
            }
            string Product = asmproduct.Product;
            string V = version_str;
            string BuildTime = buliddt;

            if (!string.IsNullOrEmpty(BuildTime))
            {
                return Product + " " + V + " at " + BuildTime;
            }
            else
            {
                return Product + " " + V;
            }
        }

        private void ButtonGitLabClick(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://private.flyautomation.net:82/panruising/weishida_dbbrower");
        }

    }
}
