コード例 #1
0
        private void panelDBTileLibList_MouseDown(object sender, MouseEventArgs e)
        {
            PanelCustom panel = (PanelCustom)sender;
            int         start = vScrollBarTileLibList.Value;
            int         index = (e.Y / this.FontHeight) + start;

            if (tileLibs.Count <= 0)
            {
                return;
            }

            if (index >= tileLibs.Count)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                SelectTileLib(index);

                textBoxCustomTileWidth.Text  = currentTileLib.cellWidth.ToString();
                textBoxCustomTileHeight.Text = currentTileLib.cellHeight.ToString();
            }

            panel.Invalidate();
        }
コード例 #2
0
        private void panelDBLayerList_MouseDown(object sender, MouseEventArgs e)
        {
            PanelCustom panel = (PanelCustom)sender;
            int         start = vScrollBarMapLayerList.Value;
            int         index = (e.Y / this.FontHeight) + start;

            if (tileMap.layerList.Count <= 0)
            {
                return;
            }

            if (index >= tileMap.layerList.Count)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                SelectMapLayer(index);
            }

            label11.Text = currentMapLayer.ToString() + ": " + tileMap.layerList.IndexOf(currentMapLayer).ToString();

            panel.Invalidate();
            panelCustomMapWindow.Invalidate();
        }
コード例 #3
0
        private void panelCustomColourSample_Paint(object sender, PaintEventArgs e)
        {
            PanelCustom panel = (PanelCustom)sender;

            colour          = Color.FromArgb(red, green, blue);
            panel.BackColor = colour;
        }
コード例 #4
0
        private void PanelCustomMapWindow_Paint(object sender, PaintEventArgs e)
        {
            PanelCustom  panel = (PanelCustom)sender;
            int          cellWidth, cellHeight;
            int          fieldCols, fieldRows;
            int          hScroll, vScroll;
            int          cellIndex;
            int          tileLibIndex;
            int          tileIndex;
            TileMapLayer layer;
            Bitmap       image;

            for (int layerIndex = 0; layerIndex < tileMap.layerList.Count; layerIndex++)
            {
                if (mapLayerCheckBoxes[layerIndex].Checked == true)
                {
                    layer      = tileMap.layerList[layerIndex];
                    cellWidth  = layer.cellWidth;
                    cellHeight = layer.cellHeight;
                    hScroll    = layer.hScroll;
                    vScroll    = layer.vScroll;
                    fieldCols  = panel.Width / cellWidth;
                    fieldRows  = panel.Height / cellHeight;

                    if (fieldCols > layer.columnCount)
                    {
                        fieldCols = layer.columnCount;
                    }

                    if (fieldRows > layer.rowCount)
                    {
                        fieldRows = layer.rowCount;
                    }

                    for (int row = 0; row < fieldRows; row++)
                    {
                        for (int col = 0; col < fieldCols; col++)
                        {
                            int index = ((layer.columnCount * row) + vScroll) + (col + hScroll);
                            tileLibIndex = layer.cellCache[index].tileLibIndex;
                            tileIndex    = layer.cellCache[index].tileIndex;

                            if (tileIndex >= 0 && tileIndex >= 0)
                            {
                                image = tileLibs[tileLibIndex].GetImage(tileIndex);
                                e.Graphics.DrawImage(image, cellWidth * col, cellHeight * row);
                            }

                            e.Graphics.DrawRectangle(new Pen(currentMapLayer.gridColour), cellWidth * col, cellHeight * row, cellWidth, cellHeight);
                        }
                    }
                }
            }
        }
コード例 #5
0
        private void panelDBLayerList_Paint(object sender, PaintEventArgs e)
        {
            PanelCustom panel          = (PanelCustom)sender;
            Point       mousePoint     = panel.PointToClient(Cursor.Position);
            int         fieldRows      = panel.Height / this.FontHeight;
            int         rowHeight      = this.FontHeight;
            int         index          = GetCurrentLayerIndex();
            int         highlightIndex = mousePoint.Y / this.FontHeight;
            int         start          = vScrollBarMapLayerList.Value;

            if (tileMap.layerList.Count <= 0)
            {
                return;
            }

            if (index >= 0)
            {
                e.Graphics.FillRectangle(Brushes.PowderBlue, 0, rowHeight * (index - start), panelCustomLayerList.Width, rowHeight);
            }

            if (highlightIndex + start < tileMap.layerList.Count)
            {
                if (mousePoint.X > 0 && mousePoint.X < panelCustomLayerList.Width - 3)
                {
                    if (mousePoint.Y > 0 && mousePoint.Y < panelCustomLayerList.Height - 3)
                    {
                        e.Graphics.DrawRectangle(Pens.Blue, 0, rowHeight * highlightIndex, panel.Width, rowHeight);
                    }
                }
            }

            for (int i = 0; i < fieldRows; i++)
            {
                if (i >= tileMap.layerList.Count)
                {
                    return;
                }

                string   info     = "MapLayer: " + (i + start).ToString();
                CheckBox checkBox = mapLayerCheckBoxes[i + start];
                checkBox.Location = new Point(panel.Width - checkBox.Width, rowHeight * i);

                e.Graphics.DrawString(info, this.Font, Brushes.Black, 0, rowHeight * i);
            }
        }
コード例 #6
0
        private void panelDBTileLibList_Paint(object sender, PaintEventArgs e)
        {
            PanelCustom panel          = (PanelCustom)sender;
            Point       mousePoint     = panel.PointToClient(Cursor.Position);
            int         fieldRows      = panel.Height / this.FontHeight;
            int         rowHeight      = this.FontHeight;
            int         index          = GetCurrentTileLibIndex();
            int         highlightIndex = mousePoint.Y / this.FontHeight;
            int         start          = vScrollBarTileLibList.Value;

            if (tileLibs.Count <= 0)
            {
                return;
            }

            if (index >= 0)
            {
                e.Graphics.FillRectangle(Brushes.PowderBlue, 0, rowHeight * (index - start), panelCustomTileLibList.Width, rowHeight);
            }

            if (highlightIndex + start < tileLibs.Count)
            {
                if (mousePoint.X > 0 && mousePoint.X < panelCustomTileLibList.Width - 3)
                {
                    if (mousePoint.Y > 0 && mousePoint.Y < panelCustomTileLibList.Height - 3)
                    {
                        e.Graphics.DrawRectangle(Pens.Blue, 0, rowHeight * highlightIndex, panel.Width, rowHeight);
                    }
                }
            }

            for (int i = 0; i < fieldRows; i++)
            {
                if (i >= tileLibs.Count)
                {
                    return;
                }

                e.Graphics.DrawString("TileLib: " + (i + start), this.Font, Brushes.Black, 0, rowHeight * i);
            }
        }
コード例 #7
0
        private void panelCustomTileWindow_Paint(object sender, PaintEventArgs e)
        {
            PanelCustom panel = (PanelCustom)sender;

            try
            {
                int cellWidth  = currentTileLib.cellWidth;
                int cellHeight = currentTileLib.cellHeight;
                int cols       = panel.Width / cellWidth;
                int rows       = panel.Height / cellHeight;

                if (cols > currentTileLib.columnCount)
                {
                    cols = currentTileLib.columnCount;
                }

                if (rows > currentTileLib.rowCount)
                {
                    rows = currentTileLib.rowCount;
                }

                for (int row = 0; row < rows; row++)
                {
                    for (int col = 0; col < cols; col++)
                    {
                        int index = (currentTileLib.columnCount * (row + currentTileLib.vScroll)) + (col + currentTileLib.hScroll);

                        e.Graphics.DrawImage(currentTileLib.GetImage(index), cellWidth * col, cellHeight * row);
                        e.Graphics.DrawRectangle(Pens.Black, cellWidth * col, cellHeight * row, cellWidth, cellHeight);
                    }
                }
            }
            catch
            {
            }
        }
コード例 #8
0
        private void panelDBTileLibList_MouseLeave(object sender, EventArgs e)
        {
            PanelCustom panel = (PanelCustom)sender;

            panel.Invalidate();
        }
コード例 #9
0
        private void panelCustomLayerList_MouseMove(object sender, MouseEventArgs e)
        {
            PanelCustom panel = (PanelCustom)sender;

            panel.Invalidate();
        }