/[RomCheater]/trunk/RomCheater/Serialization/SearchResultReader.cs
ViewVC logotype

Diff of /trunk/RomCheater/Serialization/SearchResultReader.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Serialization/SearchResultReader.cs	2013/06/03 03:00:13	460
+++ trunk/RomCheater/Serialization/SearchResultReader.cs	2013/06/03 03:24:07	461
@@ -32,6 +32,8 @@
     public class SearchResultReader : SerializationReader, ISearchResultReader
     {
 
+        public delegate void update_progress(int progress, string message);
+
         private Guid _ResultGuid;
         private Guid ResultGuid { get { return _ResultGuid; } set { _ResultGuid = value; } }
 
@@ -133,29 +135,29 @@
         #endregion
 
 
-        public ResultItem[] GetResultItems(SearchType SearchArgs, IAcceptsProcessAndConfig iapc, ProgressBarWithPercentageLabel progress)
+        public ResultItem[] GetResultItems(bool unsigned, SearchDataTypes datatype, Action<int, string> update_progress)
         {
-            var arr = GetResults(SearchArgs, iapc, progress);
+            var arr = GetResults(unsigned, datatype, update_progress);
             ResultItem[] items = new ResultItem[arr.Count()];
             for (int i = 0; i < items.Count(); i++)
             {
                 var v = arr[i];
-                switch (SearchArgs.DataType)
+                switch (datatype)
                 {
                     case SearchDataTypes._8bits:
-                        if (SearchArgs.IsUnsignedDataType) { items[i] = new ResultItem(v.Address, false, Convert.ToByte(v.Value)); }
+                        if (unsigned) { items[i] = new ResultItem(v.Address, false, Convert.ToByte(v.Value)); }
                         else { items[i] = new ResultItem(v.Address, false, Convert.ToSByte(v.Value)); }
                         break;
                     case SearchDataTypes._16bits:
-                        if (SearchArgs.IsUnsignedDataType) { items[i] = new ResultItem(v.Address, false, Convert.ToUInt16(v.Value)); }
+                        if (unsigned) { items[i] = new ResultItem(v.Address, false, Convert.ToUInt16(v.Value)); }
                         else { items[i] = new ResultItem(v.Address, false, Convert.ToInt16(v.Value)); }
                         break;
                     case SearchDataTypes._32bits:
-                        if (SearchArgs.IsUnsignedDataType) { items[i] = new ResultItem(v.Address, false, Convert.ToUInt32(v.Value)); }
+                        if (unsigned) { items[i] = new ResultItem(v.Address, false, Convert.ToUInt32(v.Value)); }
                         else { items[i] = new ResultItem(v.Address, false, Convert.ToInt32(v.Value)); }
                         break;
                     case SearchDataTypes._64bits:
-                        if (SearchArgs.IsUnsignedDataType) { items[i] = new ResultItem(v.Address, false, Convert.ToUInt64(v.Value)); }
+                        if (unsigned) { items[i] = new ResultItem(v.Address, false, Convert.ToUInt64(v.Value)); }
                         else { items[i] = new ResultItem(v.Address, false, Convert.ToInt64(v.Value)); }
                         break;
                 }
@@ -165,9 +167,9 @@
         }
 
 
-        public uint[] GetResultAddresses(SearchType SearchArgs, IAcceptsProcessAndConfig iapc, ProgressBarWithPercentageLabel progress)
+        public uint[] GetResultAddresses(bool unsigned, SearchDataTypes datatype, Action<int, string> update_progress)
         {
-            var arr = GetResults(SearchArgs, iapc, progress);
+            var arr = GetResults(unsigned, datatype, update_progress);
             uint[] items = new uint[arr.Count()];
             for (int i = 0; i < items.Count(); i++)
             {
@@ -177,16 +179,14 @@
             }
             return items;
         }
-        public ResultType<object>[] GetResults(SearchType SearchArgs, IAcceptsProcessAndConfig iapc, ProgressBarWithPercentageLabel progress)
+        public ResultType<object>[] GetResults(bool unsigned, SearchDataTypes datatype, Action<int, string> update_progress)
         {
-            return GetResultsInternal(SearchArgs, iapc, progress);
+            return GetResultsInternal(unsigned, datatype, update_progress);
         }
 
-        private ResultType<object>[] GetResultsInternal(SearchType SearchArgs, IAcceptsProcessAndConfig iapc, ProgressBarWithPercentageLabel progress)
+        private ResultType<object>[] GetResultsInternal(bool unsigned, SearchDataTypes datatype, Action<int, string> update_progress)
         {
-            progress.Value = 0;
-            progress.Message = string.Empty;
-
+            update_progress.Invoke(0, string.Empty);
             int Last_Whole_Percent_Done = 0;
 
             ResultType<object>[] results = new ResultType<object>[ResultCount];
@@ -200,19 +200,19 @@
                     {                        
                         uint Address = binReader.ReadUInt32();
                         object Value = 0;
-                        switch (SearchArgs.DataType)
+                        switch (datatype)
                         {
                             case SearchDataTypes._8bits:
-                                if (SearchArgs.IsUnsignedDataType) { Value = binReader.ReadByte(); } else { Value = binReader.ReadSByte(); }
+                                if (unsigned) { Value = binReader.ReadByte(); } else { Value = binReader.ReadSByte(); }
                                 break;
                             case SearchDataTypes._16bits:
-                                if (SearchArgs.IsUnsignedDataType) { Value = binReader.ReadUInt16(); } else { Value = binReader.ReadInt16(); }
+                                if (unsigned) { Value = binReader.ReadUInt16(); } else { Value = binReader.ReadInt16(); }
                                 break;
                             case SearchDataTypes._32bits:
-                                if (SearchArgs.IsUnsignedDataType) { Value = binReader.ReadUInt32(); } else { Value = binReader.ReadInt32(); }
+                                if (unsigned) { Value = binReader.ReadUInt32(); } else { Value = binReader.ReadInt32(); }
                                 break;
                             case SearchDataTypes._64bits:
-                                if (SearchArgs.IsUnsignedDataType) { Value = binReader.ReadUInt64(); } else { Value = binReader.ReadInt64(); }
+                                if (unsigned) { Value = binReader.ReadUInt64(); } else { Value = binReader.ReadInt64(); }
                                 break;
                         }
                         results[i] = new ResultType<object>(Address, Value);
@@ -222,17 +222,15 @@
                         if (int_percent_done != Last_Whole_Percent_Done && i % 100000 == 0)
                         {
                             if (int_percent_done <= 100)
-                            {
-                                progress.Value = int_percent_done;
-                                progress.Message = string.Format(" -> Loading value for Address: 0x{0:x8}", Address);
+                            {                                
+                                update_progress.Invoke(int_percent_done, string.Format(" -> Loading value for Address: 0x{0:x8}", Address));
                                 Last_Whole_Percent_Done = int_percent_done;
                             }
                         }
                     }
                 }
             }
-            progress.Value = 0;
-            progress.Message = string.Empty;
+            update_progress.Invoke(0, string.Empty);
             return results;
         }
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22