private void applyToHistory(int chanel, int min, int max) { TifFileInfo fi = IA.TabPages.TabCollections[IA.TabPages.SelectedIndex].tifFI; IA.delHist = true; IA.TabPages.TabCollections[IA.TabPages.SelectedIndex].tifFI.delHist = true; IA.DeleteFromHistory(); if (applyToAll.Checked == true & applyToAll.Visible == true) { for (int i = 0; i < fi.sizeC; i++) { WriteApplyToHistory(i, min, max, fi); } } else { WriteApplyToHistory(chanel, min, max, fi); } IA.UpdateUndoBtns(); }
private void xAxisTB_ChangeIndex(object sender, EventArgs e) { if (xAxisTB.Focused == false) { return; } //find selected image TifFileInfo fi = null; try { fi = IA.TabPages.TabCollections[IA.TabPages.SelectedIndex].tifFI; } catch { return; } if (fi == null) { return; } if (fi.xAxisTB == xAxisTB.SelectedIndex) { return; } //Parse value fi.delHist = true; IA.delHist = true; IA.UnDoBtn.Enabled = true; IA.DeleteFromHistory(); AddXAxisTBToHistory(fi); fi.xAxisTB = xAxisTB.SelectedIndex; AddXAxisTBToHistory(fi); //ReloadImage IA.UpdateUndoBtns(); IA.MarkAsNotSaved(); IA.ReloadImages(); }
private void TrackBar_ValueChange(ChangeValueEventArgs e, CTTrackBar tb) { //variables TifFileInfo fi = IA.TabPages.TabCollections[IA.TabPages.SelectedIndex].tifFI; int[] vals = fi.thresholdValues[fi.cValue]; int val = int.Parse(e.Value); int valRef = val; //find trackbar index int index = 0; for (int i = 0; i < threshTrackBars.Length; i++) { if (threshTrackBars[i] == tb) { index = i; break; } } //Check the avaliable min if (index > 0) { if (val <= vals[index]) { val = vals[index] + 1; } } //Check the avaliable max if (index < fi.thresholds[fi.cValue] - 1) { if (val >= vals[index + 2]) { val = vals[index + 2] - 1; } } //refresh if value is wrong if (val != valRef) { tb.Refresh(val, tb.TrackBar1.Minimum, tb.TrackBar1.Maximum); } //apply changes if (val != vals[index + 1]) { if (tb.TrackBar1.Focused == true | tb.TextBox1.Focused == true | tb.ApplyBtn.Focused == true) { #region apply to history fi.delHist = true; IA.delHist = true; IA.UnDoBtn.Enabled = true; IA.DeleteFromHistory(); fi.History.Add("segmentation.SetThreshOld(" + fi.cValue + "," + (index + 1).ToString() + "," + vals[index + 1].ToString() + ")"); fi.History.Add("segmentation.SetThreshOld(" + fi.cValue + "," + (index + 1).ToString() + "," + val.ToString() + ")"); IA.UpdateUndoBtns(); IA.MarkAsNotSaved(); #endregion apply to history } vals[index + 1] = val; IA.ReloadImages(); } }
private void Control_MouseDown(object sender, MouseEventArgs e) { Button ctr = (Button)sender; int i = 0; foreach (Button btn in ColorBtnList) { if (btn == ctr) { break; } i++; } if (e.Button == MouseButtons.Left) { if (ctr.ImageIndex == 0) { int count = 0; foreach (Button btn in ColorBtnList) { if (btn.ImageIndex == 0) { count++; } } if (count < 2) { return; } ctr.ImageIndex = 1; #region apply to history TifFileInfo fi = IA.TabPages.TabCollections[IA.TabPages.SelectedIndex].tifFI; fi.delHist = true; IA.delHist = true; IA.UnDoBtn.Enabled = true; IA.DeleteFromHistory(); fi.History.Add("enableColorChanel(" + ColorBtnList.IndexOf(ctr).ToString() + ",true)"); fi.History.Add("enableColorChanel(" + ColorBtnList.IndexOf(ctr).ToString() + ",false)"); IA.UpdateUndoBtns(); #endregion apply to history //apply settings if (i < tifFI.sizeC & i == tifFI.cValue) { IA.RoiMan.current = null; for (int j = 0; j < ColorBtnList.Count - 1; j++) { if (ColorBtnList[j].ImageIndex == 0) { tifFI.cValue = j; break; } } } } else { ctr.ImageIndex = 0; #region apply to history TifFileInfo fi = IA.TabPages.TabCollections[IA.TabPages.SelectedIndex].tifFI; fi.delHist = true; IA.delHist = true; IA.UnDoBtn.Enabled = true; IA.DeleteFromHistory(); fi.History.Add("enableColorChanel(" + ColorBtnList.IndexOf(ctr).ToString() + ",false)"); fi.History.Add("enableColorChanel(" + ColorBtnList.IndexOf(ctr).ToString() + ",true)"); IA.UpdateUndoBtns(); #endregion apply to history if (ColorBtnList[tifFI.cValue].ImageIndex != 0) { for (int j = 0; j < ColorBtnList.Count - 1; j++) { if (ColorBtnList[j].ImageIndex == 0) { IA.RoiMan.current = null; tifFI.cValue = j; break; } } } } IA.ReloadImages(); } else if (e.Button == MouseButtons.Right) { if (i >= tifFI.LutList.Count) { return; } ColorDialog colorDialog1 = new ColorDialog(); colorDialog1.AllowFullOpen = true; colorDialog1.AnyColor = true; colorDialog1.FullOpen = true; colorDialog1.Color = tifFI.LutList[i]; //set Custom Colors if (IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex] != "@") { List <int> colorsList = new List <int>(); foreach (string j in IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex] .Split(new[] { "\t" }, StringSplitOptions.None)) { colorsList.Add(int.Parse(j)); } colorDialog1.CustomColors = colorsList.ToArray(); } // Show the color dialog. DialogResult result = colorDialog1.ShowDialog(); //Copy Custom Colors int[] colors = (int[])colorDialog1.CustomColors.Clone(); string txt = "@"; if (colors.Length > 0) { txt = colors[0].ToString(); for (int j = 1; j < colors.Length; j++) { txt += "\t" + colors[j].ToString(); } } IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex] = txt; IA.settings.Save(); if (result == DialogResult.OK) { IA.Input.ChangeValueFunction("LUT(" + i.ToString() + "," + ColorTranslator.ToHtml(colorDialog1.Color).ToString() + ")"); } } }
private void ColBtn_Click(object sender, MouseEventArgs e) { TifFileInfo fi = IA.TabPages.TabCollections[IA.TabPages.SelectedIndex].tifFI; Button btn = (Button)sender; if (e.Button == MouseButtons.Left) { //disable/enable color if (fi.SpotColor[fi.cValue] == Color.Transparent) { fi.SpotColor[fi.cValue] = fi.RefSpotColor[fi.cValue]; } else { fi.SpotColor[fi.cValue] = Color.Transparent; } #region apply to history //segmentation.SpotDetector(chanelN,ThreshVal,HTML color, tail type, thresh type) Color val = fi.RefSpotColor[fi.cValue]; Color oldVal = Color.Transparent; if (fi.SpotColor[fi.cValue] == Color.Transparent) { val = Color.Transparent; oldVal = fi.RefSpotColor[fi.cValue]; } fi.delHist = true; IA.delHist = true; IA.UnDoBtn.Enabled = true; IA.DeleteFromHistory(); fi.History.Add("segmentation.SpotDetector(" + fi.cValue.ToString() + "," + fi.SpotThresh[fi.cValue].ToString() + "," + fi.spotSensitivity[fi.cValue].ToString() + "," + ColorTranslator.ToHtml(oldVal) + "," + fi.SpotTailType[fi.cValue] + "," + fi.SelectedSpotThresh[fi.cValue].ToString() + "," + fi.typeSpotThresh[fi.cValue].ToString() + ")"); fi.History.Add("segmentation.SpotDetector(" + fi.cValue.ToString() + "," + fi.SpotThresh[fi.cValue].ToString() + "," + fi.spotSensitivity[fi.cValue].ToString() + "," + ColorTranslator.ToHtml(val) + "," + fi.SpotTailType[fi.cValue] + "," + fi.SelectedSpotThresh[fi.cValue].ToString() + "," + fi.typeSpotThresh[fi.cValue].ToString() + ")"); IA.UpdateUndoBtns(); IA.MarkAsNotSaved(); #endregion apply to history IA.ReloadImages(); } else if (e.Button == MouseButtons.Right & btn.Text == "") { //change color ColorDialog colorDialog1 = new ColorDialog(); colorDialog1.AllowFullOpen = true; colorDialog1.AnyColor = true; colorDialog1.FullOpen = true; colorDialog1.Color = fi.RefSpotColor[fi.cValue]; //set Custom Colors if (IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex] != "@") { List <int> colorsList = new List <int>(); foreach (string j in IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex] .Split(new[] { "\t" }, StringSplitOptions.None)) { colorsList.Add(int.Parse(j)); } colorDialog1.CustomColors = colorsList.ToArray(); } // Show the color dialog. DialogResult result = colorDialog1.ShowDialog(); //Copy Custom Colors int[] colors = (int[])colorDialog1.CustomColors.Clone(); string txt = "@"; if (colors.Length > 0) { txt = colors[0].ToString(); for (int j = 1; j < colors.Length; j++) { txt += "\t" + colors[j].ToString(); } } IA.settings.CustomColors[IA.FileBrowser.ActiveAccountIndex] = txt; IA.settings.Save(); if (result == DialogResult.OK) { #region apply to history //segmentation.SpotDetector(chanelN,ThreshVal,HTML color, tail type, thresh type) fi.delHist = true; IA.delHist = true; IA.UnDoBtn.Enabled = true; IA.DeleteFromHistory(); fi.History.Add("segmentation.SpotDetector(" + fi.cValue.ToString() + "," + fi.SpotThresh[fi.cValue].ToString() + "," + fi.spotSensitivity[fi.cValue].ToString() + "," + ColorTranslator.ToHtml(fi.RefSpotColor[fi.cValue]) + "," + fi.SpotTailType[fi.cValue] + "," + fi.SelectedSpotThresh[fi.cValue].ToString() + "," + fi.typeSpotThresh[fi.cValue].ToString() + ")"); fi.History.Add("segmentation.SpotDetector(" + fi.cValue.ToString() + "," + fi.SpotThresh[fi.cValue].ToString() + "," + fi.spotSensitivity[fi.cValue].ToString() + "," + ColorTranslator.ToHtml(colorDialog1.Color) + "," + fi.SpotTailType[fi.cValue] + "," + fi.SelectedSpotThresh[fi.cValue].ToString() + "," + fi.typeSpotThresh[fi.cValue].ToString() + ")"); IA.UpdateUndoBtns(); IA.MarkAsNotSaved(); #endregion apply to history fi.RefSpotColor[fi.cValue] = colorDialog1.Color; fi.SpotColor[fi.cValue] = colorDialog1.Color; IA.ReloadImages(); } } }