Esempio n. 1
0
        private Identity LoadSettingIdentity(string name)
        {
            string path = settingPath + name + ".txt";
            Identity identity = new Identity();

            using (StreamReader sr = new StreamReader(path, Encoding.GetEncoding("Shift_JIS")))
            {
                identity.name = sr.ReadLine();
                identity.kind = int.Parse(sr.ReadLine());
                identity.update = int.Parse(sr.ReadLine());
                identity.damage = int.Parse(sr.ReadLine());
            }

            return identity;
        }
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;
        }
Esempio n. 3
0
        private void LoadSetting(string file, int elementNum)
        {
            string path = settingPath + file + ".txt";

            using (StreamReader sr = new StreamReader(path, Encoding.GetEncoding("Shift_JIS")))
            {
                identity = new Identity();

                identity.name = sr.ReadLine();
                identity.kind = int.Parse(sr.ReadLine());
                identity.update = int.Parse(sr.ReadLine());
                identity.damage = int.Parse(sr.ReadLine());

                for (int i = 0; i < elementNum; i++)
                {
                    sr.ReadLine();
                    sr.ReadLine();
                    sr.ReadLine();
                    sr.ReadLine();
                    sr.ReadLine();
                }

                element = new Element();
                element.pos.X = int.Parse(sr.ReadLine());
                element.pos.Y = int.Parse(sr.ReadLine());
                element.xr = int.Parse(sr.ReadLine());
                element.yr = int.Parse(sr.ReadLine());
                element.angle = int.Parse(sr.ReadLine());
            }
        }