Пример #1
0
        private async void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            DisableAll();
            label.Content = "验证配置文件...";
            await Task.Delay(100);

            probar.IsIndeterminate = true;
            try
            {
                LoadProfile();
            }
            catch (Exception)
            {
                MessageBox.Show("启动器读不了配置文件惹!阁下是不是加了访问权限呢?", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                Close();
            }
            try
            {
                FileChecksun();
                InitDeleteFakeFile();
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("请将本程序放入游戏根目录后运行!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
                Close();
            }
            catch (FileLoadException)
            {
                MessageBox.Show("你的游戏似乎是纯联机版,单人游戏将被禁用。如需进行单人游戏请下载完整版", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                cansp = false;
            }
            catch (Exception)
            {
                MessageBox.Show("启动器出错了呢,请阁下检查一下游戏根目录有没有以前版本的启动器和其他乱七八糟的文件呢,如果有的话先清理一下吧。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                Close();
            }
            await Task.Delay(1000);

            label.Content          = "检查更新...";
            probar.IsIndeterminate = true;
            try
            {
                await Task.Factory.StartNew(() => CheckUpdate.DoCheckUpdate(new Uri("http://superteknomw3-upgrade.daoapp.io/upgrade.html")));

                string version    = CheckUpdate.version;
                string info       = CheckUpdate.info;
                bool   isforcibly = CheckUpdate.isforcibly;

                if (version != "1.1.4_r2")
                {
                    if (isforcibly)
                    {
                        MessageBoxResult result = MessageBox.Show("检测到新版本:" + version + "\n" + info + "\n\n请下载新版本后进行游戏!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                        Process.Start("http://bbs.3dmgame.com/thread-5030431-1-1.html");
                        Close();
                    }
                    else if (profile.SkipUpdate == false)
                    {
                        MessageBoxResult result = MessageBox.Show("检测到新版本:" + version + "\n" + info + "\n\n本次更新是非强制性的,是否立即下载新版本?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
                        if (result == MessageBoxResult.Yes)
                        {
                            Process.Start("http://bbs.3dmgame.com/thread-5030431-1-1.html");
                            Close();
                        }
                        else
                        {
                            profile.SkipUpdate = true;
                            SaveProfile();
                            await Task.Delay(1000);

                            label.Content          = "准备就绪了呢";
                            probar.IsIndeterminate = false;
                        }
                    }
                    else
                    {
                        label.Content          = "准备就绪了呢";
                        probar.IsIndeterminate = false;

                        if (newuser)
                        {
                            MessageBoxResult result = MessageBox.Show("阁下可能是第一次使用 SuperTeknoMW3 呢,本喵强烈建议你看一下使用帮助。\n是否立即查看?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
                            if (result == MessageBoxResult.Yes)
                            {
                                Help help = new Help();
                                help.ShowDialog();
                            }
                        }
                    }
                }
                else
                {
                    label.Content          = "准备就绪了呢";
                    probar.IsIndeterminate = false;

                    if (newuser)
                    {
                        MessageBoxResult result = MessageBox.Show("阁下可能是第一次使用 SuperTeknoMW3 呢,本喵强烈建议你看一下使用帮助。\n是否立即查看?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
                        if (result == MessageBoxResult.Yes)
                        {
                            Help help = new Help();
                            help.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                label.Content          = ex.Message;
                probar.IsIndeterminate = false;
            }
            finally
            {
                EnableAll();
            }
        }