public void Initialize() { this.settings = SettingsHost.Instance <KanColleWindowSettings>(); this.settings?.IsSplit.Subscribe(x => this.IsSplit = x).AddTo(this); this.settings?.AlwaysTopView.Subscribe(x => this.AlwaysTopView = x).AddTo(this); this.settings?.Dock.Subscribe(x => this.Dock = x).AddTo(this); }
public void UpdateDockPattern() { if (this.currentMode == WindowServiceMode.NotStarted) { return; } if (this.kanColleWindow == null) { return; } KanColleWindowSettings settings = SettingsHost.Instance <KanColleWindowSettings>(); if (!settings.IsSplit) //분할모드가 아닌경우 { if (settings?.Dock == Dock.Right || settings?.Dock == Dock.Left) { this.kanColleWindow.TopView = Visibility.Visible; this.kanColleWindow.BottomView = Visibility.Collapsed; } else { this.kanColleWindow.TopView = Visibility.Collapsed; this.kanColleWindow.BottomView = Visibility.Visible; } } else { this.kanColleWindow.TopView = Visibility.Collapsed; this.kanColleWindow.BottomView = Visibility.Visible; } }
public KanColleWindowViewModel(bool isMainWindow) : base(isMainWindow) { this.Settings = SettingsHost.Instance <KanColleWindowSettings>(); this.Settings.Dock.Subscribe(x => this.BrowserDock = x.Reverse()).AddTo(this); this.Settings.Dock.Subscribe(x => this.ToolAreaMaxWidth = this.GetToolAreaWidth(x)).AddTo(this); this.Settings.IsSplit.Subscribe(this.SplitWindow).AddTo(this); this.Navigator = new NavigatorViewModel().AddTo(this); this.Volume = new VolumeViewModel().AddTo(this); this.ZoomFactor = new BrowserZoomFactor { Current = GeneralSettings.BrowserZoomFactor }; this.ZoomFactor .Subscribe(nameof(this.ZoomFactor.Current), () => GeneralSettings.BrowserZoomFactor.Value = this.ZoomFactor.Current) .AddTo(this); GeneralSettings.BrowserZoomFactor.Subscribe(x => this.ZoomFactor.Current = x).AddTo(this); _RefreshNavigator = new RelayCommand(Navigator.ReNavigate); this.taskbarProgress = new TaskbarProgress().AddTo(this); this.taskbarProgress .Subscribe(nameof(TaskbarProgress.Updated), () => this.UpdateTaskbar()) .AddTo(this); if (this.Settings?.Dock == Dock.Right || this.Settings?.Dock == Dock.Left || this.Settings?.IsSplit || this.Settings?.AlwaysTopView) { this.TopView = Visibility.Visible; this.BottomView = Visibility.Collapsed; } else { this.TopView = Visibility.Collapsed; this.BottomView = Visibility.Visible; } /* * KanColleClient.Current.Proxy.api_start2 * .TryParse() * .Subscribe(x => StatusService.Current.Set(Resources.StatusBar_Ready)); */ KanColleClient.Current.Proxy.ApiSessionSource .Select(x => { KanColleWrapper.Models.SvData result; result = KanColleWrapper.Models.SvData.TryParse(x, out result) ? result : null; return(result); }) .Where(x => x != null && !x.IsSuccess) .Subscribe(x => { var text = $"서버에서 {x.RawData.api_result} 오류를 전달했습니다."; StatusService.Current.Set(text); }); }
public KanColleWindow() { this.InitializeComponent(); this.settings = SettingsHost.Instance <KanColleWindowSettings>(); this.settings.IsSplit.Subscribe(_ => this.ChangeSizeByDock()).AddTo(this); this.settings.Dock.Subscribe(_ => this.ChangeSizeByDock()).AddTo(this); }
public void InformationWindowViewModelTest() { string key = "Info"; var vm = new InformationWindowViewModel(key); vm.Setting.TopMost = true; vm.Setting.Placement = new MetroRadiance.Interop.Win32.WINDOWPLACEMENT(); SettingsHost.SaveFile(); }
public static void ShowAcmeSettings(EditorCanvas currentEditor, AcmeOptions options, IChem4WordTelemetry telemetry, Point topLeft) { var mode = Application.Current.ShutdownMode; Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; var pe = new SettingsHost(options, telemetry, topLeft); ShowDialog(pe, currentEditor); Application.Current.ShutdownMode = mode; }
public QuestsViewModel() { Setting = SettingsHost.Cache <QuestsSetting>(k => new QuestsSetting(), nameof(QuestsSetting)); var quests = KanColleClient.Current.Homeport.Quests; quests.Subscribe(nameof(quests.IsUntaken), () => this.IsUntaken = quests.IsUntaken).AddTo(this); quests.Subscribe(nameof(quests.All), () => this.All = quests.All.Select(x => new QuestViewModel(x)).ToArray()).AddTo(this); quests.Subscribe(nameof(quests.Current), () => UpdateCurrent(quests)).AddTo(this); quests.Subscribe(nameof(quests.IsEmpty), () => this.IsEmpty = quests.IsEmpty).AddTo(this); }
public void Initialize() { DebugModel.WriteLine("KanburaLike Init"); SettingsHost.LoadFile(); infovm = new ViewModels.InformationWindowViewModel(nameof(Views.InformationWindow)); info = new Views.InformationWindow { DataContext = infovm }; }
public void Dispose() { if (info.IsVisible == true) { info.Close(); } SettingsHost.SaveFile(); //DebugModel.Dump(infovm.Info.Brilliant.Ships.FirstOrDefault().Ship, nameof(infovm.Info.Brilliant)); DebugModel.WriteLine("KanburaLike Dispose"); }
public MaterialsViewModel() { Setting = SettingsHost.Cache <MaterialsSetting>(k => new MaterialsSetting(), nameof(MaterialsSetting)); Items = new MaterialItemsViewModel[Setting.CurrentMaterialCount]; int lastindex = MaterialItemsSource.Instance.Values.Count() - 1; for (int i = 0; i < Setting.CurrentMaterialCount; i++) { Items[i] = new MaterialItemsViewModel(i, Setting); Items[i].SelectedItem = Items[i].Values.FirstOrDefault(x => x.Key == Setting.CurrentSelectedItem[i]) ?? Items[i].Values.ElementAt(lastindex - i); } }
public override void OnStop() { base.OnStop(); if (ProxyService.IsChangeSupportProxyServicesStatus) { ProxyService.IsChangeSupportProxyServicesStatus = false; SettingsHost.Save(); #if DEBUG Toast.Show("已保存勾选状态"); #endif } }
public PlayerTabController(SettingsHost settingsHost, SpotifyProcessManager spotifyProcessManager, Logger logger) { this.SettingsHost = settingsHost; this.SpotifyProcessManager = spotifyProcessManager; this.Logger = logger; this.SpotifyController = new SpotifyController(spotifyProcessManager); this.SongTracker = new SongTracker( spotifyProcessManager, settingsHost.SongClassificationInfo, settingsHost.SongRefreshInterval, logger, maxSongs: 11 //Minimum suported non-infinite value //There's no need to store songs for the player, just get notified when they change ); this.SongTracker.StartTracking(); }
public OverviewViewModel(InformationViewModel owner) { this.Content = owner; this.Settings = SettingsHost.Instance <KanColleWindowSettings>(); if (this.Settings?.Dock == Dock.Right || this.Settings?.Dock == Dock.Left || this.Settings?.IsSplit) { this.Vertical = Visibility.Collapsed; this.Horizontal = Visibility.Visible; } else { this.Vertical = Visibility.Visible; this.Horizontal = Visibility.Collapsed; } }
public KanColleWindowViewModel(bool isMainWindow) : base(isMainWindow) { this.Settings = SettingsHost.Instance <KanColleWindowSettings>(); this.Settings.Dock.Subscribe(x => this.BrowserDock = x.Reverse()).AddTo(this); this.Settings.Dock.Subscribe(x => this.ToolAreaMaxWidth = this.GetToolAreaWidth(x)).AddTo(this); this.Settings.IsSplit.Subscribe(this.SplitWindow).AddTo(this); this.Navigator = new NavigatorViewModel().AddTo(this); this.Volume = new VolumeViewModel().AddTo(this); this.ZoomFactor = new BrowserZoomFactor { Current = GeneralSettings.BrowserZoomFactor }; this.ZoomFactor .Subscribe(nameof(this.ZoomFactor.Current), () => GeneralSettings.BrowserZoomFactor.Value = this.ZoomFactor.Current) .AddTo(this); GeneralSettings.BrowserZoomFactor.Subscribe(x => this.ZoomFactor.Current = x).AddTo(this); }
public InformationViewModel() { this.Settings = SettingsHost.Instance <KanColleWindowSettings>(); if (this.Settings?.Dock == Dock.Right || this.Settings?.Dock == Dock.Left || this.Settings?.IsSplit) { this.Vertical = Visibility.Collapsed; this.Horizontal = Visibility.Visible; } else { this.Vertical = Visibility.Visible; this.Horizontal = Visibility.Collapsed; } this.TabItems = new List <TabItemViewModel> { (this.Overview = new OverviewViewModel(this).AddTo(this)), (this.Fleets = new FleetsViewModel().AddTo(this)), (this.Shipyard = new ShipyardViewModel(this.Fleets).AddTo(this)), (this.Quests = new QuestsViewModel(this.Fleets).AddTo(this)), (this.Expeditions = new ExpeditionsViewModel(this.Fleets).AddTo(this)), (this.Tools = new ToolsViewModel(this.Fleets).AddTo(this)), }; this.SystemTabItems = new List <TabItemViewModel> { SettingsViewModel.Instance, #region DEBUG #if DEBUG new DebugTabViewModel().AddTo(this), #endif #endregion }; this.SelectedItem = this.TabItems.FirstOrDefault(); this.Admiral = new AdmiralViewModel().AddTo(this); this.Materials = new MaterialsViewModel().AddTo(this); this.Ships = new ShipsViewModel().AddTo(this); this.SlotItems = new SlotItemsViewModel().AddTo(this); _AkashiTimer = new AkashiTimerViewModel(); KanColleSettings.DisplayMaterialExtended.ValueChanged += (s, e) => this.MaterialExtended = e.NewValue; this.MaterialExtended = KanColleSettings.DisplayMaterialExtended; }
// Avalonia configuration, don't remove; also used by visual designer. static AppBuilder BuildAvaloniaApp() { #if DEBUG // 设计器模式不会执行 Main 函数所以以此区分来初始化文件系统 if (Assembly.GetCallingAssembly() != Assembly.GetExecutingAssembly()) { FileSystem2.InitFileSystem(); } #endif SettingsHost.Load(); var builder = AppBuilder.Configure <App>() .UsePlatformDetect() .LogToTrace() .UseReactiveUI(); var useGpu = !IApplication.DisableGPU && GeneralSettings.UseGPURendering.Value; #if MAC builder.With(new AvaloniaNativePlatformOptions { UseGpu = useGpu }); #elif LINUX builder.With(new X11PlatformOptions { UseGpu = useGpu }); #elif WINDOWS var useWgl = IApplication.UseWgl || GeneralSettings.UseWgl.Value; var options = new Win32PlatformOptions { UseWgl = useWgl, AllowEglInitialization = useGpu, }; builder.With(options); #else throw new PlatformNotSupportedException(); #endif RenderingSubsystemName = builder.RenderingSubsystemName; return(builder); }
public RecordingTabController(SettingsHost settingsHost, SpotifyProcessManager spotifyProcessManager, Logger logger) { this.SettingsHost = settingsHost; this.SpotifyProcessManager = spotifyProcessManager; this.Logger = logger; this.RecordingHost = new RecordingHost(settingsHost, spotifyProcessManager, logger); this.SongGroupSplitterHost = new SongGroupSplitterHost(settingsHost, logger); this.SongConversionHost = new SongConversionHost(settingsHost, logger); this.RecordingHost.GroupFinished += (sender, e) => { this.SongGroupSplitterHost.Enqueue(sender.RecordedGroup); }; this.SongGroupSplitterHost.SongGroupSplit += (sender, e) => { this.SongConversionHost.EnqueueAll(e.Splitter.CompletedSongs); }; }
public KanColleWindowViewModel(bool isMainWindow) : base(isMainWindow) { this.Settings = SettingsHost.Instance <KanColleWindowSettings>(); this.Settings.Dock.Subscribe(x => this.BrowserDock = x.Reverse()).AddTo(this); this.Settings.Dock.Subscribe(x => this.ToolAreaMaxWidth = this.GetToolAreaWidth(x)).AddTo(this); this.Settings.IsSplit.Subscribe(this.SplitWindow).AddTo(this); this.Navigator = new NavigatorViewModel().AddTo(this); this.Volume = new VolumeViewModel().AddTo(this); this.ZoomFactor = new BrowserZoomFactor { Current = GeneralSettings.BrowserZoomFactor }; this.ZoomFactor .Subscribe(nameof(this.ZoomFactor.Current), () => GeneralSettings.BrowserZoomFactor.Value = this.ZoomFactor.Current) .AddTo(this); GeneralSettings.BrowserZoomFactor.Subscribe(x => this.ZoomFactor.Current = x).AddTo(this); _RefreshNavigator = new RelayCommand(Navigator.ReNavigate); this.taskbarProgress = new TaskbarProgress().AddTo(this); this.taskbarProgress .Subscribe(nameof(TaskbarProgress.Updated), () => this.UpdateTaskbar()) .AddTo(this); if (this.Settings?.Dock == Dock.Right || this.Settings?.Dock == Dock.Left || this.Settings?.IsSplit || this.Settings?.AlwaysTopView) { this.TopView = Visibility.Visible; this.BottomView = Visibility.Collapsed; } else { this.TopView = Visibility.Collapsed; this.BottomView = Visibility.Visible; } }
public void Test1() { var target = new PrivateType(typeof(SettingsHost)); var fullpath = (string)target.GetStaticField("fullpath"); if (File.Exists(fullpath) == true) { File.Delete(fullpath); } SettingsHost.Init(); var vm = new InformationWindowViewModel(); vm.Setting.Topmost = true; //ここでプロパティを書き換え Console.WriteLine(vm.Setting.Topmost); SettingsHost.SaveFile(); var wsetting = SettingsHost.Instance <InformationWindowSetting>(); Console.WriteLine(wsetting.Topmost); }
protected override void OnStartup(StartupEventArgs e) { this.ChangeState(ApplicationState.Startup); // 開発中に多重起動検知ついてると起動できなくて鬱陶しいので // デバッグ時は外すんじゃもん #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); GeneralSettings.Culture.Subscribe(x => ResourceService.Current.ChangeCulture(x)).AddTo(this); 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(); Helper.SetRegistryFeatureBrowserEmulation(); Helper.SetMMCSSTask(); // 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 }
/// <summary> /// 启动时 /// </summary> /// <param name="e"></param> protected override void OnStartup(StartupEventArgs e) { //AppCenter.Start("ccca922e-40fe-48ab-9982-45ba496b1201", //typeof(Analytics), typeof(Crashes)); #if !DEBUG var appInstance = new MetroTrilithon.Desktop.ApplicationInstance().AddTo(this); if (appInstance.IsFirst) #endif { #if DEBUG if (e.Args.ContainsArg("-app")) { this.ProcessCommandLineParameter(e.Args); base.OnStartup(e); return; } Logger.EnableTextLog = true; #endif App.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; this.DispatcherUnhandledException += App_DispatcherUnhandledException; DispatcherHelper.UIDispatcher = this.Dispatcher; SettingsHost.Load(); this.compositeDisposable.Add(SettingsHost.Save); this.compositeDisposable.Add(ProxyService.Current.Shutdown); this.compositeDisposable.Add(SteamConnectService.Current.Shutdown); this.compositeDisposable.Add(() => { if (TaskbarService.Current.Taskbar != null) { //TaskbarService.Current.Taskbar.Icon = null; //避免托盘图标没有自动消失 TaskbarService.Current.Taskbar.Icon.Dispose(); } }); Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding; if (e.Args.ContainsArg("-log") || GeneralSettings.IsEnableLogRecord) { Logger.EnableTextLog = true; } //每次启动都覆盖设置一次开机自启确保路径变换后开机自启依然生效 if (GeneralSettings.WindowsStartupAutoRun) { var steamService = SteamToolCore.Instance.Get <SteamToolService>(); steamService.SetWindowsStartupAutoRun(GeneralSettings.WindowsStartupAutoRun.Value, ProductInfo.Title); } GeneralSettings.Culture.Subscribe(x => ResourceService.Current.ChangeCulture(x)).AddTo(this); WindowService.Current.AddTo(this).Initialize(); ProxyService.Current.Initialize(); SteamConnectService.Current.Initialize(); AuthService.Current.Initialize(); if (GeneralSettings.IsAutoCheckUpdate.Value) { AutoUpdateService.Current.CheckUpdate(); } //托盘加载 TaskbarService.Current.Taskbar = (TaskbarIcon)FindResource("Taskbar"); ThemeService.Current.Register(this, Theme.Windows, Accent.Windows); SetWebBrowserIeVersion(); this.MainWindow = WindowService.Current.GetMainWindow(); if (e.Args.ContainsArg("-minimized") || GeneralSettings.IsStartupAppMinimized.Value) { //this.MainWindow.Show(); //(WindowService.Current.MainWindow as MainWindowViewModel).IsVisible = false; (WindowService.Current.MainWindow as MainWindowViewModel).Initialize(); } else { this.MainWindow.Show(); } if (GeneralSettings.IsAutoRunSteam.Value && Process.GetProcessesByName("steam").Length < 1) { var steamTool = SteamToolCore.Instance.Get <SteamToolService>(); if (!string.IsNullOrEmpty(steamTool.SteamPath)) { steamTool.StartSteam("-silent " + GeneralSettings.SteamStratParameter.Value); } } #if !DEBUG appInstance.CommandLineArgsReceived += (sender, args) => { // 检测到多次启动时将主窗口置于最前面 this.Dispatcher.Invoke(() => { (WindowService.Current.MainWindow as MainWindowViewModel).IsVisible = true; }); //this.ProcessCommandLineParameter(args.CommandLineArgs); }; #endif base.OnStartup(e); } #if !DEBUG else { if (e.Args.Length > 0) { this.ProcessCommandLineParameter(e.Args); } else { appInstance.SendCommandLineArgs(e.Args); App.Current.Shutdown(); } } #endif }
public HomeportViewModel() { Setting = SettingsHost.Cache <HomeportSetting>(k => new HomeportSetting(), nameof(HomeportSetting)); }
protected override void OnStartup(StartupEventArgs e) { this.ChangeState(ApplicationState.Startup); // 開発中に多重起動検知ついてると起動できなくて鬱陶しいので // デバッグ時は外すんじゃもん #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); try { GeneralSettings.Culture.Subscribe(x => ResourceService.Current.ChangeCulture(x)).AddTo(this); //#1 } catch { var LocalfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "grabacr.net"); var RoamingfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "grabacr.net"); var LocalDirs = Directory.GetDirectories(LocalfilePath).ToList(); var RoamingDirs = Directory.GetDirectories(RoamingfilePath).ToList(); for (int i = 0; i < LocalDirs.Count; i++) { if (LocalDirs[i] != "KanColleViewer") { Directory.Delete(Path.Combine(LocalfilePath, LocalDirs[i]), true); } } for (int i = 0; i < RoamingDirs.Count; i++) { if (RoamingDirs[i] != "KanColleViewer") { Directory.Delete(Path.Combine(RoamingfilePath, RoamingDirs[i]), true); } } MessageBox.Show("어플리케이션 기동중 문제가 발생하여 일부 설정파일을 초기화합니다.\n프로그램이 종료됩니다", "제독업무도 바빠!", MessageBoxButton.OK, MessageBoxImage.Warning); this.Shutdown(); } 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(); Helper.SetRegistryFeatureBrowserEmulation(); if (GeneralSettings.MMCSSEnabled) { Helper.SetMMCSSTask(); } KanColleClient.Current.Translations.EnableTranslations = KanColleSettings.EnableTranslations; KanColleClient.Current.Translations.EnableAddUntranslated = KanColleSettings.EnableAddUntranslated; // Update notification and download new translations (if enabled) if (KanColleClient.Current.Updater.LoadVersion(AppSettings.Default.KCVUpdateUrl.AbsoluteUri)) { //null error if (KanColleSettings.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(); this.Shutdown(); } else //AutoUpdater.exe가 없는 경우 알림만 띄운다. { 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 }
public WindowSettingViewModel(string key) { Setting = SettingsHost.Cache <WindowSetting>(k => new WindowSetting(key), key); }
//#if DEBUG //RefWatcher? _refWatcher; //void SetupLeakCanary() //{ // // “A small leak will sink a great ship.” - Benjamin Franklin // if (LeakCanaryXamarin.IsInAnalyzerProcess(this)) // { // // This process is dedicated to LeakCanary for heap analysis. // // You should not init your app in this process. // return; // } // _refWatcher = LeakCanaryXamarin.Install(this); //} //#endif public override void OnCreate() { base.OnCreate(); //#if DEBUG // //SetupLeakCanary(); //#endif var stopwatch = Stopwatch.StartNew(); var startTrace = new StringBuilder(); FileSystem2.InitFileSystem(); stopwatch.Stop(); startTrace.AppendFormatLine("init FileSystem {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); IApplication.InitLogDir(); stopwatch.Stop(); startTrace.AppendFormatLine("init NLog {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); Startup.InitGlobalExceptionHandler(); stopwatch.Stop(); startTrace.AppendFormatLine("init ExceptionHandler {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); VisualStudioAppCenterSDK.Init(); stopwatch.Stop(); startTrace.AppendFormatLine("init AppCenter {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); XEFileProvider.TemporaryLocation = FileProviderLocation.Internal; XEPlatform.Init(this); // 初始化 Xamarin.Essentials.Platform.Init XEPlatform.ActivityStateChanged += OnActivityStateChanged; stopwatch.Stop(); startTrace.AppendFormatLine("init Essentials {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); bool GetIsMainProcess() { // 注意:进程名可以自定义,默认是包名,如果自定义了主进程名,这里就有误,所以不要自定义主进程名! var name = this.GetCurrentProcessName(); return(name == PackageName); } IsMainProcess = GetIsMainProcess(); stopwatch.Stop(); startTrace.AppendFormatLine("init IsMainProcess {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); SettingsHost.Load(); stopwatch.Stop(); startTrace.AppendFormatLine("init SettingsHost {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); InitSettingSubscribe(); stopwatch.Stop(); startTrace.AppendFormatLine("init SettingSubscribe {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); var level = DILevel.Min; if (IsMainProcess) { level = DILevel.MainProcess; } Startup.Init(level); stopwatch.Stop(); startTrace.AppendFormatLine("init Startup {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); if (IsMainProcess) { XEVersionTracking.Track(); stopwatch.Stop(); startTrace.AppendFormatLine("init VersionTracking {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); if (XEVersionTracking.IsFirstLaunchForCurrentVersion) { // 当前版本第一次启动时,清除存放升级包缓存文件夹的目录 IApplicationUpdateService.ClearAllPackCacheDir(); stopwatch.Stop(); startTrace.AppendFormatLine("init ClearAllPackCacheDir {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); } } UISettings.Language.Subscribe(x => R.ChangeLanguage(x)); stopwatch.Stop(); startTrace.AppendFormatLine("init Language.Subscribe {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); Startup.OnStartup(IsMainProcess); stopwatch.Stop(); startTrace.AppendFormatLine("init OnStartup {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); if (IsMainProcess) { var vmService = IViewModelManager.Instance; vmService.InitViewModels(); stopwatch.Stop(); startTrace.AppendFormatLine("init ViewModels {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); #if __XAMARIN_FORMS__ Forms.Init(this, null); FormsMaterial.Init(this, null); ImageCircleRenderer.Init(); stopwatch.Stop(); startTrace.AppendFormatLine("init XF {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); _Current = new(RealTheme); stopwatch.Stop(); startTrace.AppendFormatLine("init XFApp {0}ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); #endif vmService.MainWindow.Initialize(); } stopwatch.Stop(); StartupTrack = startTrace.ToString(); #if DEBUG Log.Warn("Application", $"OnCreate Complete({stopwatch.ElapsedMilliseconds}ms"); #endif }
public InformationViewModel() { this.Settings = SettingsHost.Instance <KanColleWindowSettings>(); if (this.Settings?.Dock == Dock.Right || this.Settings?.Dock == Dock.Left || this.Settings?.IsSplit) { this.Vertical = Visibility.Collapsed; this.Horizontal = Visibility.Visible; } else { this.Vertical = Visibility.Visible; this.Horizontal = Visibility.Collapsed; } this.TabItems = new List <TabItemViewModel> { (this.Overview = new OverviewViewModel(this).AddTo(this)), (this.Fleets = new FleetsViewModel().AddTo(this)), (this.Shipyard = new ShipyardViewModel(this.Fleets).AddTo(this)), (this.Quests = new QuestsViewModel(this.Fleets).AddTo(this)), (this.Expeditions = new ExpeditionsViewModel(this.Fleets).AddTo(this)), (this.Tools = new ToolsViewModel(this.Fleets).AddTo(this)), }; this.SystemTabItems = new List <TabItemViewModel> { SettingsViewModel.Instance, #region DEBUG #if DEBUG new DebugTabViewModel().AddTo(this), #endif #endregion }; this.SelectedItem = this.TabItems.FirstOrDefault(); this.Admiral = new AdmiralViewModel().AddTo(this); this.Materials = new MaterialsViewModel().AddTo(this); this.Ships = new ShipsViewModel().AddTo(this); this.SlotItems = new SlotItemsViewModel().AddTo(this); this.CompositeDisposable.Add(new PropertyChangedEventListener(this.Ships) { { nameof(this.Ships.Count), (sender, args) => this.RaisePropertyChanged(nameof(this.ShipsCountWarning)) } }); this.CompositeDisposable.Add(new PropertyChangedEventListener(this.SlotItems) { { nameof(this.SlotItems.Count), (sender, args) => this.RaisePropertyChanged(nameof(this.SlotItemsCountWarning)) } }); this.CompositeDisposable.Add(new PropertyChangedEventListener(KanColleWrapper.KanColleClient.Current.Homeport) { { nameof(KanColleWrapper.KanColleClient.Current.Homeport.Admiral), (sender, args) => { this.CompositeDisposable.Add(new PropertyChangedEventListener(KanColleWrapper.KanColleClient.Current.Homeport.Admiral) { { nameof(KanColleWrapper.KanColleClient.Current.Homeport.Admiral.MaxShipCount), (sender2, args2) => this.RaisePropertyChanged(nameof(this.ShipsCountWarning)) }, { nameof(KanColleWrapper.KanColleClient.Current.Homeport.Admiral.MaxSlotItemCount), (sender2, args2) => this.RaisePropertyChanged(nameof(this.SlotItemsCountWarning)) } }); this.RaisePropertyChanged(nameof(this.ShipsCountWarning)); this.RaisePropertyChanged(nameof(this.SlotItemsCountWarning)); } } }); _AkashiTimer = new AkashiTimerViewModel(); KanColleSettings.DisplayMaterialExtended.ValueChanged += (s, e) => this.MaterialExtended = e.NewValue; this.MaterialExtended = KanColleSettings.DisplayMaterialExtended; }
/// <summary> /// 启动时 /// </summary> /// <param name="e"></param> protected override void OnStartup(StartupEventArgs e) { #if !DEBUG var appInstance = new MetroTrilithon.Desktop.ApplicationInstance().AddTo(this); if (appInstance.IsFirst) #endif { #if DEBUG if (e.Args.ContainsArg("-app")) { this.ProcessCommandLineParameter(e.Args); base.OnStartup(e); return; } Logger.EnableTextLog = true; #endif App.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; this.DispatcherUnhandledException += App_DispatcherUnhandledException; DispatcherHelper.UIDispatcher = this.Dispatcher; if (e.Args.ContainsArg("-log")) { Logger.EnableTextLog = true; } SettingsHost.Load(); this.compositeDisposable.Add(SettingsHost.Save); this.compositeDisposable.Add(ProxyService.Current.Shutdown); this.compositeDisposable.Add(SteamConnectService.Current.Shutdown); GeneralSettings.Culture.Subscribe(x => ResourceService.Current.ChangeCulture(x)).AddTo(this); WindowService.Current.AddTo(this).Initialize(); ProxyService.Current.Initialize(); SteamConnectService.Current.Initialize(); AuthService.Current.Initialize(); if (GeneralSettings.IsAutoCheckUpdate) { AutoUpdateService.Current.CheckUpdate(); } //托盘加载 TaskbarService.Current.Taskbar = (TaskbarIcon)FindResource("Taskbar"); ThemeService.Current.Register(this, Theme.Windows, Accent.Windows); SetWebBrowserIeVersion(); this.MainWindow = WindowService.Current.GetMainWindow(); if (e.Args.ContainsArg("-minimized") || GeneralSettings.IsStartupAppMinimized.Value) { //this.MainWindow.Show(); //(WindowService.Current.MainWindow as MainWindowViewModel).IsVisible = false; (WindowService.Current.MainWindow as MainWindowViewModel).Initialize(); } else { this.MainWindow.Show(); } #if !DEBUG appInstance.CommandLineArgsReceived += (sender, args) => { // 检测到多次启动时将主窗口置于最前面 this.Dispatcher.Invoke(() => { (WindowService.Current.MainWindow as MainWindowViewModel).IsVisible = true; }); this.ProcessCommandLineParameter(args.CommandLineArgs); }; #endif base.OnStartup(e); } #if !DEBUG else { if (e.Args.Length > 0) { this.ProcessCommandLineParameter(e.Args); } else { appInstance.SendCommandLineArgs(e.Args); } } #endif }
// 시작할 때의 이벤트 protected override void OnStartup(StartupEventArgs e) { this.ChangeState(ApplicationState.Startup); // 개발중에 다중 실행이 감지되어서 실행되지 않으면 불편하니 디버그 때에는 예외로 처리 #if !DEBUG var appInstance = new MetroTrilithon.Desktop.ApplicationInstance().AddTo(this); if (appInstance.IsFirst) #endif { // 미처리 예외 this.DispatcherUnhandledException += (sender, args) => { ReportException("Dispatcher", 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 (Exception ex) { ReportException("Culture", this, ex); // 무언가 오류가 발생... try { File.Delete(Providers.LocalFilePath); File.Delete(Providers.ViewerDirectoryPath); } catch (Exception ex2) { ReportException("File.Delete", this, ex2); } MessageBox.Show( "어플리케이션 기동중 문제가 발생하여 일부 설정파일을 초기화합니다.\n" + "프로그램이 종료되며, 재시작 해주시기 바랍니다.\n\n" + ex.Message + "\n" + ex.StackTrace, "제독업무도 바빠!", MessageBoxButton.OK, MessageBoxImage.Warning ); this.Shutdown(); return; } // 기존 설정 불러오기..? if (KanColleViewer.Properties.Settings.Default.UpdateSettings) { KanColleViewer.Properties.Settings.Default.Upgrade(); KanColleViewer.Properties.Settings.Default.UpdateSettings = false; KanColleViewer.Properties.Settings.Default.Save(); } // 설정들 초기화 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(); GCWorker.Current.AddTo(this).Startup(); Helper.SetMMCSSTask(); Helper.DeleteCacheIfRequested(); CefInitialize(); // 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 }
public ShipsViewModel(string key) { Setting = SettingsHost.Cache <ShipsSetting>(k => new ShipsSetting(key), key); Setting.Subscribe(nameof(Setting.IsAscending), () => ReverseSort(), false); Setting.Subscribe(nameof(Setting.IsAscending2), () => ReverseSort2(), false); }