Hello,
I just purchased this library 2 days ago, and my first impression is WOW! Very happy with my purchase for my small team. That being said I have a unique design requirement and I’m struggling to figure out how to resolve.
Our app utilizes a cursor indicator in the form of a vertical line, this indicator is used as a visual reference and synced across multiple charts. The behavior needs to be similar to how a RollOver modifier works, however the vertical line needs to stay in place, when the user is not “Mouse – Left Down”. Because the RollOver indicator goes away when not hovering over the chart, I decided to make a custom mouse modifier.
Essentially I created a “vertical line annotation” then disabled the dragging (want it to be moved only by mouse cursor movement, and not requiring the user to drag). Made a custom mouse modifier, where OnMouseModiferDown I set a bool flag, then OnMouseMoodiferMove I get the mouse cursor position and update the X1 binding of the cursor, finally OnMouseModiferUp I set the bool flag to false.
The Issue: With my custom mouse modifier the Vertical Line annotation lags the mouse position, It almost looks like there is some sort of smoothing applied to the movement? Is there a way to turn this effect off or reduce it? Here is a link to the behavior to highlight what I’m seeing.
Video of Behavior
My Code is given below.
Xaml
<local:mouseMove ExecuteOn="MouseMove"/>
<s:VerticalSliceModifier IsEnabled="True">
<s:VerticalSliceModifier.VerticalLines>
<s:VerticalLineAnnotation IsEditable="False" LabelPlacement="Axis" ShowLabel="False" X1="{Binding cursorPoint Mode=TwoWay}" Style="{StaticResource sliceStyle}" />
</s:VerticalSliceModifier.VerticalLines>
</s:VerticalSliceModifier>
C#, Mouse Modifier (MouseMove)
public class mouseMove : XAxisDragModifier
{
private bool moveCursor { get; set; }
public override void OnModifierMouseDown(ModifierMouseArgs e)
{
if (e.MouseButtons == MouseButtons.Left)
{
moveCursor = true;
}
}
public override void OnModifierMouseUp(ModifierMouseArgs e)
{
if (e.MouseButtons == MouseButtons.Left)
{
moveCursor = false;
}
}
public override void OnModifierMouseMove(ModifierMouseArgs e)
{
if ((Keyboard.Modifiers == ModifierKeys.Control))
{
//This is my keybind for the RuberBandXY, ignore this mouse event if Ctrl + Left Mouse Down
}
else
{
if (moveCursor)
{
// Get mouse point
var mousePoint = e.MousePoint;
mousePoint = ParentSurface.RootGrid.TranslatePoint(mousePoint, ParentSurface.ModifierSurface);
var xDataValue = ParentSurface.XAxis.GetDataValue(mousePoint.X);
ParentSurface.Annotations[0].X1 = xDataValue;
}
}
}
}
- Zachary Etier asked 4 years ago
- last active 4 years ago