Remapping Mouse Controls with Zedgraph? - zedgraph

I am using ZedGraph and I want to zoom to a selected area by holding down Ctrl and dragging the box with the left mouse button instead of clicking and dragging with the middle mouse button.
The default behavior is to zoom with just the left mouse button and to pan with the middle mouse button, but I have switched these two operations already.
Does anyone have any idea how to make panning be called by clicking and dragging with the left button (without holding down Ctrl) and zooming be called by holding down Ctrl and then clicking and dragging with the left button?

The ZedGraphControl allows Pan & Zoom to be controlled through properties of the control. To enable panning with just the left mouse button:
zg1.PanButtons = MouseButtons.Left;
zg1.PanModifierKeys = Keys.None;
and to enable Zoom with Ctrl+Left mouse button:
zg1.ZoomButtons = MouseButtons.Left;
zg1.ZoomModifierKeys = Keys.Control;
The designer properties window doesn't seem to want to let you just specify Control for the Modifier Keys, so you'll have to put it in code - the Form's Load event handler, for example.

Have you try it by code using:
zg.GraphPane.XAxis.Scale.Min = xxxx;
zg.GraphPane.XAxis.Scale.Max = yyyy;
//and
zgc.ScrollGrace = 0.1;

Related

Can't fire event when I click on Label

I'm using 7.1.0.GA, nothing happened when I click on Label, So I tried to put it inside a View, the event fire when I click around the Label but dont when I click on the area of Label.
it's probably don't receive the touch maybe your label or parent have touchEnabled false, or probably you have a view above your label add different background color for each element to find the guilty
Set touchEnabled of your Label to false and then it should work when you click on the View.

VB NET What is the good way to find a position of an object inside a scrollable panel?

I have an object inside a scrollable panel, and I want to get the position of the object. Everything is okay until I have create many object inside the panel until the panel needed to be scrolled. Then I notice that the X Position of the object changed after scrolling the panel. Take a look at example image below
X Position inside a scrollable panel
I'm using Position.X to get a X Position of the object, but as you can see in the picture above. It does me no good.
Is there a way to get the actual position even if the panel is scrolled ?
UPDATE:
I have One Panel that have Auto Scroll as True , and on Button inside a Panel, let's just say the button name is Button1 and the Panel is Panel1
The Code i use to get the location of the Button1 is :
Dim msg = Button1.Location.X
msgbox(msg)
You're getting the screen position of the object, I don't know how because you didn't post your code. What you need to do is add the scroll offset, eg.
Position.X + scrollableControl.AutoScrollPosition.X

Custom context menu XAML for WP8

I try to implement a custom ContextMenu in a LongListSelector.
I'm not using the ContextMenu from Microsoft.Phone.Controls.Toolkit, it's basically the same as in the Rowi App:
(source: hiddenpineapple.com)
Approach 1
My list item toggles a VisualState on hold and an overlay is shown with controls in it.
The problem
I can't find a way to go back to the default state when the user clicks outside of the list item (as in the default ContextMenu).
Approach 2
I've implemented a custom template for the toolkit ContextMenu which looks exactly the same. I had to move its margin top to -itemHeight, as by default it is below the item.
The problem
The problem with this solution is, that it automatically closes itself when opening and I couldn't figure out how to avoid this.
Another problem was that it didn't work well with TiltEffect.IsTiltEnabled from the Toolkit (visual problems).
I need your help
Any suggestions on how to get this working?
Answer
Thanks to Cheese, now I know how to properly close the menu when the user clicks outside.
His suggestion was to get the coordinates of a Tap event on the current page, and check if it's inside the menu. When not, close the menu.
So I added a Tap listener to the page when the menu opens, and removed it when the menu closes. From the page listener I got the event coordinates and could check if it's inside the control which holds the menu (same size and position). I received the position of the control with Point leftUpperPoint = control.TransformToVisual(page).Transform(new Point(0, 0)) and the rightLowerPoint by adding the ActualWidth and ActualHeight.
But then I realized:
Why should I even calculate if the tap is inside the menu? I always want to close the menu when the user taps anywhere on the screen. If it's outside, yes. If it's on a menu button, yes.
Another modification I made was to listen for MouseLeftButtonDown instead of Tap as it also triggers when the user swipes.
So I removed this code and came up with the following:
private void ToggleMenu(object sender, System.Windows.Input.GestureEventArgs e)
{
PhoneApplicationFrame frame = ((PhoneApplicationFrame)Application.Current.RootVisual);
VisualState state = this.States.CurrentState;
if (state == null || state.Name == "DefaultState")
{
frame.MouseLeftButtonDown += MouseDownDelegate;
this.State = "MenuState";
}
else
{
frame.MouseLeftButtonDown -= MouseDownDelegate;
this.State = "DefaultState";
}
}
private void MouseDownDelegate(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
ToggleMenu(sender, null);
}
This works perfectly!
Thanks to Cheese for the hint.
Something like this by #denniscode http://dotnet.dzone.com/articles/rowi-show-tap-menu
Approach 1 problem
The best solution would be:
Get the menus coordinates, when user makes a tap - you check are tap coordinates on menu or not, if not - dissmiss - simple.
Approach 2 problem
I guess you had some button in a corner and when you tapped on it - nothing happened? And when you dissmissed the Tilt all worked. It seems that tilt works faster than a click, so, tilt changes the button coordinates, and device thiks you have missed/or dragged off
You can use what #ScottIsAFool suggested and maybe create another Dependency Property on your TapMenu control of type UIElement named CloseWhenTappedElement and automatically listen for Tap events inside your control once set. For example
<Grid x:Name="TapArea"/>
<TapMenu CloseWhenTappedElement="{Binding ElementName=TapArea"}/>

How to disable the zooming by the mousewheel for ZedGraph

I want to display a non-zoomable ZedGraph control. How do I disable the mousewheel zooming function in ZedGraph?
If you wish to only disable the zoom by mouse wheel feature, you can use:
zedGraphControl.IsEnableWheelZoom = false;
If zgc is your ZedGraphControl instance, use:
zgc.ZoomButtons = MouseButtons.None;
zgc.ZoomButtons2 = MouseButtons.None;
This will disable zooming by selecting area with mouse.
You will also need to set:
zgc.ZoomStepFraction = 0;
in order to disable zooming using mouse wheel.

making a thumbnail toolbar (windowsAPICodePack,windows 7) button invisible in vb.net

I'm trying to make a thumbnail toolbar button (TTB from now on)visible when the it is clicked. I know how to do stuff when it is clicked, AddHandler etc. But if I tell it TTB.visible=false then it doesn't become invisible. If I put TTB.enabled = False it will be disabled, so it's only the visible that isn't working.
Also I put a button on my form (not a TTB) and when that is click wrote, TTB.visible = false and that didn't work, so there is no way to make it invisible.
Try set TTB.visible=true after you Add it into toolbar button list.