/// <summary> /// Download the xml to reload the theme list /// </summary> private void ReloadThemeList() { TreeIter iter; // get selected iter if (themeTypeTreeview.Selection.GetSelected(out iter)) { if (guiTypes.ContainsKey(iter)) { _currentTheme.GetArtItemList((ArtType)guiTypes [(TreeIter)iter]); _currentArtId = (ArtType)guiTypes[(TreeIter)iter]; } else { Console.Error.WriteLine("Error : Unknown Iter"); } } // get selected iter if (themeTypeTreeview.Selection.GetSelected(out iter)) { FetchPreviews(iter); // Prints all previews } else { Console.Error.WriteLine("Error : Selection not found"); } }
public async Task <IActionResult> PutArtType([FromRoute] int id, [FromBody] ArtType artType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != artType.ID) { return(BadRequest()); } _context.Entry(artType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArtTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutArtType([FromRoute] int id, [FromBody] ArtType artType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != artType.ID) { return(BadRequest()); } _context.Entry(artType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArtTypeExists(id)) { return(BadRequest("Concurrency Error: Type has been Removed.")); } else { return(BadRequest("Concurrency Error: Doctor has been updated by another user. Cancel and try editing the record again.")); } } return(NoContent()); }
protected void FetchPreviews(TreeIter iter) { if (guiTypes.ContainsKey(iter)) { // Removes the current "Fetch - Thread" if (_currentArtId > 0) { GLib.Source.Remove(_currentIdleFetch); Console.WriteLine("Idle Removed " + _currentIdleFetch); } // Clears All TreeIter try { _previewStore.Clear(); } catch (System.NullReferenceException e) {} // Creates and Run "Fetch - Thread" _currentIdleFetch = GLib.Idle.Add(_idleHandlerFetchGuiArt); _currentArtId = (ArtType)guiTypes [(TreeIter)iter]; } else { Console.Error.WriteLine("Error : Unknown Iter"); } }
public CConfiguration(ArtType type) { GConfClient = new GConf.Client(); systemProxy = new ProxyAttrStruct(); gangProxy = new ProxyAttrStruct(); systemProxy.Ip = ""; //TODO:Why is it important to initialize it...an error occurs otherwise. gangProxy.Ip = ""; //TODO:Why is it important to initialize it...an error occurs otherwise. artType = type; dirSep = Path.DirectorySeparatorChar.ToString(); homePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + dirSep; settingsPath = Path.Combine(homePath, ".gnome2" + dirSep + "gnome-art-ng"); splashInstallPath = homePath + ".local/share/pixmaps/splash" + dirSep; applicationInstallPath = homePath + "." + themesDir + dirSep; decorationInstallPath = homePath + "." + themesDir + dirSep; iconInstallPath = homePath + iconDir + dirSep; tarIsAvailable = CUtility.TestIfProgIsInstalled("tar", "--version", "gnu tar"); grepIsAvailable = CUtility.TestIfProgIsInstalled("grep", "--version", "gnu grep"); sedIsAvailable = CUtility.TestIfProgIsInstalled("sed", "--version", "gnu sed"); setDistributionDependendSettings(); CreateDownloadDirectories(); //Create GConf listeners GConf.NotifyEventHandler changed_handler = new GConf.NotifyEventHandler(onSettingsChanged); GConfClient.AddNotify(sProxyGconfPath, changed_handler); //Load Configurations settingsLoadOk = LoadProgramSettings(); }
public ArtType GetArtType(int id) { using (var conn = Connection) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = @" SELECT Id, [Name] FROM ArtType "; cmd.Parameters.AddWithValue("@id", id); ArtType artType = new ArtType(); var reader = cmd.ExecuteReader(); if (reader.Read()) { artType = new ArtType() { Id = reader.GetInt32(reader.GetOrdinal("Id")), Name = reader.GetString(reader.GetOrdinal("Name")) }; } reader.Close(); return(artType); } } }
public ArtPiece(ArtType artType, string name, int year, bool sold) { ArtType = artType; Name = name; Year = year; Sold = sold; }
public ActionResult DeleteConfirmed(int id) { ArtType arttype = db.ArtTypes.Find(id); if (id > 6)//Since there are no audit fields, this is a poor mans way to protect the original seeded data. { try { db.ArtTypes.Remove(arttype); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DataException dex) { if (dex.InnerException.InnerException.Message.Contains("FK_")) { ModelState.AddModelError("", "Unable to delete art type. Remember, you cannot delete an art type that has artworks in the system."); } else { ModelState.AddModelError("", "Unable to delete art type. Try again, and if the problem persists see your system administrator."); } } } else { ModelState.AddModelError("", "Unable to delete art type. You cannot delete data automatically seeded into the system."); } return(View(arttype)); }
/// <summary> /// 获取指定文章分类 /// </summary> /// <param name="artTypeId">类别标识</param> /// <returns></returns> public ArtType GetArtType(string artTypeId) { var art = new ArtType { ArtTypeId = artTypeId }; return(Session.Select(art) ? art : null); }
public static void SetupNextArt(this Game game, ArtType type) { var art = game.GetArtFromStack(type); if(art != null) { game.VisitorToArtStack(art.Type, art.NumTickets); } }
/// <summary> /// 删除指定文章分类 /// </summary> /// <param name="artTypeId">类别标识</param> /// <returns></returns> public bool Delete(string artTypeId) { var art = new ArtType { ArtTypeId = artTypeId }; return(Session.Delete(art) > 0); }
private ArtMetaData(string title, string artist, string absolutePath, ArtType type, Checksum checksum) { Checksum = checksum; ArtTitle = title; ArtistName = artist; AbsolutePath = absolutePath; Type = type; }
UnsettedBlock[,] ConvertCPP(ref Image sourceImage, ArtType type) { stateLabel?.BeginInvoke(new Action(() => { stateLabel.Text = "Serialization"; })); UnsettedBlock[,] result = new UnsettedBlock[sourceImage.Width, sourceImage.Height]; int[] image1 = new int[sourceImage.Width * sourceImage.Height * 3]; int h = sourceImage.Height; int w = sourceImage.Width; using (FBitmap fbmp = new FBitmap((Bitmap)sourceImage, true)) for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { Color pixel = fbmp.GetPixel(j, i); image1[i * w * 3 + j * 3 + 0] = pixel.R; image1[i * w * 3 + j * 3 + 1] = pixel.G; image1[i * w * 3 + j * 3 + 2] = pixel.B; } } List <int> notes1 = new List <int>(_colors.Count * 4); foreach (ColorNote col in _colors) { if (col.Use) { notes1.Add(col.ColorID); notes1.Add(col.LightColor.R); notes1.Add(col.LightColor.G); notes1.Add(col.LightColor.B); } } stateLabel?.BeginInvoke(new Action(() => { stateLabel.Text = "Converting"; })); fixed(int *image = image1) fixed(int *notes = notes1.ToArray()) { int *res = Convert(image, image1.Length, (int)type, Properties.Settings.Default.ConvertingMethod == 1, notes, notes1.Count, () => { progress.BeginInvoke(new Action(() => { progress?.Increment(1); })); }, (e) => { for (int j = 0; j < _colors.Count; ++j) { _colors[j].Uses = e[j]; } }); int i = 0; for (int x = 0; x < h; ++x) { for (int y = 0; y < w; ++y) { result[y, x].ID = res[i++]; result[y, x].Set = (ColorType)res[i++]; } } } return(result); }
public ArtType MapPresentationObjectToDataObject(ArtTypeViewModel presentationViewModelObject) { var DataObj = new ArtType(); DataObj.ArtType1 = presentationViewModelObject.ArtTypeName; DataObj.ArtTypeID = presentationViewModelObject.ArtTypeID; return(DataObj); }
public ArtAsset(int idx, Art art, ArtType type, LandData?landDatum, ItemData?itemDatum, TileData tileData) { Index = idx; m_art = art; m_type = type; m_landDatum = landDatum; m_itemDatum = itemDatum; m_tileDataInstance = tileData; }
public static void SetupNextArt(this Game game, ArtType type) { var art = game.GetArtFromStack(type); if (art != null) { game.VisitorToArtStack(art.Type, art.NumTickets); } }
public int ScrapeArt(ArtType artType, LocalDB localDB) { int returner = 0; foreach (Release release in Releases) { returner += release.ScrapeArt(artType, localDB); } return(returner); }
public async Task AddArtType(ArtType typeToAdd) { var response = await client.PostAsJsonAsync("/api/ArtTypes", typeToAdd); if (!response.IsSuccessStatusCode) { var ex = Common.CreateApiException(response); throw ex; } }
public async Task UpdateArtType(ArtType typeToUpdate) { var response = await client.PutAsJsonAsync($"/api/artTypes/{typeToUpdate.ID}", typeToUpdate); if (!response.IsSuccessStatusCode) { var ex = Common.CreateApiException(response); throw ex; } }
public async Task DeleteArtType(ArtType typeToDelete) { var response = await client.DeleteAsync($"/api/ArtTypes/{typeToDelete.ID}"); if (!response.IsSuccessStatusCode) { var ex = Common.CreateApiException(response); throw ex; } }
/// <summary> /// Scrape art from the selected online database to the built-in file location unique to the release instance. /// </summary> /// <param name="artType">The type of art to scrape. Default is all available art.</param> /// <param name="localDB">Null for platforms.</param> /// <returns>Returns a negative integer to indicate the number of scraping attempts that could be tried again, or 0 if all attempts are successfull.</returns> public int ScrapeArt(ArtType artType, LocalDB localDB = 0) { int returner = 0; string url = null; string filePath = null; string property = null; switch (artType) { case ArtType.All: returner += ScrapeArt(ArtType.BoxFront); returner += ScrapeArt(ArtType.BoxBack); returner += ScrapeArt(ArtType.Banner); returner += ScrapeArt(ArtType.Console); returner += ScrapeArt(ArtType.Controller); break; case ArtType.BoxFront: url = BoxFrontUrl; filePath = BoxFrontPath; property = "BoxFrontPath"; break; case ArtType.BoxBack: url = BoxBackUrl; filePath = BoxBackPath; property = "BoxBackPath"; break; case ArtType.Banner: url = BannerUrl; filePath = BannerPath; property = "BannerPath"; break; case ArtType.Console: url = ConsoleUrl; filePath = ConsolePath; property = "ConsolePath"; break; case ArtType.Controller: url = ControllerUrl; filePath = ControllerPath; property = "ControllerPath"; break; default: // Not implemented. Debug.Assert(false, $"Called Release.ScrapeArt() with the option {artType.Description()}, which is valid only for Releases. Can't see what it's hurting, but don't do that."); break; } return(Scrape(url, filePath, property, artType.Description())); }
public SettedBlock[,] CreateScheme(ref Image sourceImage, ArtType type, out int maxHeight) { UnsettedBlock[,] RawScheme = ConvertCPP(ref sourceImage, type); stateLabel?.BeginInvoke(new Action(() => { stateLabel.Text = "Making image"; })); Bitmap tempImage = new Bitmap(RawScheme.GetLength(0), RawScheme.GetLength(1)); int gl0 = RawScheme.GetLength(0); int gl1 = RawScheme.GetLength(1); using (FBitmap fbmp = new FBitmap(tempImage, false)) for (int i = 0; i < gl0; ++i) { for (int j = 0; j < gl1; ++j) { switch (RawScheme[i, j].Set) { case ColorType.Dark: fbmp.SetPixel(i, j, _colors[RawScheme[i, j].ID - 1].DarkColor); break; case ColorType.Normal: fbmp.SetPixel(i, j, _colors[RawScheme[i, j].ID - 1].NormalColor); break; case ColorType.Light: fbmp.SetPixel(i, j, _colors[RawScheme[i, j].ID - 1].LightColor); break; } } } sourceImage = tempImage; stateLabel?.BeginInvoke(new Action(() => { stateLabel.Text = "Generating"; })); SchemeGenerator gen = new SchemeGenerator(ref RawScheme); SettedBlock[,] result; switch (Properties.Settings.Default.GeneratingMethod) { case 0: result = gen.GenerateFlow(out maxHeight); break; case 1: result = gen.GenerateSegmented(out maxHeight); break; case 2: result = gen.GenerateMixed(out maxHeight); break; default: throw new Exception("Unknown generating method"); } stateLabel?.BeginInvoke(new Action(() => { stateLabel.Text = "Done"; })); Done(); return(result); }
public async Task <IActionResult> PostArtType([FromBody] ArtType artType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ArtTypes.Add(artType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetArtType", new { id = artType.ID }, artType)); }
/// <summary> /// To add ArtItem into GUI /// </summary> /// <param name="type">ArtType to update</param> /// <param name="store">Store</param> /// <param name="iter">Iter to be defined</param> /// <returns>numbers remaining item</returns> public int AddArt(ArtType type, ref TreeStore store) { TreeIter iter; // = new TreeIter(); Gdk.Pixbuf imagePreview; // Thumbnail int remainingArt = 0; // Number of remaining item ArtItem item = null; String description = "Description unvailable"; // Default description if (_xml.InitGetArt(type) != 0) { item = _xml.GetArtItem(out remainingArt); Console.WriteLine("Remaining Art to fetch : " + remainingArt); } else { return(0); } if (item != null) { try { imagePreview = new Gdk.Pixbuf(item.ThumbnailFile); } catch (GLib.GException e) { Console.WriteLine("Error with " + item.Url + " : " + e.Message); imagePreview = new Gdk.Pixbuf(Conf.Homedir + "no-thumbnail.png"); } /*catch (System.NullReferenceException ex) { * Console.WriteLine ("Error with " + item.Url + " : " + ex.Message); * imagePreview = new Gdk.Pixbuf(Conf.Homedir + "no-thumbnail.png" ); * }*/ try { Console.WriteLine("Description :" + item.Description + " " + type); description = item.Description; } catch (System.NullReferenceException ex) {} } else { Console.Error.WriteLine("No ArtItem available"); imagePreview = new Gdk.Pixbuf(Conf.Homedir + "no-thumbnail.png"); } iter = store.AppendValues(imagePreview, description); _guiArts.Add(iter, item); // Insert the corresponding ArtItem into an Hashtable return(remainingArt); }
public ArtTypeViewModel GetObject(int id) { using (this.context = new model()) { ArtType dataObj = new ArtType(); dataObj = this.context.ArtTypes.Find(id); using (ArtTypeViewModel presentaion = new ArtTypeViewModel()) { return(this.MapDataObjectToPresentation(presentaion, dataObj)); } } }
private async Task SetFocusedCard(int cardId, ArtType artType, Language language) { string artUrl = await m_client.GetCardArtUrlAsync(cardId, artType, language); if (string.IsNullOrEmpty(artUrl)) { img_lastClickedCard.Source = null; } else { img_lastClickedCard.Source = GetImageFromUrl(artUrl); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ArtType artType = db.ArtTypes.Find(id); if (artType == null) { return(HttpNotFound()); } return(View(artType)); }
/// <summary> /// 添加或修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public ArtType AddOrUpdate(ArtType model) { if (model.ArtTypeId.IsNull()) { model.ArtTypeId = ExtendUtil.GuidToString(); model.UpdateTime = DateTime.Now; Session.Insert(model); } else { model.UpdateTime = DateTime.Now; Session.Update(model); } return(model); }
public async Task <ArtType> GetArtType(int ArtTypeID) { var response = await client.GetAsync($"/api/arttypes/{ArtTypeID}"); if (response.IsSuccessStatusCode) { ArtType artType = await response.Content.ReadAsAsync <ArtType>(); return(artType); } else { return(new ArtType()); } }
// GET: ArtTypes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ArtType artType = db.ArtTypes.Include(a => a.Artworks) .Where(a => a.ID == id).SingleOrDefault(); if (artType == null) { return(HttpNotFound()); } return(View(artType)); }
public ArtBackground( ArtType type, string resolution, string downloadStartTimestamp, string downloadCount, string name, string description, string author, string url, string thumbnailUrl ) : base(downloadStartTimestamp, downloadCount, name, description, author, url, thumbnailUrl) { _type = type; _resolution = resolution; }
/// <summary> /// Returns the url of the art required from the card name /// </summary> /// <param name="cardName">The name of the card (in English)</param> /// <param name="artType">The type of art needed</param> /// <param name="language">The language of the image to get</param> /// <returns>The url of the image</returns> public async Task <string> GetCardArtUrlAsync(string cardName, ArtType artType, Language language = Language.English) { if (m_loadedCards == null) { await GetAllCardsAsync(); } Card c = m_loadedCards.FirstOrDefault(x => x.Names.English == cardName); if (c == null) { return(null); } return(await GetCardArtUrlAsync(c.Id, artType)); }
/// <summary> /// To add ArtItem into GUI /// </summary> /// <param name="type">ArtType to update</param> /// <param name="store">Store</param> /// <param name="iter">Iter to be defined</param> /// <returns>numbers remaining item</returns> public int AddArt(ArtType type, ref TreeStore store) { TreeIter iter; // = new TreeIter(); Gdk.Pixbuf imagePreview; // Thumbnail int remainingArt = 0; // Number of remaining item ArtItem item = null; String description = "Description unvailable"; // Default description if ( _xml.InitGetArt(type) != 0 ) { item = _xml.GetArtItem( out remainingArt ); Console.WriteLine( "Remaining Art to fetch : "+remainingArt ); } else { return 0; } if (item != null) { try { imagePreview = new Gdk.Pixbuf (item.ThumbnailFile); } catch (GLib.GException e) { Console.WriteLine ("Error with " + item.Url + " : " + e.Message); imagePreview = new Gdk.Pixbuf(Conf.Homedir + "no-thumbnail.png" ); } /*catch (System.NullReferenceException ex) { Console.WriteLine ("Error with " + item.Url + " : " + ex.Message); imagePreview = new Gdk.Pixbuf(Conf.Homedir + "no-thumbnail.png" ); }*/ try { Console.WriteLine( "Description :"+item.Description+" "+type ); description = item.Description; } catch (System.NullReferenceException ex) {} } else { Console.Error.WriteLine ("No ArtItem available"); imagePreview = new Gdk.Pixbuf (Conf.Homedir + "no-thumbnail.png"); } iter = store.AppendValues( imagePreview, description ); _guiArts.Add( iter, item ); // Insert the corresponding ArtItem into an Hashtable return remainingArt; }
public static void MoveFromArtStackToPlaza(this Game game, ArtType type) { game.Visitors.Where(v => v.Location == TypeLocationMap.TypeToLocation[type]).UpdateVisitorLocation(GameVisitorLocation.Plaza); }
protected void FetchPreviews(TreeIter iter) { if (guiTypes.ContainsKey (iter)) { // Removes the current "Fetch - Thread" if (_currentArtId > 0) { GLib.Source.Remove (_currentIdleFetch); Console.WriteLine ("Idle Removed " + _currentIdleFetch); } // Clears All TreeIter try { _previewStore.Clear (); } catch (System.NullReferenceException e) {} // Creates and Run "Fetch - Thread" _currentIdleFetch = GLib.Idle.Add (_idleHandlerFetchGuiArt); _currentArtId = (ArtType) guiTypes [(TreeIter) iter]; } else Console.Error.WriteLine ("Error : Unknown Iter"); }
/// <summary> /// Download the xml to reload the theme list /// </summary> private void ReloadThemeList() { TreeIter iter; // get selected iter if (themeTypeTreeview.Selection.GetSelected (out iter)) { if (guiTypes.ContainsKey( iter )) { _currentTheme.GetArtItemList( (ArtType) guiTypes [(TreeIter) iter] ); _currentArtId = (ArtType) guiTypes[(TreeIter) iter]; } else Console.Error.WriteLine ( "Error : Unknown Iter" ); } // get selected iter if (themeTypeTreeview.Selection.GetSelected (out iter)) FetchPreviews (iter); // Prints all previews else Console.Error.WriteLine ("Error : Selection not found"); }
public CConfiguration(ArtType type) { GConfClient = new GConf.Client(); systemProxy = new ProxyAttrStruct(); gangProxy = new ProxyAttrStruct(); systemProxy.Ip = ""; //TODO:Why is it important to initialize it...an error occurs otherwise. gangProxy.Ip = ""; //TODO:Why is it important to initialize it...an error occurs otherwise. artType=type; dirSep=Path.DirectorySeparatorChar.ToString(); homePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal)+dirSep; settingsPath = Path.Combine(homePath,".gnome2"+dirSep+"gnome-art-ng"); splashInstallPath = homePath+".local/share/pixmaps/splash"+dirSep; applicationInstallPath = homePath+"."+themesDir+dirSep; decorationInstallPath = homePath+"."+themesDir+dirSep; iconInstallPath = homePath+iconDir+dirSep; tarIsAvailable = CUtility.TestIfProgIsInstalled("tar","--version","gnu tar"); grepIsAvailable = CUtility.TestIfProgIsInstalled("grep","--version","gnu grep"); sedIsAvailable = CUtility.TestIfProgIsInstalled("sed","--version","gnu sed"); setDistributionDependendSettings(); CreateDownloadDirectories(); //Create GConf listeners GConf.NotifyEventHandler changed_handler = new GConf.NotifyEventHandler(onSettingsChanged); GConfClient.AddNotify(sProxyGconfPath,changed_handler); //Load Configurations settingsLoadOk = LoadProgramSettings(); }
/// <summary> /// Compare the new downloaded xml with the old one in cache /// </summary> /// <param name="artTypeId">ArtType</param> /// <returns>nothing</returns> private void UpdateCache(ArtType artTypeId) { Console.WriteLine ("Start of the comparison"); string cacheXmlName = "art_"+artTypeId+".xml"; string tempXmlName = "art_"+artTypeId+"_Temp.xml"; // Compare the two files FileStream fs1, fs2; fs1 = File.OpenRead (tempXmlName); fs2 = File.OpenRead (cacheXmlName); XmlTextReader xml1 = new XmlTextReader (fs1); XmlTextReader xml2 = new XmlTextReader (fs2); bool xmlAreDifferent = false; while (!xml1.EOF && !xml2.EOF) { xml1.Read (); while (xml1.NodeType != XmlNodeType.Element) { if (!xml1.Read ()) break; } xml2.Read (); while (xml2.NodeType != XmlNodeType.Element) { if (!xml2.Read ()) break; } if (xml1.Name != xml2.Name) { Console.WriteLine ("Nom de noeud différents : " + xml1.Name + " / " + xml2.Name); xmlAreDifferent = true; } else if (xml1.NodeType == XmlNodeType.Element && xml1.Depth == 1 && xml1.GetAttribute ("download_start_timestamp") != xml2.GetAttribute ("download_start_timestamp")) { Console.WriteLine(xml1.GetAttribute ("download_start_timestamp")); xmlAreDifferent = true; } } xml1.Close (); xml2.Close (); fs1.Close (); fs2.Close (); if (xmlAreDifferent) { File.Delete( cacheXmlName ); File.Move( tempXmlName, cacheXmlName ); Console.WriteLine( "The old Xml was replaced by downloaded Xml" ); } else { Console.WriteLine( "Le Xml téléchargé est identique à celui en cache" ); File.Delete( tempXmlName ); } }
/// <summary> /// Download the xml of the corresponding ArtType on the site art.gnome.org /// </summary> /// <param name="artTypeId">ArtType xml list to download</param> /// <returns>nothing</returns> public void GetArtItemList(ArtType artTypeId) { WebClient web = new WebClient(); string cacheXmlName = "art_"+artTypeId+".xml"; string tempXmlName = "art_"+artTypeId+"_Temp.xml"; // Remove the cache file if there already exists if (File.Exists (tempXmlName)) { try { File.Delete (tempXmlName); Console.WriteLine ("Suppression du fihcier Temporaire déjà existant"); } catch (System.Security.SecurityException e) { Console.Error.WriteLine ("You have not enougth permissions to delete the file"); return; } } // Record the distant file in the local repertory try { Console.WriteLine ("Download XML into art.gnome.org : " + _ArtGnomeURL + (int)artTypeId); web.DownloadFile (_ArtGnomeURL + (int)artTypeId, tempXmlName); Console.WriteLine ("Le Xml a été enregistré dans le fichier " + tempXmlName); } catch (System.IO.IOException e) { Console.Error.WriteLine( "An error occurred. Please check write permissions." ); } // Compare the file just downloaded with the last downloaded file if (File.Exists (cacheXmlName)) { this.UpdateCache( artTypeId ); } else { // Save the temporary file as new cache file File.Move (tempXmlName, cacheXmlName); Console.WriteLine ("Xml was renamed to " + cacheXmlName); } }
public static GameReputationTile GetReputationTileByLocation(this Game game, ArtType row, GameReputationTileLocation column) { return game.ReputationTiles.Where(r => r.Column == column && r.Row == row).Single(); }
public static GameArt GetArtFromStack(this Game game, ArtType type) { //todo check if stack is empty return game.GetArtStack(type).FirstOrDefault(); }
public static List<GameArt> GetArtStack(this Game game, ArtType type) { return game.Art.Where(a => a.Type == type && a.Artist == null).OrderBy(a => a.Order).ToList(); }
/* public void GetURL(ArtType artTypeId, int ArtId) { } */ /// <summary> /// Initialise the class by opening the xml corresponding to the ArtType and counting elements in it. /// </summary> /// <param name="artTypeId">Select which xml to parse depending on the ArtType</param> /// <returns>Total number of elements in the xml</returns> public int InitGetArt(ArtType artTypeId) { // No initialisation if there is a ArtItem remaining if (_remaingElmt > 0 && _curArtType == artTypeId) return _totalElmt; /* Hack to handle the ArtType "All" => do nothing */ if (artTypeId == ArtType.All) return 0; string cacheXmlName = "art_"+artTypeId+".xml"; _curArtType = artTypeId; // Close any handle of the xml in case there's one if (_xmlRd != null) { _xmlRd.Close(); } //Check that the xml corresponding to the ArtType exists if (File.Exists(cacheXmlName)) { Console.WriteLine("File exists"); // Open the xml _xmlRd = new XmlTextReader(cacheXmlName); // Call a private method to count numbers of ArtItems in the xml this.ParseCacheXml(artTypeId); } else { // If the xml doesn't exists, ask the user to download it ! Console.WriteLine ("You have to refresh first !"); return 0; } Console.WriteLine ("Nombre d'éléments : " + _totalElmt); return _totalElmt; }
/// <summary> /// Parse the XML and count elements in it. Save the total numbers of items in a member variable. /// </summary> /// <param name="artTypeId">Select which xml to parse depending on the ArtType</param> /// <returns>nothing</returns> private void ParseCacheXml(ArtType artTypeId) { int totalArtItem = 0; string cacheXmlName = "art_"+artTypeId+".xml"; XmlTextReader tmpXmlRd = new XmlTextReader(cacheXmlName); // Read each node of the XML. Increase the total number of item when we met a new node with a depth of 1 while (!tmpXmlRd.EOF) { tmpXmlRd.Read(); while ((tmpXmlRd.NodeType != XmlNodeType.Element || tmpXmlRd.Depth != 1) && ! tmpXmlRd.EOF) { tmpXmlRd.Read(); } totalArtItem ++; } _totalElmt = totalArtItem - 1; // Decreased by 1 because the last incrementation occures when the end of the file is reached _remaingElmt = _totalElmt; }
public static void VisitorToArtStack(this Game game, ArtType type, int count) { game.DrawVisitors(count).UpdateVisitorLocation(TypeLocationMap.TypeToLocation[type]); }