public RotarySwitchPositionChangeArgs(RotarySwitchPosition position, string propertyName, object oldValue, object newValue) { _position = position; _property = propertyName; _oldValue = oldValue; _newValue = newValue; }
private void Add_Position_Click(object sender, RoutedEventArgs e) { RotarySwitch rotary = Control as RotarySwitch; if (rotary != null) { RotarySwitchPosition position = new RotarySwitchPosition(rotary, rotary.Positions.Count + 1, rotary.Positions.Count.ToString(CultureInfo.InvariantCulture), 0d); rotary.Positions.Add(position); ConfigManager.UndoManager.AddUndoItem(new RotarySwitchAddPositionUndoEvent(rotary, position)); } }
private void DeletePosition_Executed(object sender, ExecutedRoutedEventArgs e) { RotarySwitch rotary = Control as RotarySwitch; if (rotary != null && rotary.Positions.Contains((RotarySwitchPosition)PositionList.SelectedItem)) { RotarySwitchPosition removedPosition = (RotarySwitchPosition)PositionList.SelectedItem; int index = rotary.Positions.IndexOf(removedPosition); rotary.Positions.Remove(removedPosition); ConfigManager.UndoManager.AddUndoItem(new RotarySwitchDeletePositionUndoEvent(rotary, removedPosition, index)); } }
private void Delete_Position_Click(object sender, RoutedEventArgs e) { RotarySwitch rotary = Control as RotarySwitch; FrameworkElement senderControl = sender as FrameworkElement; if (senderControl != null && rotary != null) { RotarySwitchPosition position = senderControl.Tag as RotarySwitchPosition; if (position != null && rotary.Positions.Contains(position)) { rotary.Positions.Remove(position); } } }
private void UpdateValueHelp() { StringBuilder sb = new StringBuilder(""); sb.Append(" ("); for (int i = 0; i < Positions.Count; i++) { if (i > 0) { sb.Append(","); } RotarySwitchPosition position = Positions[i]; sb.Append(i + 1); if (position.Name != null && position.Name.Length > 0) { sb.Append("="); sb.Append(position.Name); } } sb.Append(")"); _positionValue.ValueDescription = sb.ToString(); }