void onCardListValueChange(object sender, SelectionChangeEventArgs e) { if (e.NewValue == null) { return; } MainLine ml = e.NewValue as MainLine; Crow.Configuration.Set("LastPointedCardForDebug", ml.name); Load("#MagicCrow.ui.cardModel.iml").DataSource = ml.Card; }
public DeckFile(string path) { cardLines = new List <MainLine> (); parserState state = parserState.init; using (Stream s = new FileStream(path, FileMode.Open)) { using (StreamReader sr = new StreamReader(s)) { while (!sr.EndOfStream) { string tmp = sr.ReadLine(); if (tmp.StartsWith("[")) { switch (tmp.ToLower()) { case "[shop]": state = parserState.shop; continue; case "[metadata]": state = parserState.metadata; continue; case "[main]": state = parserState.main; continue; case "[sideboard]": state = parserState.sideboard; continue; default: state = parserState.init; continue; } } switch (state) { case parserState.shop: break; case parserState.metadata: string[] tokens = tmp.Split(new char[] { '=' }); switch (tokens[0].ToLower()) { case "name": Name = tokens[1]; break; case "description": Description = tokens[1]; break; case "set": Set = tokens[1]; break; case "Image": Image = tokens[1]; break; case "deck type": DeckType = tokens[1]; break; default: break; } break; case parserState.main: if (string.IsNullOrEmpty(tmp)) { continue; } MainLine l = new MainLine(); string strCount = tmp.Split(new char[] { ' ' }) [0]; l.count = int.Parse(strCount); string strTmp = tmp.Substring(strCount.Length).Trim(); string[] ts = strTmp.Split(new char[] { '|' }); l.name = ts [0]; l.code = ""; if (ts.Length > 1) { l.code = ts [1]; } cardLines.Add(l); break; case parserState.sideboard: break; default: break; } } } } }