Ejemplo n.º 1
0
        private void AddRuleButton_Click(object sender, EventArgs e)
        {
            if (m_point != null)
            {
                IPointRule prt = _factory.CreateDefaultPointRule();
                int        idx = m_point.RuleCount;
                conditionList.AddRuleControl(prt, idx).Focus();
                m_point.AddRule(prt);
            }
            else if (m_line != null)
            {
                ILineRule lrt = _factory.CreateDefaultLineRule();
                int       idx = m_line.RuleCount;
                conditionList.AddRuleControl(lrt, idx).Focus();
                m_line.AddRule(lrt);
            }
            else if (m_area != null)
            {
                IAreaRule art = _factory.CreateDefaultAreaRule();
                int       idx = m_area.RuleCount;
                conditionList.AddRuleControl(art, idx).Focus();
                m_area.AddRule(art);
            }
            else if (m_comp != null)
            {
                ICompositeRule cr  = _factory.CreateDefaultCompositeRule();
                int            idx = m_area.RuleCount;
                conditionList.AddRuleControl(cr, idx).Focus();
                m_comp.AddCompositeRule(cr);
            }

            ItemChanged?.Invoke(this, null);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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;
                }
            }
        }