Exemplo n.º 1
0
        /// <summary>
        /// Representa el panel de control en un control DataGridView.
        /// </summary>
        private void PaintSchema(DataGridView grid, OTCSchema schema)
        {
            try
            {
                // Genera una imágen transparente para las celdas que no contienen ningún bloque
                Bitmap nullimage = new Bitmap(_library.BlockWidth, _library.BlockHeight);
                nullimage.MakeTransparent();

                // Inicializa el _grid
                grid.MultiSelect          = false;
                grid.ColumnHeadersVisible = false;
                grid.RowHeadersVisible    = false;
                grid.Columns.Clear();
                grid.BackgroundColor            = _library.BgColor;
                grid.DefaultCellStyle.BackColor = _library.BgColor;
                grid.AllowDrop = false;
                grid.AllowUserToOrderColumns  = false;
                grid.AllowUserToResizeColumns = false;
                grid.AllowUserToResizeRows    = false;
                grid.AllowUserToAddRows       = false;
                grid.AllowUserToDeleteRows    = false;

                // Añade las celdas del grid
                for (int i = 0; i < schema.Columns; i++)
                {
                    DataGridViewImageColumn col = new DataGridViewImageColumn();
                    col.Width       = _library.BlockWidth;
                    col.ImageLayout = DataGridViewImageCellLayout.Normal;
                    col.Image       = nullimage;
                    grid.Columns.Add(col);
                }
                grid.RowCount = schema.Rows;
                for (int i = 0; i < grid.Rows.Count; i++)
                {
                    grid.Rows[i].Height = _library.BlockHeight;
                }

                // Carga las imágenes
                foreach (OTCPanelBlock block in schema.Blocks)
                {
                    if (_mode == PanelModes.Design)
                    {
                        // Representa los bloques con el color de fondo transparente
                        // para que sea visible el bloque seleccionado
                        Bitmap blockimg = _library.GetBlockImage(block.LibraryBlock.Id, OTCLibrary.ImageTypes.Bitmap, block.Rotation, OTCBlockStatus.None);
                        blockimg.MakeTransparent(_library.BgColor);
                        grid.Rows[block.Y].Cells[block.X].Value = blockimg;
                    }
                    else
                    {
                        grid.Rows[block.Y].Cells[block.X].Value = _library.GetBlockImage(block.LibraryBlock.Id, OTCLibrary.ImageTypes.Bitmap, block.Rotation, block.Status);
                    }
                    grid.Rows[block.Y].Cells[block.X].Tag = block.Id;
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Devuelve una instancia de RouteEditorControl;
 /// </summary>
 public RouteEditorControl(OTCSchema schema)
 {
     InitializeComponent();
     this.Schema = schema;
 }