예제 #1
0
        private void SelectionChanged(ISavedPresetEntry entry)
        {
            if (_ignoreNext)
            {
                _ignoreNext = false;
                return;
            }

            if (entry == null)
            {
                return;
            }
            SelectedPresetFilename = entry.Filename;
            _currentUserPresetData = null;

            if (!_partiallyIgnoreNext && _presetable != null)
            {
                PresetSelected?.Invoke(this, new ChangedPresetEventArgs(_presetable.PresetableKey, entry.ToString()));

                try {
                    _presetable.ImportFromPresetData(entry.ReadData());
                } catch (Exception) {
                    return; // TODO: Informing
                }
            }

            SetChanged(false);
        }
예제 #2
0
        public void Setup(string controllerType, string selectedPreset)
        {
            spPresets.Children.Clear();
            buttons.Clear();

            string presetToUse = string.Empty;
            var    files       = Directory.GetFileSystemEntries("Presets", "*.xml");

            foreach (var file in files)
            {
                try
                {
                    using (var reader = new StreamReader(file))
                    {
                        var data = new XmlSerializer(typeof(DataDS)).Deserialize(reader) as DataDS;
                        if (data != null && data.Data != null && data.Data.Type == controllerType)
                        {
                            var shortName = file.Split('\\').Last().Replace(".xml", "");
                            var btn       = new ToggleButton {
                                Content = shortName, Tag = shortName, MinWidth = 40
                            };
                            spPresets.Children.Add(btn);
                            buttons.Add(btn);

                            if (string.IsNullOrEmpty(presetToUse) || selectedPreset == shortName)
                            {
                                foreach (var toggleButton in buttons)
                                {
                                    toggleButton.IsChecked = false;
                                }
                                btn.IsChecked = true;

                                presetToUse = shortName;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }

            PresetSelected?.Invoke(presetToUse);

            foreach (var btn in buttons)
            {
                btn.Checked   += OnBtnChecked;
                btn.Unchecked += OnBtnChecked;
            }
        }
예제 #3
0
        private void OnBtnChecked(object sender, RoutedEventArgs e)
        {
            if (muted)
            {
                return;
            }

            muted = true;

            foreach (var btn in buttons)
            {
                btn.IsChecked = btn == sender;
            }

            PresetSelected?.Invoke((sender as ToggleButton).Tag.ToString());

            muted = false;
        }
 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
 {
     PresetSelected?.Invoke(ShowDefault && indexPath.Section == 0 ? null : items[indexPath.Row]);
 }