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; } }
/// <summary> /// Sets the default color. /// </summary> /// <param name="style">The style.</param> /// <param name="c">The c.</param> public static void SetDefaultColor(this IGridSurfaceStyle style, Color c) { Check.NotNull(style, "style"); //NOXLATE style.DefaultColor = Utility.SerializeHTMLColor(c, true); }
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; } }