Esempio n. 1
0
        // 決定
        private void button_ok_Click(object sender, EventArgs e)
        {
            if (tb_pictfile_path.TextLength == 0)
            {
                MessageBox.Show("編集する画像ファイルを選択してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (!System.IO.File.Exists(tb_pictfile_path.Text))
            {
                MessageBox.Show("選択されたファイルが存在しません。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }


            string tmp = button_ok.Text;

            button_ok.Text = "変換中...";
            Enabled        = false;
            // ぱずぷれ形式に変換
            PictToDotManagement.makePzprFromMozaic(
                PictManagementForm.savedir_path,
                PictManagementForm.file_name,
                new Bitmap(pictureBox1.Image),
                (int)bar_mozaic_size.Value
                );
            button_ok.Text = tmp;
            Enabled        = true;
        }
Esempio n. 2
0
        // 反映
        private void button2_Click(object sender, EventArgs e)
        {
            if (tb_pictfile_path.TextLength == 0)
            {
                MessageBox.Show("編集する画像ファイルを選択してください。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (!System.IO.File.Exists(tb_pictfile_path.Text))
            {
                MessageBox.Show("選択されたファイルが存在しません。",
                                "エラー",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            Enabled           = false;
            pictureBox1.Image = PictToDotManagement.makeDotFromPict(
                PictManagementForm.dir_path,
                PictManagementForm.file_name,
                PictManagementForm.savedir_path,
                (byte)bar_binary.Value,
                (int)bar_mozaic_size.Value,
                (int)bar_mozaic.Value
                );
            //コントロールを再描画する。これがないと、新しい画像が表示されない。
            pictureBox1.Invalidate();
            Enabled = true;
        }
Esempio n. 3
0
        /*********************************
        *
        * 一繋がりの黒マス群を全て繋げる
        *
        * *******************************/
        private static void connectIsoBlackBoxGroup()
        {
            // 盤面の白マスを未定マスに変更する
            for (int i = 1; i <= Tapa.MAX_BOARD_ROW; i++)
            {
                for (int j = 1; j <= Tapa.MAX_BOARD_COL; j++)
                {
                    if (Tapa.box[i][j].Color == Box.WHITE)
                    {
                        Box tmp = Tapa.box[i][j];
                        tmp.revision_color = Box.NOCOLOR;
                        Tapa.not_deployedbox_coord_list.Add(tmp.coord);
                    }
                }
            }

            while (Tapa.isolation_blackboxes_group_list.Count != 1)
            {
                // 末尾のリストを取得(再構築された一繋がりの黒マスリストは末尾に追加される)
                List <Coordinates> bb_group_list
                    = Tapa.isolation_blackboxes_group_list[Tapa.isolation_blackboxes_group_list.Count - 1];

                Coordinates pair1        = new Coordinates();
                Coordinates pair2        = new Coordinates();
                int         distance     = int.MaxValue;
                int         tmp_distance = int.MaxValue;

                for (int i = bb_group_list.Count - 1; i >= 0; i--)
                {
                    Coordinates co     = bb_group_list[i];
                    Coordinates tmp_co = Box.getCloseBlackBoxCoord(co, bb_group_list);
                    tmp_distance = Box.getDistance(co, tmp_co);
                    if (tmp_distance < distance)
                    {
                        distance = tmp_distance;
                        pair1    = co;
                        pair2    = tmp_co;
                    }
                }
                // 黒マス同士を繋げる処理
                PictToDotManagement.connectBlackBox(pair1, pair2);
            }
        }
Esempio n. 4
0
        // リセット
        private void button_no_Click(object sender, EventArgs e)
        {
            if (tb_pictfile_path.TextLength == 0)
            {
                return;
            }

            Enabled = false;
            // サイズ、しきい値の初期化
            bar_binary.Value      = DEF_THR_BINARY;
            bar_mozaic_size.Value = DEF_MOZAIC_SIZE;
            bar_mozaic.Value      = DEF_THR_MOZAIC_COLOR;

            pictureBox1.Image = PictToDotManagement.makeDotFromPict(
                PictManagementForm.dir_path, PictManagementForm.file_name, PictManagementForm.savedir_path
                , DEF_THR_BINARY, DEF_MOZAIC_SIZE, DEF_THR_MOZAIC_COLOR);

            pictureBox1.Invalidate();
            Enabled = true;
        }
Esempio n. 5
0
        // 画像選択
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.tb_pictfile_path.Text.Length == 0)
            {
                this.open_pictfile.FileName         = @"*.jpg";
                this.open_pictfile.InitialDirectory =
                    Environment.GetFolderPath(
                        Environment.SpecialFolder.Desktop);
            }
            else
            {
                this.open_pictfile.FileName =
                    System.IO.Path.GetFileName(this.tb_pictfile_path.Text);
                this.open_pictfile.InitialDirectory =
                    System.IO.Path.GetDirectoryName(this.tb_pictfile_path.Text);
            }

            this.open_pictfile.DefaultExt = "画像ファイル(*.bmp,*.jpg,*.png,*.gif)|*.bmp;*.jpg;*.png;*.gif";
            //this.open_pictfile.Filter = @"JPEG(*.jpg)|*.jpg|"
            //							+ @"ビットマップファイル(*.bmp)|*.bmp|"
            //							+ @"GIFファイル(*.gif)|*.gif|"
            //							+ @"すべて(*.*)|*.*";

            this.open_pictfile.FilterIndex = 1;
            this.open_pictfile.Title       = @"問題を生成したい画像を選択";
            if (this.open_pictfile.ShowDialog() == DialogResult.OK)
            {
                this.tb_pictfile_path.Text = this.open_pictfile.FileName;
                // オリジナル画像のディレクトリパス、ファイル名の取得
                PictManagementForm.file_name = System.IO.Path.GetFileName(this.tb_pictfile_path.Text);
                PictManagementForm.dir_path  = System.IO.Path.GetDirectoryName(this.tb_pictfile_path.Text);
                // 保存先のディレクトリを作成、パスを取得
                PictManagementForm.savedir_path
                    = FolderManagement.makeFolder(PictManagementForm.dir_path, PictManagementForm.file_name);
                pictureBox1.Image = PictToDotManagement.makeDotFromPict(
                    PictManagementForm.dir_path, PictManagementForm.file_name, PictManagementForm.savedir_path);
            }
        }