private void InitAdminMask() { // Admin mask m_MaskGroup = new LayerGroup("Administrative Unit Mask"); m_CountryMask = new EidssSystemDbLayer("Country Mask"); m_CountryMask.DataSource = new EidssSqlServer2008(SystemLayerNames.Countries); m_RegionMask = new EidssSystemDbLayer("Regional Mask"); m_RegionMask.DataSource = new EidssSqlServer2008(SystemLayerNames.Regions); m_DistrictMask = new EidssSystemDbLayer("District Mask"); m_DistrictMask.DataSource = new EidssSqlServer2008(SystemLayerNames.Rayons); m_MaskGroup.Layers.Add(m_CountryMask); m_MaskGroup.Layers.Add(m_RegionMask); }
/// <summary> /// Deserialize VectorLayer /// </summary> /// <param name="vectorLayerElement">Root element to deserialize</param> /// <returns>VectorLayer</returns> public static EidssDbLayer Deserialize(XmlElement vectorLayerElement) { EidssDbLayer resultVectorLayer = null; XmlNode tempNode; LayerSerializer.LayerInfo lyrInfo; bool tempBool; int tempInt; #region <<Deserialize LayerFields >> try { lyrInfo = LayerSerializer.DeserializeLayerFields(vectorLayerElement); } catch (Exception ex) { throw new VectorLayerDeserializationException("VectorLayer can't be deserialized: " + ex.Message, ex); } //LabelLayer Guid tempNode = vectorLayerElement.SelectSingleNode("LabelLayerGuid"); if (tempNode == null) { throw new VectorLayerDeserializationException("VectorLayer can't be deserialized: 'LayerElement' don't have element 'LabelLayerGuid'!"); } var labelLayerGuid = new Guid(tempNode.InnerText); //create layer switch (vectorLayerElement.Attributes["Type"].Value) { case "eidss.gis.Layers.EidssSystemDbLayer": resultVectorLayer = new EidssSystemDbLayer(lyrInfo.LayerName, lyrInfo.Guid, labelLayerGuid); break; case "eidss.gis.Layers.EidssExtSystemDbLayer": resultVectorLayer = new EidssExtSystemDbLayer(lyrInfo.LayerName, lyrInfo.Guid, labelLayerGuid); break; } resultVectorLayer.ControledByUser = lyrInfo.ControledByUser; resultVectorLayer.Enabled = lyrInfo.Enabled; resultVectorLayer.MaxVisible = lyrInfo.MaxVisible; resultVectorLayer.MinVisible = lyrInfo.MinVisible; //resultVectorLayer.SRID = lyrInfo.SRID; - тут бля косяк в провайдере! нет проверки! resultVectorLayer.VisibleInTOC = lyrInfo.VisibleInTOC; resultVectorLayer.Transparency = lyrInfo.Transparency; #endregion #region << Deserialize >> //ClippingEnabled tempNode = vectorLayerElement.SelectSingleNode("ClippingEnabled"); if (tempNode == null) { throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'ClippingEnabled'!"); } if (!bool.TryParse(tempNode.InnerText, out tempBool)) { throw new VectorLayerDeserializationException("Can't parse node 'ClippingEnabled'!"); } resultVectorLayer.ClippingEnabled = tempBool; //DataSource try { resultVectorLayer.DataSource = EidssProviderSerializer.Instance.DeserializeFromNode(vectorLayerElement, "DataSource"); } catch (Exception ex) { throw new VectorLayerDeserializationException("DataSource can't be deserialized: " + ex.Message, ex); } //SmoothingMode tempNode = vectorLayerElement.SelectSingleNode("SmoothingMode"); if (tempNode == null) { throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'SmoothingMode'!"); } if (!Int32.TryParse(tempNode.InnerText, out tempInt) || !Enum.IsDefined(typeof(SmoothingMode), tempInt)) { throw new VectorLayerDeserializationException("Can't parse node 'SmoothingMode'!"); } resultVectorLayer.SmoothingMode = (SmoothingMode)tempInt; //SRID tempNode = vectorLayerElement.SelectSingleNode("SRID"); if (tempNode == null) { throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'SRID'!"); } if (!Int32.TryParse(tempNode.InnerText, out tempInt)) { throw new VectorLayerDeserializationException("Can't parse node 'SRID'!"); } resultVectorLayer.SRID = tempInt; //Style try { resultVectorLayer.Style = (VectorStyle)StyleSerializer.DeserializeFromNode(vectorLayerElement); } catch (Exception ex) { throw new VectorLayerSerializationException("Style can't be deserialized: " + ex.Message, ex); } //Theme try { resultVectorLayer.Theme = ThemeSerializer.DeserializeFromNode(vectorLayerElement); } catch (Exception ex) { throw new VectorLayerSerializationException("Theme can't be deserialized: " + ex.Message, ex); } //Marker size tempNode = vectorLayerElement.SelectSingleNode("MarkerSize"); if (tempNode == null) { throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'MarkerSize'!"); } if (!Int32.TryParse(tempNode.InnerText, out tempInt)) { throw new VectorLayerDeserializationException("Can't parse node 'MarkerSize'!"); } resultVectorLayer.MarkerSize = tempInt; //Marker color try { resultVectorLayer.MarkerColor = ColorSerializer.DeserializeFromNode(vectorLayerElement, "MarkerColor"); } catch (Exception ex) { throw new VectorLayerSerializationException("MarkerColor can't be deserialized: " + ex.Message, ex); } //Polygon Fill Style tempNode = vectorLayerElement.SelectSingleNode("PolygonFillStyle"); if (tempNode == null) { throw new VectorLayerDeserializationException("'VectorLayerElement' don't have element 'PolygonFillStyle'!"); } resultVectorLayer.PolygonFillStyle = tempNode.InnerText; //Polygon Fill Color try { resultVectorLayer.PolygonFillColor = ColorSerializer.DeserializeFromNode(vectorLayerElement, "PolygonFillColor"); } catch (Exception ex) { throw new VectorLayerSerializationException("PolygonFillColor can't be deserialized: " + ex.Message, ex); } #endregion return(resultVectorLayer); }