/// <summary> /// Lookup the relevant Icon from Resources /// </summary> /// <param name="cameraCategory">The desired Icon category</param> /// <returns>A bitmap from resources</returns> private static Bitmap LookupIcon(CameraCategory cameraCategory) { Bitmap icon = null; switch (cameraCategory) { case CameraCategory.Fixed: icon = Properties.Resources.Fixed; break; case CameraCategory.Mobile: icon = Properties.Resources.Mobile; break; case CameraCategory.PMobile: icon = Properties.Resources.PMobile; break; case CameraCategory.Specs: icon = Properties.Resources.Specs; break; case CameraCategory.RedLight: icon = Properties.Resources.Red_Light; break; } return(icon); }
/// <summary> /// Sort the cameras list into a the relevant categories. /// </summary> /// <param name="cameras">Unsorted list of cameras</param> /// <returns>Collection of Categories</returns> /// <exception cref="ArgumentException">Thrown when unable to identify camera type</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown when unable to assign a camera to a category</exception> public static Collection <PointOfInterestCategory> SortCameras(List <PointOfInterest> cameras) { Collection <PointOfInterestCategory> categorisedCameras = new Collection <PointOfInterestCategory>(); foreach (PointOfInterest camera in cameras) { // Parse the Camera Type CameraType cameraType = IdentifyCameraType(camera.Name); if (cameraType == CameraType.None) { throw new ArgumentException(string.Format("Unknown camera Type - {0}", camera.Name)); } // Identify the correct Category CameraCategory cameraCategory = IdentifyCameraCategory(cameraType); if (cameraCategory == CameraCategory.None) { throw new ArgumentOutOfRangeException(string.Format("Unable to identify Camera Category - {0}", cameraType.ToDescriptionString())); } // Special Case for Provisional Mobile cameras if (cameraCategory.Equals(CameraCategory.Mobile)) { if (camera.Name.Contains("pMOBILE")) { cameraCategory = CameraCategory.PMobile; } } // Add to relevant category PointOfInterestCategory targetCategory = null; foreach (PointOfInterestCategory pointOfInterestCategory in categorisedCameras) { if (pointOfInterestCategory.Name.Equals(cameraCategory.ToDescriptionString())) { targetCategory = pointOfInterestCategory; break; } } if (targetCategory == null) { targetCategory = new PointOfInterestCategory((int)cameraCategory, cameraCategory.ToDescriptionString(), LookupIcon(cameraCategory)); categorisedCameras.Add(targetCategory); } targetCategory.Items.Add(camera); } return(categorisedCameras); }