PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/NerdSharp.Net_Studio/NerdSharp_UberNet/Science/Math/TypeLibrary/Graphs_ChartsWidgets/Utils.cs

https://bitbucket.org/pastageek/scide-cad-scilife
C# | 45 lines | 36 code | 1 blank | 8 comment | 2 complexity | 68217f1a4a68a73336d27f9b94fa4aac MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Shapes;
  9. using M = System.Math;
  10. namespace NerdSharp.Net_Studio.NerdSharp_UberNet.Science.Math.TypeLibrary.Graphs_ChartsWidgets
  11. {
  12. public static class Utils
  13. {
  14. /// <summary>
  15. ///
  16. /// </summary>
  17. /// <param name="gridObj"></param>
  18. /// <param name="graphPoint"></param>
  19. /// <returns></returns>
  20. public static Point FromGraphToScreen(double width, double height, Point graphPoint)
  21. {
  22. Point pt = new Point(width / 2, height / 2);
  23. //MessageBox.Show(pt.ToString());
  24. //takes care of the x coordinate conversion
  25. if (graphPoint.Y < 0)
  26. {
  27. pt.Y += M.Abs(graphPoint.Y);
  28. }
  29. else
  30. {
  31. pt.Y -= graphPoint.Y;
  32. }
  33. if (graphPoint.X < 0)
  34. {
  35. pt.X -= M.Abs(graphPoint.X);
  36. }
  37. else
  38. {
  39. pt.X += graphPoint.X;
  40. }
  41. return pt;
  42. }
  43. }
  44. }