From 5cacb508667d504e73ff282464f77274ec92cdc4 Mon Sep 17 00:00:00 2001 From: David-MolTor Date: Fri, 20 Sep 2024 14:10:30 +0200 Subject: [PATCH] Rotary knob control and device system Updated the rotary knob control system. Updated the device control system. --- build/MidiControl/Classes/IControlMIDI.cs | 9 +++------ build/MidiControl/Classes/RotaryKnob.xaml.cs | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/build/MidiControl/Classes/IControlMIDI.cs b/build/MidiControl/Classes/IControlMIDI.cs index c0dfe17..5bf02d4 100644 --- a/build/MidiControl/Classes/IControlMIDI.cs +++ b/build/MidiControl/Classes/IControlMIDI.cs @@ -120,13 +120,10 @@ Deinitializes the output device */ public void DisconnectDevice() { - lock (lockDevice) + if (device != null) { - if (device != null) - { - device.Dispose(); - device = null; - } + device.Dispose(); + device = null; } } diff --git a/build/MidiControl/Classes/RotaryKnob.xaml.cs b/build/MidiControl/Classes/RotaryKnob.xaml.cs index 6bb39a7..6d4902f 100644 --- a/build/MidiControl/Classes/RotaryKnob.xaml.cs +++ b/build/MidiControl/Classes/RotaryKnob.xaml.cs @@ -150,7 +150,7 @@ private void SetRotation(ref double dAngle) dAngle = dAngle < Constants.KNOB_ROTATION_MIN ? Constants.KNOB_ROTATION_MIN : dAngle; //Calculate the knob status and set its angle - Status = Steps[(int)Math.Floor((dAngle - Constants.KNOB_ROTATION_MIN) / (Constants.KNOB_ROTATION_MAX - Constants.KNOB_ROTATION_MIN) * (Steps.Count - 1))]; + Status = Steps[(int)Math.Round((dAngle - Constants.KNOB_ROTATION_MIN) / (Constants.KNOB_ROTATION_MAX - Constants.KNOB_ROTATION_MIN) * (Steps.Count - 1))]; transformKnob.Angle = Constants.KNOB_ROTATION_MIN + (Constants.KNOB_ROTATION_MAX - Constants.KNOB_ROTATION_MIN) * (double)Steps.IndexOf(Status) / (Steps.Count - 1); } else