Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Problem with assigning calculated double values to Point RSS

10 replies

Last post Jul 26, 2007 02:38 PM by N.Tony

(1)
  • rabinovic

    rabinovic

    Member

    20 Points

    6 Posts

    Problem with assigning calculated double values to Point

    May 24, 2007 11:20 AM | LINK

    I have the following problem:

    ArcSegment arcSeg = this.FindName("arcSeg") as ArcSegment;

    double x = 50.0 * Math.Cos(0.1);

    double y = - 50.0 * Math.Sin(0.1);

    arcSeg.Point = new Point(x,y);

    Well x = 49,7502082639013 and y -4,99167083234141

    But arcSeg.Point is not (49.75, -4.99) what i get is (49, 7502086390)

    I have the same problem  when i use lineSegments

    Here is what i mean: http://www.bilder-hosting.de/show/CEZ6Y.html

    linesegment arcsegment point double

  • jm47

    jm47

    Member

    26 Points

    11 Posts

    Re: Problem with assigning calculated double values to Point

    May 25, 2007 07:35 AM | LINK

    Can you paste the XAML?  When I use the following code (similar except the control is created in C# instead of in xaml), the point is correct:

     

    ArcSegment arcSeg = new ArcSegment();

    double x = 50.0 * Math.Cos(0.1);

    double y = -50.0 * Math.Sin(0.1);

    arcSeg.Point = new Point(x, y);

    Console.WriteLine(arcSeg.Point.ToString());

  • rabinovic

    rabinovic

    Member

    20 Points

    6 Posts

    Re: Problem with assigning calculated double values to Point

    May 25, 2007 11:03 AM | LINK

    I have copied your code. after running i get the output: 49,7502082605056. In a WPF application the Point is correct, but in a Silverlight application It is still not correct

  • bobrob

    bobrob

    Member

    28 Points

    19 Posts

    Re: Problem with assigning calculated double values to Point

    May 28, 2007 07:21 AM | LINK

    Read http://silverlight.net/forums/t/1412.aspx

    Same bug in my opinion. Tragic bug! All floating point coordinates fail for Europeen Silverlight clients.

     

  • rabinovic

    rabinovic

    Member

    20 Points

    6 Posts

    Re: Problem with assigning calculated double values to Point

    May 28, 2007 08:04 AM | LINK

    I think have the answer (10x bobrob):

    Well i set the current culture to something like English Canada and this works:

    public void Page_Loaded(object o, EventArgs e)

    {

        try

        {

                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-CA");

        } catch { }

        // Required to initialize variables

        InitializeComponent();

     

        ArcSegment arc = new ArcSegment();     double x = 123.23423;

        double y = 567567.3534;   

        arc.Point = new Point(x, y);

    }

    I get the right values in arg.Point!

    Thanks!

    current culture cultureinfo double point

  • bobrob

    bobrob

    Member

    28 Points

    19 Posts

    Re: Re: Problem with assigning calculated double values to Point

    May 29, 2007 09:20 AM | LINK

    It does not work for me, I get the exception:

    Attempt to access the method failed: System.Threading.Thread.set_CurrentCulture(System.Globalization.CultureInfo)

    Even if ignored, the culture is not changed:

    double d= 34.12;
    string str1= d.ToString(); // "34,12"
    try
      {
      System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-CA");
      }
    catch
      {}
    string str2= d.ToString(); // "34,12"

    ...and drawing operations are erroneous.

  • rabinovic

    rabinovic

    Member

    20 Points

    6 Posts

    Re: Re: Problem with assigning calculated double values to Point

    May 29, 2007 12:10 PM | LINK

    try to change the current language of your operating system to english (in the system control).

    I think this will solve the problem.

  • luisabreu

    luisabreu

    Participant

    1676 Points

    612 Posts

    Re: Problem with assigning calculated double values to Point

    May 29, 2007 12:54 PM | LINK

    hello.

    rabinovic

    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-CA");

    i believe this won't work because the CurrentCulture set is annotated with the SecurityCritical code (which means it can only be aclled by platform code).

  • rabinovic

    rabinovic

    Member

    20 Points

    6 Posts

    Re: Problem with assigning calculated double values to Point

    May 29, 2007 01:43 PM | LINK

    you are right.

    I found that this part of code doesn't make any change. As i have mentioned in the previous post i changed the current language of my winXp to english in the system control. Now it works.

  • seemar

    seemar

    Member

    154 Points

    42 Posts

    Microsoft

    Re: Problem with assigning calculated double values to Point

    Jun 04, 2007 11:06 PM | LINK

    We have noted the bug and it is now in our silverlight bug database. Thank you for reporting!

    -SeemaR@MS

    Seema Ramchandani
    Silverlight
    Program Manager, Microsoft
    http://blogs.msdn.com/seema