public void SetMultiKeypress(int index, KeyCombo keypress) { this.multiKeypresses[index] = keypress; parent.parent.Save(); }
private void UpdateButtonDisplay() { this.ButtonTypeBox.SelectionChanged -= ButtonTypeSelected; if (this.CurrentButton == null) { this.ButtonXBox.Text = null; this.ButtonYBox.Text = null; this.ButtonWidthBox.Text = null; this.ButtonHeightBox.Text = null; this.FontSizeBox.Text = null; this.ButtonTextBox.Text = null; this.ButtonTypeBox.SelectedIndex = -1; this.KeypressLabel.Text = "No Keypress"; this.DegreesBox.Text = null; this.DefaultPositionBox.Text = null; this.LeftRightCheckbox.IsChecked = false; this.NormalButtonControls.Visibility = Visibility.Visible; this.RotaryControls.Visibility = Visibility.Collapsed; this.TwoRotaryControls.Visibility = Visibility.Collapsed; this.MultiRotaryControls.Visibility = Visibility.Collapsed; this.ThreeSwitchControls.Visibility = Visibility.Collapsed; } else { this.ButtonXBox.Text = this.CurrentButton.X.ToString(); this.ButtonYBox.Text = this.CurrentButton.Y.ToString(); this.ButtonWidthBox.Text = this.CurrentButton.Width.ToString(); this.ButtonHeightBox.Text = this.CurrentButton.Height.ToString(); this.FontSizeBox.Text = (this.CurrentButton.FontSize * 100).ToString("0.##"); this.ButtonTextBox.Text = this.CurrentButton.Text; this.ButtonTypeBox.SelectedIndex = (int)this.CurrentButton.ButtonType; this.DegreesBox.Text = this.CurrentButton.RotaryAngle.ToString("0.##"); this.DefaultPositionBox.Text = (this.CurrentButton.DefaultKeypress + 1).ToString(); this.LeftRightCheckbox.IsChecked = this.CurrentButton.IsLeftRight; if (this.CurrentButton.Keypress == null) { this.KeypressLabel.Text = "No Keypress"; this.KeypressButton.Content = "Set Key"; this.MidKeypressLabel.Text = "No Keypress"; this.MidKeypressButton.Content = "Set Mid Key"; } else { this.KeypressLabel.Text = this.CurrentButton.Keypress.ToString(); this.KeypressButton.Content = "Clear Key"; this.MidKeypressLabel.Text = this.CurrentButton.Keypress.ToString(); this.MidKeypressButton.Content = "Clear Mid Key"; } if (this.CurrentButton.CWKeypress == null) { this.CWKeypressLabel.Text = "No Keypress"; this.CWKeypressButton.Content = "Set CW Key"; this.UpKeypressLabel.Text = "No Keypress"; this.UpKeypressButton.Content = this.CurrentButton.IsLeftRight ? "Set Right Key" : "Set Up Key"; } else { this.CWKeypressLabel.Text = this.CurrentButton.CWKeypress.ToString(); this.CWKeypressButton.Content = "Clear CW Key"; this.UpKeypressLabel.Text = this.CurrentButton.CWKeypress.ToString(); this.UpKeypressButton.Content = this.CurrentButton.IsLeftRight ? "Clear Right Key" : "Clear Up Key"; } if (this.CurrentButton.CCWKeypress == null) { this.CCWKeypressLabel.Text = "No Keypress"; this.CCWKeypressButton.Content = "Set CCW Key"; this.DownKeypressLabel.Text = "No Keypress"; this.DownKeypressButton.Content = this.CurrentButton.IsLeftRight ? "Set Left Key" : "Set Down Key"; } else { this.CCWKeypressLabel.Text = this.CurrentButton.CCWKeypress.ToString(); this.CCWKeypressButton.Content = "Clear CCW Key"; this.DownKeypressLabel.Text = this.CurrentButton.CCWKeypress.ToString(); this.DownKeypressButton.Content = this.CurrentButton.IsLeftRight ? "Clear Left Key" : "Clear Down Key"; } this.NormalButtonControls.Visibility = this.CurrentButton.ButtonType == ButtonType.Normal ? Visibility.Visible : Visibility.Collapsed; this.RotaryControls.Visibility = (this.CurrentButton.ButtonType == ButtonType.TwoDirectionRotary || this.CurrentButton.ButtonType == ButtonType.MultiPositionRotary || this.CurrentButton.ButtonType == ButtonType.MultiPositionSwitch) ? Visibility.Visible : Visibility.Collapsed; this.DegreesLabel.Visibility = (this.CurrentButton.ButtonType == ButtonType.TwoDirectionRotary || this.CurrentButton.ButtonType == ButtonType.MultiPositionRotary) ? Visibility.Visible : Visibility.Collapsed; this.DegreesBox.Visibility = this.DegreesLabel.Visibility; this.TwoRotaryControls.Visibility = this.CurrentButton.ButtonType == ButtonType.TwoDirectionRotary ? Visibility.Visible : Visibility.Collapsed; this.MultiRotaryControls.Visibility = (this.CurrentButton.ButtonType == ButtonType.MultiPositionRotary || this.CurrentButton.ButtonType == ButtonType.MultiPositionSwitch) ? Visibility.Visible : Visibility.Collapsed; this.ThreeSwitchControls.Visibility = this.CurrentButton.ButtonType == ButtonType.ThreeWaySwitch ? Visibility.Visible : Visibility.Collapsed; this.LeftRightControls.Visibility = (this.CurrentButton.ButtonType == ButtonType.ThreeWaySwitch || this.CurrentButton.ButtonType == ButtonType.MultiPositionSwitch) ? Visibility.Visible : Visibility.Collapsed; this.RotaryMinusButton.IsEnabled = this.CurrentButton.MultiKeypresses.Count > 2; this.MultiRotaryContainer.Children.Clear(); this.MultiRotaryContainer.RowDefinitions.Clear(); for (int i = 0; i < this.CurrentButton.MultiKeypresses.Count; i++) { KeyCombo keypress = this.CurrentButton.MultiKeypresses[i]; this.MultiRotaryContainer.RowDefinitions.Add(new RowDefinition()); TextBlock label = new TextBlock(); label.Text = keypress == null ? "No Keypress" : keypress.ToString(); label.HorizontalAlignment = HorizontalAlignment.Stretch; label.VerticalAlignment = VerticalAlignment.Center; label.TextAlignment = TextAlignment.Right; label.TextWrapping = TextWrapping.Wrap; label.Margin = new Thickness(0, 5, 5, 5); Grid.SetRow(label, i); Grid.SetColumn(label, 0); this.MultiRotaryContainer.Children.Add(label); Button button = new Button(); button.Tag = i; button.Margin = new Thickness(5); button.Content = keypress == null ? "Set Key " + (i + 1) : "Clear Key " + (i + 1); button.HorizontalAlignment = HorizontalAlignment.Stretch; button.VerticalAlignment = VerticalAlignment.Center; Grid.SetRow(button, i); Grid.SetColumn(button, 1); button.AddHandler(Button.ClickEvent, new RoutedEventHandler(MultiKeypressSet)); this.MultiRotaryContainer.Children.Add(button); } } this.ButtonTypeBox.SelectionChanged += ButtonTypeSelected; }