コード例 #1
0
        public void Draw(Bitmap img)
        {
            new Thread(() => Application.Run(new IndicatorForm(img.Width, img.Height))).Start();
            Thread.Sleep(5000);

            Metrics metrics;

            switch (this.Mode)
            {
            case 1:
                metrics = new Metrics("OptimizedDrafter Horizontal");
                break;

            case 2:
                metrics = new Metrics("OptimizedDrafter Vertical");
                break;

            case 3:
                metrics = new Metrics("OptimizedDrafter 2D");
                break;

            case 4:
                metrics = new Metrics("OptimizedDrafter 4D");
                break;

            default:
                metrics = new Metrics("OptimizedDrafter");
                break;
            }


            List <List <bool> > img_c = new List <List <bool> >();

            for (int i = 0; i < img.Width; i++)
            {
                img_c.Add(new List <bool>());
                for (int j = 0; j < img.Height; j++)
                {
                    img_c[i].Add(false);
                }
            }

            for (int x = 0; x < img.Width; x++)
            {
                for (int y = 0; y < img.Height; y++)
                {
                    Color clr = img.GetPixel(x, y);
                    if (((clr.R + clr.G + clr.B) / 3) < Settings.Default.sensitivity)
                    {
                        img_c[x][y] = true;
                        metrics.TotalPixels++;
                    }
                }
            }

            Point st_pos = Cursor.Position;

            DrawArray(img_c, st_pos, this.Mode, metrics);

            metrics.EndTime = DateTime.Now;
            if (Settings.Default.metrics)
            {
                Application.Run(new MetricsForm(metrics));
            }
        }
コード例 #2
0
        public static void DrawArray(List <List <bool> > img_c, Point st_pos, int Mode, Metrics metrics)
        {
            while (!findPixel(img_c).IsEmpty)
            {
                Point px = findPixel(img_c);
                Cursor.Position = new Point(st_pos.X + px.X, st_pos.Y + px.Y);
                metrics.MouseClicks++;
                mouse_event((int)(MouseEventFlags.LEFTDOWN), 0, 0, 0, 0);
                img_c[px.X][px.Y] = false;
                while (toDrawExists(px, img_c, Mode) != 0)
                {
                    switch (toDrawExists(px, img_c, Mode))
                    {
                    case 1:
                        px.X++;
                        Cursor.Position   = new Point(st_pos.X + px.X, st_pos.Y + px.Y);
                        img_c[px.X][px.Y] = false;
                        break;

                    case 2:
                        px.Y++;
                        Cursor.Position   = new Point(st_pos.X + px.X, st_pos.Y + px.Y);
                        img_c[px.X][px.Y] = false;
                        break;

                    case 3:
                        px.X--;
                        Cursor.Position   = new Point(st_pos.X + px.X, st_pos.Y + px.Y);
                        img_c[px.X][px.Y] = false;
                        break;

                    case 4:
                        px.Y--;
                        Cursor.Position   = new Point(st_pos.X + px.X, st_pos.Y + px.Y);
                        img_c[px.X][px.Y] = false;
                        break;
                    }
                    metrics.PixelsDrafted++;
                }
                mouse_event((int)(MouseEventFlags.LEFTUP), 0, 0, 0, 0);
                Thread.Sleep(Settings.Default.wait_delay);
            }
        }