private void buttonChooseStack_Click(object sender, EventArgs e) { if (Filenames.Count > 0) { Filenames.Clear(); } openFileDialogStack.Filter = _dialogFilterStack; openFileDialogStack.InitialDirectory = _initDir; openFileDialogStack.FileName = ""; DialogResult result = openFileDialogStack.ShowDialog(); if (result == DialogResult.OK) { Stackname = openFileDialogStack.FileName; if (Stackname != null) { textBox1.Text = Stackname; WSIExtraction.Stack stack = ReadWriteUtils.DeserializeObjectFromJSON <WSIExtraction.Stack>(Stackname); foreach (WSIExtraction.Slice slice in stack.Section) { Filenames.Add(Path.Combine(Path.GetDirectoryName(Stackname), slice.Path)); } } textBox1.Text = Stackname; EnableButtons(); } }
private void WriteStackV2(int threshold) { WSIExtraction.Stack stack = new WSIExtraction.Stack(); stack.Stackname = this.textBox1.Text; stack.Threshold = threshold; List <int> backgroundColor = new List <int>(); backgroundColor.Add((int)(Math.Round(background_color[0]))); backgroundColor.Add((int)(Math.Round(background_color[1]))); backgroundColor.Add((int)(Math.Round(background_color[2]))); stack.Backgroundcolor = backgroundColor; stack.Resolutionlevel = (int)this.numericUpDown1.Value; List <WSIExtraction.Slice> slices = new List <WSIExtraction.Slice>(); foreach (WSIHistoObject obj in objects) { WSIExtraction.Slice slice = new WSIExtraction.Slice(); slice.Path = obj.labelTitle.Text + ".png"; slice.WsiSourcePath = obj.wsiImagePath; slice.X = obj.objRectangle.X; slice.Y = obj.objRectangle.Y; slice.Width = obj.objRectangle.Width; slice.Height = obj.objRectangle.Height; slices.Add(slice); } stack.Section = slices; ReadWriteUtils.SerializeObjectToJSON(stack, Path.Combine(ApplicationContext.OutputPath, this.textBox1.Text, "stack.json")); // back to normal cursor Cursor.Current = Cursors.Default; MessageBox.Show("Done"); }