Skip to main content

MSDN

Answered Question Problem with assigning calculated double values to PointRSS Feed

(1)

rabinovic
rabinovic

Member

Member

20 points

6 Posts

Problem with assigning calculated double values to Point

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

jm47
jm47

Member

Member

26 points

11 Posts

Re: Problem with assigning calculated double values to Point

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

Member

20 points

6 Posts

Re: Problem with assigning calculated double values to Point

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

Member

28 points

19 Posts

Re: Problem with assigning calculated double values to Point

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

Member

20 points

6 Posts

Answered Question

Re: Problem with assigning calculated double values to Point

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!

bobrob
bobrob

Member

Member

28 points

19 Posts

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

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

Member

20 points

6 Posts

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

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

Participant

1676 points

612 Posts

Re: Problem with assigning calculated double values to Point

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

Member

20 points

6 Posts

Re: Problem with assigning calculated double values to Point

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

Member

154 points

42 Posts

Microsoft

Re: Problem with assigning calculated double values to Point

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

N.Tony
N.Tony

Member

Member

36 points

19 Posts

Re: Problem with assigning calculated double values to Point

I have the same problem (my Regional options is Russian).

To work around this problem I change "Standarts and Formats" options to "English(United States)" (at Control Panel -> Regional and Language Options)

 

  • Unanswered Question
  • Answered Question
  • Announcement