Exemple #1
0
        public FormDownloadData()
        {
            InitializeComponent();

            MySQL      mysql   = new MySQL();
            List <Cut> cutList = mysql.GetCut();

            dataGridView1.Rows.Clear();

            foreach (Cut cut in cutList)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dataGridView1);
                row.Cells[0].Value  = cut.Id;
                row.Cells[1].Value  = cut.Age;
                row.Cells[2].Value  = cut.Genotype;
                row.Cells[3].Value  = cut.Animal;
                row.Cells[4].Value  = cut.CutIdentifier;
                row.Cells[5].Value  = cut.Method;
                row.Cells[6].Value  = cut.DateMeasurement.ToString("dd.MM.yyyy");
                row.Cells[7].Value  = cut.DateStaining.ToString("dd.MM.yyyy");
                row.Cells[8].Value  = cut.ZoomFactor;
                row.Cells[9].Value  = cut.Layer;
                row.Cells[10].Value = cut.Note;
                row.Cells[11].Value = "Reanalyze now";
                dataGridView1.Rows.Add(row);
            }
        }
        public FromReanalyzeAll()
        {
            InitializeComponent();

            mysql           = new MySQL();
            mysql._waitTime = _waitTime;
            cutList         = mysql.GetCut();

            if (cutList.Count <= 1)
            {
                return;
            }

            List <Cut> orderedEnumerable = cutList.OrderBy(c => c.Id).ToList();

            firstId = orderedEnumerable.First().Id;
            lastId  = orderedEnumerable.Last().Id;

            textBox1.Text = firstId.ToString();
            textBox2.Text = lastId.ToString();
        }
Exemple #3
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            btnFix.Enabled    = false;
            btnUpload.Enabled = false;

            cut            = null;
            fissureCount   = 0;
            fissurePeriSum = 0;

            fisPeri_1_old  = -1;
            fisPeri_2_old  = -1;
            fisPeri_3_old  = -1;
            fisPeri_4_old  = -1;
            fisPeri_5_old  = -1;
            fisPeri_6_old  = -1;
            fisPeri_7_old  = -1;
            fisPeri_8_old  = -1;
            fisPeri_9_old  = -1;
            fisPeri_10_old = -1;

            fisPeri_1_new  = -1;
            fisPeri_2_new  = -1;
            fisPeri_3_new  = -1;
            fisPeri_4_new  = -1;
            fisPeri_5_new  = -1;
            fisPeri_6_new  = -1;
            fisPeri_7_new  = -1;
            fisPeri_8_new  = -1;
            fisPeri_9_new  = -1;
            fisPeri_10_new = -1;

            MySQL mysql = new MySQL();

            cut = mysql.GetCut(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text);

            if (cut == null)
            {
                MessageBox.Show("No cut for this data found!");
                return;
            }

            List <Result> results = mysql.GetResults(cut.Id.ToString());

            if (results == null || results.Count == 0)
            {
                MessageBox.Show("No results for this cut found!");
                return;
            }

            string fisPeri_1_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "1" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_1_string) == false)
            {
                Double.TryParse(fisPeri_1_string, out fisPeri_1_old);
                fissureCount++;
            }

            string fisPeri_2_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "2" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_2_string) == false)
            {
                Double.TryParse(fisPeri_2_string, out fisPeri_2_old);
                fissureCount++;
            }

            string fisPeri_3_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "3" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_3_string) == false)
            {
                Double.TryParse(fisPeri_3_string, out fisPeri_3_old);
                fissureCount++;
            }

            string fisPeri_4_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "4" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_4_string) == false)
            {
                Double.TryParse(fisPeri_4_string, out fisPeri_4_old);
                fissureCount++;
            }

            string fisPeri_5_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "5" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_5_string) == false)
            {
                Double.TryParse(fisPeri_5_string, out fisPeri_5_old);
                fissureCount++;
            }

            string fisPeri_6_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "6" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_6_string) == false)
            {
                Double.TryParse(fisPeri_6_string, out fisPeri_6_old);
                fissureCount++;
            }

            string fisPeri_7_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "7" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_7_string) == false)
            {
                Double.TryParse(fisPeri_7_string, out fisPeri_7_old);
                fissureCount++;
            }

            string fisPeri_8_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "8" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_8_string) == false)
            {
                Double.TryParse(fisPeri_8_string, out fisPeri_8_old);
                fissureCount++;
            }

            string fisPeri_9_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "9" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_9_string) == false)
            {
                Double.TryParse(fisPeri_9_string, out fisPeri_9_old);
                fissureCount++;
            }

            string fisPeri_10_string = results.FirstOrDefault(res => res.ResultType == "fissure" && res.Identifier == "10" && res.Key == "perimeter")?.Value;

            if (string.IsNullOrEmpty(fisPeri_10_string) == false)
            {
                Double.TryParse(fisPeri_10_string, out fisPeri_10_old);
                fissureCount++;
            }

            AddOldRow("1", fisPeri_1_old);
            AddOldRow("2", fisPeri_2_old);
            AddOldRow("3", fisPeri_3_old);
            AddOldRow("4", fisPeri_4_old);
            AddOldRow("5", fisPeri_5_old);
            AddOldRow("6", fisPeri_6_old);
            AddOldRow("7", fisPeri_7_old);
            AddOldRow("8", fisPeri_8_old);
            AddOldRow("9", fisPeri_9_old);
            AddOldRow("10", fisPeri_10_old);

            btnFix.Enabled = true;
        }
        private void Reanalyze()
        {
            cutList.Clear();
            cutList = mysql.GetCut(firstId, lastId);

            bool   filter         = false;
            int    filterAge      = 0;
            string filterGenoType = "";
            string filterLayer    = "";

            if (string.IsNullOrEmpty(textBox3.Text) == false)
            {
                if (int.TryParse(textBox3.Text, out filterAge))
                {
                    filter = true;
                }
            }

            int customOffset        = 0;
            int customBlurredFactor = 0;
            int customIntersectionPointRestrictedRadius = 0;

            if (string.IsNullOrEmpty(textBox5.Text) == false)
            {
                int.TryParse(textBox5.Text, out customOffset);
            }

            if (string.IsNullOrEmpty(textBox6.Text) == false)
            {
                int.TryParse(textBox6.Text, out customBlurredFactor);
            }

            if (string.IsNullOrEmpty(textBox7.Text) == false)
            {
                int.TryParse(textBox7.Text, out customIntersectionPointRestrictedRadius);
            }

            if (string.IsNullOrEmpty(textBox4.Text) == false)
            {
                if (textBox4.Text.Trim().ToUpper() == "WT")
                {
                    filterGenoType = "WT";
                    filter         = true;
                }
                if (textBox4.Text.Trim().ToUpper() == "KO")
                {
                    filterGenoType = "KO";
                    filter         = true;
                }
            }

            if (string.IsNullOrEmpty(textBox8.Text) == false)
            {
                filterLayer = textBox8.Text.Trim().ToLower();
                filter      = true;
            }

            foreach (Cut cut in cutList)
            {
                try
                {
                    if (filter)
                    {
                        if (filterAge > 0 && cut.Age != filterAge)
                        {
                            continue;
                        }

                        if (string.IsNullOrEmpty(filterGenoType) == false && cut.Genotype != filterGenoType)
                        {
                            continue;
                        }

                        if (string.IsNullOrEmpty(filterLayer) == false && cut.Layer.ToLower().Contains(filterLayer) == false)
                        {
                            continue;
                        }
                    }

                    FormPleaseWait pleaseWait = new FormPleaseWait("download data");
                    pleaseWait.Owner         = this;
                    pleaseWait.StartPosition = FormStartPosition.CenterParent;
                    pleaseWait.Show(this);
                    int x = this.DesktopBounds.Left + (this.Width - pleaseWait.Width) / 2;
                    int y = this.DesktopBounds.Top + (this.Height - pleaseWait.Height) / 2;
                    pleaseWait.SetDesktopLocation(x, y);

                    string fileName =
                        $"P{cut.Age}_{cut.Animal}_{cut.Genotype}_{cut.Method}_{cut.ZoomFactor}x{cut.CutIdentifier}.jpg";
                    string filePath = Path.Combine(Path.GetTempPath(), fileName);
                    mysql.GetImage(cut.Id.ToString(), "marked image", filePath);

                    string filePathOriginal = Path.Combine(Path.GetTempPath(), "original-" + fileName);
                    string filePathMarked   = Path.Combine(Path.GetTempPath(), "marked-" + fileName);

                    mysql.GetImage(cut.Id.ToString(), "original image", filePathOriginal);
                    mysql.GetImage(cut.Id.ToString(), "marked image", filePathMarked);

                    filePath = filePathOriginal;

                    List <Point> coordinates = mysql.GetCoordinates(cut.Id.ToString());

                    pleaseWait.Close();
                    Hide();

                    FormWorker formWorker = new FormWorker(WorkerMethod.ReanalyzeSingleDatapointsAndMeasurement, this);

                    bool smthingChanged = false;
                    if (customOffset > 0)
                    {
                        formWorker.DEFAULT_OFFSET   = customOffset;
                        formWorker._offsetOuterLine = customOffset;
                        smthingChanged = true;
                    }

                    if (customBlurredFactor > 0)
                    {
                        formWorker.DEFAULT_BLURRED_FACTOR = customBlurredFactor;
                        formWorker._blurredFactor         = customBlurredFactor;
                        smthingChanged = true;
                    }

                    if (customIntersectionPointRestrictedRadius > 0)
                    {
                        formWorker.DEFAULT_INTERSECTION_POINT_RESTRICTED_RADIUS = customIntersectionPointRestrictedRadius;
                        formWorker._intersectionPointRestrictedRadius           = customIntersectionPointRestrictedRadius;
                        smthingChanged = true;
                    }

                    if (smthingChanged)
                    {
                        formWorker.FillOptionsWithDefaultValues();
                    }

                    formWorker._waitTime    = _waitTime;
                    formWorker._filePath    = filePath;
                    formWorker._coordinates = coordinates;
                    formWorker._note        = cut.Note;
                    formWorker._layer       = cut.Layer;
                    formWorker._originalPictureOVERWRITE = new Bitmap(filePathOriginal);
                    formWorker._markedPictureOVERWRITE   = new Bitmap(filePathMarked);
                    formWorker.ShowDialog();
                }
                catch (Exception ex)
                {
                    //just for debug
                }
            }
        }