Ejemplo n.º 1
0
        public void Save(ImageAnalyser IA)
        {
            TifFileInfo tifFI = this.tifFI;

            if (tifFI != null)
            {
                if (!tifFI.available)
                {
                    MessageBox.Show("Image is not avaliable!\nTry again later.");
                    return;
                }

                string dir = tifFI.Dir;
                //background worker
                var bgw = new BackgroundWorker();
                bgw.WorkerReportsProgress = true;
                //Add handlers to the backgroundworker
                //Reports when is finished

                bgw.DoWork += new DoWorkEventHandler(delegate(Object o, DoWorkEventArgs a)
                {
                    //check is the directory exist
                    if (dir.IndexOf("\\") > -1)
                    {
                        string checkDir = dir.Substring(0, dir.LastIndexOf("\\"));
                        checkDir        = OSStringConverter.StringToDir(checkDir);
                        if (!System.IO.Directory.Exists(checkDir))
                        {
                            System.IO.Directory.CreateDirectory(checkDir);
                        }
                    }
                    //save file
                    FileEncoder.SaveTif(tifFI, dir, IA);
                    //report progress
                    ((BackgroundWorker)o).ReportProgress(0);
                });

                bgw.ProgressChanged += new ProgressChangedEventHandler(delegate(Object o, ProgressChangedEventArgs a)
                {
                    if (a.ProgressPercentage == 0)
                    {
                        Saved = true;
                        if (tifFI != null)
                        {
                            tifFI.available = true;
                        }
                        IA.FileBrowser.StatusLabel.Text = "Ready";
                    }
                });

                //Start background worker
                tifFI.available = false;
                IA.FileBrowser.StatusLabel.Text = "Saving Tif Image...";

                IA.EnabletrackBars(false);
                bgw.RunWorkerAsync();
                //continue when the sae is done
                while (bgw.IsBusy)
                {
                    Application.DoEvents(); //This call is very important if you want to have a progress bar and want to update it
                                            //from the Progress event of the background worker.
                    Thread.Sleep(10);       //This call waits if the loop continues making sure that the CPU time gets freed before
                                            //re-checking.
                }

                IA.EnabletrackBars(true);
            }
            else if (ResultsExtractor != null)
            {
                //check is the directory exist
                if (dir.IndexOf("\\") > -1)
                {
                    string checkDir = dir.Substring(0, dir.LastIndexOf("\\"));
                    checkDir = OSStringConverter.StringToDir(checkDir);
                    if (!System.IO.Directory.Exists(checkDir))
                    {
                        System.IO.Directory.CreateDirectory(checkDir);
                    }
                }

                var bgw = ResultsExtractor.FileSaver.SaveCTDataFile(
                    (Cell_Tool_3.ResultsExtractor.MyForm)
                    this.ResultsExtractor.myPanel, dir);

                //continue when the sae is done
                while (bgw.IsBusy)
                {
                    Application.DoEvents(); //This call is very important if you want to have a progress bar and want to update it
                                            //from the Progress event of the background worker.
                    Thread.Sleep(10);       //This call waits if the loop continues making sure that the CPU time gets freed before
                                            //re-checking.
                }
            }
        }
Ejemplo n.º 2
0
        private string calculateCTTagValue(TifFileInfo fi, ImageAnalyser IA)
        {
            List <string> vals = new List <string>();

            string val = titleTB.Text + "\t" +
                         FiltersCB.Checked.ToString() + "\t" +
                         SegmentationCB.Checked.ToString() + "\t" +
                         SpotDetCB.Checked.ToString() + "\t" +
                         TrackingCB.Checked.ToString() + "\t" +
                         fi.sizeC + "\t" +
                         ChartAxisCB.Checked.ToString() + "\t" +
                         TimeStepCB.Checked.ToString();

            vals.Add(val);

            if (FiltersCB.Checked)
            {
                vals.Add("tracking_MaxSize->" + FileEncoder.TagValueToString(fi.tracking_MaxSize));
                vals.Add("tracking_MinSize->" + FileEncoder.TagValueToString(fi.tracking_MinSize));
                vals.Add("tracking_Speed->" + FileEncoder.TagValueToString(fi.tracking_Speed));
            }

            if (SegmentationCB.Checked)
            {
                vals.Add("SegmentationProtocol->" + FileEncoder.TagValueToString(fi.SegmentationProtocol));
                vals.Add("SegmentationCBoxIndex->" + FileEncoder.TagValueToString(fi.SegmentationCBoxIndex));
                vals.Add("thresholdsCBoxIndex->" + FileEncoder.TagValueToString(fi.thresholdsCBoxIndex));
                vals.Add("RefSpotColor->" + FileEncoder.TagValueToString(fi.RefSpotColor));
                vals.Add("sumHistogramChecked->" + FileEncoder.TagValueToString(fi.sumHistogramChecked));
                vals.Add("thresholdColors->" + FileEncoder.TagValueToString(fi.thresholdColors));
                vals.Add("RefThresholdColors->" + FileEncoder.TagValueToString(fi.RefThresholdColors));
                vals.Add("thresholdValues->" + FileEncoder.TagValueToString(fi.thresholdValues));
                vals.Add("thresholds->" + FileEncoder.TagValueToString(fi.thresholds));
            }

            if (SpotDetCB.Checked)
            {
                vals.Add("SelectedSpotThresh->" + FileEncoder.TagValueToString(fi.SelectedSpotThresh));
                vals.Add("typeSpotThresh->" + FileEncoder.TagValueToString(fi.typeSpotThresh));
                vals.Add("SpotThresh->" + FileEncoder.TagValueToString(fi.SpotThresh));
                vals.Add("spotSensitivity->" + FileEncoder.TagValueToString(fi.spotSensitivity));
                vals.Add("SpotColor->" + FileEncoder.TagValueToString(fi.SpotColor));
                vals.Add("SpotTailType->" + string.Join("\t", fi.SpotTailType));
            }

            if (FiltersCB.Checked)
            {
                if (fi.newFilterHistory != null)
                {
                    vals.Add("newFilters->" + FileEncoder.TagValueToString(fi.newFilterHistory));
                }

                //vals.Add("FilterHistory->" + FileEncoder.TagValueToString(fi.FilterHistory.ToArray()));

                // if (fi.watershedList.Count!=0)
                //vals.Add("watershed->" + string.Join("\n", fi.watershedList));
            }

            if (ChartAxisCB.Checked)
            {
                vals.Add("xAxisTB->" + fi.xAxisTB.ToString());
                vals.Add("yAxisTB->" + fi.yAxisTB.ToString());
            }

            if (TimeStepCB.Checked)
            {
                vals.Add("TimeSteps->" + FileEncoder.TagValueToString(fi.TimeSteps));
            }

            return(string.Join(";\n", vals));
        }