public ExplodeThemeDialog(IEditorService editor, IVectorScaleRange parentRange, IVectorStyle style, ILayerDefinition parentLayer) : this() { if (style.StyleType == StyleType.Composite) { throw new NotSupportedException(Strings.ErrorExplodingCompositeStyleNotSupported); } _editor = editor; _style = style; _parentRange = parentRange; _parentLayer = parentLayer; txtLayersCreate.Text = style.RuleCount.ToString(CultureInfo.InvariantCulture); txtLayerNameFormat.Text = "{0} - {1} - {2}"; //NOXLATE EvaluateStates(); if (!_editor.IsNew) { txtLayerPrefix.Text = ResourceIdentifier.GetName(_editor.ResourceID); } else { txtLayerPrefix.Text = "Theme"; //NOXLATE } }
private void SetItemInternal(IVectorScaleRange parent, object item) { m_parent = parent; m_point = item as IPointVectorStyle; m_line = item as ILineVectorStyle; m_area = item as IAreaVectorStyle; m_comp = item as ICompositeTypeStyle; this.Controls.Clear(); try { this.Visible = false; this.SuspendLayout(); if (m_point != null) { int idx = 0; foreach (IPointRule prt in m_point.Rules) { AddRuleControl(prt, idx); idx++; } } else if (m_line != null) { int idx = 0; foreach (ILineRule lrt in m_line.Rules) { AddRuleControl(lrt, idx); idx++; } } else if (m_area != null) { int idx = 0; foreach (IAreaRule art in m_area.Rules) { AddRuleControl(art, idx); idx++; } } else if (m_comp != null) { int idx = 0; foreach (ICompositeRule comp in m_comp.CompositeRule) { AddRuleControl(comp, idx); idx++; } } } finally { this.ResumeLayout(); this.Visible = true; } }
void IVectorLayerDefinition.RemoveVectorScaleRange(IVectorScaleRange range) { var r = range as VectorScaleRangeType; if (r != null) { this.VectorScaleRange.Remove(r); } }
public VectorScaleRangeGrid(IVectorScaleRange vsr, VectorLayerStyleSectionCtrl parent) : this() { try { _init = true; _parent = parent; _editedLayer = (ILayerDefinition)_parent.EditorService.GetEditedResource(); _vsr = vsr; _pts = _vsr.PointStyle; _lts = _vsr.LineStyle; _ats = _vsr.AreaStyle; chkPoints.Checked = (_pts != null); chkLine.Checked = (_lts != null); chkArea.Checked = (_ats != null); var vsr2 = _vsr as IVectorScaleRange2; if (vsr2 != null) { _cts = new BindingList <ICompositeTypeStyle>(); if (chkArea.Checked || chkLine.Checked || chkArea.Checked) { chkComposite.Checked = false; } else { foreach (var r in vsr2.CompositeStyle) { _cts.Add(r); } chkComposite.Checked = (vsr2.CompositeStyleCount > 0); } } else { chkComposite.Visible = false; SetCompositeTabVisibility(false); } SetPointUI(); SetLineUI(); SetAreaUI(); SetCompositeUI(); pointRuleGrid.Init(_parent.EditorService, _vsr, _vsr.PointStyle); lineRuleGrid.Init(_parent.EditorService, _vsr, _vsr.LineStyle); areaRuleGrid.Init(_parent.EditorService, _vsr, _vsr.AreaStyle); } finally { _init = false; } }
public VectorScaleRangeGrid(IVectorScaleRange vsr, VectorLayerStyleSectionCtrl parent) : this() { try { _init = true; _parent = parent; _editedLayer = (ILayerDefinition)_parent.EditorService.GetEditedResource(); _vsr = vsr; _pts = _vsr.PointStyle; _lts = _vsr.LineStyle; _ats = _vsr.AreaStyle; chkPoints.Checked = (_pts != null); chkLine.Checked = (_lts != null); chkArea.Checked = (_ats != null); var vsr2 = _vsr as IVectorScaleRange2; if (vsr2 != null) { _cts = new BindingList<ICompositeTypeStyle>(); if (chkArea.Checked || chkLine.Checked || chkArea.Checked) { chkComposite.Checked = false; } else { foreach (var r in vsr2.CompositeStyle) { _cts.Add(r); } chkComposite.Checked = (vsr2.CompositeStyleCount > 0); } } else { chkComposite.Visible = false; SetCompositeTabVisibility(false); } SetPointUI(); SetLineUI(); SetAreaUI(); SetCompositeUI(); pointRuleGrid.Init(_parent.EditorService, _vsr, _vsr.PointStyle); lineRuleGrid.Init(_parent.EditorService, _vsr, _vsr.LineStyle); areaRuleGrid.Init(_parent.EditorService, _vsr, _vsr.AreaStyle); } finally { _init = false; } }
int IVectorLayerDefinition.IndexOfScaleRange(IVectorScaleRange range) { var r = range as VectorScaleRangeType; if (r != null) { return(this.VectorScaleRange.IndexOf(r)); } return(-1); }
public void Init(IEditorService edSvc, IVectorScaleRange parentRange, IVectorStyle style) { try { _init = true; _edSvc = edSvc; _style = style; var p2 = style as IPointVectorStyle2; var l2 = style as ILineVectorStyle2; var a2 = style as IAreaVectorStyle2; var c2 = style as ICompositeTypeStyle2; btnShowInLegend.Visible = !(p2 == null && l2 == null && a2 == null && c2 == null); if (btnShowInLegend.Visible) { if (p2 != null) { btnShowInLegend.Checked = p2.ShowInLegend; } else if (l2 != null) { btnShowInLegend.Checked = l2.ShowInLegend; } else if (a2 != null) { btnShowInLegend.Checked = a2.ShowInLegend; } else if (c2 != null) { btnShowInLegend.Checked = c2.ShowInLegend; } } var pts = style as IPointVectorStyle; if (pts != null) { btnAllowOverpost.Checked = pts.AllowOverpost; btnDisplayAsText.Checked = pts.DisplayAsText; } else { btnAllowOverpost.Visible = btnDisplayAsText.Visible = false; } InitGrid(style is ICompositeTypeStyle); _editedLayer = (ILayerDefinition)_edSvc.GetEditedResource(); _parentScaleRange = parentRange; ReSyncRulesToBindingList(style); } finally { _init = false; } }
private static void CreateTracksLayer(IServerConnection conn, string resId, string layerId) { //We use the Utility class to create our layer. You can also use ObjectFactory, but //that requires explicitly specifying the resource version. Using Utility will pick //the latest supported version ILayerDefinition ldf = Utility.CreateDefaultLayer(conn, LayerType.Vector); IVectorLayerDefinition vldf = (IVectorLayerDefinition)ldf.SubLayer; //Set feature source vldf.ResourceId = resId; //Set the feature class vldf.FeatureName = "SHP_Schema:Rail"; //Set the designated geometry vldf.Geometry = "SHPGEOM"; //Get the first vector scale range. This will have been created for us and is 0 to infinity IVectorScaleRange vsr = vldf.GetScaleRangeAt(0); //Get the line style ILineVectorStyle lstyle = vsr.LineStyle; //Get the first rule (a created one will only have one) ILineRule rule = lstyle.GetRuleAt(0); //What are we doing here? We're checking if this vector scale range is a //IVectorScaleRange2 instance. If it is, it means this layer definition //has a composite style attached, which takes precedence over point/area/line //styles. We don't want this, so this removes the composite styles if they //exist. IVectorScaleRange2 vsr2 = vsr as IVectorScaleRange2; if (vsr2 != null) { vsr2.CompositeStyle = null; } //There's only one stroke here, but iteration is the only //way to go through foreach (var stroke in rule.Strokes) { //Set color to red stroke.Color = "ffff0000"; } //Now save it conn.ResourceService.SaveResourceAs(ldf, layerId); }
private void SetItemInternal(IVectorScaleRange parent, object item) { m_parent = parent; m_point = item as IPointVectorStyle; m_line = item as ILineVectorStyle; m_area = item as IAreaVectorStyle; m_comp = item as ICompositeTypeStyle; var ar2 = m_area as IAreaVectorStyle2; var pt2 = m_point as IPointVectorStyle2; var ln2 = m_line as ILineVectorStyle2; var cm2 = m_comp as ICompositeTypeStyle2; //Check if we're working with a 1.3.0 schema ShowInLegend.Enabled = (ar2 != null || pt2 != null || ln2 != null || cm2 != null); btnExplodeTheme.Enabled = (m_comp == null); }
/// <summary> /// Purge the specified scale range of the following styles /// </summary> /// <param name="range"></param> /// <param name="geomTypes">The geometry types to remove</param> public static void RemoveStyles(this IVectorScaleRange range, IEnumerable <string> geomTypes) { Check.NotNull(range, "range"); //NOXLATE Check.NotNull(geomTypes, "geomTypes"); //NOXLATE List <IVectorStyle> remove = new List <IVectorStyle>(); foreach (var geomType in geomTypes) { if (geomType.ToLower().Equals(FeatureGeometricType.Curve.ToString().ToLower())) { range.LineStyle = null; } else if (geomType.ToLower().Equals(FeatureGeometricType.Point.ToString().ToLower())) { range.PointStyle = null; } else if (geomType.ToLower().Equals(FeatureGeometricType.Surface.ToString().ToLower())) { range.AreaStyle = null; } } }
public async Task WritePointMarker(string varName, IVectorScaleRange vsr, StreamWriter sw) { //TODO: This should be offloaded to LeafletStyleTranslator await sw.WriteLineAsync("//Point feature function"); if (vsr.PointStyle != null && vsr.PointStyle.RuleCount > 0) { var pr = vsr.PointStyle.Rules.First(); if (pr.PointSymbolization2D != null && pr.PointSymbolization2D.Symbol is IMarkSymbol msm) { await sw.WriteLineAsync($"var {varName}_style_point = function(point, latlng) {{;"); switch (msm.Shape) { case ShapeType.Circle: await sw.WriteLineAsync(" return L.circleMarker(latlng);"); break; default: await sw.WriteLineAsync(" return L.marker(latlng);"); break; } await sw.WriteLineAsync("};"); } else { await sw.WriteLineAsync($"var {varName}_style_point = null;"); } } else { await sw.WriteLineAsync($"var {varName}_style_point = null;"); } }
public ExplodeThemeDialog(IEditorService editor, IVectorScaleRange parentRange, IVectorStyle style, ILayerDefinition parentLayer) : this() { if (style.StyleType == StyleType.Composite) throw new NotSupportedException(Strings.ErrorExplodingCompositeStyleNotSupported); _editor = editor; _style = style; _parentRange = parentRange; _parentLayer = parentLayer; txtLayersCreate.Text = style.RuleCount.ToString(CultureInfo.InvariantCulture); txtLayerNameFormat.Text = "{0} - {1} - {2}"; //NOXLATE EvaluateStates(); if (!_editor.IsNew) { txtLayerPrefix.Text = ResourceIdentifier.GetName(_editor.ResourceID); } else { txtLayerPrefix.Text = "Theme"; //NOXLATE } }
public VectorScaleRangeCtrl(IVectorScaleRange vsr, VectorLayerStyleSectionCtrl parent) { InitializeComponent(); _init = true; try { _parent = parent; _vsr = vsr; _pts = vsr.PointStyle; _lns = vsr.LineStyle; _ars = vsr.AreaStyle; chkPoints.Checked = true; chkLine.Checked = true; chkArea.Checked = true; chkComposite.Checked = true; chkPoints.Checked = (_pts != null); chkLine.Checked = (_lns != null); chkArea.Checked = (_ars != null); pointList.Owner = parent.Owner; lineList.Owner = parent.Owner; areaList.Owner = parent.Owner; pointList.Factory = parent.Factory; lineList.Factory = parent.Factory; areaList.Factory = parent.Factory; if (_pts == null) _pts = parent.Factory.CreateDefaultPointStyle(); chkDisplayAsText.Checked = _pts.DisplayAsText; chkAllowOverpost.Checked = _pts.AllowOverpost; if (_lns == null) _lns = parent.Factory.CreateDefaultLineStyle(); if (_ars == null) _ars = parent.Factory.CreateDefaultAreaStyle(); pointList.SetItem(vsr, _pts); lineList.SetItem(vsr, _lns); areaList.SetItem(vsr, _ars); if (_pts.RuleCount == 0) pointList.AddRule(); if (_lns.RuleCount == 0) lineList.AddRule(); if (_ars.RuleCount == 0) areaList.AddRule(); var vsr2 = vsr as IVectorScaleRange2; if (vsr2 != null) { _cts = new BindingList<ICompositeTypeStyle>(); foreach (var c in vsr2.CompositeStyle) _cts.Add(c); chkComposite.Checked = (_cts.Count > 0); compList.Owner = parent.Owner; compList.Factory = parent.Factory; if (_cts.Count == 0) _cts.Add(parent.Factory.CreateDefaultCompositeStyle()); compList.LoadStyles(vsr2, _cts); } else { chkComposite.Checked = false; } chkComposite.Enabled = (vsr2 != null); } finally { _init = false; } }
public VectorScaleRangeCtrl(IVectorScaleRange vsr, VectorLayerStyleSectionCtrl parent) { InitializeComponent(); _init = true; try { _parent = parent; _vsr = vsr; _pts = vsr.PointStyle; _lns = vsr.LineStyle; _ars = vsr.AreaStyle; chkPoints.Checked = true; chkLine.Checked = true; chkArea.Checked = true; chkComposite.Checked = true; chkPoints.Checked = (_pts != null); chkLine.Checked = (_lns != null); chkArea.Checked = (_ars != null); pointList.Owner = parent.Owner; lineList.Owner = parent.Owner; areaList.Owner = parent.Owner; pointList.Factory = parent.Factory; lineList.Factory = parent.Factory; areaList.Factory = parent.Factory; if (_pts == null) { _pts = parent.Factory.CreateDefaultPointStyle(); } chkDisplayAsText.Checked = _pts.DisplayAsText; chkAllowOverpost.Checked = _pts.AllowOverpost; if (_lns == null) { _lns = parent.Factory.CreateDefaultLineStyle(); } if (_ars == null) { _ars = parent.Factory.CreateDefaultAreaStyle(); } pointList.SetItem(vsr, _pts); lineList.SetItem(vsr, _lns); areaList.SetItem(vsr, _ars); if (_pts.RuleCount == 0) { pointList.AddRule(); } if (_lns.RuleCount == 0) { lineList.AddRule(); } if (_ars.RuleCount == 0) { areaList.AddRule(); } var vsr2 = vsr as IVectorScaleRange2; if (vsr2 != null) { _cts = new BindingList <ICompositeTypeStyle>(); foreach (var c in vsr2.CompositeStyle) { _cts.Add(c); } chkComposite.Checked = (_cts.Count > 0); compList.Owner = parent.Owner; compList.Factory = parent.Factory; if (_cts.Count == 0) { _cts.Add(parent.Factory.CreateDefaultCompositeStyle()); } compList.LoadStyles(vsr2, _cts); } else { chkComposite.Checked = false; } chkComposite.Enabled = (vsr2 != null); } finally { _init = false; } }
public void SetItem(IVectorScaleRange parent, ICompositeTypeStyle comp) { SetItemInternal(parent, comp); }
public void SetItem(IVectorScaleRange parent, IAreaVectorStyle area) { SetItemInternal(parent, area); }
public void SetItem(IVectorScaleRange parent, ILineVectorStyle line) { SetItemInternal(parent, line); }
public void SetItem(IVectorScaleRange parent, IAreaVectorStyle area) { SetItemInternal(parent, area); conditionList.SetItem(parent, area); }
public void SetItem(IVectorScaleRange parent, ILineVectorStyle line) { SetItemInternal(parent, line); conditionList.SetItem(parent, line); }
public void SetItem(IVectorScaleRange parent, IPointVectorStyle point) { SetItemInternal(parent, point); conditionList.SetItem(parent, point); }
/// <summary> /// String-ifies a scale range /// </summary> /// <param name="parentRange"></param> /// <returns></returns> public static string GetScaleRangeStr(IVectorScaleRange parentRange) { return string.Format("{0} to {1}", //NOXLATE parentRange.MinScale.HasValue ? parentRange.MinScale.Value.ToString(CultureInfo.InvariantCulture) : "0", //NOXLATE parentRange.MaxScale.HasValue ? parentRange.MaxScale.Value.ToString(CultureInfo.InvariantCulture) : "Infinity"); //NOXLATE }
public void SetItem(IVectorScaleRange parent, ICompositeTypeStyle comp) { SetItemInternal(parent, comp); conditionList.SetItem(parent, comp); }
/// <summary> /// Removes the styles. /// </summary> /// <param name="range">The range.</param> /// <param name="geomTypes">The geom types.</param> public static void RemoveStyles(this IVectorScaleRange range, params string[] geomTypes) { range.RemoveStyles(geomTypes); }
public void SetItem(IVectorScaleRange parent, IPointVectorStyle point) { SetItemInternal(parent, point); }
private void CreateDistrictsLayer(IServerConnection conn, string resId, string layerId) { //We use the Utility class to create our layer. You can also use ObjectFactory, but //that requires explicitly specifying the resource version. Using Utility will pick //the latest supported version ILayerDefinition ldf = Utility.CreateDefaultLayer(conn, LayerType.Vector); IVectorLayerDefinition vldf = (IVectorLayerDefinition)ldf.SubLayer; //Set feature source vldf.ResourceId = resId; //Set the feature class // //Note: In versions of the Sheboygan Dataset before 2.6, this used to be // // - Feature Class: SDF_2_Schema:VotingDistricts // - Identity Property: Autogenerated_SDF_ID // - Geometry Property: Data string featureClass = "Default:VotingDistricts"; string idProp = "FeatId"; string geometryProp = "Geometry"; vldf.FeatureName = featureClass; //Set the designated geometry vldf.Geometry = geometryProp; //Get the first vector scale range. This will have been created for us and is 0 to infinity IVectorScaleRange vsr = vldf.GetScaleRangeAt(0); //What are we doing here? We're checking if this vector scale range is a //IVectorScaleRange2 instance. If it is, it means this layer definition //has a composite style attached, which takes precedence over point/area/line //styles. We don't want this, so this removes the composite styles if they //exist. IVectorScaleRange2 vsr2 = vsr as IVectorScaleRange2; if (vsr2 != null) { vsr2.CompositeStyle = null; } //Get the area style IAreaVectorStyle astyle = vsr.AreaStyle; //Remove the default rule astyle.RemoveAllRules(); IFeatureService featSvc = conn.FeatureService; //Generate a random color for each distinct feature id //Perform a distinct value query IReader valueReader = featSvc.AggregateQueryFeatureSource(resId, featureClass, null, new NameValueCollection() { { "Value", "UNIQUE(" + idProp + ")" } //UNIQUE() is the aggregate function that collects all distinct values of FeatId }); while (valueReader.ReadNext()) { //The parent Layer Definition provides all the methods needed to create the necessary child elements IAreaRule rule = ldf.CreateDefaultAreaRule(); //Set the filter for this rule rule.Filter = idProp + " = " + valueReader["Value"].ToString(); //IReader allows object access by name in case you don't care to determine the data type rule.LegendLabel = valueReader["Value"].ToString(); //Assign a random color fill rule.AreaSymbolization2D.Fill.ForegroundColor = Utility.SerializeHTMLColor(RandomColor(), true); //Add this rule astyle.AddRule(rule); } valueReader.Close(); //Now save it conn.ResourceService.SaveResourceAs(ldf, layerId); }