コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
ファイル: VectorScaleRangeGrid.cs プロジェクト: kanbang/Colt
        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;
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: ThemeCreator.cs プロジェクト: kanbang/Colt
        private void GenerateLineThemeRules(List<RuleItem> rules, ILineVectorStyle col)
        {
            string bordAlpha = "";
            ILineRule template = null;
            if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
            {
                template = col.GetRuleAt(0);

                //TODO: Composite lines? Which "alpha" value wins there?
                foreach (var st in template.Strokes)
                {
                    if (st.Color.Length == 8)
                    {
                        bordAlpha = st.Color.Substring(0, 2);
                        break;
                    }
                }
            }

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

            foreach (RuleItem entry in rules)
            {
                var l = (template != null) ? CreateLineRule(template, _factory) : _factory.CreateDefaultLineRule();
                l.Filter = entry.Filter;
                l.LegendLabel = entry.Label;
                foreach (var st in l.Strokes)
                {
                    st.Color = bordAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(bordAlpha));
                }
                col.AddRule(l);
            }
        }
コード例 #7
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;
                }
            }
        }
コード例 #8
0
ファイル: VectorScaleRangeCtrl.cs プロジェクト: kanbang/Colt
        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;
            }
        }
コード例 #9
0
        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;
            }
        }
コード例 #10
0
ファイル: ConditionList.cs プロジェクト: kanbang/Colt
        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;
            }
        }
コード例 #11
0
ファイル: ConditionList.cs プロジェクト: kanbang/Colt
 public void SetItem(IVectorScaleRange parent, ILineVectorStyle line)
 {
     SetItemInternal(parent, line);
 }
コード例 #12
0
 public void SetItem(IVectorScaleRange parent, ILineVectorStyle line)
 {
     SetItemInternal(parent, line);
     conditionList.SetItem(parent, line);
 }
コード例 #13
0
        public async Task WriteLineStyleFunctionAsync(StreamWriter sw, IVectorLayerDefinition vl, ILineVectorStyle lineStyle)
        {
            await sw.WriteLineAsync(INDENT + "var edgeColor;");

            await sw.WriteLineAsync(INDENT + "var edgeThickness;");

            var sb = new StringBuilder(512);
            var defaultRuleBlock = "";
            var themes           = new List <(string conditon, string filter, string block)>();

            foreach (var rule in lineStyle.Rules)
            {
                if (rule.StrokeCount > 0)
                {
                    if (string.IsNullOrEmpty(rule.Filter)) //No filter = default rule effectively
                    {
                        if (string.IsNullOrEmpty(defaultRuleBlock))
                        {
                            BuildLineRuleAssignment(sb, rule);
                            defaultRuleBlock = sb.ToString();
                        }
                    }
                    else
                    {
                        //Parse this filter and see if it's translateable
                        var filter = FdoFilter.Parse(rule.Filter);
                        var check  = TryTranslateFdoFilter(filter, _featureVarName);
                        BuildLineRuleAssignment(sb, rule);
                        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 + $"stroke: new ol.style.Stroke({{ color: edgeColor, width: edgeThickness }})");

            await sw.WriteLineAsync(INDENT + "}");

            await sw.WriteLineAsync(INDENT + "return new ol.style.Style(style);");
        }
コード例 #14
0
ファイル: ConditionListButtons.cs プロジェクト: kanbang/Colt
        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);
        }