public static void AddToLog(String sText) { sText = sText.Trim(); if (sText.Length == 0) { return; } string sDate = String.Format("{0}{1}{2}", DateTime.Now.Year, EnsureDateTimeString(DateTime.Now.Month), EnsureDateTimeString(DateTime.Now.Day)); string sLogfile = Path.Combine(WOTHelper.GetApplicationData(), string.Format("Log_{0}.log", sDate)); sText = GetFormattedLogText(sText); Console.WriteLine(sText); try { System.IO.StreamWriter oWriter = new System.IO.StreamWriter(sLogfile, true, Encoding.Unicode); oWriter.WriteLine(sText); oWriter.Close(); } catch { } if (!File.Exists(sLogfile)) { } return; }
public TankDescriptions(MessageQueue message) { _message = message; _tankTypeDescriptions = new TankTypeDescription(message); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Tanks").ChildNodes; foreach (XmlNode node in nodes) { TankKey tKey = new TankKey() { CountryID = int.Parse(node.Attributes["Country"].Value), TankID = int.Parse(node.Attributes["Code"].Value) }; TankValue tValue = new TankValue() { Description = Translations.TranslationGet(node.Attributes["Country"].Value + "_" + node.Attributes["Code"].Value, "DE", node.InnerText), Tier = int.Parse(node.Attributes["Tier"].Value), Premium = int.Parse(node.Attributes["Premium"].Value), Active = (node.Attributes["Active"] == null ? true : bool.Parse(node.Attributes["Active"].Value)), TankType = node.Attributes["TankType"].Value }; _tanks.Add(tKey, tValue); } }
private static object GetDetails(string id) { object retValue = null; XmlDocument xmlDoc = new XmlDocument(); XmlNode node = null; try { xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; node = root.SelectSingleNode(string.Format(@"AppSettings/Setting[@Key=""{0}""]", id)); } catch { return(null); } if (node != null) { retValue = node.Attributes["Value"] == null ? null : node.Attributes["Value"].Value; } else { retValue = null; } return(retValue); }
public static void printRatingStruct(RatingStructure ratingStruct) { WOTHelper.AddToLog("ratingStruct.countryID:" + ratingStruct.countryID); WOTHelper.AddToLog("ratingStruct.tankID:" + ratingStruct.tankID); WOTHelper.AddToLog("ratingStruct.tier:" + ratingStruct.tier); WOTHelper.AddToLog("ratingStruct.battlesCount:" + ratingStruct.battlesCount); WOTHelper.AddToLog("ratingStruct.battlesCount8_8:" + ratingStruct.battlesCount8_8); WOTHelper.AddToLog("ratingStruct.capturePoints:" + ratingStruct.capturePoints); WOTHelper.AddToLog("ratingStruct.defencePoints:" + ratingStruct.defencePoints); WOTHelper.AddToLog("ratingStruct.damageAssistedRadio:" + ratingStruct.damageAssistedRadio); WOTHelper.AddToLog("ratingStruct.damageAssistedTracks:" + ratingStruct.damageAssistedTracks); WOTHelper.AddToLog("ratingStruct.damageDealt:" + ratingStruct.damageDealt); WOTHelper.AddToLog("ratingStruct.frags:" + ratingStruct.frags); WOTHelper.AddToLog("ratingStruct.spotted:" + ratingStruct.spotted); WOTHelper.AddToLog("ratingStruct.wins:" + ratingStruct.wins); WOTHelper.AddToLog("ratingStruct.winRate:" + ratingStruct.winRate); WOTHelper.AddToLog("--------------"); WOTHelper.AddToLog("ratingStruct.AvgcapturePoints:" + ratingStruct.AvgCapturePoints); WOTHelper.AddToLog("ratingStruct.AvgdefencePoints:" + ratingStruct.AvgDefencePoints); WOTHelper.AddToLog("ratingStruct.AvgdamageAssistedRadio:" + ratingStruct.AvgDamageAssistedRadio); WOTHelper.AddToLog("ratingStruct.AvgdamageAssistedTracks:" + ratingStruct.AvgDamageAssistedTracks); WOTHelper.AddToLog("ratingStruct.AvgdamageDealt:" + ratingStruct.AvgDamageDealt); WOTHelper.AddToLog("ratingStruct.Avgfrags:" + ratingStruct.AvgFrags); WOTHelper.AddToLog("ratingStruct.Avgspotted:" + ratingStruct.AvgSpotted); WOTHelper.AddToLog("--------------"); WOTHelper.AddToLog("ratingStruct.overallDamageDealt:" + ratingStruct.overallDamageDealt); WOTHelper.AddToLog("ratingStruct.overallFrag:" + ratingStruct.overallFrags); WOTHelper.AddToLog("ratingStruct.overallSpot:" + ratingStruct.overallSpotted); WOTHelper.AddToLog("ratingStruct.overallDefensePoints:" + ratingStruct.overallDefencePoints); WOTHelper.AddToLog("ratingStruct.overallWinrate:" + ratingStruct.overallWinRate); WOTHelper.AddToLog("--------------"); }
public CountryDescriptions(MessageQueue message) { _message = message; try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Countries").ChildNodes; foreach (XmlNode node in nodes) { _countries.Add(int.Parse(node.Attributes["Code"].Value), Translations.TranslationGet(node.Attributes["Code"].Value, "DE", node.InnerText)); } } catch (Exception) { File.Copy(Path.Combine(WOTHelper.GetEXEPath(), "settings.xml"), WOTHelper.GetSettingsFile()); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Countries").ChildNodes; foreach (XmlNode node in nodes) { _countries.Add(int.Parse(node.Attributes["Code"].Value), Translations.TranslationGet(node.Attributes["Code"].Value, "DE", node.InnerText)); } } }
public string Download(string host, string fileName, string userName, string password, MessageQueue message, string playerName) { try { FileInfo fi = new FileInfo(fileName); WebClient request = new WebClient(); if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password)) { request.Credentials = new NetworkCredential(userName, password); } byte[] fileData = request.DownloadData(@"ftp://" + host + "/" + fi.Name); string dropFileName = WOTHelper.GetTempFolder() + @"\" + fi.Name; //will dot this at a later stage //File.WriteAllBytes(dropFileName, WOTStatistics.Core.GZIP.Decompress(fileData)); File.WriteAllBytes(dropFileName, fileData); message.Add("Info : Retrieved file from FTP. [" + playerName + "]"); return(dropFileName); } catch (Exception ex) { message.Add("Error : " + ex.Message); return(fileName); } }
private void DeleteFile() { if (DevExpress.XtraEditors.XtraMessageBox.Show(Translations.TranslationGet("STR_CLEARRECENTERRORNOTIFY", "DE", "The recent battle log has become unstable. File will be resetted."), "WOT Statistics", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK) { File.Delete(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + _playerName, "LastBattle", "LastBattles.wot")); } }
public void Save() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetUserFile()); XmlElement root = xmlDoc.DocumentElement; XmlNode oldPlayers = root.SelectSingleNode(@"FTPDetails"); root.RemoveChild(oldPlayers); XmlElement players = xmlDoc.CreateElement("FTPDetails"); root.AppendChild(players); XmlElement playerNode; playerNode = xmlDoc.CreateElement("FTP"); playerNode.SetAttribute("FTPHost", Host); playerNode.SetAttribute("FTPUserID", UserID); playerNode.SetAttribute("FTPUserPWD", WOTHelper.Encrypt(UserPWD)); playerNode.SetAttribute("ShareFiles", AllowFTP == true ? "Yes" : "No"); players.AppendChild(playerNode); xmlDoc.Save(WOTHelper.GetUserFile()); }
protected internal string MasterBadgeImage(int masterLevel) { if (File.Exists(string.Format(@"{0}\Images\MasterBadge\{1}.png", WOTHelper.GetEXEPath(), masterLevel))) #if DEBUG { return(string.Empty); } #else { return(String.Format(@"<Image src='{0}\Images\MasterBadge\{1}.png' alt='{2}'/>", WOTHelper.GetEXEPath(), masterLevel, MasterBadgeDescription(masterLevel))); }
private void ReadGraphSettings() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetUserFile()); XmlElement root = xmlDoc.DocumentElement; if (root.SelectSingleNode(@"Graphs") != null) { XmlNodeList nodes = root.SelectSingleNode(@"Graphs").ChildNodes; if (nodes != null) { foreach (XmlNode node in nodes) { if (!_graphCollection.ContainsKey(node.Attributes["Name"].Value)) { _graphCollection.Add(node.Attributes["Name"].Value, new GraphFields() { Name = node.Attributes["Name"].Value, Caption = node.Attributes["Caption"].Value, DataField = node.Attributes["DataField"].Value, InnerText = node.InnerText, Period = int.Parse(node.Attributes["Period"].Value), Type = node.Attributes["Type"].Value, StatsBase = node.Attributes["StatsBase"].Value }); } } } } }
public WN8ExpValues() { XmlDocument xmlDoc = new XmlDocument(); XmlNodeList nodes = null; XmlNodeList headerNodes = null; try { xmlDoc.Load(WOTHelper.GetWN8ExpectedTankValuesFile()); XmlElement root = xmlDoc.DocumentElement; nodes = root.SelectSingleNode("WN8").ChildNodes; headerNodes = root.SelectSingleNode("Header").ChildNodes; } catch (Exception ex) { WOTHelper.AddToLog(ex.Message); } WN8Version = 0; WN8DateEpoch = 0; WN8Date = new DateTime(1970, 1, 1, 0, 0, 0); if (headerNodes != null) { foreach (XmlNode headerNode in headerNodes) { if (headerNode.Name == "Version") { WN8Version = Convert.ToInt16(headerNode.InnerText); } if (headerNode.Name == "Date") { WN8DateEpoch = Convert.ToInt32(headerNode.InnerText); WN8Date = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(WN8DateEpoch); } } } if (nodes != null) { MessageQueue _messages = null; TankDescriptions tankDescription = new TankDescriptions(_messages); foreach (XmlNode node in nodes) { WN8ExpValue expVal = new WN8ExpValue(); expVal.Tank = tankDescription.Description(Convert.ToInt32(node.Attributes["countryid"].Value), Convert.ToInt32(node.Attributes["tankid"].Value)); expVal.Country = Translations.TranslationGet(Convert.ToString(node.Attributes["countryid"].Value), "DE", Convert.ToString(node.Attributes["countryid"].Value)); expVal.Tier = tankDescription.Tier(Convert.ToInt32(node.Attributes["countryid"].Value), Convert.ToInt32(node.Attributes["tankid"].Value)); expVal.tankID = Convert.ToInt32(node.Attributes["tankid"].Value); expVal.countryID = Convert.ToInt32(node.Attributes["countryid"].Value); expVal.expFrag = double.Parse(node.Attributes["expFrag"].Value, System.Globalization.CultureInfo.InvariantCulture); expVal.expDamage = double.Parse(node.Attributes["expDamage"].Value, System.Globalization.CultureInfo.InvariantCulture); expVal.expSpot = double.Parse(node.Attributes["expSpot"].Value, System.Globalization.CultureInfo.InvariantCulture); expVal.expDefense = double.Parse(node.Attributes["expDef"].Value, System.Globalization.CultureInfo.InvariantCulture); expVal.expWin = double.Parse(node.Attributes["expWinRate"].Value, System.Globalization.CultureInfo.InvariantCulture); Add(expVal); } } }
private static void Save(string id, object value) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNode settingGroup = root.SelectSingleNode("AppSettings"); if (settingGroup == null) { settingGroup = xmlDoc.CreateElement("AppSettings"); root.AppendChild(settingGroup); } XmlElement iSetting = (XmlElement)root.SelectSingleNode(string.Format(@"AppSettings/Setting[@Key=""{0}""]", id)); if (iSetting == null) { iSetting = xmlDoc.CreateElement("Setting"); settingGroup.AppendChild(iSetting); } iSetting.SetAttribute("Key", id); iSetting.SetAttribute("Value", value.ToString()); xmlDoc.Save(WOTHelper.GetSettingsFile()); }
public static void PrintDictionary(Dictionary <string, string> oDictionary) { WOTHelper.AddToLog("Printing Dictionary"); foreach (KeyValuePair <string, string> kvp in oDictionary) { WOTHelper.AddToLog("Key = {0}, Value = {1}" + kvp.Key + kvp.Value); } }
private static void printExpectedTank(WN8ExpValue WN8EX) { WOTHelper.AddToLog("WN8ExpValue.expDamage:" + WN8EX.expDamage); WOTHelper.AddToLog("WN8ExpValue.expDefense:" + WN8EX.expDefense); WOTHelper.AddToLog("WN8ExpValue.expFrag:" + WN8EX.expFrag); WOTHelper.AddToLog("WN8ExpValue.expSpot:" + WN8EX.expSpot); WOTHelper.AddToLog("WN8ExpValue.expWin:" + WN8EX.expWin); }
protected internal string TankImageLarge(int countryID, int tankID, string tankDescription) { string tankName = string.Format("{0}_{1}_Large.png", countryID, tankID); #if DEBUG return(string.Empty); #else return(String.Format(@"<Image src='{0}' alt='{2}'/>", WOTHelper.GetImagePath(tankName), tankName, tankDescription)); #endif }
private static void LoadFile() { _translation.Clear(); _languages.Clear(); try { //Lets load the xml XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetTranslationFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodeList = root.SelectSingleNode("//WorldOfTanks").ChildNodes; foreach (XmlNode baseNode in nodeList) { foreach (XmlNode childNode in baseNode.ChildNodes) { if (childNode.Name.ToUpper() == "LANGUAGES") { foreach (XmlNode fieldNode in childNode.ChildNodes) { string national = fieldNode.SelectSingleNode("NameNat").InnerText; string english = fieldNode.SelectSingleNode("NameENG").InnerText; WOTHelper.AddToLog("Adding Language to dict: " + english); _languages.Add(fieldNode.Attributes["ID"].Value, new Languages() { National = national, English = english }); } } else if (childNode.Name.ToUpper() == "FIELDS") { foreach (XmlNode fieldNode in childNode.ChildNodes) { foreach (XmlNode item in fieldNode) { if (item.Name != "#comment") { if (!_translation.ContainsKey(String.Format("{0}|{1}", fieldNode.Attributes["Name"].Value, item.Attributes["LanID"].Value))) { _translation.Add(String.Format("{0}|{1}", fieldNode.Attributes["Name"].Value, item.Attributes["LanID"].Value), item.InnerText); } } } } } } } } catch (Exception ex) { WOTHelper.AddToLog("Error with Translation: " + ex.Message); // throw ex; } }
public TankTypeDescription(MessageQueue message) { _message = message; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"TankTypes").ChildNodes; foreach (XmlNode node in nodes) { _tankTypes.Add(node.Attributes["Code"].Value, Translations.TranslationGet(node.Attributes["Code"].Value, "DE", node.InnerText)); } }
void _dossierWatcher_Changed(object sender, FileSystemEventArgs e) { if (GetPlayerName == WOTHelper.PlayerIdFromDatFile(e.Name)) { if (string.Compare(_dossierFilePath, e.FullPath, true) != 0) { using (PlayerListing player = new PlayerListing(_messages)) { player.SetPlayerWatchFile(GetPlayerID, e.FullPath); player.Save(); } _dossierFilePath = e.FullPath; } ProcessDossierFile(); } }
public CustomGrouping(MessageQueue message) { _message = message; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetUserFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"CustomGroups").ChildNodes; foreach (XmlNode node in nodes) { if (!_customGroupings.ContainsKey(node.Attributes["Name"] == null ? "" : node.Attributes["Name"].Value)) { _customGroupings.Add(node.Attributes["Name"] == null ? "" : node.Attributes["Name"].Value, new Tuple <string, string>(node.Attributes["Caption"] == null ? "" : node.Attributes["Caption"].Value, node.InnerText)); } } }
public string GetSession() { string key = String.Empty; using (DBHelpers newSession = new DBHelpers(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + _playerName, "LastBattle", "WOTSStore.db"))) { key = newSession.ExecuteScalar("select rsKey from RecentBattles_Session where datetime(rsUEDateTo,'unixepoch', 'localtime') >= datetime('now', 'localtime')"); if (string.IsNullOrEmpty(key)) { return(NewSession()); } else { return(key); } } }
public TankDescriptions(MessageQueue message, string playerDBFile) { _message = message; _tankTypeDescriptions = new TankTypeDescription(message); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Tanks").ChildNodes; //TODO DataTable dt = getMyTanks(playerDBFile); bool gotIt = false; foreach (XmlNode node in nodes) { //TODO gotIt = false; string strExpr = "cmCountryID = " + int.Parse(node.Attributes["Country"].Value) + " AND cmTankID = " + int.Parse(node.Attributes["Code"].Value); var match = dt.Select(strExpr); if (match.Length > 0) { gotIt = true; } // TankKey tKey = new TankKey() { CountryID = int.Parse(node.Attributes["Country"].Value), TankID = int.Parse(node.Attributes["Code"].Value) }; TankValue tValue = new TankValue() { Description = Translations.TranslationGet(node.Attributes["Country"].Value + "_" + node.Attributes["Code"].Value, "DE", node.InnerText), Tier = int.Parse(node.Attributes["Tier"].Value), Premium = int.Parse(node.Attributes["Premium"].Value), Active = (node.Attributes["Active"] == null ? true : bool.Parse(node.Attributes["Active"].Value)), TankType = node.Attributes["TankType"].Value, //TODO GotIt = gotIt }; _tanks.Add(tKey, tValue); } }
public void Add(string value) { int max; if (base.Count == 0) { max = 0; } else { max = (from m in base.Keys select m).Max(); } base.Add(max + 1, string.Format("{0:yyyy-MM-dd HH:mm:ss} : {1}", DateTime.Now, value)); OnAdd(new MessageEventArgs(max + 1, string.Format("{0:yyyy-MM-dd HH:mm:ss} : {1}", DateTime.Now, value))); WOTHelper.AddToLog(value); }
private void GetFTPDetails() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetUserFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"FTPDetails").ChildNodes; int i = 0; foreach (XmlNode node in nodes) { Host = node.Attributes["FTPHost"] == null ? "" : node.Attributes["FTPHost"].Value; UserID = node.Attributes["FTPUserID"] == null ? "" : node.Attributes["FTPUserID"].Value; UserPWD = WOTHelper.Decrypt(node.Attributes["FTPUserPWD"] == null ? "" : node.Attributes["FTPUserPWD"].Value); AllowFTP = node.Attributes["ShareFiles"] == null ? false : node.Attributes["ShareFiles"].Value == "Yes" ? true : false; i++; } }
public Achievements() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Achievements").ChildNodes; foreach (XmlNode node in nodes) { string trKey = node.Attributes["Key"] == null ? "" : node.Attributes["Key"].Value; _achievements.Add(int.Parse(node.Attributes["Order"].Value), new Achievement() { Name = Translations.TranslationGet(trKey, "DE", node.Attributes["Name"].Value), Value = Convert.ToInt16(node.Attributes["Value"].Value), Tanks = node.Attributes["Tanks"].Value.Split('|') }); } }
public bool IsEmptySession(string sessionID) { string sql = String.Format(@"select count(rbID) from RecentBattles where rbSessionID = '{0}'", sessionID); int value = 0; using (DBHelpers db = new DBHelpers(Path.Combine(WOTHelper.GetApplicationData(), "Hist_" + _playerName, "LastBattle", "WOTSStore.db"))) { value = int.Parse(db.ExecuteScalar(sql)); } if (value > 0) { return(false); } else { return(true); } }
public void Save(GraphFields fields) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetUserFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList oldCustomGroups = root.SelectNodes("Graphs/Graph[@Name='" + fields.Name + "']"); XmlNode customGroups = root.SelectSingleNode("Graphs"); XmlElement customGroup = null; if (oldCustomGroups.Count != 0) { foreach (XmlNode item in oldCustomGroups) { customGroup = (XmlElement)item; } } else { customGroup = xmlDoc.CreateElement("Graph"); } customGroup.SetAttribute("Name", fields.Name.Replace(" ", "_")); customGroup.SetAttribute("Caption", fields.Caption); customGroup.SetAttribute("StatsBase", fields.StatsBase); customGroup.SetAttribute("Type", fields.Type); customGroup.SetAttribute("DataField", fields.DataField); customGroup.SetAttribute("Period", fields.Period.ToString()); customGroup.InnerText = fields.InnerText; if (customGroups == null) { customGroups = xmlDoc.CreateElement("Graphs"); root.AppendChild(customGroups); } if (oldCustomGroups.Count == 0) { customGroups.AppendChild(customGroup); } xmlDoc.Save(WOTHelper.GetUserFile()); }
public static List <WOTChart> LoadCharts() { List <WOTChart> holder = new List <WOTChart>(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetChartFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList chartNodes = root.SelectSingleNode(@"Charts").ChildNodes; foreach (XmlNode chartNode in chartNodes) { WOTChart myChart = new WOTChart() { Name = chartNode.Attributes["Name"].Value.ToString(), Period = chartNode.Attributes["Period"].Value.ToString(), Saved = true }; XmlNodeList curveNodes = chartNode.SelectSingleNode(@"Curves").ChildNodes; foreach (XmlNode curveNode in curveNodes) { WOTCurve myCurve = new WOTCurve() { Name = curveNode.Attributes["Name"] == null ? "New Chart" : curveNode.Attributes["Name"].Value.ToString(), chartName = myChart.Name.ToString(), Category = curveNode.Attributes["Category"] == null ? "" : curveNode.Attributes["Category"].Value.ToString(), Country = curveNode.Attributes["Country"] == null ? "" : curveNode.Attributes["Country"].Value.ToString(), Class = curveNode.Attributes["Class"] == null ? "" : curveNode.Attributes["Class"].Value.ToString(), Tier = curveNode.Attributes["Tier"] == null ? 0 : Convert.ToInt32(curveNode.Attributes["Tier"].Value.ToString()), Tank = curveNode.Attributes["Tank"] == null ? "0" : curveNode.Attributes["Tank"].Value.ToString(), Color = curveNode.Attributes["Color"] == null ? "Black" : curveNode.Attributes["Color"].Value.ToString(), Display = curveNode.Attributes["Display"] == null ? "Total" : curveNode.Attributes["Display"].Value.ToString(), ShowValues = curveNode.Attributes["ShowValues"] == null ? true : Convert.ToBoolean(curveNode.Attributes["ShowValues"].Value) }; myChart.Curves.Add(myCurve); } holder.Add(myChart); } return(holder); }
public void Refresh() { _players.Clear(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetUserFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Players").ChildNodes; int i = 0; foreach (XmlNode node in nodes) { string sRealm = string.Empty; if (node.Attributes["Realm"] == null) { //XmlAttribute oAttr = new XmlAttribute(); //oAttr.InnerText = "Realm"; //node.Attributes.Append(oAttr); sRealm = "worldoftanks.eu"; } else { sRealm = node.Attributes["Realm"].Value; } _players.Add(node.Attributes["ID"].Value.Replace("_", "*"), new Player() { PlayerID = node.Attributes["ID"].Value, PlayerRealm = sRealm, WatchFile = node.Attributes["WatchFile"].Value, Monitor = node.Attributes["Monitor"].Value, PreviousFile = node.Attributes["FileA"] == null ? "1" : node.Attributes["FileA"].Value, CurrentFile = node.Attributes["FileB"] == null ? "0" : node.Attributes["FileB"].Value, OnlineURL = (node.Attributes["OnlineURL"] == null) ? "#" : node.Attributes["OnlineURL"].Value == "" ? "#" : node.Attributes["OnlineURL"].Value }); i++; } }
public void Remove(string name) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetUserFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList oldCustomGroups = root.SelectNodes(string.Format(@"CustomGroups/CustomGroup[@Name=""{0}""]", name.Replace(" ", "_"))); try { foreach (XmlNode item in oldCustomGroups) { item.ParentNode.RemoveChild(item); } } catch { _message.Add("Info : cant find item in settings."); } xmlDoc.Save(WOTHelper.GetUserFile()); }
public static void SaveChart(WOTChart myChart, int chartIndex) { //TODO - below works for adding charts/curves. need to implement editing charts/curves XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetChartFile()); XmlElement root = xmlDoc.DocumentElement; XmlNode chartsNode = root.SelectSingleNode("Charts"); XmlElement elChart = xmlDoc.CreateElement("Chart"); elChart.SetAttribute("Name", myChart.Name); elChart.SetAttribute("Period", myChart.Period); XmlElement elCurves = xmlDoc.CreateElement("Curves"); elChart.AppendChild(elCurves); foreach (WOTCurve curve in myChart.Curves) { if (curve.chartName == myChart.Name) { XmlElement elCurve = xmlDoc.CreateElement("Curve"); elCurve.SetAttribute("Name", curve.Name); elCurve.SetAttribute("Category", curve.Category); elCurve.SetAttribute("Country", curve.Country); elCurve.SetAttribute("Class", curve.Class); elCurve.SetAttribute("Tier", curve.Tier.ToString()); elCurve.SetAttribute("Tank", curve.Tank); elCurve.SetAttribute("Display", curve.Display); elCurve.SetAttribute("Color", curve.Color); elCurve.SetAttribute("ShowValues", curve.ShowValues.ToString()); elCurves.AppendChild(elCurve); } } chartsNode.InsertBefore(elChart, chartsNode.ChildNodes[chartIndex + 1]); xmlDoc.Save(WOTHelper.GetChartFile()); myChart.Saved = true; }