Esempio n. 1
0
        void MappingListDoubleClicked(PropertyPage props, int propertyIndex, int itemIndex, int columnIndex)
        {
            var src      = channelSources[itemIndex];
            var srcNames = GetSourceNames(src.type);
            var allowChannel10Mapping = src.type == MidiSourceType.Channel && src.index == 9;

            var dlg = new PropertyDialog(300, true, true, dialog);

            dlg.Properties.AddDropDownList("Source Type:", MidiSourceType.Names, MidiSourceType.Names[src.type]); // 0
            dlg.Properties.AddDropDownList("Source:", srcNames, srcNames[src.index]);                             // 1
            dlg.Properties.AddLabel(null, "Channel 10 keys:");                                                    // 2
            dlg.Properties.AddCheckBoxList(null, MidiFileReader.MidiDrumKeyNames, GetSelectedChannel10Keys(src)); // 3
            dlg.Properties.AddButton(null, "Select All", SelectClicked);                                          // 4
            dlg.Properties.AddButton(null, "Select None", SelectClicked);                                         // 5
            dlg.Properties.Build();
            dlg.Properties.PropertyChanged += MappingProperties_PropertyChanged;
            dlg.Properties.SetPropertyEnabled(1, src.type != MidiSourceType.None);
            dlg.Properties.SetPropertyEnabled(3, src.type != MidiSourceType.None && allowChannel10Mapping);
            dlg.Properties.SetPropertyEnabled(4, src.type != MidiSourceType.None && allowChannel10Mapping);
            dlg.Properties.SetPropertyEnabled(5, src.type != MidiSourceType.None && allowChannel10Mapping);

            if (dlg.ShowDialog(null) == DialogResult.OK)
            {
                var sourceType = MidiSourceType.GetValueForName(dlg.Properties.GetPropertyValue <string>(0));
                var sourceName = dlg.Properties.GetPropertyValue <string>(1);
                var keysBool   = dlg.Properties.GetPropertyValue <bool[]>(3);

                src.type  = sourceType;
                src.index = sourceType == MidiSourceType.None ? 0 : (Utils.ParseIntWithTrailingGarbage(sourceName.Substring(sourceType == MidiSourceType.Track ? 6 : 8)) - 1);
                src.keys  = 0ul;

                for (int i = 0; i < keysBool.Length; i++)
                {
                    if (keysBool[i])
                    {
                        src.keys |= (1ul << i);
                    }
                }

                UpdateListView();
            }
        }
Esempio n. 2
0
        public void ShowDialogAsync(FamiStudioForm parent, Action <DialogResult> callback)
        {
            dialog.ShowDialogAsync(parent, (r) =>
            {
                if (r == DialogResult.OK)
                {
                    var pageGeneral = pages[(int)ConfigSection.General];
                    var pageUI      = pages[(int)ConfigSection.UserInterface];
                    var pageSound   = pages[(int)ConfigSection.Sound];
                    var pageMixer   = pages[(int)ConfigSection.Mixer];

                    // General
                    Settings.CheckUpdates           = pageGeneral.GetPropertyValue <bool>(0);
                    Settings.ShowTutorial           = pageGeneral.GetPropertyValue <bool>(1);
                    Settings.TrackPadControls       = pageGeneral.GetPropertyValue <bool>(2);
                    Settings.ClearUndoRedoOnSave    = pageGeneral.GetPropertyValue <bool>(3);
                    Settings.OpenLastProjectOnStart = pageGeneral.GetPropertyValue <bool>(4);
                    Settings.AutoSaveCopy           = pageGeneral.GetPropertyValue <bool>(5);

                    // UI
                    var scalingString = pageUI.GetPropertyValue <string>(0);

                    Settings.DpiScaling             = scalingString == "System" ? 0 : Utils.ParseIntWithTrailingGarbage(scalingString);
                    Settings.TimeFormat             = pageUI.GetSelectedIndex(1);
                    Settings.FollowMode             = pageUI.GetSelectedIndex(2);
                    Settings.FollowSync             = pageUI.GetSelectedIndex(3);
                    Settings.ScrollBars             = pageUI.GetSelectedIndex(4);
                    Settings.ShowPianoRollViewRange = pageUI.GetPropertyValue <bool>(5);
                    Settings.ShowNoteLabels         = pageUI.GetPropertyValue <bool>(6);
                    Settings.ShowImplicitStopNotes  = pageUI.GetPropertyValue <bool>(7);
                    Settings.ShowOscilloscope       = pageUI.GetPropertyValue <bool>(8);
                    Settings.ForceCompactSequencer  = pageUI.GetPropertyValue <bool>(9);

                    // Sound
                    Settings.NumBufferedAudioFrames = pageSound.GetPropertyValue <int>(0);
                    Settings.InstrumentStopTime     = pageSound.GetPropertyValue <int>(1);
                    Settings.SquareSmoothVibrato    = pageSound.GetPropertyValue <bool>(2);
                    Settings.NoDragSoungWhenPlaying = pageSound.GetPropertyValue <bool>(3);
                    Settings.MetronomeVolume        = (int)pageSound.GetPropertyValue <double>(4);

                    // Mixer.
                    Settings.GlobalVolume = (float)pageMixer.GetPropertyValue <double>(0);
                    Array.Copy(expansionMixer, Settings.ExpansionMixerSettings, Settings.ExpansionMixerSettings.Length);

                    // MIDI
                    var pageMIDI = pages[(int)ConfigSection.MIDI];

                    Settings.MidiDevice = pageMIDI.GetPropertyValue <string>(0);

                    // FFmpeg
                    var pageFFmpeg = pages[(int)ConfigSection.FFmpeg];

                    Settings.FFmpegExecutablePath = pageFFmpeg.GetPropertyValue <string>(1);

                    // QWERTY
                    Array.Copy(qwertyKeys, Settings.QwertyKeys, Settings.QwertyKeys.Length);
                    Settings.UpdateKeyCodeMaps();

                    // Mac OS
                    var pageMacOS                  = pages[(int)ConfigSection.MacOS];
                    Settings.ReverseTrackPad       = pageMacOS.GetPropertyValue <bool>(0);
                    Settings.TrackPadMoveSensitity = pageMacOS.GetPropertyValue <int>(1);
                    Settings.TrackPadZoomSensitity = pageMacOS.GetPropertyValue <int>(2);

                    // Mobile
                    var pageMobile             = pages[(int)ConfigSection.Mobile];
                    Settings.AllowVibration    = pageMobile.GetPropertyValue <bool>(0);
                    Settings.DoubleClickDelete = pageMobile.GetPropertyValue <bool>(1);

                    Settings.Save();
                }

                callback(r);
            });
        }
Esempio n. 3
0
        private void Properties_PropertyChanged(PropertyPage props, int propIdx, int rowIdx, int colIdx, object value)
        {
            if (propIdx == 4)
            {
                var expansionMask   = GetExpansionMask(props.GetPropertyValue <bool[]>(4));
                var newChannelCount = Channel.GetChannelCountForExpansionMask(expansionMask, 8);
                var oldChannelCount = channelSources.Length;

                var maxChannelIndex = 2;
                for (int i = 0; i < oldChannelCount; i++)
                {
                    if (channelSources[i].type == MidiSourceType.Channel && channelSources[i].index != 9)
                    {
                        maxChannelIndex = Math.Max(maxChannelIndex, channelSources[i].index);
                    }
                }

                Array.Resize(ref channelSources, newChannelCount);

                for (int i = oldChannelCount; i < newChannelCount; i++)
                {
                    maxChannelIndex = Math.Min(maxChannelIndex + 1, 15);
                    if (maxChannelIndex == 9)
                    {
                        maxChannelIndex++;
                    }
                    channelSources[i] = new MidiFileReader.MidiSource()
                    {
                        index = maxChannelIndex
                    };
                }

                UpdateListView();

                bool allowPal = expansionMask == ExpansionType.NoneMask;
                dialog.Properties.SetPropertyEnabled(3, allowPal);
                if (!allowPal)
                {
                    dialog.Properties.SetPropertyValue(3, false);
                }
            }
            else if (propIdx == 6)
            {
                Debug.Assert(colIdx == 1);

                var src = channelSources[rowIdx];
                var str = (string)value;

                if (str.StartsWith("Track"))
                {
                    src.type  = MidiSourceType.Track;
                    src.index = Utils.ParseIntWithTrailingGarbage(str.Substring(6)) - 1;
                }
                else if (str.StartsWith("Channel"))
                {
                    src.type  = MidiSourceType.Channel;
                    src.index = Utils.ParseIntWithTrailingGarbage(str.Substring(8)) - 1;
                }
                else
                {
                    src.type  = MidiSourceType.None;
                    src.index = 0;
                }

                UpdateListView();
            }
        }