private void setChart(DateTime date, int x_position, DateTime limit) { if (date.CompareTo(limit) == 0) { return; } Materials.Materials materials; string key = limit.ToString("yyyyMMdd"); try { KanColleMaterialsGraph.MaterialsCache.TryGetValue(key, out materials); } catch (ArgumentNullException) { setChart(date, x_position += 1, limit.AddDays(1)); return; } if (materials == null) { setChart(date, x_position += 1, limit.AddDays(1)); return; } Fuel.Add(new Point { X = limit.ToOADate(), Y = materials.Fuel }); Ammunition.Add(new Point { X = limit.ToOADate(), Y = materials.Ammunition }); Steel.Add(new Point { X = limit.ToOADate(), Y = materials.Steel }); Bauxite.Add(new Point { X = limit.ToOADate(), Y = materials.Bauxite }); InstantRepairMaterials.Add(new Point { X = limit.ToOADate(), Y = materials.InstantRepairMaterials * 100 }); ImprovementMaterials.Add(new Point { X = limit.ToOADate(), Y = materials.ImprovementMaterials * 100 }); DateTimeXAxis xaxis = new DateTimeXAxis(); setChart(date, x_position += 1, limit.AddDays(1)); return; }
public void AddAmmunition(string macro, string value) { try { if (string.IsNullOrEmpty(macro)) { throw new Exception("macro must contain a value"); } if (string.IsNullOrEmpty(value)) { throw new Exception("value must contain a value"); } try { Convert.ToInt64(value); } catch (Exception ex) { throw new Exception("value must contain a valid integer value", ex); } XmlNode childNode = XMLFunctions.FindChild(ShipNode.FirstChild, "ammunition"); XmlNode newAmmoNode = null; if (childNode == null) { XmlNode previousChildNode = XMLFunctions.FindChild(ShipNode.FirstChild, "shields"); childNode = ShipNode.OwnerDocument.CreateElement("ammunition"); childNode.AppendChild(ShipNode.OwnerDocument.CreateElement("available")); ShipNode.FirstChild.InsertAfter(childNode, previousChildNode); } childNode = childNode.FirstChild; try { newAmmoNode = childNode.OwnerDocument.CreateNode(XmlNodeType.Element, "item", ""); newAmmoNode.Attributes.Append(childNode.OwnerDocument.CreateAttribute("macro")); newAmmoNode.Attributes.Append(childNode.OwnerDocument.CreateAttribute("amount")); newAmmoNode.Attributes["macro"].Value = macro; newAmmoNode.Attributes["amount"].Value = value; } catch (Exception ex) { throw new Exception("Unable to create the new inventory node", ex); } try { childNode.AppendChild(newAmmoNode); Ammunition.Add(new ShipAmmunitionItemData(newAmmoNode, cde)); } catch (Exception ex) { throw new Exception("Unable to add the new inventory node", ex); } } catch (Exception ex) { throw new Exception("Unable to add new player inventory item", ex); } }