예제 #1
0
        //GUI METHODS
        //PICTURE BOX METHODS
        #region GUI ACTIONS
        private void ViewPictureBox_Click(object sender, EventArgs e)
        {
            if (running || mcRunning)
            {
                return;
            }
            MouseEventArgs me = (MouseEventArgs)e;
            //Calculate pictureBox click position to grid position
            int x = (int)(me.X / cellXSize) + currentPositionX;
            int y = (int)(me.Y / cellYSize) + currentPositionY;

            if (x >= Grid.SizeX || x < 0 ||
                y >= Grid.SizeY || y < 0)
            {
                return;
            }
            if (selectionModePropertiesGrainBoundariesComboBox.SelectedIndex == 1)
            {
                gridController.GenerateCellBoundary(x, y, decimal.ToInt32(sizePropertiesGrainBoundariesNumericUpDown.Value));
                gbPercentTextBox.Text = gridController.GetBoundaryPercentSize();

                DrawFunction(ref nextImage);
                viewPictureBox.Refresh();
            }
            else
            {
                if (me.Button == MouseButtons.Left)
                {
                    if (gridController.emptyCount == 0)
                    {
                        gridController.selectGrainForDP(x, y, selectionTypeSubstructureComboBox.SelectedIndex);
                        DrawFunction(ref nextImage);
                    }
                    else
                    {
                        if (gridController.ChangeGridValue(x, y))
                        {
                            FillCell(x, y, nextImage, ColorTranslator.FromHtml(ColorManager.indexcolors[gridController.CurrentNucleonID % ColorManager.indexcolors.Count()]));
                        }
                        else
                        {
                            FillCell(x, y, nextImage, BackgroundColor);
                        }
                    }
                }
                else
                {
                    gridController.ChangeCurrentNucleonID();
                }
            }

            viewPictureBox.Image = nextImage;
        }