Exemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            //②-A 描画に利用するリソースの初期化
            textFormat = SpriteBatch.CreateTextformat("Meiriyo", 30, FontWeight.Bold);
            //Specify the text format alignment do。
            textFormat.Format.ParagraphAlignment = ParagraphAlignment.Center; //Vertical alignment。Center:中央、Near:上、Far:下
            textFormat.Format.TextAlignment      = TextAlignment.Center;      //Horizontal alignment。Center:中央、Near:左、Far:右


            colorBrush = SpriteBatch.CreateSolidColorBrush(Color.OrangeRed);


            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "ビットマップファイル(*.bmp)|*.bmp|PNGファイル(*.png)|*.png|JPGファイル(*.jpg)|*.jpg|すべてのファイル(*.*)|*.*";
            if (ofd.ShowDialog(this) == DialogResult.OK)
            {
                bitmap = SpriteBatch.CreateBitmap(ofd.FileName);
            }
            else
            {
                Close();
            }



            /*
             * 画面がリサイズされた時などには、SpriteBatchが自動的にリサイズされる。
             * この時、リソースも作り直す必要性があるためSpriteBatch.Create~~として取得できるD2DSprite~~は自動的に
             * リサイズ時などに同じ設定で再作成される。
             * ただし、すべてのDirectWriteに利用するクラスについてこれは実装を完了していない。
             */
            OpenFileDialog ofd2 = new OpenFileDialog();

            ofd2.Filter = "PMXモデルファイル(*.pmx)|*.pmx";
            if (ofd2.ShowDialog(this) == DialogResult.OK)
            {
                WorldSpace.AddResource(PMXModelWithPhysics.OpenLoad(ofd2.FileName, RenderContext));
            }
        }