public static AttachGroup operator -(AttachGroup a, ObservableCollection <TileFrame> b) { var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.RemoveRange(b); return(c); }
public static AttachGroup operator -(AttachGroup a, AttachGroup b) { var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.RemoveRange(b.AttachesTo); return(c); }
public static AttachGroup TryParseInline(string aStr) { AttachGroup result = new AttachGroup(); TryParse(aStr, ref result); return(result); }
public static AttachGroup operator -(AttachGroup a, TileFrame b) { var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.Remove(b); return(c); }
public static bool TryParse(string aStr, ref ObservableCollection <TileFrame> attach) { AttachGroup result = new AttachGroup(); bool valid = TryParse(aStr, ref result); attach = result.AttachesTo; return(valid); }
public static AttachGroup operator +(AttachGroup a, ObservableCollection <TileFrame> b) { var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.AddRange(b); c.AttachesTo = (ObservableCollection <TileFrame>)c.AttachesTo.Distinct(); return(c); }
public AttachGroup(string n, string s) { _name = n; AttachGroup result = new AttachGroup(); TryParse(s, ref result); _placement = result.Placement; _attachesTo = result.AttachesTo; }
public static AttachGroup operator +(AttachGroup a, TileFrame b) { if (a.AttachesTo.Contains(b)) { return(a); } var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.Add(b); return(c); }
public static AttachGroup operator -(AttachGroup a, TileFrame b) { var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.Remove(b); return c; }
public static AttachGroup operator -(AttachGroup a, ObservableCollection<TileFrame> b) { var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.RemoveRange(b); return c; }
public static AttachGroup operator -(AttachGroup a, AttachGroup b) { var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.RemoveRange(b.AttachesTo); return c; }
public static AttachGroup operator +(AttachGroup a, TileFrame b) { if (a.AttachesTo.Contains(b)) return a; var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.Add(b); return c; }
public static AttachGroup operator +(AttachGroup a, ObservableCollection<TileFrame> b) { var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo); c.AttachesTo.AddRange(b); c.AttachesTo = (ObservableCollection<TileFrame>)c.AttachesTo.Distinct(); return c; }
public AttachGroup XMLConvert(AttachGroup v, XElement el) { if (el == null) return v; return new AttachGroup((string)el.Attribute("name"), (string)el.Attribute("attachTiles")); }
private static bool MatchFields(AttachGroup a, string m) { return(a.Name == m); }
public static bool TryParse(string aStr, ref ObservableCollection<TileFrame> attach) { AttachGroup result = new AttachGroup(); bool valid = TryParse(aStr, ref result); attach = result.AttachesTo; return valid; }
private static bool MatchFields(AttachGroup a, ObservableCollection<TileFrame> m) { return (a.AttachesTo == m); }
public bool Equals(AttachGroup ag) { return MatchFields(this, ag); }
private static bool MatchFields(AttachGroup a, ObservableCollection <TileFrame> m) { return(a.AttachesTo == m); }
private static bool MatchFields(AttachGroup a, FramePlacement m) { return(a.Placement == m); }
public static bool TryParse(string aStr, ref AttachGroup attach) { string raw = Regex.Replace(aStr, @"\s", String.Empty); var newAttach = new AttachGroup(); newAttach.Name = attach.Name ?? String.Empty; newAttach.Placement = attach.Placement; if (string.IsNullOrWhiteSpace(raw)) { attach = newAttach; return false; } // first split - colons string[] ptf = raw.Split(':'); if (ptf.Length == 2) { newAttach.Placement = (new FramePlacement()).Convert<FramePlacement>(ptf[0]); raw = ptf[1]; } else if (ptf.Length > 2) { attach = newAttach; return false; } // second split - commas string[] tiles = raw.Split(','); foreach (string rawTF in tiles) { byte t; byte? f; // third split - periods (not using TileFrame for this, as there may be multiples) string[] tf = rawTF.Split('.'); if (tf.Length == 2) { t = byte.Parse(tf[0]); // fourth split - dashes string[] fRng = tf[1].Split('-'); if (fRng.Length == 2) { int s = int.Parse(fRng[0]); int c = int.Parse(fRng[1]) - s + 1; var rng = Enumerable.Range(s, c); foreach (int frm in rng) { newAttach.AttachesTo.Add(new TileFrame(t, (byte)frm)); } } else if (fRng.Length > 2) { attach = newAttach; return false; } else { f = byte.Parse(tf[1]); newAttach.AttachesTo.Add(new TileFrame(t, f)); } } else if (tf.Length == 1) { // fourth split - dashes string[] tRng = rawTF.Split('-'); if (tRng.Length == 2) { int s = int.Parse(tRng[0]); int c = int.Parse(tRng[1]) - s + 1; var rng = Enumerable.Range(s, c); foreach (int tile in rng) { newAttach.AttachesTo.Add(new TileFrame((byte)tile)); } } else if (tRng.Length > 2) { attach = newAttach; return false; } else { t = byte.Parse(rawTF); newAttach.AttachesTo.Add(new TileFrame(t)); } } } attach = newAttach; return true; }
private static bool MatchFields(AttachGroup a, TileFrame m) { return(a.AttachesTo.Count == 1 && a.AttachesTo.Contains(m)); }
private static bool MatchFields(AttachGroup a, TileFrame m) { return (a.AttachesTo.Count == 1 && a.AttachesTo.Contains(m)); }
public bool Equals(AttachGroup ag) { return(MatchFields(this, ag)); }
public static AttachGroup TryParseInline(string aStr) { AttachGroup result = new AttachGroup(); TryParse(aStr, ref result); return result; }
private static bool MatchFields(AttachGroup a, AttachGroup m) { return(a.AttachesTo == m.AttachesTo && a.Name == m.Name && a.Placement == m.Placement); }
private static bool MatchFields(AttachGroup a, AttachGroup m) { return (a.AttachesTo == m.AttachesTo && a.Name == m.Name && a.Placement == m.Placement); }
public static bool TryParse(string aStr, ref AttachGroup attach) { string raw = Regex.Replace(aStr, @"\s", String.Empty); var newAttach = new AttachGroup(); newAttach.Name = attach.Name ?? String.Empty; newAttach.Placement = attach.Placement; if (string.IsNullOrWhiteSpace(raw)) { attach = newAttach; return(false); } // first split - colons string[] ptf = raw.Split(':'); if (ptf.Length == 2) { newAttach.Placement = (new FramePlacement()).Convert <FramePlacement>(ptf[0]); raw = ptf[1]; } else if (ptf.Length > 2) { attach = newAttach; return(false); } // second split - commas string[] tiles = raw.Split(','); foreach (string rawTF in tiles) { byte t; byte?f; // third split - periods (not using TileFrame for this, as there may be multiples) string[] tf = rawTF.Split('.'); if (tf.Length == 2) { t = byte.Parse(tf[0]); // fourth split - dashes string[] fRng = tf[1].Split('-'); if (fRng.Length == 2) { int s = int.Parse(fRng[0]); int c = int.Parse(fRng[1]) - s + 1; var rng = Enumerable.Range(s, c); foreach (int frm in rng) { newAttach.AttachesTo.Add(new TileFrame(t, (byte)frm)); } } else if (fRng.Length > 2) { attach = newAttach; return(false); } else { f = byte.Parse(tf[1]); newAttach.AttachesTo.Add(new TileFrame(t, f)); } } else if (tf.Length == 1) { // fourth split - dashes string[] tRng = rawTF.Split('-'); if (tRng.Length == 2) { int s = int.Parse(tRng[0]); int c = int.Parse(tRng[1]) - s + 1; var rng = Enumerable.Range(s, c); foreach (int tile in rng) { newAttach.AttachesTo.Add(new TileFrame((byte)tile)); } } else if (tRng.Length > 2) { attach = newAttach; return(false); } else { t = byte.Parse(rawTF); newAttach.AttachesTo.Add(new TileFrame(t)); } } } attach = newAttach; return(true); }
private static bool MatchFields(AttachGroup a, FramePlacement m) { return (a.Placement == m); }
public AttachGroup XMLConvert(AttachGroup v, XAttribute attr) { if (attr == null) return v; return new AttachGroup((string)attr.Parent.Attribute("name") ?? String.Empty, (string)attr); }
private static bool MatchFields(AttachGroup a, string m) { return (a.Name == m); }
public void XMLConvert(ObservableCollection<AttachGroup> v, XAttribute attr) { var oc = new ObservableCollection<AttachGroup>(); if (string.IsNullOrWhiteSpace((string)attr)) return; foreach (string ag in ((string)attr).Split(';')) { var newAG = new AttachGroup(); newAG.Name = "Tile: " + this.Name; var raw = ag; string[] ptf = raw.Split(':'); if (ptf.Length == 2) { newAG.Placement = (new FramePlacement()).Convert<FramePlacement>(ptf[0]); raw = ptf[1]; } // Check for named AttachGroups if (Regex.IsMatch(raw, @"[a-zA-Z]+")) { if (!_hasReadCache) { _readAttachGroups(attr.Parent); } raw = Regex.Replace(raw, @"\s", String.Empty); foreach (var agc in _attachGroupsCache) { if (agc == raw) { if (agc.Placement != null && newAG.Placement == null) newAG.Placement = agc.Placement; newAG.AttachesTo = agc.AttachesTo; break; } } } else { AttachGroup.TryParse(raw, ref newAG); } oc.Add(newAG); } v.ReplaceRange(oc); }