Exemplo n.º 1
0
        public static IRasterLayer FromXElement(XElement ele)
        {
            if (ele == null)
            {
                return(null);
            }
            string       name              = ele.Attribute("name").Value;
            bool         visible           = bool.Parse(ele.Attribute("visible").Value);
            ScaleRange   displayScaleRange = ScaleRange.FromXElement(ele.Element("DisplayScaleRange"));
            IRasterClass rasterclass       = AgileMap.Core.RasterClass.FromXElement(ele.Element("RasterClass"));

            rasterclass.Name = name;
            IRasterLayer lyr = new RasterLayer(name, rasterclass);

            (lyr as ILayerDrawable).Visible = visible;
            return(lyr);
        }
Exemplo n.º 2
0
        public static IFeatureLayer FromXElement(XElement ele)
        {
            if (ele == null)
            {
                return(null);
            }
            string name               = ele.Attribute("name").Value;
            bool   visible            = bool.Parse(ele.Attribute("visible").Value);
            bool   enableDisplayLevel = true;

            if (ele.Attribute("enabledisplayLevel") != null)
            {
                enableDisplayLevel = bool.Parse(ele.Attribute("enabledisplayLevel").Value);
            }
            ScaleRange       displayScaleRange = ScaleRange.FromXElement(ele.Element("DisplayScaleRange"));
            LabelDef         labelDef          = AgileMap.Core.LabelDef.FromXElement(ele.Element("LabelDef"));
            IFeatureRenderer renderer          = PersistObject.ReflectObjFromXElement(ele.Element("Renderer")) as IFeatureRenderer;
            RotateFieldDef   rotateFieldDef    = RotateFieldDef.FromXElement(ele.Element("RotateField"));
            IFeatureClass    fetclass          = AgileMap.Core.FeatureClass.FromXElement(ele.Element("FeatureClass"));

            if (fetclass == null)
            {
                return(null);
            }
            fetclass.Name = name;
            IFeatureLayer lyr = new FeatureLayer(name, fetclass, renderer, labelDef);

            lyr.RotateFieldDef              = rotateFieldDef;
            lyr.DisplayScaleRange           = displayScaleRange;
            lyr.EnabledDisplayLevel         = enableDisplayLevel;
            (lyr as ILayerDrawable).Visible = visible;
            //
            if (ele.Attribute("twostepflag") != null)
            {
                string twoStepflagstring = ele.Attribute("twostepflag").Value;
                lyr.IsTwoStepDraw = bool.Parse(twoStepflagstring);
            }
            //
            return(lyr);
        }
Exemplo n.º 3
0
        //<LabelDef enabled="False" field="ADMIN_NAME" fields="FIPS_ADMIN,GMI_ADMIN,ADMIN_NAME,FIPS_CNTRY,GMI_CNTRY,CNTRY_NAME,POP_ADMIN,TYPE_ENG,TYPE_LOC,SQKM,SQMI,COLOR_MAP" ruler="Center" invalidvalue="">
        //  <Font font="Microsoft Sans Serif,9,Regular" color="255,0,0,0" maskcolor="0,0,0,0" />
        //  <DisplayScaleRange enabled="False" minscale="-1" maxscale="1" />
        //</LabelDef>
        public static LabelDef FromXElement(XElement ele)
        {
            if (ele == null)
            {
                return(null);
            }
            enumLabelSource source = enumLabelSource.Label;

            if (ele.Attribute("source") != null)
            {
                string sourceString = ele.Attribute("source").Value;
                foreach (enumLabelSource s in Enum.GetValues(typeof(enumLabelSource)))
                {
                    if (s.ToString() == sourceString)
                    {
                        source = s;
                        break;
                    }
                }
            }
            Font       font          = FontHelper.StringToFont(ele.Element("Font").Attribute("font").Value);
            ScaleRange range         = ScaleRange.FromXElement(ele.Element("DisplayScaleRange"));
            Color      color         = ColorHelper.StringToColor(ele.Element("Font").Attribute("color").Value);
            Color      maskcolor     = ColorHelper.StringToColor(ele.Element("Font").Attribute("maskcolor").Value);
            string     field         = ele.Attribute("field").Value;
            string     fields        = ele.Attribute("fields").Value;
            bool       enabled       = bool.Parse(ele.Attribute("enabled").Value);
            bool       autotonewline = false;

            if (ele.Attribute("autotonewline") != null)
            {
                autotonewline = bool.Parse(ele.Attribute("autotonewline").Value);
            }
            int charcount = 6;

            if (ele.Attribute("charcountperline") != null)
            {
                charcount = int.Parse(ele.Attribute("charcountperline").Value);
            }
            masLabelPosition ruler       = masLabelPosition.Center;
            string           rulerstring = ele.Attribute("ruler").Value;

            foreach (masLabelPosition r in Enum.GetValues(typeof(masLabelPosition)))
            {
                if (r.ToString() == rulerstring)
                {
                    ruler = r;
                    break;
                }
            }
            string invalidvalue = ele.Attribute("invalidvalue").Value;
            //
            IContainerSymbol csym = null;

            if (ele.Element("ContainerSymbol") != null)
            {
                csym = PersistObject.ReflectObjFromXElement(ele.Element("ContainerSymbol")) as IContainerSymbol;
            }
            //
            LabelDef def = new LabelDef(field, fields.Trim() != string.Empty ? fields.Split(',') : null);

            def.LabelFont         = font;
            def.DisplayScaleRange = range;
            def.EnableLabeling    = enabled;
            def.ForeColor         = color;
            def.MaskColor         = maskcolor;
            def.MasLabelRuler     = ruler;
            def.InvalidValue      = invalidvalue;
            def.LabelSource       = source;
            def.ContainerSymbol   = csym;
            def.AutoToNewline     = autotonewline;
            def.CharcountPerLine  = charcount;
            return(def);
        }