private void Button_PreviewMouseDown(object sender, MouseButtonEventArgs e) { switch (ButtonFunction) { case buttonFunction.SetBitWhileKeyPressed: PLCConnection.WriteTag(ControlTag, true); break; case buttonFunction.InvertBit: PLCConnection.WriteToggle(ControlTag); break; case buttonFunction.SetBit: PLCConnection.WriteTag(ControlTag, true); break; case buttonFunction.ResetBit: PLCConnection.WriteTag(ControlTag, false); break; } }