public void InitializeVariables() { bitmapStencil = new Bitmap(pictureBoxFront.Width, pictureBoxFront.Height); pictureFront = new PictureBoxPainting(this, pictureBoxFront); pictureSide = new PictureBoxPainting(this, pictureBoxSide); pictureFront.MouseCurrentPosition = mouseCurrentPosition; pictureFront.MousePreviousPosition = mousePreviousPosition; penEraser = new Pen(Color.White, 5); AddStandartMaterials(); //Так работать с comboBox намного удобнее, чем было до этого, когда я циклом проходио по всем его значениям и сравнивал с названиями из materials comboBoxConductorMaterial.DataSource = materials; //Связываю comboBox и List с материалами comboBoxConductorMaterial.DisplayMember = "Name"; //Выбираю поле для отображения у класса, из элементов которого составлен List comboBoxConductorMaterial.ValueMember = "Resistivity"; //Выбираю поле для значения у класса, из элементов которого составлен List pictureFront.CellSquare = trackBarScale.Value == 0 ? 1 : Convert.ToUInt32(Math.Pow(Math.Pow(pictureFront.CellRowCount, 2), trackBarScale.Value)); pictureSide.CellSquare = pictureFront.CellSquare; pictureFront.CellRowCount = Convert.ToInt32(pictureBoxFront.Width / pictureBoxScale.Width); pictureSide.CellRowCount = pictureFront.CellRowCount; pictureFront.PixelsInCellCount = Convert.ToInt32(Math.Pow(pictureBoxFront.Width / pictureFront.CellRowCount, 2)); pictureSide.PixelsInCellCount = pictureFront.PixelsInCellCount; PrintScales(); toolStripButtonCurrent = toolStripButtonPencil; }
private bool IsColorAvailable(Color color) { bool result = true; result = PictureBoxPainting.IsAvailableColor(color); foreach (var material in windowMain.materials) { if (material.PixelColor == color) { if (currentMaterial != null && currentMaterial.PixelColor != color) { result = false; break; } } } return(result); }