private void EnsurePointStyle() { if (_pts == null) { _pts = _editedLayer.CreateDefaultPointStyle(); } }
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; } }
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; } }
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); }
private void GeneratePointThemeRules(List<RuleItem> rules, IPointVectorStyle col) { string fillAlpha = ""; IPointRule template = null; if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0) { template = col.GetRuleAt(0); var sym = template.PointSymbolization2D.Symbol; if (sym.Type == PointSymbolType.Mark) { string htmlColor = ((IMarkSymbol)sym).Fill.ForegroundColor; if (htmlColor.Length == 8) fillAlpha = htmlColor.Substring(0, 2); } else if (sym.Type == PointSymbolType.Font) { string htmlColor = ((IFontSymbol)sym).ForegroundColor; if (htmlColor.Length == 8) fillAlpha = htmlColor.Substring(0, 2); } } if (OverwriteRules.Checked) col.RemoveAllRules(); foreach (RuleItem entry in rules) { IPointRule r = (template != null) ? CreatePointRule(template, _factory) : _factory.CreateDefaultPointRule(); r.Filter = entry.Filter; r.LegendLabel = entry.Label; var sym = r.PointSymbolization2D.Symbol; if (sym.Type == PointSymbolType.Mark) { ((IMarkSymbol)sym).Fill.ForegroundColor = fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha)); } else if (sym.Type == PointSymbolType.Font) { ((IFontSymbol)sym).ForegroundColor = fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha)); } col.AddRule(r); } }
private void ReSyncBindingListToRules(IVectorStyle style) { if (style != null) { switch (style.StyleType) { case StyleType.Point: { IPointVectorStyle pts = style as IPointVectorStyle; pts.RemoveAllRules(); for (int i = 0; i < _rules.Count; i++) { ILabeledRuleModel rule = (ILabeledRuleModel)_rules[i]; IPointRule pr = (IPointRule)rule.UnwrapRule(); pts.AddRule(pr); rule.SetIndex(i); } } break; case StyleType.Line: { ILineVectorStyle lts = style as ILineVectorStyle; lts.RemoveAllRules(); for (int i = 0; i < _rules.Count; i++) { ILabeledRuleModel rule = (ILabeledRuleModel)_rules[i]; ILineRule lr = (ILineRule)rule.UnwrapRule(); lts.AddRule(lr); rule.SetIndex(i); } } break; case StyleType.Area: { IAreaVectorStyle ats = style as IAreaVectorStyle; ats.RemoveAllRules(); for (int i = 0; i < _rules.Count; i++) { ILabeledRuleModel rule = (ILabeledRuleModel)_rules[i]; IAreaRule ar = (IAreaRule)rule.UnwrapRule(); ats.AddRule(ar); rule.SetIndex(i); } } break; case StyleType.Composite: { ICompositeTypeStyle cts = style as ICompositeTypeStyle; cts.RemoveAllRules(); for (int i = 0; i < _rules.Count; i++) { IRuleModel rule = (IRuleModel)_rules[i]; ICompositeRule cr = (ICompositeRule)rule.UnwrapRule(); cts.AddCompositeRule(cr); rule.SetIndex(i); } } break; } } }
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, IPointVectorStyle point) { SetItemInternal(parent, point); }
public void SetItem(IVectorScaleRange parent, IPointVectorStyle point) { SetItemInternal(parent, point); conditionList.SetItem(parent, point); }
public async Task WritePointStyleFunctionAsync(StreamWriter sw, IVectorLayerDefinition vl, IPointVectorStyle pointStyle) { await sw.WriteLineAsync(INDENT + "var fillColor;"); await sw.WriteLineAsync(INDENT + "var edgeColor;"); await sw.WriteLineAsync(INDENT + "var edgeThickness;"); await sw.WriteLineAsync(INDENT + "var pointRadius = 10;"); var sb = new StringBuilder(512); var defaultRuleBlock = ""; var themes = new List <(string conditon, string filter, string block)>(); await sw.WriteLineAsync(INDENT + "var pointStyle = OLPointCircle;"); foreach (var rule in pointStyle.Rules) { if (rule.PointSymbolization2D != null) { if (string.IsNullOrEmpty(rule.Filter)) //No filter = default rule effectively { if (string.IsNullOrEmpty(defaultRuleBlock)) { BuildPointRuleAssignment(sb, rule.PointSymbolization2D.Symbol as IMarkSymbol); defaultRuleBlock = sb.ToString(); } } else { //Parse this filter and see if it's translateable var filter = FdoFilter.Parse(rule.Filter); var check = TryTranslateFdoFilter(filter, _featureVarName); BuildPointRuleAssignment(sb, rule.PointSymbolization2D.Symbol as IMarkSymbol); themes.Add((check, rule.Filter, sb.ToString())); } } } //Now write out the theme if (themes.Count > 0) { bool bFirst = true; foreach (var th in themes) { if (bFirst) { await sw.WriteLineAsync(INDENT + $"if ({th.conditon}) {{ // Translated from rule filter: {th.filter}"); await sw.WriteLineAsync(th.block); await sw.WriteLineAsync(INDENT + "}"); } else { await sw.WriteLineAsync(INDENT + $"else if ({th.conditon}) {{ // Translated from rule filter: {th.filter}"); await sw.WriteLineAsync(th.block); await sw.WriteLineAsync(INDENT + "}"); } bFirst = false; } if (!string.IsNullOrEmpty(defaultRuleBlock)) { await sw.WriteLineAsync(INDENT + $"else {{ // Default rule"); await sw.WriteLineAsync(defaultRuleBlock); await sw.WriteLineAsync(INDENT + "}"); } } else { await sw.WriteLineAsync("//Default rule"); await sw.WriteLineAsync(defaultRuleBlock); } await sw.WriteLineAsync(INDENT + "var style = {"); await sw.WriteLineAsync(INDENT + INDENT + "radius: pointRadius,"); await sw.WriteLineAsync(INDENT + INDENT + $"fill: new ol.style.Fill({{ color: fillColor }}),"); await sw.WriteLineAsync(INDENT + INDENT + $"stroke: new ol.style.Stroke({{ color: edgeColor, width: edgeThickness }})"); await sw.WriteLineAsync(INDENT + "}"); await sw.WriteLineAsync(INDENT + "return new ol.style.Style({ image: pointStyle(style) });"); }