public MainWindow()
        {
            DataContext = _translateModel;
            InitializeComponent();
            _notifyIcon.Text         = @"Google translate desktop";
            _notifyIcon.Visible      = true;
            _notifyIcon.Icon         = new System.Drawing.Icon(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logo.ico"));
            _notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
            if (!AppSettingsManager.ExistConfig())
            {
                _notifyIcon.BalloonTipTitle = @"Hi, 我在这儿呢";
                _notifyIcon.BalloonTipText  = @"使用快捷键 Control+` 可以打开我哦";
                _notifyIcon.ShowBalloonTip(5000);
            }

            Closing += MainWindow_Closing;

            var menuItems = new[]
            {
                //new MenuItem("热键",SetHotKey),
                new MenuItem("开机启动", SetAutoStartup)
                {
                    Name = "AutoStartup", Checked = AutoStartup.IsExistKey("Google translate desktop"),
                },
                new MenuItem("开打主窗口( Control+` )", Show),
                new MenuItem("退出", Exit)
            };

            _notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(menuItems);

            _translateModel.OnChangeTargetLanguage += async arg => { await _translateModel.Translate(); };
            var appSettings = AppSettingsManager.Read();

            if (appSettings.TopMost)
            {
                Topmost             = true;
                TopMostIcon.Source  = BitmapFrame.Create(new Uri("pack://application:,,,/resources/topmost_yes.ico", UriKind.RelativeOrAbsolute));
                TopMostIcon.ToolTip = "取消置顶";
            }
            else
            {
                Topmost             = false;
                TopMostIcon.Source  = BitmapFrame.Create(new Uri("pack://application:,,,/resources/topmost_no.ico", UriKind.RelativeOrAbsolute));
                TopMostIcon.ToolTip = "置顶";
            }

            var lag = _translateModel.Languages.FirstOrDefault(p => p.Code == (string.IsNullOrWhiteSpace(appSettings.CurrentTargetLanguage) ? "en" : appSettings.CurrentTargetLanguage));

            if (lag != null)
            {
                _translateModel.TargetLanguage     = lag.Code;
                _translateModel.TargetLanguageText = lag.Name;
            }



            InputTextBox.Focus();
            HideWindow();
        }
        private void SetAutoStartup(object sender, EventArgs e)
        {
            var menu = (MenuItem)sender;

            if (AutoStartup.SelfRunning(!menu.Checked, "Google translate desktop",
                                        System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GoogleTranslate.Desktop.exe")))
            {
                menu.Checked = !menu.Checked;
            }
            else
            {
                this.ShowMessageAsync("错误", "设置失败,请以管理员身份运行!");
            }
        }