Domanda

I want to set the Zedgraph scale limits from the user interface level using mouse based events, with the help of following code I could change the scale values pro-grammatically,

       GraphPane myPane = zedGraphControl1.GraphPane;
        // Set Min & Max of X-Axis Scale
        myPane.XAxis.Scale.Min = 0;
        myPane.YAxis.Scale.Max = 100;
        myPane.AxisChange();

but I'm trying to provide an option to the end user, so that he or she could place the mouse over the scale values and change the limits dynamically.

Edit:

enter image description here

Simple Thought: We should be able to change the scale limits by simply clicking the mouse twice on those scale limits(0.0 or 1.2).

your ideas & suggestions are appreciated & thanks for your time....:)

È stato utile?

Soluzione

The only thing I can think of doing is utilizing the MouseClick event and then trying to pull off a big dirty hack. I would check the Location property of the graph (that will usually give you the upper left coordinate) and then by checking the Size property (do this in case your window has changed size and so has your graph) and then get your System.Windows.Forms.Cursor.Position. If the cursor is over the scale values then maybe have a pop-up show where they can enter their new Max or Min values? Figuring out roughly where the scale values are shown in a dynamically changing graph might be a nuisance but it can definitely be done, especially if you sit down and do the math to find at what percentage of the size the labels are shown.

I hope this helps!

EDIT: Also make sure it is the left button being clicked:

 if (e.Button == MouseButtons.Left)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top