Beispiel #1
0
        public void Initialize()
        {
            var dispatcher = new WPFDispatcher(Application.Current.Dispatcher);

            // Initialize Settings
            var settingsImpl = new SettingsImpl((string)null);

            settings_ = new Settings(settingsImpl, dispatcher);

            // Load settings from file if it exists
            if (File.Exists(PluginInfo.SettingsFilePath))
            {
                try {
                    using (var fs = new FileStream(PluginInfo.SettingsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                        var serializer = new DataContractSettingsSerializer();
                        serializer.Deserialize(fs, settingsImpl);
                    }
                }
                catch (Exception ex) {
                    Logger.Error("Failed to load settings from file.", ex);
                    if (ex.IsCritical())
                    {
                        throw;
                    }
                }
            }

            // Initialize settings auto expoter
            expoter_ = new SettingsAutoExpoter(
                PluginInfo.SettingsFilePath, PluginInfo.SettingsFilePath + ".temp",
                settingsImpl, new DataContractSettingsSerializer());
        }
        private void KanColleClient_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (KanColleClient.Current.Homeport != null)
            {
                KanColleClient.Current.PropertyChanged -= KanColleClient_PropertyChanged;

                var admiral    = KanColleClient.Current.Homeport.Admiral;
                var dispatcher = new WPFDispatcher(Application.Current.Dispatcher);

                // Initialize Settings
                var settingsImpl = new SettingsImpl((string)null);
                settings_ = new Settings(settingsImpl, dispatcher);

                // Load settings from file if it exists
                if (File.Exists(PluginInfo.SettingsFilePath))
                {
                    try {
                        using (var fs = new FileStream(PluginInfo.SettingsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                            var serializer = new DataContractSettingsSerializer();
                            serializer.Deserialize(fs, settingsImpl);
                        }
                    }
                    catch (Exception ex) {
                        Logger.Error("Failed to load settings from file.", ex);
                        if (ex.IsCritical())
                        {
                            throw;
                        }
                    }
                }

                // Initialize settings auto expoter
                expoter_ = new SettingsAutoExpoter(
                    PluginInfo.SettingsFilePath, PluginInfo.SettingsFilePath + ".temp",
                    settingsImpl, new DataContractSettingsSerializer());

                viewModel_ = new ViewModels.KanburaTimerToolViewModel(
                    KanColleClient.Current,
                    settings_,
                    dispatcher);

                viewModel_.StartMonitoring();
            }
        }
        public void Initialize()
        {
            var dispatcher = new WPFDispatcher(Application.Current.Dispatcher);

            // Initialize Settings
            var settingsImpl = new SettingsImpl((string)null);
            settings_ = new Settings(settingsImpl, dispatcher);

            // Load settings from file if it exists
            if (File.Exists(PluginInfo.SettingsFilePath)) {
                try {
                    using (var fs = new FileStream(PluginInfo.SettingsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                        var serializer = new DataContractSettingsSerializer();
                        serializer.Deserialize(fs, settingsImpl);
                    }
                }
                catch (Exception ex) {
                    Logger.Error("Failed to load settings from file.", ex);
                    if (ex.IsCritical()) { throw; }
                }
            }

            // Initialize settings auto expoter
            expoter_ = new SettingsAutoExpoter(
                PluginInfo.SettingsFilePath, PluginInfo.SettingsFilePath + ".temp",
                settingsImpl, new DataContractSettingsSerializer());
        }