示例#1
0
        internal RedlineStyle GetUpdatedStyle()
        {
            var style = RedlineStyle.CreateDefault();

            style.LabelSizeUnits  = (SizeUnit)cmbLabelSizeUnits.SelectedItem;
            style.LineSizeUnits   = (SizeUnit)cmbLineThicknessUnit.SelectedItem;
            style.BorderSizeUnits = (SizeUnit)cmbPolyBorderThicknessUnit.SelectedItem;
            style.MarkerSizeUnits = (SizeUnit)cmbMarkerSizeUnit.SelectedItem;
            style.LinePattern     = (LinePattern)cmbLinePattern.SelectedItem;
            style.BorderPattern   = (LinePattern)cmbPolyBorderPattern.SelectedItem;
            style.FillPattern     = (FillPattern)cmbPolyFillPattern.SelectedItem;
            style.MarkerType      = (MarkerType)cmbPointMarkerType.SelectedItem;
            style.LabelBackStyle  = (LabelStyle)cmbLabelStyle.SelectedItem;

            style.LabelBackColor = clrLabelBackground.BackColor;
            style.LabelForeColor = clrLabelForeground.BackColor;
            style.FillBackColor  = clrPolyFillBackground.BackColor;
            style.FillForeColor  = clrPolyFillForeground.BackColor;
            style.LineColor      = clrLine.BackColor;
            style.MarkerColor    = clrMarker.BackColor;
            style.BorderColor    = clrPolyBorder.BackColor;

            style.FillTransparency = Math.Min(100.0, Convert.ToDouble(numFillTransparency.Value));

            style.LabelFontSize   = Convert.ToDouble(txtLabelSizeValue.Text);
            style.LineThickness   = Convert.ToDouble(txtLineThicknessValue.Text);
            style.MarkerSize      = Convert.ToDouble(txtMarkerSizeValue.Text);
            style.BorderThickness = Convert.ToDouble(txtPolyBorderThicknessValue.Text);

            style.LabelBold      = chkBold.Checked;
            style.LabelItalic    = chkItalic.Checked;
            style.LabelUnderline = chkUnderline.Checked;

            return(style);
        }
示例#2
0
        public RedlineStyle GetLayerStyle(RedlineLayer layer)
        {
            var style = RedlineStyle.CreateDefault();

            var ldfId = new MgResourceIdentifier(layer.LayerDefinition);
            var br    = _resSvc.GetResourceContent(ldfId);
            var doc   = new XmlDocument();

            doc.LoadXml(br.ToString());

            if (layer.StyleType == RedlineStylizationType.Basic)
            {
                var vsr = doc.GetElementsByTagName("VectorScaleRange")[0];
                var pts = vsr["PointTypeStyle"];
                var ats = vsr["AreaTypeStyle"];
                var lts = vsr["LineTypeStyle"];

                if (pts != null)
                {
                    var label = (XmlElement)pts.GetElementsByTagName("Label")[0];
                    var psym  = pts.GetElementsByTagName("PointSymbolization2D");
                    if (psym.Count > 0)
                    {
                        var mark = psym[0]["Mark"];

                        style.MarkerSizeUnits = ParseEnumValue <SizeUnit>(GetNodeValue(mark, "Unit"));
                        style.MarkerSize      = Convert.ToDouble(GetNodeValue(mark, "SizeX"));
                        style.MarkerType      = ParseEnumValue <MarkerType>(GetNodeValue(mark, "Shape"));
                        style.MarkerColor     = Util.FromHtmlColor(GetNodeValue(mark, "ForegroundColor"), false);
                    }
                    style.LabelSizeUnits = ParseEnumValue <SizeUnit>(GetNodeValue(label, "Unit"));
                    style.LabelFontSize  = Convert.ToDouble(GetNodeValue(label, "SizeX"));
                    style.LabelForeColor = Util.FromHtmlColor(GetNodeValue(label, "ForegroundColor"), false);
                    style.LabelBackColor = Util.FromHtmlColor(GetNodeValue(label, "BackgroundColor"), false);
                    style.LabelBackStyle = ParseEnumValue <LabelStyle>(GetNodeValue(label, "BackgroundStyle"));
                    style.LabelBold      = Convert.ToBoolean(GetNodeValue(label, "Bold"));
                    style.LabelItalic    = Convert.ToBoolean(GetNodeValue(label, "Italic"));
                    style.LabelUnderline = Convert.ToBoolean(GetNodeValue(label, "Underlined"));
                }
                if (lts != null)
                {
                    var label = (XmlElement)lts.GetElementsByTagName("Label")[0];

                    style.LabelSizeUnits = ParseEnumValue <SizeUnit>(GetNodeValue(label, "Unit"));
                    style.LabelFontSize  = Convert.ToDouble(GetNodeValue(label, "SizeX"));
                    style.LabelForeColor = Util.FromHtmlColor(GetNodeValue(label, "ForegroundColor"), false);
                    style.LabelBackColor = Util.FromHtmlColor(GetNodeValue(label, "BackgroundColor"), false);
                    style.LabelBackStyle = ParseEnumValue <LabelStyle>(GetNodeValue(label, "BackgroundStyle"));

                    if (pts == null)
                    {
                        style.LabelBold      = Convert.ToBoolean(GetNodeValue(label, "Bold"));
                        style.LabelItalic    = Convert.ToBoolean(GetNodeValue(label, "Italic"));
                        style.LabelUnderline = Convert.ToBoolean(GetNodeValue(label, "Underlined"));
                    }

                    var lsym = lts.GetElementsByTagName("LineSymbolization2D");
                    if (lsym.Count > 0)
                    {
                        var line = (XmlElement)lsym[0];
                        style.LinePattern   = ParseEnumValue <LinePattern>(GetNodeValue(line, "LineStyle"));
                        style.LineThickness = Convert.ToDouble(GetNodeValue(line, "Thickness"));
                        style.LineColor     = Util.FromHtmlColor(GetNodeValue(line, "Color"), false);
                        style.LineSizeUnits = ParseEnumValue <SizeUnit>(GetNodeValue(line, "Unit"));
                    }
                }
                if (ats != null)
                {
                    var label = (XmlElement)ats.GetElementsByTagName("Label")[0];

                    style.LabelSizeUnits = ParseEnumValue <SizeUnit>(GetNodeValue(label, "Unit"));
                    style.LabelFontSize  = Convert.ToDouble(GetNodeValue(label, "SizeX"));
                    style.LabelForeColor = Util.FromHtmlColor(GetNodeValue(label, "ForegroundColor"), false);
                    style.LabelBackColor = Util.FromHtmlColor(GetNodeValue(label, "BackgroundColor"), false);
                    style.LabelBackStyle = ParseEnumValue <LabelStyle>(GetNodeValue(label, "BackgroundStyle"));

                    if (pts == null && lts == null)
                    {
                        style.LabelBold      = Convert.ToBoolean(GetNodeValue(label, "Bold"));
                        style.LabelItalic    = Convert.ToBoolean(GetNodeValue(label, "Italic"));
                        style.LabelUnderline = Convert.ToBoolean(GetNodeValue(label, "Underlined"));
                    }

                    var asym = ats.GetElementsByTagName("AreaSymbolization2D");
                    if (asym.Count > 0)
                    {
                        var fill   = asym[0]["Fill"];
                        var stroke = asym[0]["Stroke"];

                        style.FillPattern   = ParseEnumValue <FillPattern>(GetNodeValue(fill, "FillPattern"));
                        style.FillForeColor = Util.FromHtmlColor(GetNodeValue(fill, "ForegroundColor"), false);
                        style.FillBackColor = Util.FromHtmlColor(GetNodeValue(fill, "BackgroundColor"), false);

                        style.BorderPattern   = ParseEnumValue <LinePattern>(GetNodeValue(stroke, "LineStyle"));
                        style.BorderThickness = Convert.ToDouble(GetNodeValue(stroke, "Thickness"));
                        style.BorderColor     = Util.FromHtmlColor(GetNodeValue(stroke, "Color"));
                        style.BorderSizeUnits = ParseEnumValue <SizeUnit>(GetNodeValue(stroke, "Unit"));
                    }
                }
            }
            else
            {
                var extData = doc.GetElementsByTagName("ExtendedData1");
                if (extData.Count == 1)
                {
                    var ext = (XmlElement)extData[0];
                    style.MarkerColor          = Util.FromHtmlColor(GetNodeValue(ext, "MG_MARKER_COLOR"));
                    style.MarkerType           = ParseEnumValue <MarkerType>(GetNodeValue(ext, "MG_MARKER_TYPE"));
                    style.MarkerSizeUnits      = ParseEnumValue <SizeUnit>(GetNodeValue(ext, "MG_MARKER_UNITS"));
                    style.MarkerSize           = Convert.ToDouble(GetNodeValue(ext, "MG_MARKER_SIZE"));
                    style.LineColor            = Util.FromHtmlColor(GetNodeValue(ext, "MG_LINE_COLOR"));
                    style.LinePattern          = ParseEnumValue <LinePattern>(GetNodeValue(ext, "MG_LINE_PATTERN"));
                    style.LineSizeUnits        = ParseEnumValue <SizeUnit>(GetNodeValue(ext, "MG_LINE_UNITS"));
                    style.LineThickness        = Convert.ToDouble(GetNodeValue(ext, "MG_LINE_THICKNESS"));
                    style.FillPattern          = ParseEnumValue <FillPattern>(GetNodeValue(ext, "MG_FILL_PATTERN"));
                    style.FillTransparency     = 100 - ((Convert.ToInt32(GetNodeValue(ext, "MG_FILL_FORE_TRANSPARENCY"), 16) / 255.0) * 100.0);
                    style.FillForeColor        = Util.FromHtmlColor(GetNodeValue(ext, "MG_FILL_FORE_COLOR"));
                    style.FillBackColor        = Util.FromHtmlColor(GetNodeValue(ext, "MG_FILL_BACK_COLOR"));
                    style.FillBackTransparency = (GetNodeValue(ext, "MG_FILL_BACK_TRANSPARENCY") == "FF");
                    style.BorderPattern        = ParseEnumValue <LinePattern>(GetNodeValue(ext, "MG_BORDER_PATTERN"));
                    style.BorderSizeUnits      = ParseEnumValue <SizeUnit>(GetNodeValue(ext, "MG_BORDER_UNITS"));
                    style.BorderColor          = Util.FromHtmlColor(GetNodeValue(ext, "MG_BORDER_COLOR"));
                    style.BorderThickness      = Convert.ToDouble(GetNodeValue(ext, "MG_BORDER_THICKNESS"));
                    style.LabelSizeUnits       = ParseEnumValue <SizeUnit>(GetNodeValue(ext, "MG_LABEL_FONT_UNITS"));
                    style.LabelFontSize        = Convert.ToDouble(GetNodeValue(ext, "MG_LABEL_FONT_SIZE"));
                    style.LabelBold            = Convert.ToBoolean(GetNodeValue(ext, "MG_BOLD"));
                    style.LabelItalic          = Convert.ToBoolean(GetNodeValue(ext, "MG_ITALIC"));
                    style.LabelUnderline       = Convert.ToBoolean(GetNodeValue(ext, "MG_UNDERLINE"));
                    style.LabelForeColor       = Util.FromHtmlColor(GetNodeValue(ext, "MG_LABEL_FORECOLOR"));
                    style.LabelBackColor       = Util.FromHtmlColor(GetNodeValue(ext, "MG_LABEL_BACKCOLOR"));
                    style.LabelBackStyle       = ParseEnumValue <LabelStyle>(GetNodeValue(ext, "MG_LABEL_STYLE"));
                }
            }

            return(style);
        }