Ejemplo n.º 1
0
        public static void ShowAnime()
        {
            //素材を拡大して色を変えるメソッド
            //Sheet1のR1C1に素材名R1C2に拡大率(整数)R1C3に色(0なら色はそのまま)
            //Ctrl + Shift + Q
            dynamic app  = ExcelDnaUtil.Application;
            dynamic ws1  = app.Worksheets["Sheet1"];
            string  name = ws1.Cells[1, 1].Text;

            CellImage[] images = null;
            if (!ImageContainer.Instance.Animations.ContainsKey(name))
            {
                if (!ImageContainer.Instance.Images.ContainsKey(name))
                {
                    MessageBox.Show("No Image");
                    return;
                }
                images    = new CellImage[1];
                images[0] = ImageContainer.Instance.Images[name];
            }
            images = ImageContainer.Instance.Animations[name].Images;
            var mag   = Convert.ToInt32(ws1.Cells[1, 2].Text);
            var color = Convert.ToInt32((ws1.Cells[1, 3].Text), 16);

            for (int i = 0; i < images.Length; i++)
            {
                var image = images[images.Length - i - 1];
                image.DrawExtend(ws1, mag, 1 + i * image.Height * mag, 4, color);
                var range = ws1.Range[ws1.Cells[1 + i * image.Height * mag, 4], ws1.Cells[1 + (i + 1) * image.Height * mag - 1, 3 + image.Width * mag]];
                range.BorderAround2(LineStyle: 1);//XlDataBarBorderType.xlDataBarBorderSolid
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ワークシートからセル画像をロードします
        /// </summary>
        /// <param name="sheet">ロード元の画像</param>
        /// <param name="images">画像と名前のテーブル</param>
        /// <param name="animes">アニメーションと名前のテーブル</param>
        void LoadImages(dynamic sheet)
        {
            var imagePairs  = new Dictionary <string, CellImage>();
            var animePairs  = new Dictionary <string, CellAnimation>();
            int currentLine = 2;

            while (!String.IsNullOrEmpty((sheet.Cells[currentLine, 1].Text)))
            {
                var name  = sheet.Cells[currentLine, 1].Text;
                var rect  = CellRectangle.LoadImageInfo(sheet, currentLine);
                var frame = sheet.Cells[currentLine, 6].Text;
                var image = new CellImage(sheet, rect);
                imagePairs.Add(name, image);

                var frameCount = Int32.Parse(frame);
                //一枚以上あるなら
                if (frameCount > 1)
                {
                    //アニメーションを読み込み
                    animePairs.Add(name, CellAnimation.Load(sheet, rect, frameCount));
                }

                currentLine++;
            }
            images     = imagePairs;
            animations = animePairs;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// アニメーションをロードします
        /// </summary>
        /// <param name="sheet">取得元のワークシート</param>
        /// <param name="rect">一つのフレームの大きさ</param>
        /// <param name="frameCount">フレーム数</param>
        /// <returns>取得されたアニメーション</returns>
        public static CellAnimation Load(dynamic sheet, CellRectangle rect, int frameCount)
        {
            var imageList = new List <CellImage>();

            for (int i = 0; i < frameCount; i++)
            {
                var rec = new CellRectangle()
                {
                    Row    = rect.Row + rect.Height * i,
                    Column = rect.Column,
                    Width  = rect.Width,
                    Height = rect.Height,
                };
                var img = new CellImage(sheet, rec);
                imageList.Add(img);
            }
            imageList.Reverse();
            return(new CellAnimation(imageList.ToArray()));
        }