public static AmbientIllumination ReadFromXml(XElement xmlEl, IUndoManager undoManager, L3dFilePath ownerPath = null) { if (xmlEl != null && xmlEl.Name == FileDescriptions.FILE_WEATHER_EL_ILLUMINATION) { XElement illuminationProps = xmlEl.Element(FileDescriptions.FILE_WEATHER_EL_ILLUMINATION_PROPS); if (illuminationProps != null) { AmbientIllumination ill = new AmbientIllumination(undoManager); ill._brightnessDay = illuminationProps.Attribute(FileDescriptions.FILE_WEATHER_AT_ILLUMINATION_BRIGHTNESS_DAY).Read <float>(1.0f); ill._brightnessNight = illuminationProps.Attribute(FileDescriptions.FILE_WEATHER_AT_ILLUMINATION_BRIGHTNESS_NIGHT).Read <float>(0.0f); ill._dawnBegin = illuminationProps.Attribute(FileDescriptions.FILE_WEATHER_AT_ILLUMINATION_DAWN_BEGIN).ReadTime(new TimeSpan(3, 0, 0)); ill._dawnEnd = illuminationProps.Attribute(FileDescriptions.FILE_WEATHER_AT_ILLUMINATION_DAWN_END).ReadTime(new TimeSpan(6, 0, 0)); ill._duskBegin = illuminationProps.Attribute(FileDescriptions.FILE_WEATHER_AT_ILLUMINATION_DUSK_BEGIN).ReadTime(new TimeSpan(17, 0, 0)); ill._duskEnd = illuminationProps.Attribute(FileDescriptions.FILE_WEATHER_AT_ILLUMINATION_DUSK_END).ReadTime(new TimeSpan(23, 0, 0)); return(ill); } } return(null); }
protected override void LoadFromDoc(System.Xml.Linq.XDocument doc) { _weatherSet = new UndoAwareObservableCollection <WeatherTimeRange>(this); //WeatherSet.AllowNew = false; XElement root = (XElement)doc.FirstNode; XElement rootProps = doc.Elements().First().Element(FileDescriptions.FILE_GENERAL_EL_PROPS); if (rootProps != null) { _header = rootProps.Attribute(FileDescriptions.FILE_WEATHER_AT_PROPS_HEADER).Read <string>(string.Empty); } XElement illumination = root.Element(FileDescriptions.FILE_WEATHER_EL_ILLUMINATION); Illumination = AmbientIllumination.ReadFromXml(illumination, this, OwnPath); if (Illumination == null) { Illumination = new AmbientIllumination(this); } var set = root.Element(FileDescriptions.FILE_WEATHER_EL_WEATHER_SET); if (set != null) { List <WeatherTimeRange> tempL = new List <WeatherTimeRange>(); foreach (XElement timeRange in set.Elements(FileDescriptions.FILE_WEATHER_EL_TIME_RANGE)) { WeatherTimeRange r = WeatherTimeRange.ReadFromXml(timeRange, this, OwnPath); if (r != null) { tempL.Add(r); } } foreach (var it in tempL.OrderBy(w => w.Begin)) { _weatherSet.Add(it); } } ClearUndoRedo(); }
public WeatherFile() { _illumination = new AmbientIllumination(this); _weatherSet = new UndoAwareObservableCollection <WeatherTimeRange>(this); }