//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; }
public void Load(string filePath, ref GridController gridController) { JObject jsonObject = JObject.Parse(File.ReadAllText(filePath)); int width = jsonObject["Size"]["width"].Value <int>(); int height = jsonObject["Size"]["height"].Value <int>(); gridController.ResizeGrid(width, height); gridController.SetNucleonsPopulationDecimal(jsonObject["caProperties"]["nucleonAmout"].Value <int>()); Dictionary <int, List <MultiscaleModeling.Model.Point> > points = new Dictionary <int, List <Model.Point> >(); foreach (var cell in jsonObject["Grid"]) { gridController.ChangeGridValue(cell["x"].Value <int>(), cell["y"].Value <int>(), cell["id"].Value <int>()); } }