Beispiel #1
0
        /// <summary>
        /// Sets the initial state of this editor and sets up any databinding
        /// within such that user interface changes will propagate back to the
        /// model.
        /// </summary>
        /// <param name="service"></param>
        public override void Bind(IEditorService service)
        {
            _edsvc = service;
            _rldf  = (IRasterLayerDefinition)((ILayerDefinition)_edsvc.GetEditedResource()).SubLayer;
            _edsvc.RegisterCustomNotifier(this);
            rasterLayerSettingsSectionCtrl.Bind(_edsvc);
            rasterLayerVisibilitySectionCtrl.Bind(_edsvc);
            rasterLayerAdvancedSectionCtrl.Bind(_edsvc);

            //Add watermark component if supported
            var sl2 = _rldf as ISubLayerDefinition2;

            if (sl2 != null)
            {
                this.Controls.Remove(rasterLayerSettingsSectionCtrl);
                this.Controls.Remove(rasterLayerVisibilitySectionCtrl);
                this.Controls.Remove(rasterLayerAdvancedSectionCtrl);

                var wm = new WatermarkCollectionEditorCtrl(service, sl2);
                wm.Dock = DockStyle.Top;

                this.Controls.Add(wm);
                this.Controls.Add(rasterLayerAdvancedSectionCtrl);
                this.Controls.Add(rasterLayerVisibilitySectionCtrl);
                this.Controls.Add(rasterLayerSettingsSectionCtrl);
            }
        }
Beispiel #2
0
        private void InitScaleRanges(IRasterLayerDefinition rl)
        {
            List <double> scales = new List <double>();

            foreach (var gsr in rl.GridScaleRange)
            {
                if (gsr.MinScale.HasValue)
                {
                    scales.Add(gsr.MinScale.Value);
                }
                else
                {
                    scales.Add(0.0);
                }

                if (gsr.MaxScale.HasValue)
                {
                    scales.Add(gsr.MaxScale.Value);
                }
                else
                {
                    scales.Add(InfinityScale);
                }
            }
            _scaleRanges = scales.ToArray();
            EnsureOrderedMinMaxScales();
        }
        public override void Bind(IEditorService service)
        {
            _init = true;
            try
            {
                _edsvc = service;
                _edsvc.RegisterCustomNotifier(this);
                _rl = (IRasterLayerDefinition)((ILayerDefinition)service.GetEditedResource()).SubLayer;

                _activeRange = _rl.GetScaleRangeAt(0);
                _colorStyle = _activeRange.ColorStyle;

                _backgroundColor = _colorStyle.GetColorRuleAt(0);
                _foregroundColor = _colorStyle.GetColorRuleAt(1);

                txtVisibleFrom.Text = (_activeRange.MinScale.HasValue ? _activeRange.MinScale.Value : 0).ToString();
                txtRebuildFactor.Text = _activeRange.RebuildFactor.ToString();
                cmbVisibleTo.Text = (_activeRange.MaxScale.HasValue ? _activeRange.MaxScale.Value.ToString() : Strings.Infinity);

                string fg = _foregroundColor.Color.GetValue();
                string bg = _backgroundColor.Color.GetValue();

                if (!string.IsNullOrEmpty(fg))
                    cmbForegroundColor.CurrentColor = Utility.ParseHTMLColor(fg);
                if (!string.IsNullOrEmpty(bg))
                    cmbBackgroundColor.CurrentColor = Utility.ParseHTMLColor(bg);
            }
            finally
            {
                _init = false;
            }
        }
Beispiel #4
0
 /// <summary>
 /// Sets the initial state of this editor and sets up any databinding
 /// within such that user interface changes will propagate back to the
 /// model.
 /// </summary>
 /// <param name="service"></param>
 public override void Bind(IEditorService service)
 {
     _edsvc = service;
     _rldf = (IRasterLayerDefinition)((ILayerDefinition)_edsvc.GetEditedResource()).SubLayer;
     _edsvc.RegisterCustomNotifier(this);
     rasterLayerSettingsSectionCtrl.Bind(_edsvc);
     rasterLayerVisibilitySectionCtrl.Bind(_edsvc);
     rasterLayerAdvancedSectionCtrl.Bind(_edsvc);
 }
Beispiel #5
0
 /// <summary>
 /// Sets the initial state of this editor and sets up any databinding
 /// within such that user interface changes will propagate back to the
 /// model.
 /// </summary>
 /// <param name="service"></param>
 public override void Bind(IEditorService service)
 {
     _edsvc = service;
     _rldf  = (IRasterLayerDefinition)((ILayerDefinition)_edsvc.GetEditedResource()).SubLayer;
     _edsvc.RegisterCustomNotifier(this);
     rasterLayerSettingsSectionCtrl.Bind(_edsvc);
     rasterLayerVisibilitySectionCtrl.Bind(_edsvc);
     rasterLayerAdvancedSectionCtrl.Bind(_edsvc);
 }
        /// <summary>
        /// Returns the associated spatial context for this Layer Definition
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        public static IFdoSpatialContext GetSpatialContext(this ILayerDefinition layer)
        {
            Check.NotNull(layer, "layer"); //NOXLATE
            if (layer.CurrentConnection == null)
            {
                throw new System.Exception(OSGeo.MapGuide.MaestroAPI.Strings.ErrorNoServerConnectionAttached);
            }

            var conn  = layer.CurrentConnection;
            var ltype = layer.SubLayer.LayerType;

            if (ltype == LayerType.Vector ||
                ltype == LayerType.Raster)
            {
                var sContexts = conn.FeatureService.GetSpatialContextInfo(layer.SubLayer.ResourceId, false);
                if (ltype == LayerType.Vector)
                {
                    IVectorLayerDefinition vl = (IVectorLayerDefinition)layer.SubLayer;
                    var clsDef = conn.FeatureService.GetClassDefinition(vl.ResourceId, vl.FeatureName);
                    var geom   = clsDef.FindProperty(vl.Geometry) as GeometricPropertyDefinition;
                    if (geom != null)
                    {
                        var sc = FindSpatialContext(sContexts, geom.SpatialContextAssociation);
                        return(sc);
                    }
                    return(null);
                }
                else if (ltype == LayerType.Raster)
                {
                    IRasterLayerDefinition rl = (IRasterLayerDefinition)layer.SubLayer;
                    var clsDef = conn.FeatureService.GetClassDefinition(rl.ResourceId, rl.FeatureName);
                    var geom   = clsDef.FindProperty(rl.Geometry) as RasterPropertyDefinition;
                    if (geom != null)
                    {
                        var sc = FindSpatialContext(sContexts, geom.SpatialContextAssociation);
                        return(sc);
                    }
                    return(null);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #7
0
        public override void Bind(IEditorService service)
        {
            _edsvc = service;
            _edsvc.RegisterCustomNotifier(this);

            var res = service.GetEditedResource() as ILayerDefinition;

            Debug.Assert(res != null);

            _rl = res.SubLayer as IRasterLayerDefinition;
            Debug.Assert(_rl != null);

            TextBoxBinder.BindText(txtFeatureSource, _rl, nameof(_rl.ResourceId));
            TextBoxBinder.BindText(txtFeatureClass, _rl, nameof(_rl.FeatureName));
            TextBoxBinder.BindText(txtGeometry, _rl, nameof(_rl.Geometry));
            _rl.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(OnRasterLayerPropertyChanged, (eh) => _rl.PropertyChanged -= eh);
        }
Beispiel #8
0
            /// <summary>
            /// Returns the associated spatial context for this Layer Definition
            /// </summary>
            /// <param name="layer">The layer definition</param>
            /// <param name="conn">The server connection</param>
            /// <returns>The associated spatial context</returns>
            public static IFdoSpatialContext GetSpatialContext(this ILayerDefinition layer, IServerConnection conn)
            {
                Check.ArgumentNotNull(layer, nameof(layer));
                Check.ArgumentNotNull(conn, nameof(conn));
                var ltype = layer.SubLayer.LayerType;

                if (ltype == LayerType.Vector ||
                    ltype == LayerType.Raster)
                {
                    var sContexts = conn.FeatureService.GetSpatialContextInfo(layer.SubLayer.ResourceId, false);
                    if (ltype == LayerType.Vector)
                    {
                        IVectorLayerDefinition vl = (IVectorLayerDefinition)layer.SubLayer;
                        var clsDef = conn.FeatureService.GetClassDefinition(vl.ResourceId, vl.FeatureName);
                        var geom   = clsDef.FindProperty(vl.Geometry) as GeometricPropertyDefinition;
                        if (geom != null)
                        {
                            var sc = FindSpatialContext(sContexts, geom.SpatialContextAssociation);
                            return(sc);
                        }
                        return(null);
                    }
                    else if (ltype == LayerType.Raster)
                    {
                        IRasterLayerDefinition rl = (IRasterLayerDefinition)layer.SubLayer;
                        var clsDef = conn.FeatureService.GetClassDefinition(rl.ResourceId, rl.FeatureName);
                        var geom   = clsDef.FindProperty(rl.Geometry) as RasterPropertyDefinition;
                        if (geom != null)
                        {
                            var sc = FindSpatialContext(sContexts, geom.SpatialContextAssociation);
                            return(sc);
                        }
                        return(null);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        public override void Bind(IEditorService service)
        {
            _init = true;
            try
            {
                _edsvc = service;
                _edsvc.RegisterCustomNotifier(this);
                _rl = (IRasterLayerDefinition)((ILayerDefinition)service.GetEditedResource()).SubLayer;

                _activeRange = _rl.GetScaleRangeAt(0);
                _colorStyle  = _activeRange.ColorStyle;

                _backgroundColor = _colorStyle.GetColorRuleAt(0);
                _foregroundColor = _colorStyle.GetColorRuleAt(1);

                txtVisibleFrom.Text   = (_activeRange.MinScale.HasValue ? _activeRange.MinScale.Value : 0).ToString();
                txtRebuildFactor.Text = _activeRange.RebuildFactor.ToString();
                cmbVisibleTo.Text     = (_activeRange.MaxScale.HasValue ? _activeRange.MaxScale.Value.ToString() : Strings.Infinity);

                string fg = _foregroundColor.Color.GetValue();
                string bg = _backgroundColor.Color.GetValue();

                if (!string.IsNullOrEmpty(fg))
                {
                    cmbForegroundColor.CurrentColor = Utility.ParseHTMLColor(fg);
                }
                if (!string.IsNullOrEmpty(bg))
                {
                    cmbBackgroundColor.CurrentColor = Utility.ParseHTMLColor(bg);
                }
            }
            finally
            {
                _init = false;
            }
        }
        public override void Bind(IEditorService service)
        {
            _edsvc = service;
            _edsvc.RegisterCustomNotifier(this);

            var res = service.GetEditedResource() as ILayerDefinition;
            Debug.Assert(res != null);

            _rl = res.SubLayer as IRasterLayerDefinition;
            Debug.Assert(_rl != null);

            TextBoxBinder.BindText(txtFeatureSource, _rl, "ResourceId"); //NOXLATE
            TextBoxBinder.BindText(txtFeatureClass, _rl, "FeatureName"); //NOXLATE
            TextBoxBinder.BindText(txtGeometry, _rl, "Geometry"); //NOXLATE
            _rl.PropertyChanged += OnRasterLayerPropertyChanged;
        }
Beispiel #11
0
        private void InitScaleRanges(IRasterLayerDefinition rl)
        {
            List<double> scales = new List<double>();
            foreach (var gsr in rl.GridScaleRange)
            {
                if (gsr.MinScale.HasValue)
                    scales.Add(gsr.MinScale.Value);
                else
                    scales.Add(0.0);

                if (gsr.MaxScale.HasValue)
                    scales.Add(gsr.MaxScale.Value);
                else
                    scales.Add(InfinityScale);
            }
            _scaleRanges = scales.ToArray();
            EnsureOrderedMinMaxScales();
        }
Beispiel #12
0
        public override void Bind(IEditorService service)
        {
            _init = true;
            try
            {
                _edsvc = service;
                _rl    = (IRasterLayerDefinition)((ILayerDefinition)service.GetEditedResource()).SubLayer;
                _edsvc.RegisterCustomNotifier(this);

                //Set active range. There has to be one!
                _activeRange = _rl.GetScaleRangeAt(0);

                //Assign color style. If this range has none, we'll create
                //one and assign that. Changing the checkbox will attach/detach
                //this object
                if (_activeRange.ColorStyle == null)
                {
                    _colorStyle = _activeRange.CreateColorStyle();
                }
                else
                {
                    _colorStyle = _activeRange.ColorStyle;
                }

                //Assign surface style. If this range has none, we'll create
                //one and assign that. Changing the checkbox will attach/detach
                //this object
                if (_activeRange.SurfaceStyle == null)
                {
                    _surfaceStyle = _activeRange.CreateSurfaceStyle();
                }
                else
                {
                    _surfaceStyle = _activeRange.SurfaceStyle;
                }

                if (_colorStyle.HillShade == null)
                {
                    _hillShade = _colorStyle.CreateHillShade();
                }
                else
                {
                    _hillShade = _colorStyle.HillShade;
                }

                txtBrightnessFactor.Text = _colorStyle.BrightnessFactor.HasValue ? _colorStyle.BrightnessFactor.Value.ToString() : "0"; //NOXLATE
                txtContrastFactor.Text   = _colorStyle.ContrastFactor.HasValue ? _colorStyle.ContrastFactor.Value.ToString() : "0";     //NOXLATE

                if (!string.IsNullOrEmpty(_colorStyle.TransparencyColor))
                {
                    cmbTransparencyColor.CurrentColor = Utility.ParseHTMLColor(_colorStyle.TransparencyColor);
                }

                txtHillshadeAltitude.Text    = _hillShade.Altitude.ToString();
                txtHillshadeAzimuth.Text     = _hillShade.Azimuth.ToString();
                txtHillshadeBand.Text        = _hillShade.Band;
                txtHillshadeScaleFactor.Text = _hillShade.ScaleFactor.ToString();

                txtSurfaceBand.Text        = _surfaceStyle.Band;
                txtSurfaceScaleFactor.Text = _surfaceStyle.ScaleFactor.ToString();
                txtSurfaceZeroValue.Text   = _surfaceStyle.ZeroValue.ToString();

                if (!string.IsNullOrEmpty(_surfaceStyle.DefaultColor))
                {
                    cmbSurfaceDefaultColor.CurrentColor = Utility.ParseHTMLColor(_surfaceStyle.DefaultColor);
                }

                chkAdvanced.Checked         = _colorStyle.ContrastFactor.HasValue && _colorStyle.BrightnessFactor.HasValue && !string.IsNullOrEmpty(_colorStyle.TransparencyColor);
                txtBrightnessFactor.Enabled = txtContrastFactor.Enabled = cmbTransparencyColor.Enabled = chkAdvanced.Checked;
                EnableSurface.Checked       = (_activeRange.SurfaceStyle != null);
                EnableHillshade.Checked     = (_colorStyle.HillShade != null);
            }
            finally
            {
                _init = false;
            }
        }
        public override void Run()
        {
            var wb = Workbench.Instance;

            if (wb != null)
            {
                if (wb.ActiveSiteExplorer != null)
                {
                    var items = wb.ActiveSiteExplorer.SelectedItems;
                    if (items.Length == 1)
                    {
                        var it = items[0];
                        if (it.ResourceType == ResourceTypes.LayerDefinition.ToString())
                        {
                            var connMgr = ServiceRegistry.GetService <ServerConnectionManager>();
                            var conn    = connMgr.GetConnection(wb.ActiveSiteExplorer.ConnectionName);
                            BusyWaitDialog.Run(Strings.RetrievingSpatialContextForLayer,
                                               () =>
                            {
                                var resId = it.ResourceId;
                                var ldf   = (ILayerDefinition)conn.ResourceService.GetResource(resId);

                                //If selected item is a Layer, it must be pointing to a Feature Source and not a Drawing Source
                                if (ldf.SubLayer.ResourceId.EndsWith(ResourceTypes.FeatureSource.ToString()))
                                {
                                    var ltype = ldf.SubLayer.LayerType;
                                    if (ltype == LayerType.Vector ||
                                        ltype == LayerType.Raster)
                                    {
                                        var sc = ldf.GetSpatialContext(conn);
                                        if (sc == null)
                                        {
                                            if (ltype == LayerType.Vector)
                                            {
                                                IVectorLayerDefinition vl = (IVectorLayerDefinition)ldf.SubLayer;
                                                throw new SpatialContextNotFoundException(string.Format(Strings.GeometryPropertyNotFound, vl.Geometry));
                                            }
                                            else //Raster
                                            {
                                                IRasterLayerDefinition rl = (IRasterLayerDefinition)ldf.SubLayer;
                                                throw new SpatialContextNotFoundException(string.Format(Strings.RasterPropertyNotFound, rl.Geometry));
                                            }
                                        }
                                        return(sc);
                                    }
                                    else
                                    {
                                        throw new SpatialContextNotFoundException(string.Format(Strings.NonApplicableLayerType, ldf.SubLayer.LayerType));
                                    }
                                }
                                else
                                {
                                    throw new SpatialContextNotFoundException(string.Format(Strings.NonApplicableLayerType, ldf.SubLayer.LayerType));
                                }
                            }, (res, ex) =>
                            {
                                if (ex != null)
                                {
                                    var nf = ex as SpatialContextNotFoundException;
                                    if (nf != null)
                                    {
                                        MessageService.ShowMessage(nf.Message);
                                    }
                                    else
                                    {
                                        ErrorDialog.Show(ex);
                                    }
                                }
                                else
                                {
                                    var sc = res as IFdoSpatialContext;
                                    if (sc != null)
                                    {
                                        new SpatialContextInfoDialog(sc).ShowDialog();
                                    }
                                }
                            });
                        }
                    }
                }
            }
        }
        public override void Bind(IEditorService service)
        {
            _init = true;
            try
            {
                _edsvc = service;
                _rl = (IRasterLayerDefinition)((ILayerDefinition)service.GetEditedResource()).SubLayer;
                _edsvc.RegisterCustomNotifier(this);

                //Set active range. There has to be one!
                _activeRange = _rl.GetScaleRangeAt(0);

                //Assign color style. If this range has none, we'll create
                //one and assign that. Changing the checkbox will attach/detach
                //this object
                if (_activeRange.ColorStyle == null)
                    _colorStyle = _activeRange.CreateColorStyle();
                else
                    _colorStyle = _activeRange.ColorStyle;

                //Assign surface style. If this range has none, we'll create
                //one and assign that. Changing the checkbox will attach/detach
                //this object
                if (_activeRange.SurfaceStyle == null)
                    _surfaceStyle = _activeRange.CreateSurfaceStyle();
                else
                    _surfaceStyle = _activeRange.SurfaceStyle;

                if (_colorStyle.HillShade == null)
                    _hillShade = _colorStyle.CreateHillShade();
                else
                    _hillShade = _colorStyle.HillShade;

                txtBrightnessFactor.Text = _colorStyle.BrightnessFactor.HasValue ? _colorStyle.BrightnessFactor.Value.ToString() : "0"; //NOXLATE
                txtContrastFactor.Text = _colorStyle.ContrastFactor.HasValue ? _colorStyle.ContrastFactor.Value.ToString() : "0"; //NOXLATE

                if (!string.IsNullOrEmpty(_colorStyle.TransparencyColor))
                {
                    cmbTransparencyColor.CurrentColor = Utility.ParseHTMLColor(_colorStyle.TransparencyColor);
                }

                txtHillshadeAltitude.Text = _hillShade.Altitude.ToString();
                txtHillshadeAzimuth.Text = _hillShade.Azimuth.ToString();
                txtHillshadeBand.Text = _hillShade.Band;
                txtHillshadeScaleFactor.Text = _hillShade.ScaleFactor.ToString();

                txtSurfaceBand.Text = _surfaceStyle.Band;
                txtSurfaceScaleFactor.Text = _surfaceStyle.ScaleFactor.ToString();
                txtSurfaceZeroValue.Text = _surfaceStyle.ZeroValue.ToString();

                if (!string.IsNullOrEmpty(_surfaceStyle.DefaultColor))
                    cmbSurfaceDefaultColor.CurrentColor = Utility.ParseHTMLColor(_surfaceStyle.DefaultColor);

                chkAdvanced.Checked = _colorStyle.ContrastFactor.HasValue && _colorStyle.BrightnessFactor.HasValue && !string.IsNullOrEmpty(_colorStyle.TransparencyColor);
                txtBrightnessFactor.Enabled = txtContrastFactor.Enabled = cmbTransparencyColor.Enabled = chkAdvanced.Checked;
                EnableSurface.Checked = (_activeRange.SurfaceStyle != null);
                EnableHillshade.Checked = (_colorStyle.HillShade != null);
            }
            finally
            {
                _init = false;
            }
        }