I'm using a horizontal slider in WPF, but would like to also perform some action if the mouse is moved vertically (like change the brightness of some control).
I tried responding to MouseMove, but I don't get an update when dragging the slider, if the mouse moves purely vertically - my function only gets called when the slider actually moves.
You could attach a handler to the slider's PreviewMouseMove event.
Related
I have a realtime scrolling chart with a legend. The legend works as expected but when the legend is clicked the mouse click propagates to the Scichart surface below, this is problematic as the surface is also setup to zoom and pan. When a series IsVisible is toggled through the legend the surface will also change to pan or zoom from the mouse activity.
From the How To Add Mouse Interaction to Scichart article it explains ChartModifier Precedence (Handled Events) in this section "...the first modifier that handles an event marks it as e.Handled. Subsequent modifiers will not receive the event". This doesn't seem to be the case, the LegendModifier gets handled but so does the ZoomPanModifier.
<SciChart:SciChartSurface.ChartModifier>
<SciChart:ModifierGroup>
<SciChart:LegendModifier x:Name="mainLegend" GetLegendDataFor="SelectedSeries"
MouseEnter="mainLegend_MouseEnter"
MouseLeave="mainLegend_MouseLeave"
PreviewMouseLeftButtonDown="mainLegend_PreviewMouseLeftButtonDown"
MouseLeftButtonDown="mainLegend_MouseLeftButtonDown"
ReceiveHandledEvents="False"/>
<SciChart:MouseWheelZoomModifier x:Name="mouseWheelZoomMod" XyDirection="XDirection" ReceiveHandledEvents="False"/>
<SciChart:ZoomPanModifier x:Name="zoomPanMod" ExecuteOn="MouseLeftButton" ReceiveHandledEvents="False"/>
</SciChart:ModifierGroup>
I've ensured ReceiveHandledEvents="False" for all the modifiers. Also tried an assortment of events on the legendmodifier: MouseLeftButtonDown, PreviewMouseLeftButtonDown, MouseEnter and MouseLeave but none of these ever fire.
Is it possible to stop the mouse activity for the Legend propagating to the surface below/other modifiers?
I have a WPF app with a canvas inside a ScrollViewer. On the canvas I have some rectangles that I drag along a timeline (left-right). This works fine with a mouse, but on a touch screen I get weird behavior if the canvas is wider than the main form. First, when you begin to drag the rectangle, the canvas pans until it has scrolled to the limit, then the rectangle starts to move. I doesn't do this when using a mouse.
Another strange this is that if I pan/drag the canvas (using touch) to the limit of the scrollviewer, the main form compresses by 20-50 pixels on the side opposite of the pan direction. It springs back to shape as soon as you stop dragging. What's going on here and how do I disable this?
It seems that this has to do with ManipulationBoundaryFeedback, but I don't understand exactly how...
EDIT:
So I was able to get a little further by setting the scrollviewer panningmode to PanningMode.None in the rectangle TouchDown handler and then setting it back to PanningMode.Both in the TouchUp handler. This solved the problem of the canvas panning to the limit before the rectangle would move.
Well, I finally got my app to work with touch. As I mentioned above, setting the PanningMode to None on the TouchDown event eliminated the problem with the ScrollViewer. Setting it back to Both in the TouchUp event re-enabled it. What this means is that I can't drag the rectangle past the point where the ScrollViewer would start panning, but in my case this was not a problem.
I also had some issues with the MouseLeftButtonDown event firing during the TouchMove event so I removed it during TouchDown
-= new MouseButtonEventHandler(drag_start)
and re-added it back during TouchUp to eliminate the glitchy behavior.
+= new MouseButtonEventHandler(drag_start)
Maybe this will help someone in the future...
At the moment, the user can click on the Slider's thumb and move it to the left and to the right in the same speed independent from the mouse cursor's position. I want to update its work, so that the drag speed decreases, when the mouse cursor distance to the Slider increases. That means, when the user drags the Slider's thumb with his mouse and the mouse cursor is over the Slider itself, the drag speed is normal (as it is at the moment). But if he moves the mouse cursor away from the Slider while he is still dragging the Slider's thumb, the drag speed is lower. The further away the mouse cursor is, the lower the drag speed becomes.
Try something like:
public class YourSlider : Slider
{
protected override void OnThumbDragDelta(System.Windows.Controls.Primitives.DragDeltaEventArgs e)
{
// Use distance to modify value change
}
}
And of course you're going to have to calculate where the mouse is, relative to the thumb.
You can work out the thumb using visual.pointtoscreen
https://msdn.microsoft.com/en-us/library/aa346961.aspx?f=255&MSPPError=-2147217396
You can use mouse.getposition and visual.pointtoscreen to get the mouse position.
Is there any way to animate or fade a LibraryBar? I want a Library Bar which isnt shown to 100 percent on normal use. I want a little bar at the bottom (maybe a part of the LibrarayBar). When the mouse or finger click on the bar (little part of the LibrarayBar) the whole bar should appear with a slow fade in or animation.
Anybody of you know how to this?
Sry fpr my English......
You could write 2 routed event handlers for GetFocus and LostFocus events by declaring them as attributes of GetFocusEvent and LostFocusEvent (or MouseEnter and MouseLeave) depending on whether you want the glowing/dimming to happen with an explicit click or reactive to just "hovering".
These handlers would alter the OpacityProperty property.
To start "dimmed", you can adjust an initial value for the Opacity propert
I have an slider control in my application and an image control. When the slider value is going up, the image is zoomed in and vice versa.
In addtion i have a zoom-in and a zoom-out button. the zoom-in button will increase the slider value by one smallchange and the zoom-out will decrease it.
What i want: while the zoom-in (and out) button is pressed i want to slider to keep increasing(performin a zoom in) and not just one time.
In other words, as long as the left button is pressed, i want to keep performing the mousebuttonpressed on the button until the mousebutton is released.
Oh, by the way, im using Silverlight 3.
Thanks.
You can use the RepeatButton class to do this. It raises it's click event repeatedly while held down, much like the thumb of a scrollbar or an up/down spinner.
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.repeatbutton(VS.95).aspx