Beispiel #1
0
        /// <summary>
        /// 点击菜单项:检查更新,如有更新,提示是否更新
        /// </summary>
        private void Update(bool confirm = true)
        {
            var model = new UpdateModel();
            var view  = model.view;

            view.Confirm.Click += (sender, args) =>
            {
                CloseDialog(view);
                if (!model.restart)
                {
                    return;
                }

                // 运行restart.bat重启应用程序
                Process.Start(model.CreateBat());
                Application.Exit();
            };

            // 检查更新
            var count = model.CheckUpdate();

            if (count == 0)
            {
                if (confirm)
                {
                    Messages.ShowMessage("当前无可用更新!");
                }
                return;
            }

            var msg = $"当前有 {count} 个文件需要更新,是否立即更新?";

            if (confirm && !Messages.ShowConfirm(msg))
            {
                return;
            }

            view.ShowDialog();
        }