private void fillDialogWithData() { switch (layerType) { case LayerType.Shape: { if (currentShape != null) { this.label5.Enabled = true; this.label1.Enabled = true; this.layerFileNameLabel.Enabled = true; this.layerFilePathLabel.Enabled = true; this.checkDrawComment.Visible = false; this.numCommentMaxSize.Visible = false; this.label1.Visible = true; this.layerFilePathLabel.Visible = true; this.clearLayerButton.Visible = false; this.lblMaxCommentSize.Visible = false; LayerInfo tempLayerInfo = currentShape.LayerInfo; VectorInfo tempVectorInfo = currentShape.VectorInfo; this.layerNameTextBox.Text = currentShape.LayerName; this.layerCommentTextBox.Text = currentShape.Comment; this.layerFileNameLabel.Text = tempLayerInfo.FileName; this.layerFilePathLabel.Text = tempLayerInfo.FilePath; this.layerShapeTypeLabel.Text = currentShape.ShapeType.ToString(); this.layerShapeCountLabel.Text = currentShape.NumberOfShapes.ToString(); this.layerMinXLabel.Text = currentShape.BoundingBox.Left.ToString(); this.layerMinYLabel.Text = currentShape.BoundingBox.Bottom.ToString(); this.layerMaxXLabel.Text = currentShape.BoundingBox.Right.ToString(); this.layerMaxYLayer.Text = currentShape.BoundingBox.Top.ToString(); this.layerWidthLabel.Text = currentShape.Width.ToString(); this.layerHeightLabel.Text = currentShape.Height.ToString(); this.layerScaleLabel.Text = mainControler.LayerManager.Scale.ToString(); //this.layerTabControl.Controls.Add(this.scaleTab); this.layerTabControl.Controls.Add(this.infoTab); if (currentShape.ShapeType == MapTools.ShapeLib.ShapeType.Point) { layerLineColorPanel.Enabled = false; lineColorLabel.Enabled = false; layerLineColorPanel.BackColor = Color.LightGray; layerFillColorPanel.Enabled = false; fillColorLabel.Enabled = false; layerFillColorPanel.BackColor = Color.LightGray; layerPointColorPanel.BackColor = tempVectorInfo.PointColor; layerLineWidth.Enabled = false; layerLineWidthLabel.Enabled = false; layerDashTypeCombo.Enabled = false; layerDashTypeLabel.Enabled = false; } if (currentShape.ShapeType == MapTools.ShapeLib.ShapeType.PolyLine) { layerLineColorPanel.Enabled = true; lineColorLabel.Enabled = true; layerFillColorPanel.Enabled = false; fillColorLabel.Enabled = false; layerFillColorPanel.BackColor = Color.LightGray; layerPointColorPanel.BackColor = tempVectorInfo.PointColor; layerLineColorPanel.BackColor = tempVectorInfo.LineColor; layerLineWidth.Enabled = true; layerLineWidthLabel.Enabled = true; layerLineWidth.Value = Convert.ToDecimal(tempVectorInfo.LayerPen.Width); layerDashTypeCombo.Enabled = true; layerDashTypeLabel.Enabled = true; } else if (currentShape.ShapeType == MapTools.ShapeLib.ShapeType.Polygon) { layerLineColorPanel.Enabled = true; lineColorLabel.Enabled = true; layerFillColorPanel.Enabled = true; fillColorLabel.Enabled = true; fillColorLabel.Checked = tempVectorInfo.Fill; layerPointColorPanel.BackColor = tempVectorInfo.PointColor; layerLineColorPanel.BackColor = tempVectorInfo.LineColor; layerFillColorPanel.BackColor = tempVectorInfo.FillColor; layerLineWidth.Enabled = true; layerLineWidthLabel.Enabled = true; layerLineWidth.Value = Convert.ToDecimal(tempVectorInfo.LayerPen.Width); layerDashTypeCombo.Enabled = true; layerDashTypeLabel.Enabled = true; } } else { MessageBox.Show("Fehler beim Lesen von Shape"); mainControler.addLogMessage("[LayerEdit] Fehler beim Lesen von Shape"); currentShape = null; } break; } case LayerType.PointCanvas: //layerType == plineTransport { this.layerNameTextBox.Text = config.ExPntLayerName; this.layerCommentTextBox.Text = config.ExPntLayerComment; this.fillColorLabel.Enabled = false; this.layerFillColorPanel.Enabled = false; this.layerFillColorPanel.BackColor = Color.LightGray; this.lineColorLabel.Enabled = false; this.layerLineColorPanel.Enabled = false; this.layerLineColorPanel.BackColor = Color.LightGray; this.layerPointColorPanel.Enabled = true; this.pointColorLabel.Enabled = true; this.layerPointColorPanel.BackColor = config.ExPntLayerPointColor; this.layerLineWidth.Visible = false; this.layerLineWidthLabel.Visible = false; this.lblPointsize.Visible = true; this.layerPointSize.Visible = true; this.layerPointSize.Value = config.ExPntLayerPointWidth; this.checkDrawComment.Checked = config.ExPntLayerDisplayComments; this.numCommentMaxSize.Value = config.ExPntLayerDisplayCommentMaxLength; this.label1.Visible = false; this.layerFilePathLabel.Visible = false; this.clearLayerButton.Visible = true; this.layerShapeTypeLabel.Text = "Punkt Austauschlayer"; this.layerShapeCountLabel.Text = tPoint.Count.ToString(); this.layerMinXLabel.Text = tPoint.BoundingBox.Left.ToString(); this.layerMinYLabel.Text = tPoint.BoundingBox.Bottom.ToString(); this.layerMaxXLabel.Text = tPoint.BoundingBox.Right.ToString(); this.layerMaxYLayer.Text = tPoint.BoundingBox.Top.ToString(); this.layerWidthLabel.Text = tPoint.Width.ToString(); this.layerHeightLabel.Text = tPoint.Height.ToString(); this.layerScaleLabel.Text = mainControler.LayerManager.Scale.ToString(); break; } case LayerType.PolygonCanvas: //layerType == plineTransport { this.layerNameTextBox.Text = config.ExPGonLayerName; this.layerCommentTextBox.Text = config.ExPGonLayerComment; this.fillColorLabel.Enabled = true; this.fillColorLabel.Checked = config.ExPGonLayerFill; this.layerFillColorPanel.Enabled = true; this.layerFillColorPanel.BackColor = config.ExPGonLayerFillColor; this.lineColorLabel.Enabled = true; this.layerLineColorPanel.Enabled = true; this.layerLineColorPanel.BackColor = config.ExPGonLayerLineColor; this.layerPointColorPanel.Enabled = true; this.pointColorLabel.Enabled = true; this.layerPointColorPanel.BackColor = config.ExPGonLayerPointColor; this.layerLineWidth.Value = Math.Round((decimal)config.exPGonLayerLineWidth); this.layerPointSize.Value = Math.Round((decimal)config.ExPGonLayerPointWidth); this.layerLineWidth.Visible = true; this.layerLineWidthLabel.Visible = true; this.checkDrawComment.Checked = config.ExPGonLayerDisplayComments; this.label1.Visible = false; this.layerFilePathLabel.Visible = false; this.clearLayerButton.Visible = true; this.numCommentMaxSize.Value = config.ExPGonLayerDisplayCommentMaxLength; this.layerShapeTypeLabel.Text = "Polygon Austauschlayer"; this.layerShapeCountLabel.Text = tPolygon.Count.ToString(); this.layerMinXLabel.Text = tPolygon.BoundingBox.Left.ToString(); this.layerMinYLabel.Text = tPolygon.BoundingBox.Bottom.ToString(); this.layerMaxXLabel.Text = tPolygon.BoundingBox.Right.ToString(); this.layerMaxYLayer.Text = tPolygon.BoundingBox.Top.ToString(); this.layerWidthLabel.Text = tPolygon.Width.ToString(); this.layerHeightLabel.Text = tPolygon.Height.ToString(); this.layerScaleLabel.Text = mainControler.LayerManager.Scale.ToString(); break; } case LayerType.PolylineCanvas: { this.layerNameTextBox.Text = config.ExPLineLayerName; this.layerCommentTextBox.Text = config.ExPLineLayerComment; this.fillColorLabel.Enabled = false; this.layerFillColorPanel.Enabled = false; this.layerFillColorPanel.BackColor = Color.LightGray; this.lineColorLabel.Enabled = true; this.layerLineColorPanel.Enabled = true; this.layerLineColorPanel.BackColor = config.ExPLineLayerLineColor; this.layerPointColorPanel.Enabled = true; this.pointColorLabel.Enabled = true; this.layerPointColorPanel.BackColor = config.ExPLineLayerPointColor; this.layerLineWidth.Value = Math.Round((decimal)config.exPLineLayerLineWidth); this.layerPointSize.Value = Math.Round((decimal)config.ExPLineLayerPointWidth); this.layerLineWidth.Visible = true; this.layerLineWidthLabel.Visible = true; this.checkDrawComment.Checked = config.ExPLineLayerDisplayComments; this.label1.Visible = false; this.layerFilePathLabel.Visible = false; this.clearLayerButton.Visible = true; this.numCommentMaxSize.Value = config.ExPLineLayerDisplayCommentMaxLength; this.layerShapeTypeLabel.Text = "Linienzug Austauschlayer"; this.layerShapeCountLabel.Text = tLine.Count.ToString(); this.layerMinXLabel.Text = tLine.BoundingBox.Left.ToString(); this.layerMinYLabel.Text = tLine.BoundingBox.Bottom.ToString(); this.layerMaxXLabel.Text = tLine.BoundingBox.Right.ToString(); this.layerMaxYLayer.Text = tLine.BoundingBox.Top.ToString(); this.layerWidthLabel.Text = tLine.Width.ToString(); this.layerHeightLabel.Text = tLine.Height.ToString(); this.layerScaleLabel.Text = mainControler.LayerManager.Scale.ToString(); break; } default: break; } if (layerType != LayerType.Shape) { this.label5.Enabled = false; this.label1.Enabled = false; this.layerFileNameLabel.Visible = false; this.layerFilePathLabel.Visible = false; this.checkDrawComment.Visible = true; this.numCommentMaxSize.Visible = true; this.lblMaxCommentSize.Visible = true; if (checkDrawComment.Checked) { this.lblMaxCommentSize.Enabled = true; this.numCommentMaxSize.Enabled = true; } else { this.lblMaxCommentSize.Enabled = false; this.numCommentMaxSize.Enabled = false; } } }
public DialogResult ShowDialog(LayerType transLayerType) { this.layerType = transLayerType; this.currentShape = null; fillDialogWithData(); return base.ShowDialog(); }
public void generateGeometryStructureInDLL(ShapeObject shpObject, ref GravurGIS.Topology.Grid.Grid partGrid) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IntPtr cPointObjectPtr; if (LayerCount == 0) cPointObjectPtr = ShapeLib.SHPGetPolyLineList(shpObject.LayerInfo.FilePath, shpObject.Access, mainControler.MapPanel.Width, mainControler.MapPanel.Height, mainControler.MapPanel.Margin, 1, 1.0d, 0,pointSize, 0); else cPointObjectPtr = ShapeLib.SHPGetPolyLineList(shpObject.LayerInfo.FilePath, shpObject.Access, mainControler.MapPanel.Width, mainControler.MapPanel.Height, mainControler.MapPanel.Margin, 1, firstScale, 1,0, 0); if (cPointObjectPtr.Equals(IntPtr.Zero)) { mainControler.showErrorMessage("Fehler 0x0002: Shapereferenz ist ungültig"); } else { int momentaryPointCount; double[] xWorldList; double[] yWorldList; int[] xDispList; int[] yDispList; int pointCount = 0; ShapeLib.PointObject pntObj = new ShapeLib.PointObject(); Marshal.PtrToStructure(cPointObjectPtr, pntObj); shpObject.BoundingBox = new WorldBoundingBoxD(pntObj.minBX, pntObj.maxBY, pntObj.maxBX, pntObj.minBY); if (pntObj.isWellDefines == 0) shpObject.IsWellDefined = false; else shpObject.IsWellDefined = true; if (LayerCount == 0) { mainControler.MapPanel.AbsolutZoom = 1; if (pntObj.isPoint == 0) //normal shpObject { this.firstScale = this.scale = pntObj.scale; mainControler.MapPanel.DX = firstScale * pntObj.minBX; mainControler.MapPanel.DY = firstScale * pntObj.maxBY; } else //shpObject contains only 1 point { // 1:1 Maßstab oder lieber schon etwas rauszoomen? this.scale = pntObj.scale; // ((mainControler.MapPanel.Width) - 2 * (mainControler.MapPanel.Margin) - 2) / (double)defaultShapeSize; this.firstScale = this.scale; shpObject.IsOnePoint = true; mainControler.MapPanel.DX = firstScale * (pntObj.minBX - (int)(defaultShapeSize / 2)); mainControler.MapPanel.DY = firstScale * (pntObj.maxBY + (int)(defaultShapeSize / 2)); } } shpObject.NumberOfShapes = (uint)(pntObj.shapeCount > 0 ? pntObj.shapeCount : 0); shpObject.ShapeType = pntObj.shpType; shpObject.PartCount = (uint)(pntObj.partCount > 0 ? pntObj.partCount : 0); PointList[] polyLinePointList; // make sure we have shapes and parts if (pntObj.shapeCount > 0 && (pntObj.partCount > 0 || pntObj.shpType == ShapeLib.ShapeType.Point)) { // Create the outer list which holds the pointers to the sublists xWorldList = new double[pntObj.nVertices]; Marshal.Copy(pntObj.worldX, xWorldList, 0, pntObj.nVertices); yWorldList = new double[pntObj.nVertices]; Marshal.Copy(pntObj.worldY, yWorldList, 0, pntObj.nVertices); xDispList = new int[pntObj.nVertices]; Marshal.Copy(pntObj.dispX, xDispList, 0, pntObj.nVertices); yDispList = new int[pntObj.nVertices]; Marshal.Copy(pntObj.dispY, yDispList, 0, pntObj.nVertices); // Create a new Grid partGrid = new GravurGIS.Topology.Grid.Grid(25, 25, Convert.ToInt32(shpObject.Width * firstScale), Convert.ToInt32(shpObject.Height * firstScale), false); if (pntObj.shpType != ShapeLib.ShapeType.MultiPoint && pntObj.shpType != ShapeLib.ShapeType.Point) { // Get the list with the lengths of the sublists int[] partListLengths = new int[pntObj.partCount]; Marshal.Copy(pntObj.partListLengths, partListLengths, 0, pntObj.partCount); // Copy the sublists to a new pointList polyLinePointList = new PointList[pntObj.partCount]; for (int i = 0; i < pntObj.partCount; i++) { momentaryPointCount = partListLengths[i]; polyLinePointList[i] = new PointList(momentaryPointCount); // Copy the temporay lists into points and into the polyPointList for (int j = 0; j < momentaryPointCount; j++) { int pos = pointCount + j; polyLinePointList[i].add(xWorldList[pos], yWorldList[pos], xDispList[pos], yDispList[pos], j); } partGrid.insert(polyLinePointList[i], getBoundingBox(ref polyLinePointList[i])); pointCount += momentaryPointCount; } } else //shpType == MultiPoint { polyLinePointList = new PointList[pntObj.shapeCount]; for (int i = 0; i < pntObj.shapeCount; i++) { polyLinePointList[i] = new PointList(1); polyLinePointList[i].add(xWorldList[i], yWorldList[i], xDispList[i], yDispList[i], 0); partGrid.insert(polyLinePointList[i], getBoundingBox(ref polyLinePointList[i])); } } shpObject.PolyLinePointList = polyLinePointList; //double tempAbsZoom = mainControler.MapPanel.AbsolutZoom; // TODO: Warum wird das hier gemacht? Wird das wirklich gebraucht? // Tom: Ich habe es erstmal auskommentiert //int dispHeight = (int)(shpObject.BoundingBox.Height * scale + 0.5); //for (int pointList = 0; pointList < shpObject.PartCount; pointList++) // shpObject.PolyLinePointList[pointList].recalculatePoints(scale, dispHeight, pntObj.minBX, pntObj.minBY); } shpObject.Changed = true; stopWatch.Stop(); mainControler.addLogMessage(String.Format("[Shape] geladen nach {0}ms", stopWatch.ElapsedMilliseconds.ToString())); // clean things up MapTools.ShapeLib.deletePointObject(cPointObjectPtr); } }
public DialogResult ShowDialog(ShapeObject currentShape) { this.layerType = 0; this.currentShape = currentShape; fillDialogWithData(); return base.ShowDialog(); }
public ShapeObject addShapefileLayer(string FilePath) { ShapeObject shapeObject = new ShapeObject(this, FilePath); shapeObject.init(); layerListViewMappingList.Add(LayerCount, LayerCount); // ListView-Index, Shape-Index layerArray.Add(shapeObject); addLayerPostProcessing(shapeObject); return shapeObject; }