Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

Dot net drawing classes query - urgent

Hi,
I have to draw few curves using dot net drawing classes which is fine. now when user right clicks on the curve, i need to save value associated with that point to the database. how do i do that? how do i retrive the database values associated with curve? please help...
regards
0
savitasawlani
Asked:
savitasawlani
  • 16
  • 13
  • 2
1 Solution
 
Diane258Commented:
are you wanting to save just the curve, or are you wanting to save the entire image?
0
 
savitasawlaniAuthor Commented:
No no i just want to save the database value associated with the curve at that x-y coordinate..say curve is drawn for limit versus attachment. so wherever user right clicks on the curve, what is the value of limit and attachment at that x,y coordinate.
thanks.
0
 
Diane258Commented:
Om, are these set curves?

Because a tru curve would have several values, Start X, Start Y, End X, End Y, Radius(since a curve is apart of a circle) , Midpoint.

the only other way would be to save an array of X-Y values.

However if each curve is "set" like ( and ) are, then all you need is the starting X-Y part and let the program draw out the curve.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
RonaldBiemansCommented:
you could use the X and Y coordinates from the mouse up or mouse down event, could you show how you draw the curve  so we can suggest the best method

    Private Sub Form11_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
'        e.X()
'        e.Y()
    End Sub
0
 
savitasawlaniAuthor Commented:
x, y cooidinates will give me the screen x,y coordinate, i want to knwo the datbase value associated with that x-y coordinate..
0
 
RonaldBiemansCommented:
That's why I asked if you could show the code you use to draw the curve, you could use the screen coordinates to calculate the point they click on the curve
0
 
savitasawlaniAuthor Commented:
I have not written any code as of now. I am in desing pahse and tryign to know how this can be ahcieved..thanks a lot for prompt reply.can u suggest me somethng. if u can mail me ur id, i can send u snapshot of what i want to achieve. regards
0
 
RonaldBiemansCommented:
Email to ronald dot biemans at compagnie dot be
0
 
savitasawlaniAuthor Commented:
thanks. i have emailed.
0
 
RonaldBiemansCommented:
I 'll see if I can come up with some usefull.
0
 
savitasawlaniAuthor Commented:
thanks for that.
0
 
RonaldBiemansCommented:
Sorry but could you mail it again (I'm not at the location I gave earlier, I'm at a client at the moment)

info at strategus dot be
0
 
savitasawlaniAuthor Commented:
I have mailed u at the above id.
0
 
RonaldBiemansCommented:
Hi savitasawlani,

What kind of curve do you draw, a bezier, or a cubic/cardinal spline ?
0
 
RonaldBiemansCommented:
Or is it just a serie of Points (X,Y)
0
 
savitasawlaniAuthor Commented:
series of Points (X,Y)
0
 
RonaldBiemansCommented:
Sorry I completly forgot about this question, what is the information you are basing your curve on,

to explain, is the curve completely made of XY coordinates you got from an array or table, or do you have just a few XY coordinates and you let the programm calculated the rest of the points ?
0
 
savitasawlaniAuthor Commented:
x,y coordinates wi ll come from a table in db.
0
 
RonaldBiemansCommented:
Sorry but a bit more information is needed, could you show the contents of the tabel so I know exactly what you want to draw, if I have this information I'll work out a solution for you
0
 
savitasawlaniAuthor Commented:
thanks.

here is the table structure
              ResultsSetID      int      part of composite PK
      GraphPointID      int      part of composite PK
      AttachmentPoint      decimal      x coordinate
      LimitBand      decimal      
                ExpectedLoss      decimal      y coordi for 1st curve
      CatPrice      decimal      y coordiante for 2nd curve
      RiskLoad      decimal      y coordiante for 3rd curve
0
 
RonaldBiemansCommented:
Sorry that I have to keep asking questions, but I still don't know if all the points are in the table, of just a few reference points.

To explain a little more.

1. I could build a curve with, lets say just 4 points (and calculate the other points to draw a smooth curve)
    X = 0, Y = 20    
    X = 20, Y = 10
    X = 40, Y = 30
    X = 60, Y = 20

2. or do you have all the points of the curve (where every point of the curve is defined and no calculation is needed)
0
 
RonaldBiemansCommented:
To answer your question I need an answer to my previous question, because the method used is VERY different between the two possibilties
0
 
savitasawlaniAuthor Commented:
I have all points of the curve.
0
 
RonaldBiemansCommented:
ok , here is a small example (it draws on a panel)
the example draw 3 lines from a table I created and filled with some values. when you left click on a pixel in the panel it will retrieve the row from the table. If you have aditional questions don't hesitate to ask

    Dim dt As New DataTable
    Dim xRange As Double
    Dim YRange As Double
    Dim bm As Bitmap
    Dim el As New ArrayList
    Dim cp As New ArrayList
    Dim rl As New ArrayList

Private Sub Form15_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        bm = New Bitmap(Panel1.Width, Panel1.Height)
    End Sub

    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        If Not IsNothing(bm) Then
            e.Graphics.DrawImage(bm, 0, 0)
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        dt.Columns.Add("AttachmentPoint", GetType(System.Decimal))
        dt.Columns.Add("ExpectedLoss", GetType(System.Decimal))
        dt.Columns.Add("CatPrice", GetType(System.Decimal))
        dt.Columns.Add("RiskLoad", GetType(System.Decimal))


        For x As Integer = 0 To 100
            Dim dr As DataRow = dt.NewRow
            dr.Item("AttachmentPoint") = x * 10
            dr.Item("ExpectedLoss") = x * 2
            dr.Item("CatPrice") = x * 3
            dr.Item("RiskLoad") = x * 4
            dt.Rows.Add(dr)
        Next
        xRange = Decimal.Round(Panel1.Width / dt.Rows.Count, 2)
        GetTopYrange()

        For y As Integer = 0 To dt.Rows.Count - 1
            el.Add(CStr(CInt(dt.Rows(y).Item("AttachmentPoint") / xRange)) & CStr(CInt(dt.Rows(y).Item("ExpectedLoss") * YRange)))
            cp.Add(CStr(CInt(dt.Rows(y).Item("AttachmentPoint") / xRange)) & CStr(CInt(dt.Rows(y).Item("CatPrice") * YRange)))
            rl.Add(CStr(CInt(dt.Rows(y).Item("AttachmentPoint") / xRange)) & CStr(CInt(dt.Rows(y).Item("Riskload") * YRange)))
            bm.SetPixel(CInt(dt.Rows(y).Item("AttachmentPoint") / xRange), CInt(dt.Rows(y).Item("ExpectedLoss") * YRange), Color.Green)
            bm.SetPixel(CInt(dt.Rows(y).Item("AttachmentPoint") / xRange), CInt(dt.Rows(y).Item("CatPrice") * YRange), Color.Blue)
            bm.SetPixel(CInt(dt.Rows(y).Item("AttachmentPoint") / xRange), CInt(dt.Rows(y).Item("Riskload") * YRange), Color.Red)
        Next
        Panel1.Invalidate()
    End Sub

    Public Sub GetTopYrange()
        Dim YR As Single = 0
        For x As Integer = 0 To dt.Rows.Count - 1
            If dt.Rows(x).Item("ExpectedLoss") > YR Then
                YR = dt.Rows(x).Item("ExpectedLoss")
            End If
            If dt.Rows(x).Item("CatPrice") > YR Then
                YR = dt.Rows(x).Item("CatPrice")
            End If
            If dt.Rows(x).Item("RiskLoad") > YR Then
                YR = dt.Rows(x).Item("RiskLoad")
            End If
        Next
        YRange = Decimal.Round((Panel1.Height - 5) / YR, 2)
    End Sub

    Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
        Dim mycolor As Color
        Dim rownum As Integer
        mycolor = bm.GetPixel(e.X, e.Y)
        If mycolor.G = 128 Then 'ExpectedLoss
            rownum = el.IndexOf(CStr(e.X) & CStr(e.Y))
            MsgBox(dt.Rows(rownum).Item("expectedloss"))
        ElseIf mycolor.B = 255 Then 'catprice
            rownum = cp.IndexOf(CStr(e.X) & CStr(e.Y))
            MsgBox(dt.Rows(rownum).Item("catprice"))
        ElseIf mycolor.R = 255 Then 'Riskload
            rownum = rl.IndexOf(CStr(e.X) & CStr(e.Y))
            MsgBox(dt.Rows(rownum).Item("riskload"))
        Else
            Exit Sub
        End If
    End Sub
0
 
savitasawlaniAuthor Commented:
i will try this and tell u. thank u somuch for al ur efforts.
0
 
RonaldBiemansCommented:
I tested the above and it works, if you have any additional question don't hesitate to ask :-)
0
 
savitasawlaniAuthor Commented:
Hi RonaldBiemans ,
Thank u so much but I am extremly sorry..i never specified that it has to be done in the web application, that is the whole problem..is right click on the curve and trapping those coordinates possible in web?
0
 
RonaldBiemansCommented:
Hmmm, bugger, I'm not really good at web apps (actually bad). I don't think there is a mouseup/down event in web apps. But I'll see if I can dig something up
0
 
RonaldBiemansCommented:
As far as I found out , you can do that via javascript, but I since my knowledge of javascript is even worse than ASP, I'm afraid I can't help you :-(.

So get a refund for your points at community support, and maybe reask the question in the javascript topic.

Sorry.
0
 
savitasawlaniAuthor Commented:
Hi buddy,
you have really put in lot of effott on this. you deserve points. i wil work out some way for web, lets see.
0
 
RonaldBiemansCommented:
Thanks, and good luck :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 16
  • 13
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now