Esempio n. 1
0
 /// <summary>
 /// Add layer to the map
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AddButton_Click(object sender, EventArgs e)
 {
     using (new TemporaryWaitCursor())
     {
         if (LayersTabControl.SelectedTabPage == systemTab)
         {
             SelectedLayer            = new EidssSystemDbLayer(((NamedTable)systemLayersList.SelectedItem).m_Name);
             SelectedLayer.DataSource = new EidssSqlServer2008(((NamedTable)systemLayersList.SelectedItem).m_Table);
             GenerateRandomStyle(SelectedLayer);
             Close();
             return;
         }
         if (LayersTabControl.SelectedTabPage == additionalTab)
         {
             SelectedLayer            = new EidssExtSystemDbLayer(((NamedTable)extSysLayersList.SelectedItem).m_Name);
             SelectedLayer.DataSource = new EidssSqlServer2008(((NamedTable)extSysLayersList.SelectedItem).m_Table);
             GenerateRandomStyle(SelectedLayer);
             Close();
             return;
         }
         if (LayersTabControl.SelectedTabPage == bufZoneTab)
         {
             if (bufLayersGridView.SelectedRowsCount != 1)
             {
                 return;
             }
             var selectedRow = bufLayersGridView.GetDataRow(bufLayersGridView.FocusedRowHandle);
             SelectedLayer = UserDbLayersManager.GetUserLayer((Guid)selectedRow[0]);
             Close();
             return;
         }
     }
 }
Esempio n. 2
0
        void mi_Prop_Click(object sender, EventArgs e)
        {
            #region Apply movement or not

            //m_SelectedFeature = null;

            if (m_IsMoveMode)
            {
                if (ApplyMovement(false) == DialogResult.Cancel)
                {
                    return;
                }
            }

            #endregion

            var userLayer = UserDbLayersManager.GetUserLayer(m_TargetLayerGuid);
            var lyr       = (EidssUserBufZoneLayer)userLayer;
            var zone      = lyr.FeatureRowToStruct(m_SelectedFeature);
            if (zone.Radius > 0)
            {
                var frm = new CircleBufZone();
                frm.ZoneName    = zone.Name;
                frm.Description = zone.Description;
                frm.Radius      = zone.Radius;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    zone.Name        = frm.ZoneName;
                    zone.Description = frm.Description;
                    zone.Radius      = frm.Radius;

                    var projectedCenter = zone.Center;// GeometryTransform.TransformGeometry(zone.Center, CoordinateSystems.WGS84,
                    //                                     CoordinateSystems.SphericalMercatorCS);
                    var projectedBufGeom = GIS_V4.Utils.GeometryUtils.CreateBuffer(projectedCenter, zone.Radius);
                    var geom             = projectedBufGeom;//GeometryTransform.TransformGeometry(projectedBufGeom, CoordinateSystems.SphericalMercatorCS,
                    //                                    CoordinateSystems.WGS84);

                    zone.Geometry = geom;

                    lyr.UpdateZone(zone);

                    m_SelectedFeature = null;
                }
            }
            else
            {
                var frm = new PolygonBufZone();
                frm.ZoneName    = zone.Name;
                frm.Description = zone.Description;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    zone.Name        = frm.ZoneName;
                    zone.Description = frm.Description;
                    lyr.UpdateZone(zone);

                    m_SelectedFeature = null;
                }
            }
            m_MapImage.Refresh();
        }
Esempio n. 3
0
        void MapImage_MouseDown(SharpMap.Geometries.Point worldPos, MouseEventArgs e)
        {
            if (m_TargetLayerGuid == Guid.Empty)
            {
                return;
            }

            if (!m_IsMoveMode)
            {
                var area      = GIS_V4.Utils.GeometryUtils.PointToArea(worldPos, 3, MapImage.Map.PixelWidth);
                var fds       = new FeatureDataSet();
                var zoneLayer = UserDbLayersManager.GetUserLayer(m_TargetLayerGuid);
                zoneLayer.DataSource.ExecuteIntersectionQuery(area.GetBoundingBox(), fds);

                if (fds.Tables.Count <= 0)
                {
                    m_SelectedFeature = null;
                    return;
                }

                if (fds.Tables[0].Rows.Count <= 0)
                {
                    m_SelectedFeature = null;
                    MapImage.RefreshFromCache();
                    return;
                }

                m_SelectedFeature = fds.Tables[0][0];

                MapImage.RefreshFromCache();
            }
            else
            {
                //tool in move mode
                if (e.Button == MouseButtons.Left)
                {
                    //start shifting on mouse move
                    m_IsShifting    = true;
                    m_ShiftBeginPnt = worldPos;
                    m_LastShiftPnt  = new SharpMap.Geometries.Point(worldPos.X, worldPos.Y);
                }
            }

            if (m_SelectedFeature != null && e.Button == MouseButtons.Right)
            {
                if (m_SelectedFeature.Geometry.GetBoundingBox().Contains(worldPos))
                {
                    m_CMenu.Show(MapImage, e.Location);
                }
            }
        }
Esempio n. 4
0
        void MapImage_MouseDown(Point worldPos, MouseEventArgs e)
        {
            string strName;

            var geom = GetArealGeom(worldPos, out strName);

            if (geom == null)
            {
                return;
            }
            //show form
            PolygonBufZone frm = new PolygonBufZone {
                ZoneName = strName
            };

            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (m_PivotalProvider == null)
                {
                    return;
                }

                if (m_TargetLayerGuid == Guid.Empty)
                {
                    return;
                }

                var eidssUserBufZoneLayer = (EidssUserBufZoneLayer)UserDbLayersManager.GetUserLayer(m_TargetLayerGuid);

                if (eidssUserBufZoneLayer == null)
                {
                    return;
                }

                var userBufZone = new EidssUserBufZoneLayer.UserBufZone
                {
                    Geometry    = geom,
                    Description = frm.Description,
                    Name        = frm.ZoneName,
                    Center      = new Point(0, 0)
                };

                eidssUserBufZoneLayer.AddNewZone(userBufZone);

                MapImage.Refresh();

                //UserDbFeature userDbFeature = new UserDbFeature(frm.Name, frm.Description, geom);
                //DataProvider.AddUserFeature(userDbFeature);
                //MapImage.Refresh();
            }
        }
Esempio n. 5
0
        void MapImage_MouseDown(Point worldPos, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                var circleBufZone = new CircleBufZone();
                if (circleBufZone.ShowDialog() == DialogResult.OK)
                {
                    if (m_TargetLayerGuid == Guid.Empty)
                    {
                        return;
                    }

                    var projectedCenter  = worldPos;
                    var projectedBufGeom = GIS_V4.Utils.GeometryUtils.CreateBuffer(projectedCenter, circleBufZone.Radius);
                    //var geom = GeometryTransform.TransformGeometry(projectedBufGeom, CoordinateSystems.SphericalMercatorCS,
                    //                                               CoordinateSystems.WGS84);
                    //var center = GeometryTransform.TransformGeometry(projectedCenter, CoordinateSystems.SphericalMercatorCS,
                    //                                               CoordinateSystems.WGS84);
                    if (m_TargetLayerGuid == Guid.Empty)
                    {
                        return;
                    }

                    var eidssUserBufZoneLayer = (EidssUserBufZoneLayer)UserDbLayersManager.GetUserLayer(m_TargetLayerGuid);

                    if (eidssUserBufZoneLayer == null)
                    {
                        return;
                    }

                    var userBufZone = new EidssUserBufZoneLayer.UserBufZone
                    {
                        Geometry    = projectedBufGeom, //geom,
                        Description = circleBufZone.Description,
                        Name        = circleBufZone.ZoneName,
                        Center      = projectedCenter, //center,
                        Radius      = circleBufZone.Radius
                    };

                    eidssUserBufZoneLayer.AddNewZone(userBufZone);

                    MapImage.Refresh();
                }
                circleBufZone.Dispose();
            }
        }
Esempio n. 6
0
        private void DeleteSelected()
        {
            var msg     = EidssMessages.GetForCurrentLang("gis_Message_DelZone", "Would you like to delete selected buffer zone?");
            var caption = EidssMessages.GetForCurrentLang("gis_Caption_DelZone", "Delete buffer zone");

            if (MessageForm.Show(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (m_SelectedFeature != null)
                {
                    //MapImage.Cursor = Cursors.WaitCursor;
                    if (!m_IsMoveMode)
                    {
                        ((EidssUserBufZoneLayer)UserDbLayersManager.GetUserLayer(m_TargetLayerGuid)).DeleteZone(
                            (long)m_SelectedFeature["idfsGeoObject"]);
                    }
                    else
                    {
                        ((EidssUserBufZoneLayer)UserDbLayersManager.GetUserLayer(m_LastMovedTargetLayerGuid)).DeleteZone(
                            (long)m_SelectedFeature["idfsGeoObject"]);
                    }

                    m_SelectedFeature = null;

                    if (m_IsMoveMode)
                    {
                        m_MiApplyMovement.Visible  = false;
                        m_MiCancelMovement.Visible = false;
                        m_MiMove.Visible           = true;
                    }

                    if (UserDbLayersManager.GetLayerMetadata(m_TargetLayerGuid).m_PivotalLayer != PivotLayerType.None)
                    {
                        m_MiMove.Visible = false;
                    }

                    m_IsMoveMode = false;
                    m_MapImage.CommandToolPress -= m_MapImage_CommandToolPress;

                    //MapImage.Cursor = Cursors.Default;
                    MapImage.Refresh();
                }
            }
        }
Esempio n. 7
0
        void m_ZoneLayerSelectBarItem_EditValueChanged(object sender, EventArgs e)
        {
            if (m_SelfRefresh)
            {
                return;
            }
            //get selected name
            var selectedValue = m_ZoneLayerSelectBarItem.EditValue;

            MapControl.ActiveTool = null;
            if (OnItemSelect != null)
            {
                OnItemSelect(/*(KeyValuePair<Guid, string>)*/ ((KeyValuePairWrapper)selectedValue).ToKeyValuePair());
            }

            if (IsZoneLayerAlreadyAdded((KeyValuePairWrapper)selectedValue))
            {
                return;
            }

            //var msg = EidssMessages.Get("gis_Message_AddZoneLayer", "Would you like to add this buffer zone layer?", ModelUserContext.CurrentLanguage);
            //var caption = EidssMessages.Get("gis_Caption_AddZoneLayer", "Add buffer zone layer: ", ModelUserContext.CurrentLanguage);
            //var errMsg = EidssMessages.Get("gis_ErrMessage_AddZoneLayer", "Can't add selected buffer zone layer.", ModelUserContext.CurrentLanguage);

            //var captEx = caption + ((KeyValuePairWrapper) selectedValue).Value.ToString();
            //var dialogResult = MessageForm.Show(msg, captEx, MessageBoxButtons.YesNo,
            //                                                           MessageBoxIcon.Question);

            //if ( dialogResult == DialogResult.Yes)
            //{
            var eidssUserDbLayer =
                UserDbLayersManager.GetUserLayer(     /*((KeyValuePair<Guid, string>) selectedValue).Key*/
                    ((KeyValuePairWrapper)selectedValue).Key);

            MapControl.Map.Layers.Add(eidssUserDbLayer);
            MapControl.Map.Layers.Add(eidssUserDbLayer.LabelLayer);

            MapControl.Refresh();
            ((MapControl)(MapControl.Parent)).RefreshContent();
            //}
        }
Esempio n. 8
0
        void mi_Move_Click(object sender, EventArgs e)
        {
            m_IsMoveMode = true;

            m_LastMovedTargetLayerGuid = m_TargetLayerGuid;
            m_MiMove.Visible           = false;
            m_MiApplyMovement.Visible  = true;
            m_MiCancelMovement.Visible = true;

            m_BufZoneUserLayer  = UserDbLayersManager.GetUserLayer(m_TargetLayerGuid);
            m_BufZoneLayer      = (EidssUserBufZoneLayer)m_BufZoneUserLayer;
            m_BufZoneBeforeEdit = m_BufZoneLayer.FeatureRowToStruct(m_SelectedFeature);

            var wkb = m_SelectedFeature.Geometry.AsBinary();//.AsText();

            m_GeomBeforeEdit = Geometry.GeomFromWKB(wkb);

            SubscribeApplyEvents();

            MapImage.RefreshFromCache();
        }
Esempio n. 9
0
        void MapImage_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (m_ToolPhase == ToolPhase.WaitFirst)
            {
                return;
            }
            //if (DataProvider == null) NoDataProvider();

            //compleate polygon
            if (m_Vertices.Count < 3)
            {
                return;
            }

            m_Vertices.Add(m_Vertices[0]);

            var      linearRing = new LinearRing(m_Vertices);
            Geometry polygon    = new Polygon(linearRing);

            //polygon = GeometryTransform.TransformGeometry(polygon, CoordinateSystems.SphericalMercatorCS,
            //                                                      CoordinateSystems.WGS84);
            m_ToolPhase = ToolPhase.WaitFirst;

            var connectionString = ConnectionManager.DefaultInstance.ConnectionString;
            var connection       = new SqlConnection(connectionString);

            var valid = SqlExecHelper.SqlGeometryValidation(connection, polygon);

            if (!valid)
            {
                MessageForm.Show(Resources.gis_MtIndependentPolygonBufferZone_CheckValidityMsg);
            }
            else
            {
                //show form
                var frm = new PolygonBufZone();
                //frm.ZoneLayer = string.Empty;

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    if (m_TargetLayerGuid == Guid.Empty)
                    {
                        return;
                    }

                    var eidssUserBufZoneLayer =
                        (EidssUserBufZoneLayer)UserDbLayersManager.GetUserLayer(m_TargetLayerGuid);

                    if (eidssUserBufZoneLayer == null)
                    {
                        return;
                    }


                    var userBufZone = new EidssUserBufZoneLayer.UserBufZone
                    {
                        Geometry    = polygon,
                        Description = frm.Description,
                        Name        = frm.ZoneName,
                        //Center = new Point(0, 0)
                    };

                    eidssUserBufZoneLayer.AddNewZone(userBufZone);
                }
            }
            MapImage.Refresh();

            m_Vertices.Clear();
            m_Points.Clear();
            m_LastMousePosition = System.Drawing.Point.Empty;
        }
Esempio n. 10
0
        void MapImage_MouseDown(Point worldPos, MouseEventArgs e)
        {
            switch (PivotalType)
            {
            case PivotLayerType.Settlements:
                m_PivotalProvider = new EidssSqlServer2008(SystemLayerNames.Settlements);
                break;

            case PivotLayerType.AvrPoints:
                if (Content.AVRLayer != null)
                {
                    m_PivotalProvider = Content.AVRLayer.DataSource;
                }
                break;

            default:
                m_PivotalProvider = null;
                break;
            }

            string strName;
            var    nearestPoint = GetNearestPoint(worldPos, out strName);

            if (nearestPoint == null)
            {
                return;
            }
            //show form
            var frm = new CircleBufZone {
                ZoneName = strName
            };

            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (m_PivotalProvider == null)
                {
                    return;
                }

                var projectedCenter = nearestPoint;
                //var projectedCenter = GeometryTransform.TransformGeometry(nearestPoint, CoordinateSystems.WGS84,
                //                                                          CoordinateSystems.SphericalMercatorCS);
                var projectedBufGeom = GIS_V4.Utils.GeometryUtils.CreateBuffer(projectedCenter, frm.Radius);
                //var geom = GeometryTransform.TransformGeometry(projectedBufGeom, CoordinateSystems.SphericalMercatorCS,
                //                                               CoordinateSystems.WGS84);
                //var center = GeometryTransform.TransformGeometry(projectedCenter, CoordinateSystems.SphericalMercatorCS,
                //                                               CoordinateSystems.WGS84);
                if (m_TargetLayerGuid == Guid.Empty)
                {
                    return;
                }

                var eidssUserBufZoneLayer = (EidssUserBufZoneLayer)UserDbLayersManager.GetUserLayer(m_TargetLayerGuid);

                if (eidssUserBufZoneLayer == null)
                {
                    return;
                }

                var userBufZone = new EidssUserBufZoneLayer.UserBufZone
                {
                    Geometry    = projectedBufGeom, //geom,
                    Description = frm.Description,
                    Name        = frm.ZoneName,
                    Center      = projectedCenter, //center,
                    Radius      = frm.Radius
                };

                eidssUserBufZoneLayer.AddNewZone(userBufZone);

                MapImage.Refresh();
            }
        }