Esempio n. 1
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (comboBox5.SelectedIndex <= 0)
            {
                return;
            }

            Trimming.TrimmingBitmap(elements[comboBox5.SelectedIndex - 1], img, new Size(50 + (int)MyRandom.Next(100), 50 + (int)MyRandom.Next(100)));

            this.Refresh();
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (isAnswer)
            {
                Bitmap   bmp = new Bitmap(imgPath + file + ".png");
                Graphics g   = Graphics.FromImage(bmp);

                g.TranslateTransform(Trimming.centerLast.X, Trimming.centerLast.Y);
                g.DrawRectangle(Pens.Red, -img.Width / 2, -img.Height / 2, img.Width, img.Height);

                g.Dispose();

                ivf.BackgroundImage = bmp;

                button1.Text = "start";
                ivf.Size     = ansSize;
                label1.Text  = "";
            }
            else
            {
                // 画像選択
                List <string> correctFiles = new List <string>();
                int           selectedImage;

                for (int i = 0; i < filename.Length; i++)
                {
                    file = filename[i];

                    identity = LoadSettingIdentity(file);

                    if (kindChecks[identity.kind].Checked && updateChecks[identity.update].Checked && damageChecks[identity.damage].Checked)
                    {
                        correctFiles.Add(file);
                    }
                }

                while (true)
                {
                    int i;

                    selectedImage = (int)MyRandom.Next((uint)correctFiles.Count);

                    for (i = 0; i < appearingLogs.Count; i++)
                    {
                        if (selectedImage == appearingLogs[i])
                        {
                            break;
                        }
                    }

                    if (i == appearingLogs.Count)
                    {
                        break;
                    }
                }

                if (appearingLogs.Count == numericUpDown1.Value)
                {
                    appearingLogs.RemoveAt(0);
                    appearingLogs.Add(selectedImage);
                }
                else
                {
                    appearingLogs.Add(selectedImage);
                }

                //for (int i = 0; i < appearingLogs.Count; i++)
                //{
                //    Console.Write(appearingLogs[i] + " ");
                //}
                //Console.WriteLine();

                file = correctFiles[selectedImage];
                totals[selectedImage]++;

                // 属性選択
                int selectedElement;

                while (true)
                {
                    selectedElement = (int)MyRandom.Next((uint)elementChecks.Length);
                    LoadSetting(file, selectedElement);

                    if (elementChecks[selectedElement].Checked && element.pos != Point.Empty && element.xr > 1 && element.yr > 1)
                    {
                        break;
                    }
                }

                Bitmap bmp = new Bitmap(imgPath + correctFiles[selectedImage] + ".png");

                Size size = new Size(trackBar1.Value + (int)MyRandom.Next((uint)trackBar2.Value), trackBar1.Value + (int)MyRandom.Next((uint)trackBar2.Value));

                // 生成
                img = Trimming.TrimmingBitmap(element, bmp, size);

                if (radioButton1.Checked)
                {
                    ivf.BackgroundImage = img;
                    ivf.Size            = questionSize;
                }
                else
                {
                    Bitmap   hintImg = new Bitmap(bmp.Width, bmp.Height);
                    Graphics g       = Graphics.FromImage(hintImg);

                    g.Clear(Color.Black);
                    g.DrawImage(img, new Rectangle(Trimming.centerLast.X - img.Width / 2, Trimming.centerLast.Y - img.Height / 2, img.Width, img.Height), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
                    g.Dispose();

                    ivf.BackgroundImage = hintImg;
                    ivf.Size            = ansSize;
                }

                button1.Text = "answer";
            }

            isAnswer = !isAnswer;
        }