public PersistObject ToPersistObject() { PersistObject obj = new PersistObject("LabelDef"); obj.AddAttribute("source", _labelSource.ToString()); obj.AddAttribute("enabled", _enableLabeling.ToString()); obj.AddAttribute("field", _fieldname != null ? _fieldname : string.Empty); obj.AddAttribute("fields", _fields != null ? string.Join(",", _fields) : string.Empty); obj.AddAttribute("ruler", _masLabelRuler.ToString()); obj.AddAttribute("invalidvalue", _invalidValue != null ? _invalidValue.ToString() : string.Empty); obj.AddAttribute("autotonewline", _autoToNewline.ToString()); obj.AddAttribute("charcountperline", _charcountPerLine.ToString()); //Font PersistObject fontObj = new PersistObject("Font"); fontObj.AddAttribute("font", FontHelper.FontToString(_labelFont)); fontObj.AddAttribute("color", ColorHelper.ColorToString(_foreColor)); fontObj.AddAttribute("maskcolor", ColorHelper.ColorToString(_maskColor)); obj.AddSubNode(fontObj); //_scaleRange if (_displayScaleRange == null) { _displayScaleRange = new ScaleRange(-1, 1); } PersistObject rangeObj = (_displayScaleRange as IPersistable).ToPersistObject(); obj.AddSubNode(rangeObj); //_containerSymbol if (_containerSymbol != null) { PersistObject csymobj = _containerSymbol.ToPersistObject(); obj.AddSubNode(csymobj); } return(obj); }
public static ScaleRange FromXElement(XElement ele) { if (ele == null) { return(new ScaleRange(-1, 1)); } ScaleRange range = new ScaleRange(-1, 1); range.DisplayScaleOfMax = int.Parse(ele.Attribute("maxscale").Value); range.DisplayScaleOfMin = int.Parse(ele.Attribute("minscale").Value); range.Enable = bool.Parse(ele.Attribute("enabled").Value); return(range); }
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); }
public PersistObject ToPersistObject() { PersistObject obj = new PersistObject("RasterLayer"); obj.AddAttribute("name", _name != null ? _name : string.Empty); obj.AddAttribute("visible", _visible.ToString()); //displayScaleRange if (_displayScaleRange == null) { _displayScaleRange = new ScaleRange(-1, 1); } obj.AddSubNode((_displayScaleRange as IPersistable).ToPersistObject()); //feature class if (_class != null) { obj.AddSubNode((_class as IPersistable).ToPersistObject()); } return(obj); }
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); }
public PersistObject ToPersistObject() { PersistObject obj = new PersistObject("Layer"); obj.AddAttribute("name", _name != null ?_name :string.Empty); obj.AddAttribute("visible", _visible.ToString()); obj.AddAttribute("enabledisplayLevel", _enabledDisplayLevel.ToString()); obj.AddAttribute("twostepflag", _twoStepFlag.ToString()); //displayScaleRange if (_displayScaleRange == null) { _displayScaleRange = new ScaleRange(-1, 1); } obj.AddSubNode((_displayScaleRange as IPersistable).ToPersistObject()); //label def if (_labelDef != null) { obj.AddSubNode((_labelDef as IPersistable).ToPersistObject()); } //renderer if (_featureRender != null) { obj.AddSubNode((_featureRender as IPersistable).ToPersistObject()); } //rotate field if (_rotateFieldDef != null) { obj.AddSubNode((_rotateFieldDef as IPersistable).ToPersistObject()); } //feature class if (_class != null) { obj.AddSubNode((_class as IPersistable).ToPersistObject()); } return(obj); }
public FeatureLayer() { _displayScaleRange = new ScaleRange(-1, 1); _outsideIndicator = new OutsideIndicator(); }
//<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); }