Пример #1
0
        void ISvgRenderer.SetClip(Region region, CombineMode combineMode)
        {
            if (_boundables.Count == 0)
            {
                return;
            }

            if (combineMode != CombineMode.Intersect && combineMode != CombineMode.Replace)
            {
                throw new NotImplementedException();
            }

            // reset current clip
            if (combineMode == CombineMode.Replace || region == null)
            {
                _innerGraphics.PopState();
                _innerGraphics.PushState();
            }
            _innerGraphics.Transform = Matrix3x2.Multiply(_currentTransform, _initialTransform);

            if (combineMode == CombineMode.Replace || _currentClip == null || region == null)
            {
                _currentClip = region;
            }
            else if (_currentClip != region)
            {
                _currentClip = _currentClip.Clone();
                _currentClip.Intersect(region);
            }

            // set default clip
            if (_currentClip == null)
            {
                return;
            }

            RectangleF bounds;

            foreach (var clipper in RegionParser.ParseRegion(_currentClip, ((IGraphicsProvider)this).GetGraphics(), out bounds))
            {
                if (clipper is RectangleF)
                {
                    var rect = (RectangleF)clipper;
                    if (rect != _boundables.Peek().Bounds)
                    {
                        _innerGraphics.IntersectClip(Convert(rect));
                    }
                }
                else if (clipper is GraphicsPath)
                {
                    var path = (GraphicsPath)clipper;
                    _innerGraphics.IntersectClip(Convert(path));
                }
            }
        }
Пример #2
0
 private static IEnumerable <SerialInfo> GetSerials(IEnumerable <IDictionary <string, string> > cmpMatches,
                                                    string platformId)
 {
     return(from entry in cmpMatches.AsParallel()
            where entry.ContainsKey("serial")
            let name = entry["name"]
                       let serials =
                platformId.StartsWith("NINTENDO")
                 ? Regex.Replace(entry["serial"], "[A-Z]*?-[A-Z]-", string.Empty)
                 : entry["serial"] // sanitize nintendo serials
                let region = RegionParser.ParseRegion(name)
                             select new SerialInfo(platformId, name, region, serials));
 }
Пример #3
0
 private static IEnumerable <RomInfo> GetEntries(XDocument xmlDat, string platformId)
 {
     return(from game in xmlDat.Root.Elements("game").AsParallel()
            from rom in game.Elements("rom").AsParallel()
            where rom.Attribute("size").Value != "0"
            let crc = rom.Attribute("crc").Value.ToUpperInvariant()
                      let md5 = rom.Attribute("md5").Value.ToUpperInvariant()
                                let sha1 = rom.Attribute("sha1").Value.ToUpperInvariant()
                                           let filename = rom.Attribute("name").Value
                                                          let region = RegionParser.ParseRegion(filename)
                                                                       let mimetype = DatParser.GetMimeType(filename, platformId)
                                                                                      where mimetype != null
                                                                                      select new RomInfo(platformId, crc, md5, sha1, region, mimetype, filename));
 }
Пример #4
0
        private static IEnumerable <RomInfo> GetEntries(MatchCollection cmpMatches, string platformId)
        {
            const string regex = @"(?:\s|)(.*?)(?:\sname|\scrc|\scrc32|\smd5|\ssha1|\sbaddump|\snodump|\ssize|$)";

            return(from Match romEntry in cmpMatches.AsParallel()
                   let match = romEntry.Value
                               let filename = Regex.Match(match, "name" + regex).Groups[1].Value.Trim('"')
                                              let crc = Regex.Match(match, "crc" + regex).Groups[1].Value
                                                        let md5 = Regex.Match(match, "md5" + regex).Groups[1].Value
                                                                  let sha1 = Regex.Match(match, "sha1" + regex).Groups[1].Value
                                                                             let region = RegionParser.ParseRegion(filename)
                                                                                          let mimetype = DatParser.GetMimeType(filename, platformId)
                                                                                                         where mimetype != null
                                                                                                         select new RomInfo(platformId, crc, md5, sha1, region, mimetype, filename));
        }