2 Replies - 328 Views - Last Post: 12 June 2013 - 05:50 PM Rate Topic: -----

#1 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Task: Draw lines from file

Posted 12 June 2013 - 04:50 PM

I have a csv containing a list of coordinates (x,y)
-398.5569824,-264.8421753
-398.5569824,-264.8421753
-398.5569824,-264.8421753
...



I have written some code in .NET 4 which does the trick, but I'm wanting to reproduce the code for Windows 8. I'm unfamiliar with 4.5 and need some serious help on how to draw lines.

 // Read the file and display it line by line.
                System.IO.StreamReader file =
                   new System.IO.StreamReader("NoteXY.csv");
                while ((line = file.ReadLine()) != null)
                {
                    if (counter > 0)
                    {
                        brush = new SolidBrush(Color.FromArgb(255, 0, 0, B)/>);
                        string[] xy = line.Split(',');
                        double tempX = Convert.ToDouble(xy[0]);
                        double tempY = Convert.ToDouble(xy[1]);
                        
                        tempX = Math.Round(tempX * mag, 0);
                        tempY = Math.Round(tempY * mag, 0);
                        int GPSX = Convert.ToInt32(tempX) + x;
                        int GPSY = Convert.ToInt32(tempY) + y;

                        currentPoint = new Point(GPSX, GPSY);
                       
                        if (previousPoint.X!=0)
                        {
                            Pen myPen = new Pen(brush);
                            // draw the line
                            g.DrawLine(myPen, previousPoint, currentPoint);
                        }
                        previousPoint = currentPoint;
                        Refresh();
                    }                  
                }




My main issue is that I need to be able to read a coordinate from the file and draw a line (vector) on the screen. So far all my attempts have resulted in the graphics update being blocked until the async method completes. Instead of drawing the lines like an animation, I just get the finished series of lines drawn at the end.

Any help would be appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Task: Draw lines from file

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Task: Draw lines from file

Posted 12 June 2013 - 05:46 PM

You're going to need to learn how to use Storyboards to create animations:

http://code.msdn.mic...ations-f758de70
http://msdn.microsof...s/apps/BR210490

It's not really a 4.0 vs 4.5 issue, it's the difference between Windows Forms and Windows 8 Store applications (all XAML applications, really, which includes WPF, Silverlight, Win Phone 7, Win Phone 8, and Win 8 Store).
Was This Post Helpful? 0
  • +
  • -

#3 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: Task: Draw lines from file

Posted 12 June 2013 - 05:50 PM

View PostCurtis Rutland, on 12 June 2013 - 06:46 PM, said:

You're going to need to learn how to use Storyboards to create animations:

http://code.msdn.mic...ations-f758de70
http://msdn.microsof...s/apps/BR210490

It's not really a 4.0 vs 4.5 issue, it's the difference between Windows Forms and Windows 8 Store applications (all XAML applications, really, which includes WPF, Silverlight, Win Phone 7, Win Phone 8, and Win 8 Store).


Yeah, I've been reading and see it's not 4 or 4.5 but rather forms vs xaml.

I suspect it's going to be a rough day. I can't quite get my head around handling the UI thread in XAML.

Edit: just started learning about storyboards.... I think I'm going to vomit.

This post has been edited by jase81: 12 June 2013 - 06:02 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1