PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/mojoPortal.Features.UI/BingMap/Components/BingMapConfiguration.cs

#
C# | 160 lines | 103 code | 43 blank | 14 comment | 7 complexity | 87fe62e74fec4ecc60b76341da4800d3 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause, CPL-1.0, CC-BY-SA-3.0, GPL-2.0
  1. // Author: Joe Audette
  2. // Created: 2010-06-11
  3. // Last Modified: 2011-11-28
  4. //
  5. // The use and distribution terms for this software are covered by the
  6. // Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
  7. // which can be found in the file CPL.TXT at the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by
  9. // the terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. using System;
  13. using System.Collections;
  14. using System.Globalization;
  15. using System.Web.UI.WebControls;
  16. using mojoPortal.Web.Controls.google;
  17. using mojoPortal.Web.Framework;
  18. namespace mojoPortal.Web.MapUI
  19. {
  20. /// <summary>
  21. /// encapsulates the feature instance configuration loaded from module settings into a more friendly object
  22. /// </summary>
  23. public class BingMapConfiguration
  24. {
  25. public BingMapConfiguration()
  26. { }
  27. public BingMapConfiguration(Hashtable settings)
  28. {
  29. LoadSettings(settings);
  30. }
  31. private void LoadSettings(Hashtable settings)
  32. {
  33. if (settings == null) { throw new ArgumentException("must pass in a hashtable of settings"); }
  34. if (settings.Contains("LocationSetting"))
  35. {
  36. location = settings["LocationSetting"].ToString();
  37. }
  38. if (settings.Contains("Caption"))
  39. {
  40. caption = settings["Caption"].ToString();
  41. }
  42. showLocationPin = WebUtils.ParseBoolFromHashtable(settings, "ShowLocationPin", showLocationPin);
  43. mapHeight = WebUtils.ParseInt32FromHashtable(settings, "MapHeightSetting", mapHeight);
  44. mapWidth = WebUtils.ParseInt32FromHashtable(settings, "MapWidthSetting", mapWidth);
  45. zoomSetting = WebUtils.ParseInt32FromHashtable(settings, "InitialZoomSetting", zoomSetting);
  46. if (settings.Contains("InitialMapStyleSetting"))
  47. {
  48. mapStyle = settings["InitialMapStyleSetting"].ToString();
  49. }
  50. showMapControls = WebUtils.ParseBoolFromHashtable(settings, "ShowMapControls", showMapControls);
  51. enableDrivingDirections = WebUtils.ParseBoolFromHashtable(settings, "EnableDrivingDirections", enableDrivingDirections);
  52. if (settings.Contains("DrivingDirectionsDistanceUnit"))
  53. {
  54. distanceUnit = settings["DrivingDirectionsDistanceUnit"].ToString();
  55. }
  56. if (settings.Contains("CustomCssClassSetting"))
  57. {
  58. instanceCssClass = settings["CustomCssClassSetting"].ToString();
  59. }
  60. }
  61. private string location = string.Empty;
  62. public string Location
  63. {
  64. get { return location; }
  65. }
  66. private string caption = string.Empty;
  67. public string Caption
  68. {
  69. get { return caption; }
  70. }
  71. private bool showLocationPin = false;
  72. public bool ShowLocationPin
  73. {
  74. get { return showLocationPin; }
  75. }
  76. private string mapStyle = "VEMapStyle.Road";
  77. public string MapStyle
  78. {
  79. get { return mapStyle; }
  80. }
  81. private string distanceUnit = "VERouteDistanceUnit.Mile";
  82. public string DistanceUnit
  83. {
  84. get { return distanceUnit; }
  85. }
  86. private bool showMapControls = true;
  87. public bool ShowMapControls
  88. {
  89. get { return showMapControls; }
  90. }
  91. private int mapHeight = 300;
  92. public int MapHeight
  93. {
  94. get { return mapHeight; }
  95. }
  96. private int mapWidth = 500;
  97. public int MapWidth
  98. {
  99. get { return mapWidth; }
  100. }
  101. private int zoomSetting = 10;
  102. public int ZoomSetting
  103. {
  104. get { return zoomSetting; }
  105. }
  106. private bool enableDrivingDirections = false;
  107. public bool EnableDrivingDirections
  108. {
  109. get { return enableDrivingDirections; }
  110. }
  111. private string instanceCssClass = string.Empty;
  112. public string InstanceCssClass
  113. {
  114. get { return instanceCssClass; }
  115. }
  116. }
  117. }