using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Install.Core.Common
{
    /// <summary>
    /// 安装信息
    /// </summary>
    public class InstallInfo
    {
        /// <summary>
        /// 安装目录
        /// </summary>
        public string InstallPath { get; set; }

        /// <summary>
        /// 执行文件相对安装目录路径
        /// </summary>
        public string Exe { get; set; }

        /// <summary>
        /// 快捷方式名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 开机自启动
        /// </summary >
        public bool IsAutoRun { get; set; }

        /// <summary>
        /// 版本
        /// </summary>
        public string Version { get; set; }

        /// <summary>
        /// 安装包 中 最新版本
        /// </summary>
        public string NewestVersion { get; set; }

        /// <summary>
        /// 需要更新
        /// </summary>
        public bool NeedToUpdate { get; set; }

        [Newtonsoft.Json.JsonIgnore]
        /// <summary>
        /// 在注册表中的keyname
        /// </summary>
        public string KeyName
        {
            get
            {

                //对Exe 转换。 
                //1.去掉.exe 
                //2.把所有 .  转为 _
                return ProcessName.Replace('.', '_');

            }
        }

        [Newtonsoft.Json.JsonIgnore]
        /// <summary>
        /// 任务管理器中的名称
        /// </summary>
        public string ProcessName
        {
            get
            {
                //对Exe 转换。 
                //1.去掉.exe 
                return System.IO.Path.GetFileNameWithoutExtension(Exe);

            }
        }

        [Newtonsoft.Json.JsonIgnore]
        /// <summary>
        /// 快捷方式路径
        /// </summary>
        public string ShortcutPath
        {
            get {
                return $@"{InstallPath}\{Name}.lnk";
            }
        }

        [Newtonsoft.Json.JsonIgnore]
        /// <summary>
        /// 执行文件 的绝对路径
        /// </summary>
        public string ExePath
        {
            get {
                return $@"{InstallPath}\{Exe}";
            }
        }
    }
}