Пример #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();
            }
        }
Пример #2
0
        private void MappingProperties_PropertyChanged(PropertyPage props, int idx, object value)
        {
            var sourceType = MidiSourceType.GetValueForName(props.GetPropertyValue <string>(0));

            if (idx == 0)
            {
                props.UpdateDropDownListItems(1, GetSourceNames(sourceType));
            }

            var allowChannel10Mapping = false;

            if (sourceType == MidiSourceType.Channel)
            {
                var channelIdx = int.Parse(props.GetPropertyValue <string>(1).Substring(8)) - 1;
                allowChannel10Mapping = channelIdx == 9;
            }

            props.SetPropertyEnabled(1, sourceType != MidiSourceType.None);
            props.SetPropertyEnabled(3, sourceType != MidiSourceType.None && allowChannel10Mapping);
            props.SetPropertyEnabled(4, sourceType != MidiSourceType.None && allowChannel10Mapping);
            props.SetPropertyEnabled(5, sourceType != MidiSourceType.None && allowChannel10Mapping);
        }