public MainPageViewModel(IViewServices viewSvc) { dataStore = Services.MockDataStore.Instance; SpellLists = new ObservableCollection <SpellListViewModel>(); ViewSpellListCommand = new Command(vm => viewSvc.Navigation.PushAsync(new Views.ViewSpellListPage(((SpellListViewModel)vm).SpellList))); AddNewSpellListCommand = new Command(() => viewSvc.Navigation.PushAsync(new Views.EditSpellListPage(new Model.SpellList()))); DeleteSpellListCommand = new Command(vm => { viewSvc.DisplayAlert("Delete Spell List", $"Are you sure you want to delete \"{((SpellListViewModel)vm).Title}\"?", "Yes", "No") .ContinueWith(_ => { if (_.Result) { dataStore.Delete(((SpellListViewModel)vm).SpellList); SpellLists.Remove(((SpellListViewModel)vm)); } }); }); CloneSpellListCommand = new Command(vm => viewSvc.Navigation.PushAsync(new Views.EditSpellListPage(((SpellListViewModel)vm).SpellList.Clone()))); }
public EditSpellListPageViewModel(IViewServices viewSvc, ISpellList spellList) : base(spellList) { _title = spellList.Title; _class = spellList.Class; _level = spellList.Level; PickSpellListCommand = new Command(() => { spellList.Title = _title; spellList.Class = _class; spellList.Level = _level; Services.MockDataStore.Instance.Save(spellList); viewSvc.Navigation.PushAsync(new Views.PickSpellListPage(spellList)); }); DeleteSpellListCommand = new Command(async() => { if (await viewSvc.DisplayAlert("Delete Spell List", $"Are you sure you want to delete \"{Title}\"?", "Yes", "No")) { Services.MockDataStore.Instance.Delete(SpellList); await viewSvc.Navigation.PopToRootAsync(); } }); CloneSpellListCommand = new Command(() => viewSvc.Navigation.PushAsync(new Views.EditSpellListPage(SpellList.Clone()))); }
public ModuleExplorerViewModel(IViewServices viewServices, ILogger logger, DeviceViewModel deviceViewModel, Module module) : base(viewServices, logger, deviceViewModel, module.Data) { Module = module; OpenCopyInKitExplorerCommand = new DelegateCommand <DataTreeNodeViewModel>(OpenCopyInKitExplorer, true); CopyKitCommand = new DelegateCommand <DataTreeNodeViewModel>(CopyKit, true); ImportKitFromFileCommand = new DelegateCommand <DataTreeNodeViewModel>(ImportKitFromFile, true); ExportKitCommand = new DelegateCommand <DataTreeNodeViewModel>(ExportKit, true); }
public ViewSpellListPageViewModel(IViewServices viewSvc, ISpellList spellList) : base(spellList) { EditSpellListCommand = new Command(() => viewSvc.Navigation.PushAsync(new Views.EditSpellListPage(spellList))); var spells = Services.MockDataStore.Instance.LoadSpellsForSpellList(spellList); Spells = spells.Select(_ => new SpellListEntryViewModel(_)).ToList(); }
public TripController(ITripServices tripServices, IRatingServices ratingServices, ITripNotificationServices tripNotificationServices, ITownProvider townProvider, IStatisticsServices statisticsServices, IViewServices viewServices, IDateProvider dateProvider, ITripProvider tripProvider, INotificationServices notificationServices) { this.TripServices = tripServices; this.RatingServices = ratingServices; this.TripNotificationServices = tripNotificationServices; this.StatisticsServices = statisticsServices; this.ViewServices = viewServices; this.TownProvider = townProvider; this.DateProvider = dateProvider; this.TripProvider = tripProvider; this.NotificationServices = notificationServices; }
public ExplorerHomeViewModel(IViewServices viewServices, LogViewModel logViewModel, DeviceViewModel deviceViewModel) { this.viewServices = viewServices; LogViewModel = logViewModel; logger = LogViewModel.Logger; DeviceViewModel = deviceViewModel; LoadModuleFromDeviceCommand = new DelegateCommand(LoadModuleFromDevice, true); LoadKitFromDeviceCommand = new DelegateCommand(LoadKitFromDevice, true); RecordInstrumentAudioCommand = new DelegateCommand(RecordInstrumentAudio, true); SaveLogCommand = new DelegateCommand(SaveLog, true); LoadFileCommand = new DelegateCommand(LoadFile, true); }
public InstrumentAudioRecorderViewModel(IViewServices viewServices, ILogger logger, DeviceViewModel deviceViewModel) { this.logger = logger; schema = deviceViewModel.ConnectedDeviceSchema ?? throw new InvalidOperationException("Cannot record audio without a connected device"); device = deviceViewModel.ConnectedDevice ?? throw new InvalidOperationException("Cannot record audio without a connected device"); Settings = new InstrumentAudioRecorderSettingsViewModel(viewServices, schema, device.InputName); Progress = new InstrumentAudioRecorderProgressViewModel(); Title = $"Instrument Audio Recorder ({schema.Identifier.Name})"; StartRecordingCommand = new DelegateCommand(StartRecording, false); CancelCommand = new DelegateCommand(Cancel, false); Settings.PropertyChanged += (sender, args) => UpdateButtonStatus(); }
public PickSpellListPageViewModel(IViewServices viewSvc, ISpellList spellList) : base(spellList) { SaveSpellListCommand = new Command(() => { Services.MockDataStore.Instance.Save(spellList); viewSvc.Navigation.PopToRootAsync(false); viewSvc.Navigation.PushAsync(new Views.ViewSpellListPage(spellList)); }); BuySpellCommand = new Command(obj => { var vm = (SpellListEntryViewModel)obj; vm.Bought = Math.Min(vm.Max, vm.Bought + 1); }); SellSpellCommand = new Command(obj => { var vm = (SpellListEntryViewModel)obj; vm.Bought = Math.Max(0, vm.Bought - 1); }); Spells = Services.MockDataStore.Instance.LoadSpellsForSpellList(spellList) .Select(_ => new SpellListEntryViewModel(_)) .OrderByDescending(_ => _.Level) .ThenBy(_ => _.Name) .ToList(); foreach (var spells in Spells) { spells.PropertyChanged += Spells_PropertyChanged; } GroupHeaders = new PickSpellGroupHeaderViewModel[] { new PickSpellGroupHeaderViewModel(1), new PickSpellGroupHeaderViewModel(2), new PickSpellGroupHeaderViewModel(3), new PickSpellGroupHeaderViewModel(4), new PickSpellGroupHeaderViewModel(5), new PickSpellGroupHeaderViewModel(6) }; }
public InstrumentAudioRecorderSettingsViewModel(IViewServices viewServices, ModuleSchema schema, string midiName) { this.viewServices = viewServices; this.schema = schema; var groups = schema.InstrumentGroups .Where(ig => ig.Preset) .Select(ig => ig.Description) .ToList(); groups.Insert(0, "(All)"); InstrumentGroups = groups; selectedInstrumentGroup = groups[0]; InputDevices = AudioDevices.GetInputDeviceNames(); // Try to guess at a reasonable input based on known inputs including the MIDI name. var expectedInputDevices = new[] { $"MASTER ({midiName})", $"IN ({midiName})", $"KICK ({midiName})" }; SelectedInputDevice = InputDevices.FirstOrDefault(inputName => expectedInputDevices.Contains(inputName)); kitNumber = schema.KitRoots.Count; SelectOutputFileCommand = new DelegateCommand(SelectOutputFile, true); }
public ViewAdminController(IViewServices viewServices) { this.viewServices = viewServices; }