PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Main/src/DynamicDataDisplay/Charts/Isolines/Enums.cs

#
C# | 67 lines | 47 code | 4 blank | 16 comment | 15 complexity | a87cc969d238b04061c4ffa43dc3f5c6 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Microsoft.Research.DynamicDataDisplay.Charts.Isolines
  6. {
  7. /// <summary>
  8. /// Edge identifier - indicates which side of cell isoline crosses.
  9. /// </summary>
  10. internal enum Edge
  11. {
  12. // todo check if everything is ok with None.
  13. None = 0,
  14. /// <summary>
  15. /// Isoline crosses left boundary of cell (bit 0)
  16. /// </summary>
  17. Left = 1,
  18. /// <summary>
  19. /// Isoline crosses top boundary of cell (bit 1)
  20. /// </summary>
  21. Top = 2,
  22. /// <summary>
  23. /// Isoline crosses right boundary of cell (bit 2)
  24. /// </summary>
  25. Right = 4,
  26. /// <summary>
  27. /// Isoline crosses bottom boundary of cell (bit 3)
  28. /// </summary>
  29. Bottom = 8
  30. }
  31. [Flags]
  32. internal enum CellBitmask
  33. {
  34. None = 0,
  35. LeftTop = 1,
  36. LeftBottom = 8,
  37. RightBottom = 4,
  38. RightTop = 2
  39. }
  40. internal static class IsolineExtensions
  41. {
  42. internal static bool IsDiagonal(this CellBitmask bitmask)
  43. {
  44. return bitmask == (CellBitmask.RightBottom | CellBitmask.LeftTop) ||
  45. bitmask == (CellBitmask.LeftBottom | CellBitmask.RightTop);
  46. }
  47. internal static bool IsAppropriate(this SubCell sub, Edge edge)
  48. {
  49. switch (sub)
  50. {
  51. case SubCell.LeftBottom:
  52. return edge == Edge.Left || edge == Edge.Bottom;
  53. case SubCell.LeftTop:
  54. return edge == Edge.Left || edge == Edge.Top;
  55. case SubCell.RightBottom:
  56. return edge == Edge.Right || edge == Edge.Bottom;
  57. case SubCell.RightTop:
  58. default:
  59. return edge == Edge.Right || edge == Edge.Top;
  60. }
  61. }
  62. }
  63. }