public StartMenuViewModel(Game game) { this.game = game; storageBlockService = game.Services.GetRequiredService<IStorageBlockService>(); asyncTaskService = game.Services.GetRequiredService<IAsyncTaskService>(); boxIntegration = (game as BlockViewerGame).BoxIntegration; restoreSessionAction = (state) => boxIntegration.RestoreSession(); uploadDemoContentsAction = (state) => UploadDemoContents(); }
public BoxSetupViewModel(Game game) { if (game == null) throw new ArgumentNullException("game"); asyncTaskService = game.Services.GetRequiredService<IAsyncTaskService>(); boxIntegration = (game as BlockViewerGame).BoxIntegration; getTicketAsync = (state) => boxIntegration.GetTicket(); getAuthTokenAsync = (state) => boxIntegration.GetAuthToken(); prepareFolderTreeAsync = (state) => boxIntegration.PrepareFolderTree(); saveSettingsAsync = (state) => boxIntegration.SaveSettings(); }
protected override void Initialize() { // UIManager を初期化して登録します。 uiManager = new UIManager(this); uiManager.ScreenFactory = CreateScreenFactory(); Components.Add(uiManager); var fpsCounter = new FpsCounter(this); fpsCounter.Content.RootDirectory = "Content"; fpsCounter.HorizontalAlignment = DebugHorizontalAlignment.Right; fpsCounter.SampleSpan = TimeSpan.FromSeconds(2); Components.Add(fpsCounter); timeRuler = new TimeRuler(this); Components.Add(timeRuler); updateMarker = timeRuler.CreateMarker(); updateMarker.Name = "Update"; updateMarker.BarIndex = 0; updateMarker.Color = Color.Cyan; drawMarker = timeRuler.CreateMarker(); drawMarker.Name = "Draw"; drawMarker.BarIndex = 1; drawMarker.Color = Color.Yellow; // StorageManager を登録します。 storageManager = new StorageManager(this); storageManager.ContainerSelected += (s, c) => { // IBoxService が登録されているならば BoxIntegration を初期化します。 if (boxManager != null) BoxIntegration.Initialize(); }; Components.Add(storageManager); // StorageBlockManager を登録します。 storageBlockManager = new StorageBlockManager(this); // AsyncTaskManager を登録します。 asyncTaskManager = new AsyncTaskManager(this); Components.Add(asyncTaskManager); // IBoxService を登録します。 var assemblyFile = "Willcraftia.Net.Box.BlockViewer.ApiKey.dll"; var apiKeyClassName = "Willcraftia.Net.Box.BlockViewer.ApiKey"; try { boxManager = new BoxManager(assemblyFile, apiKeyClassName); Services.AddService(typeof(IBoxService), boxManager); BoxIntegration = new BoxIntegration(this); } catch { // IBoxService を無効とします。 } // マウス カーソルを可視にします。 IsMouseVisible = true; base.Initialize(); }