Exemple #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);
        }
Exemple #2
0
        private void GenerateCompositeThemeRules(List<RuleItem> rules, ICompositeTypeStyle col)
        {
            if (!chkUseFirstRuleAsTemplate.Checked || col.RuleCount == 0)
            {
                MessageBox.Show(Strings.CompositeThemeRequiresFirstRuleAsTemplate);
                return;
            }

            //TODO: Composite styles for lines probably don't have fill colors, as such theme rule generation
            //probably won't work for line styles atm

            FillColorSource? source = null;
            string fillAlpha = "";
            ICompositeRule template = null;
            if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
            {
                template = col.GetRuleAt(0);
                if (template.CompositeSymbolization != null)
                {
                    IdentifyColorSource(template, ref source, ref fillAlpha);
                }
            }

            if (OverwriteRules.Checked)
            {
                col.RemoveAllRules();
            }

            foreach (RuleItem entry in rules)
            {
                var r = (template != null) ? CreateCompositeRule(template, _factory) : _factory.CreateDefaultCompositeRule();
                Debug.WriteLine("Made rule {0}", r.GetHashCode());
                r.Filter = entry.Filter;
                r.LegendLabel = entry.Label;
                if (r.CompositeSymbolization != null)
                {
                    SetColorForCompositeRule(source, fillAlpha, entry, r);
                }

                col.AddCompositeRule(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;
                }
            }
        }