private void centralGradientToolStripMenuItem_Click(object sender, EventArgs e) { ListView.SelectedIndexCollection indexes = this.listViewHeap.SelectedIndices; if (indexes.Count > 1) { MessageBox.Show("Too many images selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int DimX = 24; int DimY = 16; int DimZ = 1; int Band = 1; float Value = 1.0f; if (indexes.Count == 1) { DimX = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Width; DimY = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Height; DimZ = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Depth; Band = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).NumBands; } RequestImage RQuest = new RequestImage(); //RQuest.ShowDialog(); Control[] ButtonControl = RQuest.Controls.Find("numericUpDownDimX", false); NumericUpDown TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = DimX; ButtonControl = RQuest.Controls.Find("numericUpDownDimY", false); TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = DimY; ButtonControl = RQuest.Controls.Find("numericUpDownDimZ", false); TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = DimZ; ButtonControl = RQuest.Controls.Find("numericUpDownBand", false); TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = Band; ButtonControl = RQuest.Controls.Find("numericUpDownIntensity", false); TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = (decimal)Value; if (RQuest.ShowDialog() != DialogResult.OK) { return; } Image3D UnitImage = new Image3D(DimX, DimY, DimZ, 1); for (int j = 0; j < UnitImage.Height; j++) { for (int i = 0; i < UnitImage.Width; i++) { UnitImage.Data[0][i + j * UnitImage.Width] = Value * (float)Math.Sqrt((i - DimX / 2.0f) * (i - DimX / 2.0f) + (j - DimY / 2.0f) * (j - DimY / 2.0f)); } } //UnitImage.Name = "Unit Image"; AddImageToHeap(UnitImage, 0); indexes.Clear(); }
private void unitImageToolStripMenuItem_Click_1(object sender, EventArgs e) { ListView.SelectedIndexCollection indexes = this.listViewHeap.SelectedIndices; if (indexes.Count > 1) { MessageBox.Show("Too many images selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int DimX = 256; int DimY = 256; int DimZ = 1; int Band = 1; float Value = 1.0f; if (indexes.Count == 1) { DimX = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Width; DimY = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Height; DimZ = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).Depth; Band = ((Image3D)(this.listViewHeap.Items[indexes[0]].Tag)).NumBands; } RequestImage RQuest = new RequestImage(); //RQuest.ShowDialog(); Control[] ButtonControl = RQuest.Controls.Find("numericUpDownDimX", false); NumericUpDown TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = DimX; ButtonControl = RQuest.Controls.Find("numericUpDownDimY", false); TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = DimY; ButtonControl = RQuest.Controls.Find("numericUpDownDimZ", false); TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = DimZ; ButtonControl = RQuest.Controls.Find("numericUpDownBand", false); TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = Band; ButtonControl = RQuest.Controls.Find("numericUpDownIntensity", false); TmpNum = (NumericUpDown)ButtonControl[0]; TmpNum.Value = (decimal)Value; if (RQuest.ShowDialog() != DialogResult.OK) { return; } CreateNewImage(RQuest.numericUpDownDimXValue, RQuest.numericUpDownDimYValue, RQuest.numericUpDownDimZValue, RQuest.numericUpDownBandValue, RQuest.numericUpDownIntensityValue); indexes.Clear(); }