public CBackgroundImage addNewImage(ImageType type) { BgType = type; CBackgroundImage res = new CBackgroundImage(); currentList.Add(res); return(res); }
public void addImage(CBackgroundImage image) { if (currentList == null) { throw new Exception("You have to set the BgType first!!!"); } currentList.Add(image); }
//Liefert alle zum aktuell gewählten Typ verfügbaren Auflösungen zurück public string[] GetAvailableResolutions() { string[] Resolutions = new string[currentList.Count]; if (bgType == ImageType.itSvg) { Resolutions[0] = Catalog.GetString("resolution-independend"); } else { for (int i = 0; i < currentList.Count; i++) { CBackgroundImage bgImg = (CBackgroundImage)(currentList[i]); Resolutions[i] = bgImg.xResolution + "x" + bgImg.yResolution; } } return(Resolutions); }
//Die XMLDatei durchgehen und die Objekte erzeugen private void parseXMLFile() { if (getThemeList().Count == 0) { XmlDocument doc = new XmlDocument(); doc.Load(config.ArtFilePath()); // Retrieve all bg from the xml XmlNodeList entries = doc.SelectNodes(config.NodeEntryPath()); Console.WriteLine("Number of themes: " + entries.Count); foreach (XmlNode node in entries) { //Neues Objekt anlegen, wird zu einem anderen gecastet wenn es nötigt ist CTheme Theme = CreateNewThemeObject(); //Background-Attribute auslesen if (node.NodeType == XmlNodeType.Element) { XmlAttributeCollection attributes = node.Attributes; XmlNode item = null; for (int i = 0; i < attributes.Count; i++) { item = attributes.Item(i); if (item.Name == "release_date") { Theme.ReleaseDate = item.InnerText; } //TODO: will be rating soon votesum and count are deprecated else if (item.Name == "vote_sum") { Theme.VoteSum = GetIntFromXML(item.InnerText); } else if (item.Name == "vote_count") { Theme.VoteCount = GetIntFromXML(item.InnerText); } else if (item.Name == "download_start_timestamp") { Theme.Timestamp = item.InnerText; } else if (item.Name == "download_count") { Theme.DownloadCount = GetIntFromXML(item.InnerText); } } XmlNodeList Childs = node.ChildNodes; for (int i = 0; i < Childs.Count; i++) { item = Childs.Item(i); if (item.Name == "name") { Theme.Name = item.InnerText; } else if (item.Name == "description") { Theme.Description = item.InnerText; } else if (item.Name == "category") { Theme.Category = item.InnerText; } else if (item.Name == "author") { Theme.Author = item.InnerText; } else if (item.Name == "license") { Theme.License = item.InnerText; } else if (item.Name == "thumbnail") { //In der Background-XML ist "Thumbnail"==SmallThumbnailUrl if (config.BackgroundChoosen) { Theme.SmallThumbnailUrl = item.InnerText; Theme.PreviewUrl = item.InnerText; } else { Theme.PreviewUrl = item.InnerText; } } else if (item.Name == "small_thumbnail") { Theme.SmallThumbnailUrl = item.InnerText; } else if (item.Name == "url") { Theme.DownloadUrl = item.InnerText; } else if (item.Name == "background_resolution") { XmlNodeList BackgroundResolutions = item.ChildNodes; CBackgroundImage bgImg = new CBackgroundImage(); for (int j = 0; j < BackgroundResolutions.Count; j++) { XmlNode bgitem = BackgroundResolutions.Item(j); if (bgitem.Name == "type") { bgImg.Type = bgitem.InnerText; ((CBackgroundTheme)Theme).addImage(bgImg.Type, bgImg); } else if (bgitem.Name == "resolution") { string tmp = bgitem.InnerText; if (tmp.Contains("scalable")) { bgImg.xResolution = 9999; bgImg.yResolution = 9999; } else { string[] sa = tmp.Split('x'); bgImg.xResolution = int.Parse(sa[0]); bgImg.yResolution = int.Parse(sa[1]); } } //Bei Hintergründen ist die URL auch gleichzeitig die DownloadUrl..jeweils die größte wählen else if (bgitem.Name == "url") { bgImg.URL = bgitem.InnerText; Theme.DownloadUrl = bgImg.URL; } } } } } //Füge Theme in die VektorArrays ein AddThemeToVectorArray(Theme); } } //if Cout==0 }
public CBackgroundImage addNewImage(ImageType type) { BgType=type; CBackgroundImage res=new CBackgroundImage(); currentList.Add(res); return res; }
public void addImage(CBackgroundImage image) { if (currentList==null) throw new Exception("You have to set the BgType first!!!"); currentList.Add(image); }
public void addImage(string type, CBackgroundImage image) { //Console.WriteLine(type.ToLower()); addImage(CUtility.StrToImageType(type),image); }
public void addImage(ImageType type, CBackgroundImage image) { BgType = type; addImage(image); }
public void addImage(string type, CBackgroundImage image) { //Console.WriteLine(type.ToLower()); addImage(CUtility.StrToImageType(type), image); }
//Die XMLDatei durchgehen und die Objekte erzeugen private void parseXMLFile() { if (getThemeList().Count==0){ XmlDocument doc = new XmlDocument(); doc.Load(config.ArtFilePath()); // Retrieve all bg from the xml XmlNodeList entries = doc.SelectNodes(config.NodeEntryPath()); Console.WriteLine("Number of themes: "+entries.Count); foreach(XmlNode node in entries){ //Neues Objekt anlegen, wird zu einem anderen gecastet wenn es nötigt ist CTheme Theme=CreateNewThemeObject(); //Background-Attribute auslesen if (node.NodeType == XmlNodeType.Element) { XmlAttributeCollection attributes = node.Attributes; XmlNode item=null; for (int i=0;i<attributes.Count;i++){ item = attributes.Item(i); if (item.Name=="release_date") Theme.ReleaseDate=item.InnerText; //TODO: will be rating soon votesum and count are deprecated else if (item.Name=="vote_sum") Theme.VoteSum=GetIntFromXML(item.InnerText); else if (item.Name=="vote_count") Theme.VoteCount=GetIntFromXML(item.InnerText); else if (item.Name=="download_start_timestamp") Theme.Timestamp=item.InnerText; else if (item.Name=="download_count") Theme.DownloadCount=GetIntFromXML(item.InnerText); } XmlNodeList Childs = node.ChildNodes; for (int i=0;i<Childs.Count;i++){ item = Childs.Item(i); if (item.Name=="name") Theme.Name=item.InnerText; else if (item.Name=="description") Theme.Description=item.InnerText; else if (item.Name=="category") Theme.Category=item.InnerText; else if (item.Name=="author") Theme.Author=item.InnerText; else if (item.Name=="license") Theme.License=item.InnerText; else if (item.Name=="thumbnail"){ //In der Background-XML ist "Thumbnail"==SmallThumbnailUrl if (config.BackgroundChoosen) { Theme.SmallThumbnailUrl=item.InnerText; Theme.PreviewUrl=item.InnerText; } else Theme.PreviewUrl=item.InnerText; } else if (item.Name=="small_thumbnail") Theme.SmallThumbnailUrl=item.InnerText; else if (item.Name=="url"){ Theme.DownloadUrl=item.InnerText; } else if (item.Name=="background_resolution"){ XmlNodeList BackgroundResolutions = item.ChildNodes; CBackgroundImage bgImg=new CBackgroundImage(); for (int j=0;j<BackgroundResolutions.Count;j++){ XmlNode bgitem = BackgroundResolutions.Item(j); if (bgitem.Name=="type"){ bgImg.Type=bgitem.InnerText; ((CBackgroundTheme)Theme).addImage(bgImg.Type,bgImg); } else if (bgitem.Name=="resolution"){ string tmp=bgitem.InnerText; if (tmp.Contains("scalable")){ bgImg.xResolution=9999; bgImg.yResolution=9999; } else{ string[] sa=tmp.Split('x'); bgImg.xResolution=int.Parse(sa[0]); bgImg.yResolution=int.Parse(sa[1]); } } //Bei Hintergründen ist die URL auch gleichzeitig die DownloadUrl..jeweils die größte wählen else if (bgitem.Name=="url"){ bgImg.URL=bgitem.InnerText; Theme.DownloadUrl=bgImg.URL; } } } } } //Füge Theme in die VektorArrays ein AddThemeToVectorArray(Theme); } } //if Cout==0 }