예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public static AttachGroup TryParseInline(string aStr)
        {
            AttachGroup result = new AttachGroup();

            TryParse(aStr, ref result);
            return(result);
        }
예제 #4
0
        public static AttachGroup operator -(AttachGroup a, TileFrame b)
        {
            var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo);

            c.AttachesTo.Remove(b);
            return(c);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
 public AttachGroup(string n, string s)
 {
     _name = n;
     AttachGroup result = new AttachGroup();
     TryParse(s, ref result);
     _placement = result.Placement;
     _attachesTo = result.AttachesTo;
 }
예제 #8
0
        public AttachGroup(string n, string s)
        {
            _name = n;
            AttachGroup result = new AttachGroup();

            TryParse(s, ref result);
            _placement  = result.Placement;
            _attachesTo = result.AttachesTo;
        }
예제 #9
0
        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);
        }
예제 #10
0
 public static AttachGroup operator -(AttachGroup a, TileFrame b)
 {
     var c = new AttachGroup(a.Name, a.Placement, a.AttachesTo);
     c.AttachesTo.Remove(b);
     return c;
 }
예제 #11
0
 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;
 }
예제 #12
0
 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;
 }
예제 #13
0
 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;
 }
예제 #14
0
 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;
 }
예제 #15
0
 public AttachGroup XMLConvert(AttachGroup v, XElement el)
 {
     if (el == null) return v;
     return new AttachGroup((string)el.Attribute("name"), (string)el.Attribute("attachTiles"));
 }
예제 #16
0
 private static bool MatchFields(AttachGroup a, string m)
 {
     return(a.Name == m);
 }
예제 #17
0
 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;
 }
예제 #18
0
 private static bool MatchFields(AttachGroup a, ObservableCollection<TileFrame> m)
 {
     return (a.AttachesTo == m);
 }
예제 #19
0
 public bool Equals(AttachGroup ag)
 {
     return MatchFields(this, ag);
 }
예제 #20
0
 private static bool MatchFields(AttachGroup a, ObservableCollection <TileFrame> m)
 {
     return(a.AttachesTo == m);
 }
예제 #21
0
 private static bool MatchFields(AttachGroup a, FramePlacement m)
 {
     return(a.Placement == m);
 }
예제 #22
0
        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;
        }
예제 #23
0
 private static bool MatchFields(AttachGroup a, TileFrame m)
 {
     return(a.AttachesTo.Count == 1 && a.AttachesTo.Contains(m));
 }
예제 #24
0
 private static bool MatchFields(AttachGroup a, TileFrame m)
 {
     return (a.AttachesTo.Count == 1 && a.AttachesTo.Contains(m));
 }
예제 #25
0
 public bool Equals(AttachGroup ag)
 {
     return(MatchFields(this, ag));
 }
예제 #26
0
 public static AttachGroup TryParseInline(string aStr)
 {
     AttachGroup result = new AttachGroup();
     TryParse(aStr, ref result);
     return result;
 }
예제 #27
0
 private static bool MatchFields(AttachGroup a, AttachGroup m)
 {
     return(a.AttachesTo == m.AttachesTo && a.Name == m.Name && a.Placement == m.Placement);
 }
예제 #28
0
 private static bool MatchFields(AttachGroup a, AttachGroup m)
 {
     return (a.AttachesTo == m.AttachesTo && a.Name == m.Name && a.Placement == m.Placement);
 }
예제 #29
0
        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);
        }
예제 #30
0
 private static bool MatchFields(AttachGroup a, FramePlacement m)
 {
     return (a.Placement == m);
 }
예제 #31
0
 public AttachGroup XMLConvert(AttachGroup v, XAttribute attr)
 {
     if (attr == null) return v;
     return new AttachGroup((string)attr.Parent.Attribute("name") ?? String.Empty, (string)attr);
 }
예제 #32
0
 private static bool MatchFields(AttachGroup a, string m)
 {
     return (a.Name == m);
 }
예제 #33
0
        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);
        }