Example #1
0
        private bool GetBitmapToFind()
        {
            Bitmap bmpToFind;

            m_pathToImage = _vm.variables.Get(m_params[1]);

            Directory.SetCurrentDirectory(_vm.host.StartupPath);

            m_pathToImage = Path.GetFullPath(m_pathToImage);
            _vm.host.WriteLog("fullpath: " + m_pathToImage);

            if (!File.Exists(m_pathToImage))
            {
                string msg = "Image File not found [" + m_pathToImage + "]";
                _vm.host.WriteLog(msg);
                return(false);
            }

            bmpToFind = (Bitmap)Bitmap.FromFile(m_pathToImage);

            imgSize  = new Size(bmpToFind.Width, bmpToFind.Height);
            arrImage = new Color[bmpToFind.Width, bmpToFind.Height];

            GetPixels(bmpToFind, arrImage);

            mapToFind.Clear();

            Color color;

            for (int y = 0; y < bmpToFind.Height; ++y)
            {
                for (int x = 0; x < bmpToFind.Width; ++x)
                {
                    color = arrImage[x, y];

                    if (mapToFind.ContainsKey(color))
                    {
                        colorInfo c = mapToFind[color];
                        ++c.count;
                        c.color          = color;
                        c.x              = x;
                        c.y              = y;
                        mapToFind[color] = c;
                    }
                    else
                    {
                        colorInfo c = new colorInfo();
                        c.color = color;
                        c.count = 1;
                        c.x     = x;
                        c.y     = y;
                        mapToFind.Add(color, c);
                    }
                }
            }

            bmpToFind.Dispose();
            return(true);
        }
Example #2
0
 public int Add(colorInfo info)
 {
     SqlParameter[] param =
     {
         new SqlParameter("@name",  info.name),
         new SqlParameter("@value", info.value)
     };
     return(int.Parse(DataHelper.ExecuteScalar(Config.ConnectString, "usp_color_Add", param).ToString()));
 }
Example #3
0
 public int Update(colorInfo info)
 {
     SqlParameter[] param =
     {
         new SqlParameter("@id",    info.id)
         ,                          new SqlParameter("@name",info.name),
         new SqlParameter("@value", info.value)
     };
     return(DataHelper.ExecuteNonQuery(Config.ConnectString, "usp_color_Update", param));
 }
Example #4
0
        private void PickColorsAndDeltas(ref Color prev)
        {
            int       count = 100000;
            int       index = 0;
            colorInfo minColor;

            minColor.color = Color.Red;
            minColor.x     = -1;
            minColor.y     = -1;
            List <colorInfo> list = new List <colorInfo>();

            foreach (colorInfo ci in mapToFind.Values)
            {
                list.Add(ci);
            }

            for (int i = 0; i < list.Count; ++i)
            {
                colorInfo ci = list[i];

                if (ci.count <= count)
                {
                    index    = i;
                    count    = ci.count;
                    minColor = ci;
                }

                list[i] = ci;
            }

            colors[0] = minColor.color;
            points[0] = new Point(minColor.x, minColor.y);

            list.RemoveAt(index);

            count = 100000;

            for (int i = 0; i < list.Count; ++i)
            {
                colorInfo ci = list[i];

                if (ci.count <= count)
                {
                    index    = i;
                    count    = ci.count;
                    minColor = ci;
                }

                list[i] = ci;
            }

            colors[1] = minColor.color;
            points[1] = new Point(minColor.x, minColor.y);
        }
Example #5
0
        public List <colorInfo> GetList(int pageIndex, int pageSize, out int total)
        {
            List <colorInfo> list = null;
            var t = 0;

            SqlParameter[] param =
            {
                new SqlParameter("@pageIndex", pageIndex),
                new SqlParameter("@pageSize",  pageSize),
                new SqlParameter("@totalrow",  DbType.Int32)
                {
                    Direction = ParameterDirection.Output
                }
            };
            SqlCommand comx;
            var        r = DataHelper.ExecuteReader(Config.ConnectString, "usp_color_GetList", param, out comx);

            if (r != null)
            {
                list = new List <colorInfo>();
                while (r.Read())
                {
                    var info = new colorInfo();
                    info.id    = Int32.Parse(r["id"].ToString());
                    info.name  = r["name"].ToString();
                    info.value = r["value"].ToString();


                    list.Add(info);
                }
                r.Close();
                r.Dispose();
                t = int.Parse(comx.Parameters[2].Value.ToString());
            }

            total = t;
            return(list);
        }
Example #6
0
        public colorInfo GetInfo(int id)
        {
            colorInfo info = null;

            SqlParameter[] param =
            {
                new SqlParameter("@id", id)
            };
            var r = DataHelper.ExecuteReader(Config.ConnectString, "usp_color_GetById", param);

            if (r != null)
            {
                info = new colorInfo();
                while (r.Read())
                {
                    info.id    = Int32.Parse(r["id"].ToString());
                    info.name  = r["name"].ToString();
                    info.value = r["value"].ToString();
                }
                r.Close();
                r.Dispose();
            }
            return(info);
        }