Exemple #1
0
        //==============================================================
        //Scale Add/Delete
        partial void RunSaveScaleDialog()
        {
            /*guardians*/
            if (currentShowScale != null)
            {
                WarnUser(this.Localizer["Cannot save the new scale while other scale is in display"]);
                return;
            }

            if (currentSound == 0)
            {
                WarnUser(this.Localizer["Cannot save empty scale"]);
                return;
            }

            var selectedNotes = new List <Note>();

            foreach (var note in Notes)
            {
                if (note.IsChecked)
                {
                    selectedNotes.Add(note);
                }
            }

            var dialogWindow = new ScaleSaveDialogWindow(selectedNotes.ToArray());

            dialogWindow.DataContext = this;
            var dialogResult = dialogWindow.ShowDialog();

            if (dialogResult == true)
            {
                /*guardians*/
                if (dialogWindow.ScaleName == null)
                {
                    throw new ArgumentNullException("dialogWindow.ScaleName");
                }
                if (dialogWindow.KeynoteOfChoice == null)
                {
                    throw new ArgumentNullException("dialogWindow.KeynoteOfChoice");
                }

                string scaleName    = dialogWindow.ScaleName;
                Sound  keynoteSound = dialogWindow.KeynoteOfChoice.Sound;

                Scale newScale = new Scale(scaleName, keynoteSound, currentSound);

                AdditionalScales.Add(newScale);

                ScalesAll.Add(newScale);
                ScalesAll.Sort(new ScalesSorter());

                Request_SaveAdditionalScales?.Invoke(AdditionalScales.ToArray());

                MessageBox.Show(this.Localizer["Scale successfully saved"]);

                ClearUI();
            }
        }
Exemple #2
0
        partial void DeleteSelectedScale()
        {
            if (currentShowScale == null)
            {
                WarnUser(this.Localizer["To delete the scale one must first select it"]);
                return;
            }

            var  scaleToDelete  = currentShowScale;
            bool itIsBasicScale = default(bool);

            foreach (var scale in ScalesBasic)
            {
                if (Object.ReferenceEquals(scaleToDelete, scale))
                {
                    itIsBasicScale = true;
                    break;
                }
            }

            if (itIsBasicScale)
            {
                WarnUser(this.Localizer["Cannot delete basic scale"]);
                return;
            }

            var confirmation = MessageBox.Show(this.Localizer["Delete this scale? Are you sure?"], "", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (confirmation != MessageBoxResult.Yes)
            {
                return;
            }

            //Point of no return
            AdditionalScales.Remove(scaleToDelete);
            ScalesAll.Remove(scaleToDelete);

            Request_SaveAdditionalScales?.Invoke(AdditionalScales.ToArray());

            MessageBox.Show(this.Localizer["Scale deleted"]);

            ClearUI();
        }