Hi,
I have a form with a control which holds the task of showing a graph,by reading (x,y)s from a file and adding them points collection of a graph. now i want to write some code which which helps me do the following:
when i choose a rectangle area containing some part of the graph or function on the form, a pop up form should come up and show me the Fourier transform (or anyother transform) of the graph.
the biggest problem here is that i don't know how to extract some part of graph from the control. i mean it should give me all (x,y)s that form the graph or at least two (x,y)s that are first point and end point of graph( and then i will extract other (x,y)s from the information file). how should i do this?
any help appreciated
thanks
Loading
PJ MartinsPosted May 27, 2010, 11:10 AM
PJ MartinsPosted May 27, 2010, 7:28 PM
List
for (int i = rect.Left; i <= rect.Left + rect.Width; i++)
{
for (int j = rect.Top; j <= rect.Top + rect.Height; j++)
{
if (points.ContainsKey(new Point(i, j))
containingPoints.Add(points[new Point(i, j)]);
}
}
silver lordPosted May 27, 2010, 7:02 PM
That brings another question and that is how i know that a point (as a key) exists in a rectangular area?
(sorry about the word outside in the image)
as you see in the picture someone may select a part of graph in way that breaks the graph into 2 parts. i'm completely new to gdi+ so i'm really confused. how can i save a rectangular area and how can i determine if a point is inside that rectangle. can i use this code (rec is selected rectangle) :
foreach( KeyValuePair
if (kvp.Key.Left > rec.Left && kvp.Key.Left < rec.Right &&
kvp.Key.Top < rec.Top && kvp.Key.Top > rec.Bottom)
{
kvp.Value is a selected graph (x,y) pair
}
any notes on this code? and error to be corrected?
Thanks
PJ MartinsPosted May 27, 2010, 2:54 PM
silver lordPosted May 27, 2010, 2:37 PM
thank you for your help. graph is drawn using zedgraph control available at http://zedgraph.org , so you say i must modify the control so the control returns a dictionary of (key=pixel , value=(x,y)) and when the MouseDown and MouseUp events occur, i must extract the part of dictionary that respond to pixels in MouseDown and MouseUp. can you please give me some advice on tecnical points?
Dushan StankovicPosted May 27, 2010, 1:58 PM
//it's graphic area of control or form for drawing and painting
Graphics g = e.Graphics;
//Reclagle of drawing area
g.ClipBounds
//methods for drawing elements
g.DrawLine DrawString DrawRectangle .......
//methods for filling elements with you Brushes
g.FillRectangle FillElipse .....