Example #1
0
        private h0 InitAOClass()
        {
            h0 h = new h0();

            h.ap(Path.Combine(Directory.GetCurrentDirectory(), "xmlFiles"), Path.Combine(Directory.GetCurrentDirectory(), "xmlFiles"));
            h.bv();

            var itemListObj = h.aq();

            int       count    = 0;
            ca        item     = itemListObj.ir(count);
            List <ca> itemList = new List <ca>();

            while (item != null)
            {
                itemList.Add(item);
                count++;
                item = itemListObj.ir(count);
            }

            List <string> itemUIDS = new List <string>();

            foreach (ca c in itemList)
            {
                itemUIDS.Add(c.d);
            }

            ItemExtractor      itemExtractor = new ItemExtractor(Directory.GetCurrentDirectory(), ExportType.Json);
            List <IDContainer> list          = itemExtractor.PureExtract(false);

            List <string> nameListExtractor = new List <string>();

            foreach (IDContainer cont in list)
            {
                nameListExtractor.Add(cont.UniqueName);
            }

            for (int id = 0; id < list.Count; id++)
            {
                string dllVal  = itemUIDS[id];
                string extrVal = nameListExtractor[id];
                if (dllVal != extrVal)
                {
                    break;
                }
            }

            return(h);
        }
Example #2
0
        private static string CompareItemExtraction(string infile, string outfile,
                                                    string titlefile, ConsoleOutputList output, bool imageCompare = false)
        {
            var match = cursorPattern.Match(infile);

            if (!match.Success)
            {
                return("failed to extract cursor position!");
            }

            var bmp       = new Bitmap(infile);
            var cursorPos = new Point(match.Groups["x"].Value.ToInt(),
                                      match.Groups["y"].Value.ToInt());

            var  sw      = new Stopwatch();
            var  ie      = new ItemExtractor(bmp, cursorPos);
            Item item    = null;
            var  success = false;

            sw.Start();
            try
            {
                success = ie.FindItem();
                item    = ie.ExtractItem(false);
            }
            catch { }
            sw.Stop();

            var itemTime = sw.Elapsed.TotalSeconds;

            extractTimes.Add(itemTime);
            output.Add("(");
            output.AddTime(itemTime);

            var result = "";

            if (imageCompare)
            {
                result = CompareImageResult(success ? item.Image : null, outfile, "item");
            }
            else
            {
                var itemMatch = itemPattern.Match(infile);
                if (!itemMatch.Success)
                {
                    if (success)
                    {
                        result = string.Format(
                            "Unexpectedly found item at {0}", ie.ItemFrame);
                    }
                }
                else
                {
                    if (success)
                    {
                        var expected = new Rectangle(
                            itemMatch.Groups["x"].Value.ToInt(),
                            itemMatch.Groups["y"].Value.ToInt(),
                            itemMatch.Groups["width"].Value.ToInt(),
                            itemMatch.Groups["height"].Value.ToInt());
                        var found = ie.ItemFrame;

                        if (found != expected)
                        {
                            result = string.Format(
                                "Found item at {0}, expected {1}", found, expected);
                        }
                    }
                    else
                    {
                        result = "No item found";
                    }
                }
            }

            if (result == "")
            {
                Bitmap title = null;
                if (success)
                {
                    var titleWatch = new Stopwatch();
                    titleWatch.Start();

                    title = ItemExtractor.ExtractItemName(item.Image);

                    titleWatch.Stop();

                    var titleTime = titleWatch.Elapsed.TotalSeconds;
                    extractTitleTimes.Add(titleTime);
                    output.Add(" - ");
                    output.AddTime(titleTime);
                }

                result = CompareImageResult(title, titlefile, "title");
            }

            output.Add(") ");

            return(result);
        }