private void ApplyFlashQuality(bool ReloadRequired = false) { if (!this.firstLoaded) { return; } try { var document = this.WebBrowser.Document as HTMLDocument; if (document == null) { return; } var frames = document.frames; for (var i = 0; i < frames.length; i++) { var item = frames.item(i); var provider = item as IServiceProvider; if (provider == null) { continue; } object ppvObject; provider.QueryService(typeof(IWebBrowserApp).GUID, typeof(IWebBrowser2).GUID, out ppvObject); var webBrowser = ppvObject as IWebBrowser2; var iframeDocument = webBrowser?.Document as HTMLDocument; if (iframeDocument == null) { continue; } string qualityString = "high"; switch (KanColleSettings.FlashElementQuality.Value) { case FlashQuality.Low: qualityString = "low"; break; case FlashQuality.Medium: qualityString = "medium"; break; case FlashQuality.High: qualityString = "high"; break; } var script = ""; script += "function kcsFlash_StartFlash(a){var b={id:'externalswf',width:'800',height:'480',wmode:'opaque',quality:'" + qualityString + "',bgcolor:'#000000',allowScriptAccess:'always'};document.getElementById('flashWrap').innerHTML=ConstMessageInfo.InstallFlashMessage,gadgets.flash.embedFlash(a+ConstURLInfo.MainFlashURL+'?api_token='+flashInfo.apiToken+'&api_starttime='+flashInfo.apiStartTime,document.getElementById('flashWrap'),6,b),document.getElementById('adFlashWrap').style.height='0px',document.getElementById('wsFlashWrap').style.height='0px',document.getElementById('flashWrap').style.height='480px',gadgets.window.adjustHeight(ConstGadgetInfo.height)};"; if (ReloadRequired) { script += "kcsLogin_StartLogin();"; } webBrowser.Navigate("javascript:" + script); GCWorker.GCRequest(); } } catch (Exception) when(Application.Instance.State == ApplicationState.Startup) { // about:blank だから仕方ない } catch (Exception ex) { Debug.WriteLine(ex); StatusService.Current.Notify("failed to apply css: " + ex.Message); } }
public void RequestGC() { GCWorker.GCRequest(); }
public void RequestGC() { GCWorker.GCRequest(-1, GCWorker.GCType.GCAll); }
// 시작할 때의 이벤트 protected override void OnStartup(StartupEventArgs e) { this.ChangeState(ApplicationState.Startup); bgGCWorker = new GCWorker(); // 개발중에 다중 실행이 감지되어서 실행되지 않으면 불편하니 디버그 때에는 예외로 처리 #if !DEBUG var appInstance = new MetroTrilithon.Desktop.ApplicationInstance().AddTo(this); if (appInstance.IsFirst) #endif { // 미처리 예외 this.DispatcherUnhandledException += (sender, args) => { ReportException(sender, args.Exception); args.Handled = true; }; DispatcherHelper.UIDispatcher = this.Dispatcher; SettingsHost.Load(); // 설정들 로드 this.compositeDisposable.Add(SettingsHost.Save); // Dispose될 때 설정을 저장 try { // 언어 변경 GeneralSettings.Culture .Subscribe(x => ResourceService.Current.ChangeCulture(x)) .AddTo(this); } catch { // 무언가 오류가 발생... try { File.Delete(Providers.LocalFilePath); File.Delete(Providers.ViewerDirectoryPath); } catch { } MessageBox.Show( "어플리케이션 기동중 문제가 발생하여 일부 설정파일을 초기화합니다.\n" + "프로그램이 종료되며, 재시작 해주시기 바랍니다.", "제독업무도 바빠!", MessageBoxButton.OK, MessageBoxImage.Warning ); this.Shutdown(); return; } // 설정들 초기화 KanColleClient.Current.Settings = new KanColleSettings(); // 테마 변경 ThemeService.Current.Register(this, Theme.Dark, Accent.Purple); // 각종 서비스 초기화 PluginService.Current.AddTo(this).Initialize(); WindowService.Current.AddTo(this).Initialize(); NotifyService.Current.AddTo(this).Initialize(); // WebBrowser 컨트롤 IE 버전 레지스트리 패치, MMCSS 설정 Helper.SetRegistryFeatureBrowserEmulation(); if (GeneralSettings.MMCSSEnabled) { Helper.SetMMCSSTask(); } // 번역 여부 KanColleClient.Current.Translations.EnableTranslations = KanColleSettings.EnableTranslations; KanColleClient.Current.Translations.EnableAddUntranslated = KanColleSettings.EnableAddUntranslated; // 설정된 경우, 업데이트 통지 및 다운로드 if (KanColleClient.Current.Updater.LoadVersion(AppSettings.Default.KCVUpdateUrl.AbsoluteUri)) { // 업데이트 알림이 설정되어있고 상위 버전이 있을 경우 if (KanColleSettings.EnableUpdateNotification && KanColleClient.Current.Updater.IsOnlineVersionGreater(TranslationType.App, ProductInfo.Version.ToString())) { // 자동 업데이트 프로그램이 존재하는 경우 if (File.Exists(Path.Combine(CurrentDirectory, "AutoUpdater.exe"))) { // 자동 업데이트 프로그램을 실행 Process MyProcess = new Process(); MyProcess.StartInfo.FileName = "AutoUpdater.exe"; MyProcess.StartInfo.WorkingDirectory = CurrentDirectory; MyProcess.Start(); MyProcess.Refresh(); this.Shutdown(); } else { // 자동 업데이트 프로그램이 존재하지 않는 경우 알림만 표시 var notification = Notification.Create( "", "제독업무도 바빠! 업데이트", "어플리케이션의 새로운 버전이 릴리즈 되었습니다!" + "블로그 등의 배포처를 확인해주시기 바랍니다.", () => WindowService.Current.MainWindow.Activate() ); NotifyService.Current.Notify(notification); } } // 번역 파일 업데이트가 설정된 경우 if (KanColleSettings.EnableUpdateTransOnStart) { // 번역 파일들 업데이트 if (KanColleClient.Current.Updater.UpdateTranslations(AppSettings.Default.XMLTransUrl.AbsoluteUri, KanColleClient.Current.Translations) > 0) { var notification = Notification.Create( "", "제독업무도 바빠! 업데이트", "번역 파일의 업데이트가 완료되었습니다.", () => WindowService.Current.MainWindow.Activate() ); NotifyService.Current.Notify(notification); } } } // BootstrapProxy()에서 Views.Settings.ProxyBootstrapper.Show()가 호출되기 전에 // Application.MainWindow를 설정해둔다. (매우 중요함) // 나중에 설정하는 경우, Views.Settings.ProxyBootstrapper가 닫히면 프로그램도 같이 닫힘. this.MainWindow = WindowService.Current.GetMainWindow(); // 로컬 프록시를 시작한다. if (BootstrapProxy()) { // 종료될 때 로컬 프록시를 종료한다. this.compositeDisposable.Add(ProxyBootstrapper.Shutdown); this.MainWindow.Show(); // 브라우저 관리 클래스 var navigator = (WindowService.Current.MainWindow as KanColleWindowViewModel)?.Navigator; if (navigator != null) { navigator.Source = KanColleViewer.Properties.Settings.Default.KanColleUrl; navigator.Navigate(); } #if !DEBUG // 디버그가 아닌 경우 다중 실행과 명령줄을 처리 appInstance.CommandLineArgsReceived += (sender, args) => { // 다중 실행을 감지한 경우, 메인 윈도우를 표시 this.Dispatcher.Invoke(() => WindowService.Current.MainWindow.Activate()); this.ProcessCommandLineParameter(args.CommandLineArgs); }; #endif base.OnStartup(e); this.ChangeState(ApplicationState.Running); // 실행중임을 처리 } else { // 로컬 프록시 시작에 실패한 경우 그대로 종료 this.ChangeState(ApplicationState.Terminate); this.Shutdown(); } } #if !DEBUG else { // 다중 실행인 경우 명령줄을 전달하고 종료 appInstance.SendCommandLineArgs(e.Args); this.ChangeState(ApplicationState.Terminate); this.Shutdown(); } #endif }