Beispiel #1
0
 static void Main(string[] args)
 {
     if (args.Length == 3)
     {
         if (args[0].ToLower() == "create")
         {
             RankTemplate.Create(args[1], args[2]);
         }
         else if (args[0].ToLower() == "match")
         {
             RankDetection.SetTemplateLocation(args[1]);
             var match = RankDetection.Match(new Bitmap(args[2]), true);
             System.Console.WriteLine(match);
         }
     }
 }
Beispiel #2
0
            private SortByRank(ListView list, string filterTypeStr)
            {
                m_list = list;

                if (!list.IsHandleCreated)
                {
                    return;
                }

                List <int> removeIndex = new List <int>();

                // Replace item data with pointer with new RankTemplate struct.
                for (int i = 0; i < m_list.Items.Count; i++)
                {
                    IEditTemplate template = m_list.Items[i].Tag as IEditTemplate;
                    int           nName, nTags, nLayerName, nDesc, nPartial;
                    if (!AnalyzeItem(filterTypeStr, template, out nName, out nTags, out nLayerName, out nDesc, out nPartial))
                    {
                        removeIndex.Insert(0, i);
                        continue;
                    }

                    m_list.Items[i].Tag = new RankTemplate(FindRank(nName, nTags, nLayerName, nDesc, nPartial), template);
                }

                for (int i = 0; i < removeIndex.Count(); i++)
                {
                    m_list.Items.RemoveAt(removeIndex[i]);
                }

                IComparer oldComparer = m_list.ListViewItemSorter;

                m_list.ListViewItemSorter = this as IComparer; //assigning performs the sort
                m_list.ListViewItemSorter = null;

                // Restore item data from RankTemplate struct.
                for (int i = 0; i < m_list.Items.Count; i++)
                {
                    RankTemplate rankTemplate = m_list.Items[i].Tag as RankTemplate;
                    if (rankTemplate != null)
                    {
                        m_list.Items[i].Tag = rankTemplate.Template;
                    }
                }
            }
Beispiel #3
0
            public int Compare(object x, object y)
            {
                //The comparison function must return a negative value if the first item should precede the second, a positive value if the first item should follow the second, or zero if the two items are equivalent.
                RankTemplate xx = ((ListViewItem)x).Tag as RankTemplate;
                RankTemplate yy = ((ListViewItem)y).Tag as RankTemplate;

                if (xx.Rank > yy.Rank)
                {
                    return(-1);
                }
                else if (xx.Rank < yy.Rank)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }