Esempio n. 1
0
        private void kcvCanceling(object o, System.ComponentModel.CancelEventArgs e)
        {
            MessageBoxResult mbr = MessageBox.Show("确定要退出KanColleViewer么?", "HoppoPlugin提示", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (mbr == MessageBoxResult.No)
            {
                e.Cancel = true;
                return;
            }
            NekoAvoidanceSystem.Shutdown();
        }
Esempio n. 2
0
        public HoppoPluginLoader()
        {
            try
            {
                // Initialize HoppoPlugin ONCE.
                if (!UniversalConstants.Initialized)
                {
                    // Check update.
                    CommonHelper.UpdateChecker();

                    // Check version.
                    if (File.Exists(HoppoPluginSettings.UsageRecordPath))
                    {
                        StreamReader s = new StreamReader(HoppoPluginSettings.UsageRecordPath);
                        string       recordedVersion = s.ReadLine();
                        s.Close();
                        if (recordedVersion == "6.0")
                        {
                            // Initialize HP Local Cache System.
                            initializeCacher();
                            // Load settings.
                            HoppoPluginSettings.Load();
                            // Start NAS.
                            NekoAvoidanceSystem.Startup();
                            // Create a instance of MainView.
                            mainView = new MainView {
                                DataContext = new MainViewViewModel {
                                    MapInfoProxy = new MapInfoProxy()
                                }
                            };
                        }

                        // Version is out of date. Clear version record and lead user to welcome window.
                        else
                        {
                            File.Delete(HoppoPluginSettings.UsageRecordPath);
                            File.Delete(HoppoPluginSettings.HPSettingsPath);
                            Welcome w = new Welcome {
                                DataContext = new HoppoPluginSettings()
                            };
                            w.ShowDialog();
                        }
                    }
                    else
                    {
                        Welcome w = new Welcome {
                            DataContext = new HoppoPluginSettings()
                        };
                        w.ShowDialog();
                    }
                    UniversalConstants.Initialized = true;
                }

                // Instance was created. Do nothing.
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("初始化错误!将重置HoppoPlugin以尝试修复此问题。\n" + ex.ToString(), "警告", MessageBoxButton.OK, MessageBoxImage.Error);
                if (Directory.Exists(HoppoPluginSettings.KCVSettingsPath))
                {
                    Directory.Delete(HoppoPluginSettings.KCVSettingsPath, true);
                }
                if (Directory.Exists(UniversalConstants.CurrentVersion + @"\HoppoPlugin\"))
                {
                    Directory.Delete(UniversalConstants.CurrentVersion + @"\HoppoPlugin\", true);
                }
            }
        }