Exemple #1
0
        private void map1_OnObjectDown(System.Windows.Forms.MouseButtons Button, 
                    short Shift, GpsToolsNET.Position objPosition, 
                    GpsViewNET.Point objPoint, GpsViewNET.IDrawObject objDrawObject)
        {
            if (ddAction.SelectedIndex == 7)
            {
                // Check Map.GetByPosition() for how to
                // reach overlapped objects
                // Check Map.SetIndex() for how to change Z-Order

                switch (objDrawObject.ObjectType)
                {
                    case GpsViewNET.ObjectType.DOBJECT_MAP_SHAPE:
                        GpsViewNET.MapShape ms = (GpsViewNET.MapShape)objDrawObject;
                        GpsShapeNET.Shape s = ms.Shape;
                        GpsShapeNET.DataRecord rec = shapeFile.GetAttribute(s.ShapeID);
                        GpsShapeNET.DataField f = rec.GetFieldByIndex(2);
                        string coluna = rec.GetColumnNameByIndex(2);
                        lInfo.Text = coluna + ": " + f.NumberField;
                        try
                        {
                            int id = Convert.ToInt32(f.NumberField);
                            MessageBox.Show("" + id);
                            ModeloEnergisa me = new ModeloEnergisa(id);
                            me.ShowDialog();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Não foi possível abrir as informações do ponto selecionado: " + ex.Message);
                        }
                        //GpsShapeNET.ShapeFile newShp = shapeFile.Copy();
                        //string fileName = Library.appDir + "\\teste.shp";
                        //newShp.Open(fileName, GpsShapeNET.FileMode.FILE_WRITE);
                        //newShp.ShapeFileType = GpsShapeNET.ShapeFileType.SHAPE_TYPE_POLYGON;
                        //newShp.Write(s);
                        //newShp.Close();
                        break;
                    case GpsViewNET.ObjectType.DOBJECT_ICON:
                        GpsViewNET.Icon icon = (GpsViewNET.Icon)objDrawObject;
                        lInfo.Text = "Icon ID: " + icon.ID;
                        break;

                    case GpsViewNET.ObjectType.DOBJECT_LINE:
                        GpsViewNET.Line line = (GpsViewNET.Line)objDrawObject;
                        lInfo.Text = "Line ID: " + line.ID;
                        break;

                    case GpsViewNET.ObjectType.DOBJECT_ELLIPSE:
                        GpsViewNET.Ellipse ellipse = (GpsViewNET.Ellipse)objDrawObject;
                        lInfo.Text = "Ellipse ID: " + ellipse.ID;
                        break;

                    case GpsViewNET.ObjectType.DOBJECT_RECTANGLE:
                        GpsViewNET.Rectangle rectangle = (GpsViewNET.Rectangle)objDrawObject;
                        lInfo.Text = "Rectangle ID: " + rectangle.ID;
                        break;
                }
            }
        }
Exemple #2
0
        private void map1_OnMouseDown(MouseButtons Button, short Shift, 
            GpsToolsNET.Position objPosition, GpsViewNET.Point objPoint)
        {
            GpsViewNET.Pen objPen;
            GpsViewNET.Brush objBrush;

            if (objPosition == null)
            {
                lInfo.Text = "Invalid position.";
                return;
            }

            //lInfo.Text = objPosition.LongitudeString(0) + ", " + objPosition.LatitudeString(0);

            //cadastro
            if (ddAction.SelectedIndex == 3)
            {
                if (firstPos == null)
                {
                    firstPos = objPosition;
                    lInfo.Text = "Click para marcar o próximo ponto";
                }
                else
                {
                    shapeFile.SelectByBoundingBoxAndResolution(firstPos.Longitude,
                        objPosition.Longitude, firstPos.Latitude, objPosition.Latitude, -1);

                    GpsShapeNET.Shape shapeTmp;
                    GpsShapeNET.Shape shapeUsual = null;

                    int quantShape = 0;
                    while ((shapeTmp = shapeFile.Read()) != null)
                    {
                        quantShape++;
                        if (quantShape > 1)
                        {
                            break;
                        }
                        shapeUsual = shapeTmp;
                        //lInfo.Text = "Shape ID: " + shapeTmp.ShapeID;
                    }

                    if (quantShape > 1)
                    {
                        MessageBox.Show("Selecione apenas um ponto no mapa");
                        firstPos = null;
                        lInfo.Text = "";
                    } else if (quantShape == 1)
                    {
                        try
                        {
                            GpsShapeNET.DataRecord rec = shapeFile.GetAttribute(shapeUsual.ShapeID);
                            GpsShapeNET.DataField f = rec.GetFieldByIndex(2);
                            string coluna = rec.GetColumnNameByIndex(2);
                            //lInfo.Text = coluna + ": " + f.NumberField;
                            int id = Convert.ToInt32(f.NumberField);
                            //MessageBox.Show("" + id);
                            ModeloEnergisa me = new ModeloEnergisa(id);
                            me.ShowDialog();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Não foi possível abrir as informações do ponto selecionado: " + ex.Message);
                        }
                    }

                    firstPos = null;
                    lInfo.Text = "";
                }
                //GpsShapeNET.DataField f = rec.GetFieldByIndex(2);
                ////string coluna = rec.GetColumnNameByIndex(2);
                //try
                //{
                //    int id = Convert.ToInt32(f.NumberField);
                //    MessageBox.Show("" + id);
                //    ModeloEnergisa me = new ModeloEnergisa(id);
                //    me.ShowDialog();
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show("Não foi possível abrir as informações do ponto selecionado: " + ex.Message);
                //}
            }

            // Center on mouse click

            if (ddAction.SelectedIndex == 0)
            {
                //GpsViewNET.Ellipse objEllipse;
                //// Find ellipse on map (that marks clicked position)
                //objEllipse = (GpsViewNET.Ellipse)map1.GetByID(2);

                //if (objEllipse == null)
                //{
                //    // Use ellipse to mark clicked position
                //    objEllipse = map1.NewEllipse();
                //    objEllipse.Width = 4;
                //    objEllipse.Height = 4;

                //    objPen = new GpsViewNET.Pen();
                //    objPen.Red = 255;
                //    objPen.Width = 4;

                //    objEllipse.Pen = objPen;

                //    objEllipse.ID = 2;	// Set to known ID so we can find it with GetByID()
                //}
                map_pos = objPosition;
                map1.Position = map_pos;
                //objEllipse.Position = objPosition;

                map1.Update();

                firstPos = null;
            }

            if (ddAction.SelectedIndex == 1)
            {
                //GpsViewNET.Ellipse objEllipse;
                //// Find ellipse on map (that marks clicked position)
                //objEllipse = (GpsViewNET.Ellipse)map1.GetByID(666);
                //// Use ellipse to mark clicked position
                //objEllipse = map1.NewEllipse();
                //objEllipse = make_ellipseMark();
                //objEllipse.ID = 666;	// Set to known ID so we can find it with GetByID()

                if (pos != null)
                {
                    GpsToolsNET.Position position = new GpsToolsNET.Position();
                    position.Latitude = pos.Latitude;
                    position.Longitude = pos.Longitude;
                    map1.Position = position;
                    //objEllipse.Position = position;
                }

                firstPos = null;

                map1.Update();
            }

            // Draw line

            //if (ddAction.SelectedIndex == 2)
            //{
            //    if (firstPos == null)
            //    {
            //        firstPos = objPosition;
            //        lInfo.Text = "Click to set endpoint for line";
            //    }
            //    else
            //    {
            //        GpsViewNET.Line objLine = map1.NewLine();

            //        objLine.Position1 = firstPos;
            //        objLine.Position2 = objPosition;

            //        // Pen
            //        objPen = new GpsViewNET.Pen();
            //        objPen.Width = 4;
            //        objLine.Pen = objPen;

            //        map1.Update();

            //        firstPos = null;
            //    }
            //}

            // Draw Ellipse

            //if (ddAction.SelectedIndex == 3)
            //{
            //    GpsViewNET.Ellipse objEllipse = map1.NewEllipse();

            //    objEllipse.Position = objPosition;
            //    objEllipse.Width = 20;
            //    objEllipse.Height = 20;

            //    objBrush = new GpsViewNET.Brush();

            //    objBrush.Blue = 255;
            //    objBrush.Transparent = false;
            //    objEllipse.Brush = objBrush;

            //    map1.Update();
            //    firstPos = null;
            //}

            // Draw Icon

            if (ddAction.SelectedIndex == 4)
            {
                findMoreLatLon();

                GpsToolsNET.Position upperLeft = new GpsToolsNET.Position();
                upperLeft.Latitude = moreNorthLat;
                upperLeft.Longitude = moreWestLon;

                GpsToolsNET.Position lowerRight = new GpsToolsNET.Position();
                lowerRight.Latitude = moreSouthLat;
                lowerRight.Longitude = moreEastLon;

                map1.ZoomByBoundingBox(upperLeft, lowerRight);
            }

            if (ddAction.SelectedIndex == 2)
            {
                if (firstPoint == null)
                {
                    firstPoint = map1.Position2Point(objPosition);
                    lInfo.Text = "Clique no próximo canto";
                }
                else
                {
                    map1.ZoomByBoundingBox(firstPoint, map1.Position2Point(objPosition));
                    //GpsViewNET.Rectangle objRect = map1.NewRectangle();

                    //objPen = new GpsViewNET.Pen();
                    //objPen.Width = 3;
                    //objRect.Pen = objPen;

                    //objRect.Position1 = firstPos;
                    //objRect.Position2 = objPosition;

                    map1.Update();
                    firstPoint = null;
                }
            }
        }
        private void map1_OnMouseDown(MouseButtons Button, short Shift,
            GpsToolsNET.Position objPosition, GpsViewNET.Point objPoint)
        {
            GpsViewNET.Pen objPen;
            GpsViewNET.Brush objBrush;

            if (objPosition == null)
            {
                lInfo.Text = "Invalid position.";
                return;
            }

            //lInfo.Text = objPosition.LongitudeString(0) + ", " + objPosition.LatitudeString(0);

            //cadastro
            if (ddAction.SelectedIndex == 3)
            {
                if (firstPos == null)
                {
                    firstPos = objPosition;
                    lInfo.Text = "Click para marcar o próximo ponto";
                }
                else
                {
                    shapeFile.SelectByBoundingBoxAndResolution(firstPos.Longitude,
                        objPosition.Longitude, firstPos.Latitude, objPosition.Latitude, -1);

                    GpsShapeNET.Shape shapeTmp;
                    GpsShapeNET.Shape shapeUsual = null;

                    int quantShape = 0;
                    while ((shapeTmp = shapeFile.Read()) != null)
                    {
                        quantShape++;
                        if (quantShape > 1)
                        {
                            break;
                        }
                        shapeUsual = shapeTmp;
                        //lInfo.Text = "Shape ID: " + shapeTmp.ShapeID;
                    }

                    if (quantShape > 1)
                    {
                        MessageBox.Show("Selecione apenas um ponto no mapa");
                        firstPos = null;
                        lInfo.Text = "";
                    }
                    else if (quantShape == 1)
                    {
                        try
                        {
                            GpsShapeNET.DataRecord rec = shapeFile.GetAttribute(shapeUsual.ShapeID);
                            GpsShapeNET.DataField f = rec.GetFieldByIndex(2);
                            string coluna = rec.GetColumnNameByIndex(2);
                            //lInfo.Text = coluna + ": " + f.NumberField;
                            int id = Convert.ToInt32(f.NumberField);
                            //MessageBox.Show("" + id);
                            ModeloEnergisa me = new ModeloEnergisa(id);
                            me.ShowDialog();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Não foi possível abrir as informações do ponto selecionado: " + ex.Message);
                        }
                    }

                    firstPos = null;
                    lInfo.Text = "";
                }

            }

            // Center on mouse click
            if (ddAction.SelectedIndex == 0)
            {
                map_pos = objPosition;
                map1.Position = map_pos;
                //objEllipse.Position = objPosition;

                map1.Update();

                firstPos = null;
            }

            if (ddAction.SelectedIndex == 1)
            {
                if (pos != null)
                {
                    GpsToolsNET.Position position = new GpsToolsNET.Position();
                    position.Latitude = pos.Latitude;
                    position.Longitude = pos.Longitude;
                    map1.Position = position;
                    //objEllipse.Position = position;
                }

                firstPos = null;

                map1.Update();
            }

            if (ddAction.SelectedIndex == 2)
            {
                if (firstPoint == null)
                {
                    firstPoint = map1.Position2Point(objPosition);
                    lInfo.Text = "Clique no próximo canto";
                }
                else
                {
                    map1.ZoomByBoundingBox(firstPoint, map1.Position2Point(objPosition));
                    //GpsViewNET.Rectangle objRect = map1.NewRectangle();

                    //objPen = new GpsViewNET.Pen();
                    //objPen.Width = 3;
                    //objRect.Pen = objPen;

                    //objRect.Position1 = firstPos;
                    //objRect.Position2 = objPosition;

                    map1.Update();
                    firstPoint = null;
                }
            }
        }