コード例 #1
0
        private void animeView_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);

            float elapsedTime = 0;
            int   i           = -1;

            for (i = 0; i < animeCells.Count; i++)
            {
                elapsedTime += animeCells[i].durationMilliseconds;
                if (playTime <= elapsedTime)
                {
                    break;
                }
            }

            if (i < 0 || animeCells.Count <= i)
            {
                return;
            }

            AnimeCell cell = animeCells[i];

            if (!composedImageDict.ContainsKey(cell.key))
            {
                return;
            }

            Bitmap bmp  = composedImageDict[cell.key];
            SizeF  size = BitmapHandler.GetFittingSize(bmp, animeView.Width, animeView.Height);
            float  ox   = (animeView.Width - size.Width) * 0.5f;
            float  oy   = (animeView.Height - size.Height) * 0.5f;

            e.Graphics.DrawImage(bmp, ox, oy, size.Width, size.Height);
        }
コード例 #2
0
        private void AssignAnimeCells(List <AnimeCell> cells, AnimeCell prevCell)
        {
            var prevCells = new List <AnimeCell>();

            prevCells.Add(prevCell);
            for (int i = 0; i < cells.Count - 1; i++)
            {
                prevCells.Add(cells[i]);
            }
            AssignAnimeCells(cells, prevCells, true);
        }
コード例 #3
0
ファイル: Form1_View.cs プロジェクト: furaga/Magic2D_rev3
        private void DrawAnimeCells(Graphics g, Dictionary <string, Bitmap> imageDict, List <AnimeCell> cells, List <AnimeCell> addingCells, AnimeCell prevCell, List <AnimeCell> selectCells, int fw, int fh)
        {
            g.Clear(Color.White);

            int gw = fw / cellGridWidth;
            int gh = cells.Count / gw + (cells.Count % gw >= 1 ? 1 : 0);

            int idx = 0;

            for (int gy = 0; gy < gh; gy++)
            {
                for (int gx = 0; gx < gw; gx++)
                {
                    Rectangle rect = new Rectangle(gx * cellGridWidth, gy * cellGridHeight, cellWidth, cellHeight);

                    if (idx >= cells.Count)
                    {
                        continue;
                    }

                    g.FillRectangle(Brushes.LightGray, rect);
                    if (imageDict.ContainsKey(cells[idx].key))
                    {
                        Bitmap bmp  = imageDict[cells[idx].key];
                        SizeF  size = BitmapHandler.GetFittingSize(bmp, cellWidth, cellHeight);
                        float  ox   = (cellWidth - size.Width) * 0.5f;
                        float  oy   = (cellHeight - size.Height) * 0.5f;
                        g.DrawImage(bmp, rect.X + ox, rect.Y + oy, size.Width, size.Height);
                    }

                    idx++;
                }
            }

            foreach (var cell in selectCells)
            {
                if (prevCell != null && !cells.Contains(cell))
                {
                    continue;
                }
                int       i    = cells.IndexOf(cell);
                int       gx   = i % gw;
                int       gy   = i / gw;
                Rectangle rect = new Rectangle(gx * cellGridWidth, gy * cellGridHeight, cellWidth, cellHeight);
                g.DrawRectangle(cellHighlightPen, rect);
            }

            if (prevCell == null || cells.Contains(prevCell))
            {
                int i = prevCell == null ? -1 : cells.IndexOf(prevCell);
                i += 1;
                int       gx   = i % gw;
                int       gy   = i / gw;
                Rectangle rect = new Rectangle(gx * cellGridWidth, gy * cellGridHeight, 3, cellGridHeight);
                g.FillRectangle(Brushes.Black, rect);
            }
        }