public void LoadFromXdxf(string xdxfFileName) { var document = XDocument.Load(xdxfFileName); var xdxfElement = document.Element("xdxf"); LanguageFrom = TextTranslator.GetLanguageFromId(xdxfElement.Attribute("lang_from").Value); LanguageTo = TextTranslator.GetLanguageFromId(xdxfElement.Attribute("lang_to").Value); Format = xdxfElement.Attribute("format").Value; var fullNameElem = document.Element("full_name"); //FullName = document.Element("full_name").Value; //Description = document.Element("description").Value; SortedList = new SerializableSortedList <string, TranscriptionTranslation>(); var documentElements = xdxfElement.Elements("ar"); foreach (var element in documentElements) { var transcriptionTranslate = new TranscriptionTranslation { Transcription = element.Element("tr") == null ? string.Empty : element.Element("tr").Value, Translation = element.Value }; SortedList.Add(element.Element("k").Value, transcriptionTranslate); } }
public virtual int AddElement(double t, T element) { if (_data.ContainsKey(t)) { throw new Exception("Добавляешь дубликат по t"); } _data.Add(t, element); return(_data.IndexOfValue(element)); }
public SerializableSortedList <int, LayerItem> MapGlitchItems(@object decos, Layer layer) { var items = new SerializableSortedList <int, LayerItem>(); //FIX middleground items, they are handle a bit different; var middleGroundFixX = 0; var middleGroundFixY = 0; if (layer.Name == "middleground") { middleGroundFixX = layer.Width / 2; middleGroundFixY = layer.Height; } foreach (var obj in decos.object1) { var item = new LayerItem { Height = Convert.ToInt32([email protected](x => x.id == "h").Value), Width = Convert.ToInt32([email protected](x => x.id == "w").Value), X = Convert.ToInt32([email protected](x => x.id == "x").Value) + middleGroundFixX, Y = Convert.ToInt32([email protected](x => x.id == "y").Value) + middleGroundFixY, ZIndex = Convert.ToInt32([email protected](x => x.id == "z").Value), Name = obj.str.Single(x => x.id == "name").Value, SpriteClass = String.Format("{0}.png", obj.str.Single(x => x.id == "sprite_class").Value), Visible = true, }; var rotate = [email protected](x => x.id == "r"); if (rotate != null) { item.Rotate = Convert.ToInt32(rotate.Value); } if (obj.@bool != null) { var flip = [email protected](x => x.id == "h_flip"); if (flip != null) { item.Flip = Convert.ToBoolean(flip.Value); } } items.Add(item.ZIndex, item); } return(items); }
public static SerializableSortedList <string, TranscriptionTranslation> XdxfToSortedList(Stream stream) { var sortedList = new SerializableSortedList <string, TranscriptionTranslation>(); var document = XDocument.Load(stream); var documentElements = document.Element("xdxf").Elements("ar"); foreach (var element in documentElements) { var transcriptionTranslate = new TranscriptionTranslation { Transcription = element.Element("tr") == null ? string.Empty : element.Element("tr").Value, Translation = element.Value }; sortedList.Add(element.Element("k").Value, transcriptionTranslate); } return(sortedList); }
public SerializableSortedList<int, Layer> MapGlitchLayers(@object layerObj) { var list = new SerializableSortedList<int, Layer>(); foreach (var obj in layerObj.object1) { var layer = new Layer { ZIndex = Convert.ToInt32([email protected](x => x.id == "z").Value), Name = [email protected](x => x.id == "name").Value, Filters = MapGlitchFilters(obj.object1.Single(x => x.id == "filtersNEW")), Height = Convert.ToInt32([email protected](x => x.id == "h").Value), Width = Convert.ToInt32([email protected](x => x.id == "w").Value), Visible = true, }; layer.Items = MapGlitchItems(obj.object1.Single(x => x.id == "decos"), layer); list.Add(layer.ZIndex, layer); } return list; }
public SerializableSortedList<int, LayerItem> MapGlitchItems(@object decos, Layer layer) { var items = new SerializableSortedList<int, LayerItem>(); //FIX middleground items, they are handle a bit different; var middleGroundFixX = 0; var middleGroundFixY = 0; if (layer.Name == "middleground") { middleGroundFixX = layer.Width /2; middleGroundFixY = layer.Height; } foreach (var obj in decos.object1) { var item = new LayerItem { Height = Convert.ToInt32([email protected](x => x.id == "h").Value), Width = Convert.ToInt32([email protected](x => x.id == "w").Value), X = Convert.ToInt32([email protected](x => x.id == "x").Value) + middleGroundFixX, Y = Convert.ToInt32([email protected](x => x.id == "y").Value) + middleGroundFixY, ZIndex = Convert.ToInt32([email protected](x => x.id == "z").Value), Name = obj.str.Single(x => x.id == "name").Value, SpriteClass = String.Format("{0}.png", obj.str.Single(x => x.id == "sprite_class").Value), Visible = true, }; var rotate = [email protected](x => x.id == "r"); if (rotate != null) { item.Rotate = Convert.ToInt32(rotate.Value); } if (obj.@bool != null) { var flip = [email protected](x => x.id == "h_flip"); if (flip != null) { item.Flip = Convert.ToBoolean(flip.Value); } } items.Add(item.ZIndex, item); } return items; }
public SerializableSortedList <int, Layer> MapGlitchLayers(@object layerObj) { var list = new SerializableSortedList <int, Layer>(); foreach (var obj in layerObj.object1) { var layer = new Layer { ZIndex = Convert.ToInt32([email protected](x => x.id == "z").Value), Name = [email protected](x => x.id == "name").Value, Filters = MapGlitchFilters(obj.object1.Single(x => x.id == "filtersNEW")), Height = Convert.ToInt32([email protected](x => x.id == "h").Value), Width = Convert.ToInt32([email protected](x => x.id == "w").Value), Visible = true, }; layer.Items = MapGlitchItems(obj.object1.Single(x => x.id == "decos"), layer); list.Add(layer.ZIndex, layer); } return(list); }