private void CreateDevicesForBulkRegistration() { List <BasicGeoposition> coordinates = Item.Project.Coordinates; BasicGeoposition centroid = GeopositionHandler.GetPolygonCentroid(coordinates); BasicGeoposition northwest = GeopositionHandler.GetNorthWestPosition(coordinates, centroid); BasicGeoposition southeast = GeopositionHandler.GetSouthEastPosition(coordinates, centroid); var projectName = Item.Project.Name.Substring(0, 3).ToUpper(CultureInfo.InvariantCulture); var length = 16; Item.Devices.Clear(); for (int i = 0; i < Item.NMessages; i++) { var now = DateTime.Now; var datetime = now.Ticks.ToString(CultureInfo.InvariantCulture); var deviceID = projectName + i + datetime.Substring(datetime.Length - length, length); Windows.Devices.Geolocation.BasicGeoposition devicePosition = new Windows.Devices.Geolocation.BasicGeoposition() { Latitude = MathHandler.GetRandomNumber(southeast.Latitude, northwest.Latitude), Longitude = MathHandler.GetRandomNumber(northwest.Longitude, southeast.Longitude), }; Item.Devices.Add(new Device(deviceID, devicePosition)); } }
public void BindData(Tenant project, EnvironmentHandler.Type environment) { if (project is null) { return; } MapLayers = new List <MapElementsLayer>(); Project = project; EnvironmentT = environment; var area = GeopositionHandler.GetAreaInKmFromCoordinates(Project.Coordinates, 1); var perimeter = GeopositionHandler.GetPerimeterInKmFromCoordinates(Project.Coordinates, 1); var projectName = TextHandler.GetOnlyAlphabetChars(Project.Name); var projectNameLength = Math.Min(projectName.Length, 3); TB_Title_Prefix.Text = projectNameLength > 0 ? projectName.Substring(0, projectNameLength).ToUpperInvariant() : string.Empty; TB_ProjectName.Text = Project.Name; TB_Title.Text = Project.Name; TB_Timezone.Text = Project.Timezone; TB_NDevices.Text = Project.NDevices.ToString(CultureInfo.InvariantCulture); TB_Area.Text = string.Format(CultureInfo.InvariantCulture, "{0:### ### ###.#}", area); TB_Perimeter.Text = string.Format(CultureInfo.InvariantCulture, "{0:### ### ###.#}", perimeter); FillColor = ColorHandler.FromHex(Project.FillColor, Project.FillOpacity * 255); BRD_Info_BT.Background = new SolidColorBrush(ColorHandler.FromHex(Project.FillColor, 200)); BRD_Info_Title.Background = new SolidColorBrush(ColorHandler.FromHex(Project.FillColor, 200)); Scheduler.Start(); if (!MapControlLoaded) { InitializeMapControl(); } }