private void ServerCreated(object sender, ServerCreatedEventArgs args) { // Save user settings as there might be new settings _userSettings.ServerSetup = args.Settings; SaveUserSettings(UserSettingsFilePath, _userSettings); BitmapRepository bitmapRepository = new BitmapRepository(new FileSystem(), _userSettings.ServerSetup.BitmapFolder); BitmapThumbnailRepository thumbnailRepository = new BitmapThumbnailRepository(new FileSystem(), ThumbnailRepository, bitmapRepository); thumbnailRepository.Create(); BitmapStoryboardCreator bitmapStoryboardCreator = new BitmapStoryboardCreator(bitmapRepository, 480, 3, 2); // TODO get these magic values from the config StoryboardRepository storyboardRepository = new StoryboardRepository(_userSettings.ServerSetup.StoryboardFolder); SelectedViewModel = new MainControlPanelViewModel(args.StellaServer, storyboardRepository, bitmapStoryboardCreator, bitmapRepository, thumbnailRepository, LogViewModel, args.MidiInputManager); }
public AnimationsPanelViewModel(StoryboardRepository storyboardRepository, BitmapStoryboardCreator bitmapStoryboardCreator, BitmapRepository bitmapRepository) { _storyboardRepository = storyboardRepository; _bitmapStoryboardCreator = bitmapStoryboardCreator; _bitmapRepository = bitmapRepository; // Load storyboards animations List <Storyboard> storyboards = storyboardRepository.LoadStoryboards(); // Load bitmap animations storyboards.AddRange(_bitmapStoryboardCreator.Create()); // Create play lists List <IAnimation> animations = storyboards.Cast <IAnimation>().ToList(); animations.Add(PlaylistCreator.Create("All combined", storyboards, 120)); animations.AddRange(PlaylistCreator.CreateFromCategory(storyboards, 120)); var list = animations.Select(x => new AnimationPanelItemViewModel(x)).Select(vm => { vm.StartCommand.Subscribe(onNext => { StartAnimationRequested?.Invoke(this, vm.Animation); }); vm.SendToPad.Subscribe(onNext => { SendToPadRequested?.Invoke(this, new SendToPadEventArgs(vm.Animation, onNext)); }); return(vm); }).ToList(); _animationViewModels.AddRange(list); _animationViewModels.Connect().Bind(out var animationPanelItemViewModels).Subscribe(); Items = animationPanelItemViewModels; /*// TODO why is this not working? * this.WhenAnyValue(x => x.SelectedAnimation) * .Where(x=> x!=null) * .Select(x => new StoryboardDetailsControlViewModel(SelectedAnimation.Animation)) * .ToProperty(this, x=> x.StoryboardDetails);*/ }
public MainControlPanelViewModel(StellaServerLib.StellaServer stellaServer, StoryboardRepository storyboardRepository, BitmapStoryboardCreator bitmapStoryboardCreator, BitmapRepository bitmapRepository, BitmapThumbnailRepository thumbnailRepository, LogViewModel logViewModel, MidiInputManager midiInputManager) { _stellaServer = stellaServer; AnimationsPanelViewModel = new AnimationsPanelViewModel(storyboardRepository, bitmapStoryboardCreator, bitmapRepository); AnimationsPanelViewModel.StartAnimationRequested += StartAnimation; AnimationsPanelViewModel.SendToPadRequested += AnimationsPanelViewModel_OnSendToPadRequested; this.WhenAnyValue(x => x.AnimationsPanelViewModel.SelectedAnimation) .Subscribe(onNext => { if (onNext == null) { SelectedViewModel = null; return; } if (onNext.Animation is Storyboard storyboard) { var viewmodel = new StoryboardDetailsControlViewModel(storyboard, bitmapRepository); viewmodel.Back.Subscribe(next => { SelectedViewModel = NavigationViewModel; }); SelectedViewModel = viewmodel; return; } if (onNext.Animation is PlayList playList) { var viewmodel = new PlaylistDetailsContolViewModel(playList, bitmapRepository); viewmodel.Back.Subscribe(next => { SelectedViewModel = NavigationViewModel; }); SelectedViewModel = viewmodel; return; } throw new NotImplementedException("Unknown animation type"); }); StatusViewModel = new StatusViewModel(stellaServer, 3, logViewModel); //TODO insert number of clients AnimationCreationViewModel = new AnimationCreationViewModel(bitmapRepository, bitmapStoryboardCreator, thumbnailRepository, 6, 24); // Todo insert number of rows, number of tubes AnimationCreationViewModel.Save.Subscribe(onNext => AnimationsPanelViewModel.AddItem(onNext)); AnimationCreationViewModel.Start.Subscribe(onNext => StartAnimation(null, onNext)); AnimationCreationViewModel.Back.Subscribe(onNext => SelectedViewModel = NavigationViewModel); if (midiInputManager != null) { MidiPanelViewModel = new MidiPanelViewModel(4, 4, 10, midiInputManager); //TODO configurable midi buttons MidiPanelViewModel.StartAnimation.Subscribe(x => { StartAnimation(null, x); }); midiInputManager.Stop.Subscribe(x => { StartAnimation(null, FindStopAnimation()); }); } NavigationViewModel = new NavigationViewModel(); NavigationViewModel.NavigateToCreateAnimation.Subscribe(onNext => SelectedViewModel = AnimationCreationViewModel); NavigationViewModel.NavigateToMidiPanel.Subscribe(onNext => SelectedViewModel = MidiPanelViewModel); SelectedViewModel = NavigationViewModel; }