Inheritance: Livet.NotificationObject
示例#1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += (sender, args) => ReportException(sender, args.Exception);

            DispatcherHelper.UIDispatcher = this.Dispatcher;
            ProductInfo = new ProductInfo();

            Settings.Load();
            PluginHost.Instance.Initialize();
            NotifierHost.Instance.Initialize(KanColleClient.Current);
            Helper.SetRegistryFeatureBrowserEmulation();

            KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort);
            KanColleClient.Current.Proxy.UpstreamProxySettings = Settings.Current.ProxySettings;

            ResourceService.Current.ChangeCulture(Settings.Current.Culture);
            ThemeService.Current.Initialize(this, Theme.Dark, Accent.Purple);

            ViewModelRoot   = new MainWindowViewModel();
            this.MainWindow = new MainWindow {
                DataContext = ViewModelRoot
            };
            this.MainWindow.Show();
        }
示例#2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += (sender, args) => ReportException(sender, args.Exception);

            DispatcherHelper.UIDispatcher = this.Dispatcher;
            ProductInfo = new ProductInfo();

            Settings.Load();
            WindowsNotification.Notifier.Initialize();
            Helper.SetRegistryFeatureBrowserEmulation();

            KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort);
            KanColleClient.Current.Proxy.UseProxyOnConnect    = Settings.Current.EnableProxy;
            KanColleClient.Current.Proxy.UseProxyOnSSLConnect = Settings.Current.EnableSSLProxy;
            KanColleClient.Current.Proxy.UpstreamProxyHost    = Settings.Current.ProxyHost;
            KanColleClient.Current.Proxy.UpstreamProxyPort    = Settings.Current.ProxyPort;

            ResourceService.Current.ChangeCulture(Settings.Current.Culture);

            // Initialize translations
            KanColleClient.Current.Translations.EnableTranslations    = Settings.Current.EnableTranslations;
            KanColleClient.Current.Translations.EnableAddUntranslated = Settings.Current.EnableAddUntranslated;
            KanColleClient.Current.Translations.ChangeCulture(Settings.Current.Culture);

            // Update notification and download new translations (if enabled)
            if (KanColleClient.Current.Updater.LoadVersion(AppSettings.Default.KCVUpdateUrl.AbsoluteUri))
            {
                if (Settings.Current.EnableUpdateNotification && KanColleClient.Current.Updater.IsOnlineVersionGreater(0, ProductInfo.Version.ToString()))
                {
                    WindowsNotification.Notifier.Show(
                        KanColleViewer.Properties.Resources.Updater_Notification_Title,
                        string.Format(KanColleViewer.Properties.Resources.Updater_Notification_NewAppVersion, KanColleClient.Current.Updater.GetOnlineVersion(0)),
                        () => Process.Start(KanColleClient.Current.Updater.GetOnlineVersion(0, true)));
                }

                if (Settings.Current.EnableUpdateTransOnStart)
                {
                    if (KanColleClient.Current.Updater.UpdateTranslations(AppSettings.Default.XMLTransUrl.AbsoluteUri, Settings.Current.Culture, KanColleClient.Current.Translations) > 0)
                    {
                        WindowsNotification.Notifier.Show(
                            KanColleViewer.Properties.Resources.Updater_Notification_Title,
                            KanColleViewer.Properties.Resources.Updater_Notification_TransUpdate_Success,
                            () => App.ViewModelRoot.Activate());

                        KanColleClient.Current.Translations.ChangeCulture(Settings.Current.Culture);
                    }
                }
            }

            ThemeService.Current.Initialize(this, Theme.Dark, Accent.Purple);

            ViewModelRoot   = new MainWindowViewModel();
            this.MainWindow = new MainWindow {
                DataContext = ViewModelRoot
            };
            this.MainWindow.Show();
        }
示例#3
0
		public static void Load()
		{
			try
			{
				Current = filePath.ReadXml<Settings>();
			}
			catch (Exception ex)
			{
				Current = GetInitialSettings();
				System.Diagnostics.Debug.WriteLine(ex);
			}
		}
示例#4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += (sender, args) => ReportException(sender, args.Exception);

            DispatcherHelper.UIDispatcher = this.Dispatcher;
            ProductInfo = new ProductInfo();

            Settings.Load();

            PluginHost.Instance.Initialize();
            NotifierHost.Instance.Initialize(KanColleClient.Current);
            Helper.SetRegistryFeatureBrowserEmulation();
            Helper.SetMMCSSTask();

            KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort);
            KanColleClient.Current.Proxy.UpstreamProxySettings = Settings.Current.ProxySettings;

            ResourceService.Current.ChangeCulture(Settings.Current.Culture);
            // Initialize translations
            KanColleClient.Current.Translations.EnableTranslations = Settings.Current.EnableTranslations;
            KanColleClient.Current.Translations.ChangeCulture(Settings.Current.Culture);

            // Update notification and download new translations (if enabled)
            Task.Factory.StartNew(
                () =>
            {
                if (KanColleClient.Current.Updater.LoadVersion(AppSettings.Default.KCVUpdateUrl.AbsoluteUri, AppSettings.Default.KCVUpdateTransUrl.AbsoluteUri))
                {
                    if (Settings.Current.EnableUpdateNotification && KanColleClient.Current.Updater.IsOnlineVersionGreater(0, ProductInfo.Version.ToString()))
                    {
                        PluginHost.Instance.GetNotifier().Show(NotifyType.Other,
                                                               KanColleViewer.Properties.Resources.Updater_Notification_Title,
                                                               string.Format(KanColleViewer.Properties.Resources.Updater_Notification_NewAppVersion, KanColleClient.Current.Updater.GetOnlineVersion(0)),
                                                               () => Process.Start(KanColleClient.Current.Updater.GetOnlineVersion(0, true)));
                    }

                    if (Settings.Current.EnableUpdateTransOnStart)
                    {
                        if (KanColleClient.Current.Updater.UpdateTranslations(KanColleClient.Current.Translations, Settings.Current.Culture) > 0)
                        {
                            PluginHost.Instance.GetNotifier().Show(NotifyType.Other,
                                                                   KanColleViewer.Properties.Resources.Updater_Notification_Title,
                                                                   KanColleViewer.Properties.Resources.Updater_Notification_TransUpdate_Success,
                                                                   () => ViewModelRoot.Activate());
                            KanColleClient.Current.Translations.ChangeCulture(Settings.Current.Culture);
                        }
                    }
                }
            }
                );

            ThemeService.Current.Initialize(this, Theme.Dark, Accent.Purple);

            ViewModelRoot   = new MainWindowViewModel();
            this.MainWindow = new MainWindow {
                DataContext = ViewModelRoot
            };
            this.MainWindow.Show();

            this.RestoreWindowSize();
        }
示例#5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += (sender, args) => ReportException(sender, args.Exception);

            DispatcherHelper.UIDispatcher = this.Dispatcher;
            ProductInfo = new ProductInfo();

            Settings.Load();
            PluginHost.Instance.Initialize();
            NotifierHost.Instance.Initialize(KanColleClient.Current);
            Helper.SetRegistryFeatureBrowserEmulation();
            Helper.SetMMCSSTask();

            KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort);
            KanColleClient.Current.Proxy.UpstreamProxySettings = Settings.Current.ProxySettings;

            ResourceService.Current.ChangeCulture(Settings.Current.Culture);
            // Initialize translations
            KanColleClient.Current.Translations.EnableTranslations    = Settings.Current.EnableTranslations;
            KanColleClient.Current.Translations.EnableAddUntranslated = Settings.Current.EnableAddUntranslated;
            KanColleClient.Current.Translations.ChangeCulture(Settings.Current.Culture);

            // Update notification and download new translations (if enabled)
            if (KanColleClient.Current.Updater.LoadVersion(AppSettings.Default.KCVUpdateUrl.AbsoluteUri))
            {
                if (Settings.Current.EnableUpdateNotification && KanColleClient.Current.Updater.IsOnlineVersionGreater(0, ProductInfo.Version.ToString()))
                {
                    PluginHost.Instance.GetNotifier().Show(NotifyType.Other,
                                                           KanColleViewer.Properties.Resources.Updater_Notification_Title,
                                                           string.Format(KanColleViewer.Properties.Resources.Updater_Notification_NewAppVersion, KanColleClient.Current.Updater.GetOnlineVersion(0)),
                                                           () => Process.Start(KanColleClient.Current.Updater.GetOnlineVersion(0, true)));
                }

                if (Settings.Current.EnableUpdateTransOnStart)
                {
                    if (KanColleClient.Current.Updater.UpdateTranslations(AppSettings.Default.XMLTransUrl.AbsoluteUri, Settings.Current.Culture, KanColleClient.Current.Translations) > 0)
                    {
                        PluginHost.Instance.GetNotifier().Show(NotifyType.Other,
                                                               KanColleViewer.Properties.Resources.Updater_Notification_Title,
                                                               KanColleViewer.Properties.Resources.Updater_Notification_TransUpdate_Success,
                                                               () => App.ViewModelRoot.Activate());

                        KanColleClient.Current.Translations.ChangeCulture(Settings.Current.Culture);
                    }
                }
            }

            ThemeService.Current.Initialize(this, Theme.Dark, Accent.Purple);

            ViewModelRoot   = new MainWindowViewModel();
            this.MainWindow = new MainWindow {
                DataContext = ViewModelRoot
            };
            this.MainWindow.Show();

            // Check if Adobe Flash is installed in Microsoft Explorer
            if (GetFlashVersion() == "")
            {
                MessageBoxResult MB = MessageBox.Show(KanColleViewer.Properties.Resources.System_Flash_Not_Installed_Text, KanColleViewer.Properties.Resources.System_Flash_Not_Installed_Caption, MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes);
                if (MB == MessageBoxResult.Yes)
                {
                    Process.Start("IExplore.exe", @"http://get.adobe.com/flashplayer/");
                    this.MainWindow.Close();
                }
            }
        }
示例#6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += (sender, args) => ReportException(sender, args.Exception);

            DispatcherHelper.UIDispatcher = this.Dispatcher;
            ProductInfo = new ProductInfo();

            Settings.Load();
            PluginHost.Instance.Initialize();
            NotifierHost.Instance.Initialize(KanColleClient.Current);
            Helper.SetRegistryFeatureBrowserEmulation();
            if (Settings.Current.EnableMMCSS)
            {
                Helper.SetMMCSSTask();
            }

            //기본값을 설정.
            string portNumStr = string.Empty;
            int    portNum    = AppSettings.Default.LocalProxyPort;


            //port.txt이 존재하는 경우 파일에서 port번호를 읽는다
            if (File.Exists(Path.Combine(MainFolder, "Port.txt")))
            {
                var stream = new StreamReader(Path.Combine(MainFolder, "Port.txt"), Encoding.UTF8);

                portNumStr = stream.ReadToEnd();
                stream.Close();

                try
                {
                    portNum = Convert.ToInt32(portNumStr);

                    if (portNum != AppSettings.Default.LocalProxyPort)
                    {
                        try
                        {
                            KanColleClient.Current.Proxy.Startup(portNum);
                        }
                        catch (Exception ex)
                        {
                            KanColleClient.Current.CatchedErrorLogWriter.ReportException(ex.Source, ex);
                            KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort);
                        }
                    }
                    else
                    {
                        KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("txt파일의 내용을 Int로 변경하는데 실패했습니다. Port번호는 기존 설정값을 유지합니다", ex);
                    KanColleClient.Current.CatchedErrorLogWriter.ReportException(ex.Source, ex);

                    WritePortFile(AppSettings.Default.LocalProxyPort);
                }
            }
            else            //해당 파일이 없는 경우 파일을 기본값으로 작성한다.
            {
                WritePortFile(AppSettings.Default.LocalProxyPort);
                KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort);
            }


            KanColleClient.Current.Proxy.UpstreamProxySettings = Settings.Current.ProxySettings;

            ResourceService.Current.ChangeCulture(Settings.Current.Culture);
            ThemeService.Current.Initialize(this, Theme.Dark, Accent.Purple);
            //Custom Settings
            //KanColleHost.Current.EnableResizing = Settings.Current.EnableResizing;
            KanColleClient.Current.Logger.EnableLogging = Settings.Current.EnableLogging;
            // Initialize translations
            KanColleClient.Current.Translations.EnableTranslations    = Settings.Current.EnableTranslations;
            KanColleClient.Current.Translations.EnableAddUntranslated = Settings.Current.EnableAddUntranslated;
            // Update notification and download new translations (if enabled)
            if (KanColleClient.Current.Updater.LoadVersion(AppSettings.Default.KCVUpdateUrl.AbsoluteUri))
            {
                if (Settings.Current.EnableUpdateNotification && KanColleClient.Current.Updater.IsOnlineVersionGreater(0, ProductInfo.Version.ToString()))
                {
                    if (File.Exists(Path.Combine(MainFolder, "AutoUpdater.exe")))
                    {
                        this.IsUpdate = true;
                        Process MyProcess = new Process();
                        MyProcess.StartInfo.FileName         = "AutoUpdater.exe";
                        MyProcess.StartInfo.WorkingDirectory = MainFolder;
                        MyProcess.Start();
                        MyProcess.Refresh();
                    }
                    else                    //AutoUpdater.exe가 없는 경우 알림만 띄운다.
                    {
                        PluginHost.Instance.GetNotifier().Show(
                            NotifyType.Update,
                            KanColleViewer.Properties.Resources.Updater_Notification_Title,
                            string.Format(KanColleViewer.Properties.Resources.Updater_Notification_NewAppVersion, KanColleClient.Current.Updater.GetOnlineVersion(0)),
                            () => App.ViewModelRoot.Activate());
                    }
                }

                if (Settings.Current.EnableUpdateTransOnStart)
                {
                    if (KanColleClient.Current.Updater.UpdateTranslations(AppSettings.Default.XMLTransUrl.AbsoluteUri, KanColleClient.Current.Translations) > 0)
                    {
                        PluginHost.Instance.GetNotifier().Show(
                            NotifyType.Update,
                            KanColleViewer.Properties.Resources.Updater_Notification_Title,
                            KanColleViewer.Properties.Resources.Updater_Notification_TransUpdate_Success,
                            () => App.ViewModelRoot.Activate());
                    }
                }
            }


            ViewModelRoot   = new MainWindowViewModel();
            this.MainWindow = new MainWindow {
                DataContext = ViewModelRoot
            };
            this.MainWindow.Show();

            RestoreWindowSize();
            // Check if Adobe Flash is installed in Microsoft Explorer
            //https://github.com/Yuubari/KanColleViewer/commit/d94a2c215122e4d03bf458f2a060b3a06f3c6599
            if (GetFlashVersion() == "")
            {
                MessageBoxResult MB = MessageBox.Show("Internet Explorer용 Flash Player ActiveX가 설치되어있지않습니다. 지금 설치하시겠습니까?", "Adobe Flash ActiveX를 찾을 수 없습니다", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes);
                if (MB == MessageBoxResult.Yes)
                {
                    Process.Start("IExplore.exe", @"http://get.adobe.com/flashplayer/");
                    this.MainWindow.Close();
                }
            }


            if (this.IsUpdate)
            {
                this.MainWindow.Close();
            }
        }
示例#7
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += (sender, args) => ReportException(sender, args.Exception);

            DispatcherHelper.UIDispatcher = this.Dispatcher;
            ProductInfo = new ProductInfo();

            Settings.Load();
            PluginHost.Instance.Initialize();
            NotifierHost.Instance.Initialize(KanColleClient.Current);
            Helper.SetRegistryFeatureBrowserEmulation();
            if (Settings.Current.EnableMMCSS)
            {
                Helper.SetMMCSSTask();
            }

            KanColleClient.Current.Proxy.Startup(AppSettings.Default.LocalProxyPort);
            KanColleClient.Current.Proxy.UpstreamProxySettings = Settings.Current.ProxySettings;

            ResourceService.Current.ChangeCulture(Settings.Current.Culture);
            ThemeService.Current.Initialize(this, Theme.Dark, Accent.Purple);
            //Custom Settings
            //KanColleHost.Current.EnableResizing = Settings.Current.EnableResizing;
            KanColleClient.Current.Logger.EnableLogging = Settings.Current.EnableLogging;
            KanColleClient.Current.OracleOfCompass.EnableBattlePreview = Settings.Current.EnableBattlePreview;
            KanColleClient.Current.OracleOfCompass.IsBattleCalculated  = false;
            KanColleClient.Current.OracleOfCompass.IsCompassCalculated = false;
            // Initialize translations
            KanColleClient.Current.Translations.EnableTranslations    = Settings.Current.EnableTranslations;
            KanColleClient.Current.Translations.EnableAddUntranslated = Settings.Current.EnableAddUntranslated;
            // Update notification and download new translations (if enabled)
            if (KanColleClient.Current.Updater.LoadVersion(AppSettings.Default.KCVUpdateUrl.AbsoluteUri))
            {
                if (Settings.Current.EnableUpdateNotification && KanColleClient.Current.Updater.IsOnlineVersionGreater(0, ProductInfo.Version.ToString()))
                {
                    string MainFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                    if (File.Exists(Path.Combine(MainFolder, "AutoUpdater.exe")))
                    {
                        this.IsUpdate = true;
                        Process MyProcess = new Process();
                        MyProcess.StartInfo.FileName         = "AutoUpdater.exe";
                        MyProcess.StartInfo.WorkingDirectory = MainFolder;
                        MyProcess.Start();
                        MyProcess.Refresh();
                    }
                    else
                    {
                        PluginHost.Instance.GetNotifier().Show(
                            NotifyType.Update,
                            KanColleViewer.Properties.Resources.Updater_Notification_Title,
                            string.Format(KanColleViewer.Properties.Resources.Updater_Notification_NewAppVersion, KanColleClient.Current.Updater.GetOnlineVersion(0)),
                            () => App.ViewModelRoot.Activate());
                    }
                }

                if (Settings.Current.EnableUpdateTransOnStart)
                {
                    if (KanColleClient.Current.Updater.UpdateTranslations(AppSettings.Default.XMLTransUrl.AbsoluteUri, KanColleClient.Current.Translations) > 0)
                    {
                        PluginHost.Instance.GetNotifier().Show(
                            NotifyType.Update,
                            KanColleViewer.Properties.Resources.Updater_Notification_Title,
                            KanColleViewer.Properties.Resources.Updater_Notification_TransUpdate_Success,
                            () => App.ViewModelRoot.Activate());
                    }
                }
            }


            ViewModelRoot   = new MainWindowViewModel();
            this.MainWindow = new MainWindow {
                DataContext = ViewModelRoot
            };
            this.MainWindow.Show();

            RestoreWindowSize();
            // Check if Adobe Flash is installed in Microsoft Explorer
            //https://github.com/Yuubari/KanColleViewer/commit/d94a2c215122e4d03bf458f2a060b3a06f3c6599
            if (GetFlashVersion() == "")
            {
                MessageBoxResult MB = MessageBox.Show("Internet Explorer용 Flash Player ActiveX가 설치되어있지않습니다. 지금 설치하시겠습니까?", "Adobe Flash ActiveX를 찾을 수 없습니다", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes);
                if (MB == MessageBoxResult.Yes)
                {
                    Process.Start("IExplore.exe", @"http://get.adobe.com/flashplayer/");
                    this.MainWindow.Close();
                }
            }


            if (this.IsUpdate)
            {
                this.MainWindow.Close();
            }
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            this.ChangeState(ApplicationState.Startup);

            this.DispatcherUnhandledException += (sender, args) => {
                ReportException(sender, args.Exception, false);
                args.Handled = true;
            };

            System.Windows.Media.Animation.Timeline.DesiredFrameRateProperty.OverrideMetadata(
                typeof(System.Windows.Media.Animation.Timeline),
                new FrameworkPropertyMetadata {
                DefaultValue = 20
            }
                );

            DispatcherHelper.UIDispatcher = this.Dispatcher;

            Settings.Load();
            ResourceService.Current.ChangeCulture(Settings.Current.Culture);
            ThemeService.Current.Initialize(this, Theme.Dark, Accent.Purple);

            PluginHost.Instance.Initialize();
            NotifierHost.Instance.Initialize();
            Helper.SetRegistryFeatureBrowserEmulation();
            Helper.SetRegistryFeatureLegacyInputModel();
            Helper.SetMMCSSTask();

            this.MainWindowViewModel = new MainWindowViewModel();

            // Application.OnExit で破棄 (or 処理) するものたち
            this.compositeDisposable.Add(this.MainWindowViewModel);
            this.compositeDisposable.Add(PluginHost.Instance);
            this.compositeDisposable.Add(NotifierHost.Instance);
            this.compositeDisposable.Add(Settings.Current.Save);

            // BootstrapProxy() で Views.Settings.ProxyBootstrapper.Show() が呼ばれるより前に
            // Application.MainWindow を設定しておく。これ大事
            this.MainWindow = new MainWindow {
                DataContext = this.MainWindowViewModel,
            };
            MainWindowViewModel.UpdateLayout(Settings.Current.LRSplit);

            KanColleClient.Current.Proxy.UpstreamProxySettings = Settings.Current.ProxySettings;
            KanColleClient.Current.Proxy.Startup();
            this.compositeDisposable.Add(KanColleClient.Current.Proxy.Shutdown);

            this.MainWindow.Show();

            base.OnStartup(e);
            this.ChangeState(ApplicationState.Running);

            if (Definitions.UnixTimestamp - Settings.Current.LastUpdateCheck > 86400)
            {
                var wc = new System.Net.WebClient();
                wc.DownloadStringTaskAsync(ProductInfo.UpdateCheckUri).ContinueWith(task => {
                    wc.Dispose();
                    if (task.Status == TaskStatus.RanToCompletion)
                    {
                        Settings.Current.LastUpdateVersion = task.Result.Trim();
                        Settings.Current.LastUpdateCheck   = Definitions.UnixTimestamp;
                    }
                });
            }
        }