예제 #1
0
        private void h_drawControls(CLevel pLevel)
        {
            const int Width  = 20;
            const int Height = 20;

            panel1.SuspendLayout();
            try {
                //panel1.Controls.Clear();
                foreach (CCell pCell in pLevel.Field)
                {
                    Control pControl = h_GetInCell(pCell);
                    if (pControl == null)
                    {
                        pControl = new Button();
                        // - для поиска по элементам управления
                        pControl.Tag = pCell;
                        // для "прямого" поиска
                        pCell.Container = pControl;

                        pControl.Parent = panel1;
                        pControl.Width  = Width;
                        pControl.Height = Height;
                        pControl.Left   = pCell.X * Width;
                        pControl.Top    = pCell.Y * Height;
                    }
                    pControl.BackColor = h_GetCellColor(pCell);
                }
            }
            finally {
                panel1.ResumeLayout(true);
            }
        }
예제 #2
0
        private void h_drawField(CLevel pLevel)
        {
            pictureBoxField.SuspendLayout();
            try {
                Bitmap bmp = new Bitmap(pictureBoxField.Width, pictureBoxField.Height);
                using (Graphics g = Graphics.FromImage(bmp)) {
                    g.Clear(Color.White);

                    IEnumerable <CCell> pCellsNotWorker = pLevel.Field.Where(p => p.CellType != ECellType.Worker);
                    foreach (CCell pCell in pCellsNotWorker)
                    {
                        Color      pColor = h_GetCellColor(pCell);
                        SolidBrush pBrush = new SolidBrush(pColor);
                        g.FillEllipse(pBrush, pCell.X * Width, pCell.Y * Height, Width, Height);
                    }
                    IEnumerable <CCell> pCellsWhereWorker =
                        pLevel.Field.Where(p => p.CellType == ECellType.Worker);
                    foreach (CCell pCell in pCellsWhereWorker)
                    {
                        Color      pColor = h_GetCellColor(pCell);
                        SolidBrush pBrush = new SolidBrush(pColor);
                        g.FillEllipse(pBrush, pCell.X * Width - 4, pCell.Y * Height - 4, Width + 4, Height + 4);
                    }
                    pictureBoxField.Image = bmp;
                }
            }
            finally {
                pictureBoxField.Invalidate();
                pictureBoxField.ResumeLayout(true);
            }
        }
예제 #3
0
        /// <summary>
        /// Добавить уровень из файла (загрузить)
        /// </summary>
        /// <param name="sFileName"></param>
        public void AddLevel(string sFileName)
        {
            CLevel pLevel = new CLevel();

            pLevel.Load(sFileName);
            m_pLevels.Add(pLevel);
        }