/// <summary> /// Returns a ShapeFileFeatureLayer with the region's shape file. /// </summary> /// <returns></returns> public static ShapeFileFeatureLayer GetRegionFeatureLayer(Region region) { if (String.IsNullOrEmpty(region.ShapeFileName)) { return(null); } string featureIDsToExclude = RegionHelper.GetFeatureIDsToExclude(region.IDRegion); ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(GetShapeFileFullPath(region)) { Name = region.IDRegion.ToString() }; if (featureIDsToExclude != null) { string[] ids = featureIDsToExclude.Split('|'); foreach (string id in ids) { if (id.Trim() == string.Empty) { continue; } int index = Convert.ToInt32(id); //seems the featureID is actually index + 1. layer.FeatureIdsToExclude.Add((index + 1).ToString()); } } RebuildIndexFile(layer); return(layer); }
/// <summary> /// Gets the ShapeFileFeatureLayer for the region, if it's included in the provided list /// </summary> /// <param name="region"></param> /// <param name="modelLayers"></param> /// <returns></returns> public static ShapeFileFeatureLayer GetRegionFeatureLayer(Region region, List <ShapeFileFeatureLayer> modelLayers) { if (modelLayers == null || modelLayers.Count == 0) { return(null); } return(modelLayers.Where(ml => ml.Name.Substring(0, 1) == region.RegionLevel.ToString()).FirstOrDefault(shapeFileFeatureLayer => shapeFileFeatureLayer.ShapePathFileName.Contains(region.ShapeFileName))); }
/// <summary> /// Returns two feature layers: one for the selected region and one for the childs. /// </summary> /// <param name="selectedRegion"></param> /// <returns></returns> public static List <ShapeFileFeatureLayer> GetFeatureLayers(Region selectedRegion) { List <ShapeFileFeatureLayer> aux = new List <ShapeFileFeatureLayer> { GetRegionFeatureLayer(selectedRegion) }; List <Region> childRegions = RegionHelper.GetChilds(selectedRegion.IDRegion).GroupBy(r => r.ShapeFileName).Select(g => g.First()).ToList(); aux.AddRange(from Region region in childRegions select GetRegionFeatureLayer(region)); return(aux); }
private void button1_Click(object sender, EventArgs e) { User user; UserHelper.Login("admin", "123456", out user); if (user.Role != null) { Console.WriteLine(user.Role.Description); } Region reg = RegionHelper.GetWorld(); List <Model> models = ModelHelper.GetAll(); List <Region> regions2 = RegionHelper.GetAll(); }
/// <summary> /// Returns a ShapeFileFeatureLayer with the region's path shape file. /// </summary> /// <returns></returns> public static ShapeFileFeatureLayer GetRegionPathLayer(Region region) { if (String.IsNullOrEmpty(region.PathFileName)) { return(null); } ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(GetPathShapeFileFullPath(region)) { Name = region.IDRegion + "PATH" }; layer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColors.GreenYellow, 1, GeoColors.GreenYellow, 0, GeoColors.GreenYellow, 0, false); layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; RebuildIndexFile(layer); return(layer); }
/// <summary> /// Returns a ShapeFileFeatureLayer with the region's path shape file. /// </summary> /// <returns></returns> public static ShapeFileFeatureLayer GetRegionPOILayer(Region region) { if (String.IsNullOrEmpty(region.POIFileName)) { return(null); } ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(GetPOIShapeFileFullPath(region)) { Name = region.IDRegion + "POI" }; layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City2; layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; RebuildIndexFile(layer); return(layer); }
public static string GetPOIShapeFileFullPath(Region region) { return(DirectoryAndFileHelper.ClientShapefilesFolder + region.POIFileName); }
private void EditRiskAndAction_Load(object sender, EventArgs e) { //TREEVIEW Model model = ERMTSession.Instance.CurrentModel; if (model != null) { tvRegions.Nodes.Clear(); Region current = RegionHelper.Get(model.IDRegion); List <Region> regions = new List <Region>(); regions.Add(RegionHelper.Get(1)); if (current.IDParent.HasValue && current.IDParent != 1) { regions.Add(RegionHelper.Get(current.IDParent.Value)); } regions.Add(current); regions.AddRange(RegionHelper.GetAllChilds(current.IDRegion)); TreeNode node = new TreeNode() { Text = current.RegionName, Name = current.IDRegion.ToString(), Tag = current }; int mainRegionLevel = RegionHelper.GetLevel(current.IDRegion); tvRegions.Nodes.Add(node); AddChildRegions(tvRegions.Nodes[0], regions, mainRegionLevel); tvRegions.SelectedNode = tvRegions.Nodes[0]; tvRegions.ExpandAll(); } //Electoral Phase cbElectoralPhases.Items.Add(new ComboBoxItemFace(null)); cbElectoralPhases.Items.AddRange(PhaseHelper.GetAll().Select(p => new ComboBoxItemFace(p)).ToArray()); cbElectoralPhases.SelectedIndex = 0; // Add data from alert: if (_alert.IDModel != 0) { tbCode.Text = _alert.Code; tbTitle.Text = _alert.Title; dtpDateFrom.Value = _alert.DateFrom; dtpDateTo.Value = _alert.DateTo; tbDescription.Text = _alert.RiskDescription; tbAction.Text = _alert.Action; tbResult.Text = _alert.Result; rbStatusActive.Checked = _alert.Active; rbStatusInactive.Checked = !_alert.Active; // Phases: List <ModelRiskAlertPhase> modelRiskAlertPhaseList = ModelRiskAlertHelper.GetPhases(_alert); foreach (ModelRiskAlertPhase mrap in modelRiskAlertPhaseList) { foreach (var cboPhase in cbElectoralPhases.Items) { if (((ComboBoxItemFace)cboPhase).IFase != null) { if (((ComboBoxItemFace)cboPhase).IFase.IDPhase == mrap.IDPhase) { lbElectoralPhases.Items.Add(cboPhase); } } } } // Regions: List <ModelRiskAlertRegion> modelRiskAlertRegionList = ModelRiskAlertHelper.GetModelRiskAlertRegions(_alert); foreach (ModelRiskAlertRegion region in modelRiskAlertRegionList) { foreach (TreeNode node in tvRegions.Nodes) { CheckRegion(node, region); } } // Add analysis: List <ModelRiskAlertAttachment> modelRiskAlertAttachment = ModelRiskAlertHelper.GetModelRiskAlertAttachments(_alert); foreach (ModelRiskAlertAttachment att in modelRiskAlertAttachment) { addUpdater(att); } // And a last button to add more: addUpdater(); } else { Label newLabel = new Label { Text = ResourceHelper.GetResourceText("RiskAndActionSaveWarning"), ForeColor = Color.Red, Width = 500 }; analysisPanel.Controls.Add(newLabel); } }
private void LoadModelAndRegions() { Model model = ERMTSession.Instance.CurrentModel; if (model == null) { return; } if (!IsMasterRAR) { // Load tree: tvRegions.Nodes.Clear(); Region current = RegionHelper.Get(model.IDRegion); List <Region> regions = new List <Region>(); regions.Add(RegionHelper.Get(1)); if (current.IDParent.HasValue && current.IDParent != 1) { regions.Add(RegionHelper.Get(current.IDParent.Value)); } regions.Add(current); regions.AddRange(RegionHelper.GetAllChilds(current.IDRegion)); TreeNode node = new TreeNode() { Text = current.RegionName, Name = current.IDRegion.ToString(), Tag = current }; int mainRegionLevel = RegionHelper.GetLevel(current.IDRegion); // node.ContextMenuStrip = NodeMenu; tvRegions.Nodes.Add(node); AddChildRegions(tvRegions.Nodes[0], regions, mainRegionLevel); tvRegions.ExpandAll(); tvRegions.SelectedNode = tvRegions.Nodes[0]; } else { // Load tree: tvRegions.Nodes.Clear(); //Region current = RegionHelper.Get(model.IDRegion); //List<Region> regions = ModelRiskAlertHelper.GetAllRegionsWithAlerts(); List <Region> regions = RegionHelper.GetAll().OrderBy(r => r.RegionLevel).ToList(); //regions.Add(RegionHelper.GetWorld()); if (regions.Count == 0) { return; } TreeNode node = new TreeNode { Text = regions[0].RegionName, Name = regions[0].IDRegion.ToString(), Tag = regions[0] }; int mainRegionLevel = RegionHelper.GetLevel(regions[0].IDRegion); // node.ContextMenuStrip = NodeMenu; tvRegions.Nodes.Add(node); AddChildRegions(tvRegions.Nodes[0], regions, mainRegionLevel); tvRegions.ExpandAll(); tvRegions.SelectedNode = tvRegions.Nodes[0]; } }