/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListViewBanksSelectionChanged(object sender, SelectionChangedEventArgs e) { PcgViewModel.BanksChanged(); Patches(); // Due to some bug, remove all selected items from the same bank type which are selected, except when ALL items // are to be removed (in the case of going to another bank type or all-patches. try { listViewBanks.UpdateLayout(); } catch (InvalidOperationException) { // Ignore. } if (e.RemovedItems.Count > 0) { var selectedBanks = PcgViewModel.Banks.Where(item => item.IsSelected && item.Parent == ((IBank)(e.RemovedItems[0])).Parent).ToList().Count; if (selectedBanks != e.RemovedItems.Count) { foreach (var bank in PcgViewModel.Banks.Where(item => item.IsSelected && (e.RemovedItems.Contains(item)))) { bank.IsSelected = false; } } PcgViewModel.NumberOfSelectedPatches = PcgViewModel.Patches.Count(item => item.IsSelected); } }
/// <summary> /// /// </summary> private void OnViewPropertyChangedAllPatchesSelected() { if (PcgViewModel.AllPatchesSelected) { SetAllPatchesGridViews(); PcgViewModel.BanksChanged(); Patches(); } }
/// <summary> /// /// </summary> private void OnViewPropertyChangedWaveSequenceBanksSelected() { if (PcgViewModel.WaveSequenceBanksSelected) { SetWaveSequenceBanksGridViews(); PcgViewModel.BanksChanged(); Patches(); } }
/// <summary> /// /// </summary> private void OnViewPropertyChangedDrumPatternBanksSelected() { if (PcgViewModel.DrumPatternBanksSelected) { SetDrumPatternBanksGridViews(); PcgViewModel.BanksChanged(); Patches(); } }
/// <summary> /// /// </summary> private void OnViewPropertyChangedSetListsSelected() { if (PcgViewModel.SetListsSelected) { SetSetListsGridViews(); PcgViewModel.BanksChanged(); Patches(); } }
/// <summary> /// /// </summary> private void OnViewPropertyChangedCombiBanksSelected() { if (PcgViewModel.CombiBanksSelected) { SetCombiBanksGridViews(); PcgViewModel.BanksChanged(); Patches(); } }
/// <summary> /// /// </summary> private void OnViewPropertyChangedProgramBanksSelected() { if (PcgViewModel.ProgramBanksSelected) { SetProgramBanksGridViews(); PcgViewModel.BanksChanged(); Patches(); } }
private void OnPcgRootChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case "AssignedClearProgram": ReassignClearProgram(); break; case "IsDirty": // No action required break; case "FileName": PcgViewModel.UpdateTimbresWindows(); break; // default: Ignore file name (and possibly more. } }
/// <summary> /// Clear duplicates only. /// </summary> /// <param name="pcgViewModel"></param> /// <param name="selectedPatches"></param> /// <returns>True if at least one patch cleared</returns> internal bool ClearDuplicatesPatches(PcgViewModel pcgViewModel, List <IPatch> selectedPatches) { var atLeastOneCleared = false; var reversedSelectedPatches = selectedPatches; reversedSelectedPatches.Reverse(); foreach (var patch in reversedSelectedPatches) { var firstDuplicate = patch.FirstDuplicate; if (firstDuplicate != null) { ((IReferencable)(patch)).ChangeReferences(firstDuplicate); patch.Clear(); atLeastOneCleared = true; } } return(atLeastOneCleared); }
/// <summary> /// /// </summary> /// <param name="mainWindow"></param> /// <param name="pcgFileName"></param> /// <param name="pcgMemory"></param> public PcgWindow(MainWindow mainWindow, string pcgFileName, IPcgMemory pcgMemory) { InitializeComponent(); _mainWindow = mainWindow; ViewModel = new PcgViewModel(mainWindow.ViewModel.PcgClipBoard) { ShowDialog = (type, items) => { Window window = null; switch (type) { // Programs case ViewModels.PcgViewModel.DialogType.EditSingleProgram: window = new WindowEditSingleProgram(items.First() as IProgram) { Owner = _mainWindow }; break; case ViewModels.PcgViewModel.DialogType.EditMultiplePrograms: //window = new WindowEditMultiplePrograms(items as List<IProgram>) { Owner = _mainWindow }; break; case ViewModels.PcgViewModel.DialogType.EditSingleProgramBank: //window = new WindowEditSingleProgramBank(items.First() as IProgramBank) { Owner = _mainWindow }; break; case ViewModels.PcgViewModel.DialogType.EditMultipleProgramBanks: //window = new WindowEditMultipleProgramBanks(items as List<IProgramBank>) { Owner = _mainWindow }; break; // Combis case ViewModels.PcgViewModel.DialogType.EditSingleCombi: window = new WindowEditSingleCombi(items.First() as ICombi) { Owner = _mainWindow }; break; case ViewModels.PcgViewModel.DialogType.EditMultipleCombis: //window = new WindowEditMultipleCombis(items as List<ICombi>) { Owner = _mainWindow }; break; case ViewModels.PcgViewModel.DialogType.EditSingleCombiBank: //window = new WindowEditSingleCombiBank(items.First() as ICombiBank) { Owner = _mainWindow }; break; case ViewModels.PcgViewModel.DialogType.EditMultipleCombiBanks: //window = new WindowEditMultipleCombiBanks(items as List<ICombiBank>) { Owner = _mainWindow }; break; // Set list slots case ViewModels.PcgViewModel.DialogType.EditSingleSetListSlot: window = new WindowEditSingleSetListSlot(items.First() as ISetListSlot) { Owner = _mainWindow }; break; case ViewModels.PcgViewModel.DialogType.EditMultipleSetListSlots: //window = new WindowEditMultipleSetListSlot(items as List<ISetListSlot>) //{ // Owner = _mainWindow //}; break; case ViewModels.PcgViewModel.DialogType.EditSingleSetList: window = new WindowEditSingleSetList(items.First() as ISetList) { Owner = _mainWindow }; break; case ViewModels.PcgViewModel.DialogType.EditMultipleSetLists: //window = new WindowEditMultipleSetLists(items as List<ISetLists>) { Owner = _mainWindow }; break; default: throw new ApplicationException("Illegal window type"); } window?.ShowDialog(); }, ShowPasteWindow = () => { var window = new SettingsWindow { Owner = _mainWindow }; window.ShowDialog(); }, ShowMessageBox = (text, title, messageBoxButton, messageBoxImage, messageBoxResult) => WindowUtils.ShowMessageBox(_mainWindow, text, title, messageBoxButton, messageBoxImage, messageBoxResult), SetCursor = WindowUtils.SetCursor, ShowListGenerator = () => { var window = new ListGeneratorWindow((PcgMemory)ViewModel.SelectedMemory) { Owner = _mainWindow }; try { window.ShowDialog(); } catch (InvalidOperationException) { // Do nothing } }, ShowProgramReferencesChanger = () => { var window = new ProgramReferenceChangerWindow((PcgMemory)ViewModel.SelectedMemory) { Owner = _mainWindow }; try { window.ShowDialog(); } catch (InvalidOperationException) { // Do nothing } }, ShowTimbresWindow = (combi, width, height) => { // Check if already exists. If so, show the already opened window. foreach (var child in from child in _mainWindow.Container.Children where (child.Content is CombiWindow) let combiWindowIteration = child.Content as CombiWindow where combiWindowIteration.CombiViewModel.Combi == combi select child) { child.Focus(); return; } // Create combi window if not already present. var mdiChild = new MdiChild { Title = GenerateCombiWindowTitle(combi), Content = new CombiWindow(PcgViewModel, combi), MinimizeBox = false, MaximizeBox = false, Width = width, Height = height, Margin = new Thickness(0, 0, 0, 0) }; ((CombiWindow)(mdiChild.Content)).MdiChild = mdiChild; _mainWindow.Container.Children.Add(mdiChild); mdiChild.GotFocus += _mainWindow.MdiGotFocus; mdiChild.Closing += _mainWindow.MdiClosing; }, EditParameterWindow = patches => { var window = new WindowEditParameter(patches); window.ShowDialog(); }, UpdateTimbresWindows = () => { // Update every timbre window. foreach (var child in from child in _mainWindow.Container.Children where (child.Content is CombiWindow) select child) { var viewModel = ((CombiWindow)(child.Content)).CombiViewModel; viewModel.UpdateUiContent(); child.Title = GenerateCombiWindowTitle(viewModel.Combi); } /* * // If it is a master file being changed, also update all other windows. * var masterFile = MasterFiles.Instances.FindMasterPcg(PcgMemory.ModelType); * if (masterFile != null) * { * * _mainWindow.ViewModel.UpdatePcgWindowsOfModelType(PcgMemory.ModelType); * } */ }, MoveSelectedPatchesUp = MoveSelectedPatchesUp, MoveSelectedPatchesDown = MoveSelectedPatchesDown, GetSelectedPatchListViewIndex = () => listViewPatches.SelectedIndex, SetPcgFileAsMasterFile = SetPcgFileAsMasterFile, CloseWindow = CloseWindow }; DataContext = ViewModel; ViewModel.PropertyChanged += OnViewPropertyChanged; listViewBanks.ItemsSource = PcgViewModel.Banks; listViewPatches.ItemsSource = PcgViewModel.Patches; _pcgMemory = pcgMemory; _pcgMemory.FileName = pcgFileName; if (_pcgMemory.CombiBanks == null) { ButtonTimbres.Visibility = Visibility.Collapsed; } if (_pcgMemory.SetLists == null) { ButtonAssign.Visibility = Visibility.Collapsed; } //ToolTipService.ShowOnDisabled = "True" // ToolTipService.IsEnabled = "{Binding Path=ToolTipEnabled, Converter={StaticResource InverseBooleanConverter}}" // ToolTipService.ToolTip = "{Binding Path=ToolTip, Mode=OneTime}" }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnBanksDoubleClick(object sender, MouseButtonEventArgs e) { PcgViewModel.EditSelectedItem(); }