private void UpdateSuppressed(object sender, EventArgs e) { foreach (SoloSuppressButton btn in _bumpButtons) { btn.LitRight = DMXController.IsSuppressed(ParseTag(btn)); } }
private void bump_MouseDown(object sender, MouseEventArgs e) { SoloSuppressButton btn = (SoloSuppressButton)sender; // Zach discovered Tag, which works great for this // Get the channel number from the tag int channelNum = ParseTag((Control)sender); if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { DMXController.FlushHTP(channelNum); if (btn.LitLeft) { DMXController.SetLevel(btn.Name, channelNum, 255); } DMXController.SetLevel(_sliders[channelNum - 1].Name, channelNum, Convert.ToInt32(_sliders[channelNum - 1].Value)); } else if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { _shiftPressed = true; if (!DMXController.IsSuppressed(channelNum)) { DMXController.Suppress(channelNum); btn.LitRight = true; } else { DMXController.Unsuppress(channelNum); btn.LitRight = false; } } else { // Set the level string buttonName = btn.Name; DMXController.SetLevel(buttonName, channelNum, 255); // If it was a right-click, toggle if (e.RightButton == MouseButtonState.Pressed) { btn.LitLeft = !btn.LitLeft; } } }
private void GenerateSliders() { foreach (Slider s in _sliders) { this.cnv_sliders.Children.Remove(s); } foreach (SoloSuppressButton b in _bumpButtons) { this.cnv_sliders.Children.Remove(b); } //Remember, arrays still start at 0 _sliders = new List <Slider>(); _bumpButtons = new List <SoloSuppressButton>(); for (int i = 1; i <= _numSliders; i++) { //Generate a trackbar Slider tbar = new Slider(); //We will set location in a minute tbar.Margin = new Thickness(); tbar.Name = "tbar_Chan" + i; //Zach discovered this //This property stores the associated channel tbar.Tag = i.ToString(); tbar.LargeChange = 15; tbar.Maximum = 255; //tbar tbar.Width = 45; tbar.Height = 78; //We don't want to accidentally tab to this tbar.IsTabStop = false; tbar.Orientation = Orientation.Vertical; tbar.TickFrequency = 25; tbar.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.Both; //Attach the scroll event handler tbar.ValueChanged += new RoutedPropertyChangedEventHandler <double>(this.tbr_Scroll); //Add it to the list _sliders.Add(tbar); //Actually add it to the form this.cnv_sliders.Children.Add(tbar); //Generate a button SoloSuppressButton btn = new SoloSuppressButton(45, 45); //We will set location in a minute btn.Margin = new Thickness(); btn.Name = "btn_Chan" + i; //Zach discovered this //This property stores the associated channel btn.Tag = i.ToString(); btn.IsTabStop = false; btn.Label = i.ToString(); //Attach the event handlers btn.MouseDown += new MouseButtonEventHandler(this.bump_MouseDown); btn.MouseUp += new MouseButtonEventHandler(this.bump_MouseUp); //Add it to the list _bumpButtons.Add(btn); //Actually add it to the form this.cnv_sliders.Children.Add(btn); //Set the button's Green (bump) status to false btn.LitLeft = false; //Set the Red (suppressed) state btn.LitRight = DMXController.IsSuppressed(i); } PositionSliders(20, 10, 10, 5); }