Beispiel #1
0
 void m_Content_LayerSelected(SharpMap.Layers.ILayer layer)
 {
     if (layer is EidssUserBufZoneLayer)
     {
         m_TargetLayerGuid = ((EidssUserBufZoneLayer)layer).LayerDbGuid;
         if (m_TargetLayerGuid != Guid.Empty)
         {
             IsEnabled = (UserDbLayersManager.GetLayerMetadata(m_TargetLayerGuid).m_PivotalLayer ==
                          PivotLayerType.None);
             if (IsActive)
             {
                 IsActive = false;
                 IsActive = true;
             }
             if (!IsEnabled)
             {
                 IsActive = false;
             }
         }
     }
     else
     {
         IsActive = IsEnabled = false;
     }
 }
Beispiel #2
0
 void m_Content_LayerSelected(SharpMap.Layers.ILayer layer)
 {
     if (layer is EidssUserBufZoneLayer)
     {
         m_TargetLayerGuid = ((EidssUserBufZoneLayer)layer).LayerDbGuid;
         if (m_TargetLayerGuid != Guid.Empty)
         {
             IsEnabled = true;
             if (IsActive)
             {
                 IsActive = false;
                 IsActive = true;
             }
             if (m_MiMove != null)
             {
                 if (UserDbLayersManager.GetLayerMetadata(m_TargetLayerGuid).m_PivotalLayer != PivotLayerType.None || m_IsMoveMode)
                 {
                     m_MiMove.Visible = false;
                 }
                 else
                 {
                     m_MiMove.Visible = true;
                 }
             }
         }
     }
     else
     {
         IsActive = IsEnabled = false;
     }
 }
Beispiel #3
0
        protected override void OnToolActivated()
        {
            MapImage.Cursor     = Cursors.Cross;
            MapImage.MouseDown += MapImage_MouseDown;

            if (m_FirstActivation)
            {
                m_MapImage.CreateGraphics();

                MapImage.MapRefreshed += MapImage_MapRefreshed;

                m_CMenu            = new ContextMenu();
                m_MiProp           = new MenuItem(Resources.m_MtSelectBufZones_BZProperties);
                m_MiDel            = new MenuItem(Resources.gis_MtSelectBufZones_BZDelete);
                m_MiMove           = new MenuItem(Resources.gis_MtSelectBufZones_BZMove);
                m_MiApplyMovement  = new MenuItem(Resources.gis_MtSelectBufZones_BZApply);
                m_MiCancelMovement = new MenuItem(Resources.gis_MtSelectBufZones_BZCancel);

                m_CMenu.MenuItems.Add(m_MiProp);
                m_CMenu.MenuItems.Add(m_MiDel);
                m_CMenu.MenuItems.Add(m_MiMove);
                m_CMenu.MenuItems.Add(m_MiApplyMovement);
                m_CMenu.MenuItems.Add(m_MiCancelMovement);

                m_MiApplyMovement.Visible  = false;
                m_MiCancelMovement.Visible = false;

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

                //MapImage.ContextMenu = m_CMenu;
                m_MiDel.Click            += mi_Del_Click;
                m_MiProp.Click           += mi_Prop_Click;
                m_MiMove.Click           += mi_Move_Click;
                m_MiApplyMovement.Click  += miApplyMovement_Click;
                m_MiCancelMovement.Click += miCancelMovement_Click;

                m_MapImage.MouseMove += m_MapImage_MouseMove;
                m_MapImage.MouseUp   += m_MapImage_MouseUp;

                m_MapImage.OnActiveToolChanged += m_MapImage_OnActiveToolChanged;
            }
            m_FirstActivation = false;
        }
Beispiel #4
0
        private void PropertiesButton_Click(object sender, EventArgs e)
        {
            //get selected layer props
            var             row     = bufLayersGridView.GetDataRow(bufLayersGridView.FocusedRowHandle);
            var             layerId = (Guid)row["ID"];
            UserDbLayerInfo layerInfo;

            try
            {
                layerInfo = UserDbLayersManager.GetLayerMetadata(layerId);
            }
            catch (Exception)
            {
                ErrorForm.ShowError(Resources.DbLayersFormFailedToObtainMetadata);
                return;
            }

            var propForm = new BufZonesLayer();

            propForm.ZoneLayerName     = layerInfo.m_Name;
            propForm.Description       = layerInfo.m_Description;
            propForm.PivotalLayer      = layerInfo.m_PivotalLayer;
            propForm.PivotComboEnabled = false;
            if (propForm.ShowDialog(this) == DialogResult.OK)
            {
                var msgCaption = Resources.DbLayersForm_MsgBoxCaption;
                var msgText    = Resources.DbLayersForm_SaveMetadataMsg;
                if (MessageForm.Show(msgText, msgCaption, MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
                layerInfo.m_Name        = propForm.ZoneLayerName;
                layerInfo.m_Description = propForm.Description;
                try
                {
                    UserDbLayersManager.UpdateUserLayerMetadata(layerInfo);
                }
                catch (Exception)
                {
                    ErrorForm.ShowErrorDirect(Resources.DbLayersForm_FailedToSaveMetadata);
                    return;
                }
                RefreshUserLayers();
            }
        }
Beispiel #5
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();
                }
            }
        }
Beispiel #6
0
        private DialogResult ApplyMovement(bool clearSelection)
        {
            var dialogResult = MessageBox.Show(Resources.gis_MtSelectBufZones_BZApplyWarning, "",
                                               MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                m_IsMoveMode = false;

                //apply changes
                m_MiMove.Visible           = true;
                m_MiApplyMovement.Visible  = false;
                m_MiCancelMovement.Visible = false;

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

                if (clearSelection)
                {
                    m_SelectedFeature = null;
                }

                m_GeomBeforeEdit = null;
                MapImage.RefreshFromCache();
                UnsubscribeApplyEvents();
            }
            else if (dialogResult == DialogResult.No)
            {
                m_IsMoveMode = false;
                UndoMovement(clearSelection);
            }

            return(dialogResult);
        }