Ejemplo n.º 1
0
        //Sets the intial environment of the program...
        private void InitializeProgram()
        {
            LoadControls();

            if (treeViewSample.Nodes.Count != 0)
            {
                treeViewSample.Nodes.Clear();
                Sample.lst_Samples.Clear();
                Sample.lst_Colors.Clear();
                Sample.lst_State.Clear();
                richTxtBoxStatus.Clear();
            }

            //create a welcome form object & show it up..

            formWelcome = new frmWelcome(this);
            formWelcome.ShowDialog();

            //Create initial sample in the treview..


            CustomTreeNode treeNode_Sample_Original = new CustomTreeNode();

            treeNode_Sample_Original.SampleIndex = 0;
            treeNode_Sample_Original.Text        = "Original_Sample";
            treeNode_Sample_Original.ForeColor   = Color.Black;
            treeNode_Sample_Original.BackColor   = Color.White;
            treeViewSample.Nodes.Add(treeNode_Sample_Original);
            treeViewSample.ExpandAll();
            treeViewSample.SelectedNode = treeNode_Sample_Original;

            UpdateStatus("Your sample is ready for the analysis...!");

            //Set initial settings for the porgram..

            FileOperator fo = new FileOperator();

            frmOptions.NumberOfSpeciesInRandomSample = Convert.ToInt32(fo.GetXMLValue("Settings.xml", "NumOfSpeciesInRndmSmple"));
        }
Ejemplo n.º 2
0
        public void PopulateTreeView(TreeView treeView, List <string> paths, List <string> nodeName, List <string> nodeIndex)
        {
            TreeNode lastNode = null;
            int      a        = 0;



            foreach (string path in paths)
            {
                if (lastNode == null)
                {
                    CustomTreeNode treeNode = new CustomTreeNode();

                    treeNode.SampleIndex = Convert.ToInt32(nodeIndex[a]);
                    treeNode.Text        = nodeName[a];
                    treeView.Nodes.Add(treeNode);
                    lastNode = treeNode;
                }
                else
                {
                    lastNode = lastNode.Nodes.Add(path, nodeName[a]);

                    int index = treeView.Nodes.IndexOf(lastNode);

                    CustomTreeNode treeNode = new CustomTreeNode();

                    treeNode.SampleIndex = Convert.ToInt32(nodeIndex[a]);

                    lastNode.Parent.Nodes.Add(treeNode);

                    treeView.Nodes.RemoveAt(index);

                    lastNode = treeNode;
                }


                a += 1;
            }
        }
Ejemplo n.º 3
0
        ////Creates nodes in sampleTreeView...~
        public void CreateNewSample(string sampleName)
        {
            //Check whether the entered name is already existing in the treeview..

            for (int i = 0; i < mainForm.treeViewSample.Nodes.Count; i++)
            {
                var nodeName = mainForm.treeViewSample.Nodes[i].Text;
                if (nodeName == sampleName)
                {
                    throw new Exception("You can't use the same name for different samples...!");
                }
            }

            //if not existing, create a new node..

            CustomTreeNode subSampleTreeNode = new CustomTreeNode();

            subSampleTreeNode.Text      = sampleName;
            subSampleTreeNode.ForeColor = Color.Black;
            subSampleTreeNode.BackColor = Color.White;

            if (mainForm.treeViewSample.SelectedNode == null)
            {
                subSampleTreeNode.SampleIndex = Sample.lst_Samples.Count;
                mainForm.treeViewSample.Nodes.Add(subSampleTreeNode);
                mainForm.treeViewSample.ExpandAll();

                //Make a copy of each list within multiple list holders..

                var sampleAtIndex = Sample.lst_Samples.ElementAt(Sample.lst_Samples.Count - 1);
                Sample.lst_Samples.Insert(subSampleTreeNode.SampleIndex, sampleAtIndex);

                var colorAtIndex = Sample.lst_Colors.ElementAt(Sample.lst_Colors.Count - 1);
                Sample.lst_Colors.Insert(subSampleTreeNode.SampleIndex, colorAtIndex);

                var stateAtIndex = Sample.lst_State.ElementAt(Sample.lst_State.Count - 1);
                Sample.lst_State.Insert(subSampleTreeNode.SampleIndex, stateAtIndex);

                var imageAtIndex = Sample.lst_Images.ElementAt(Sample.lst_Images.Count - 1);
                Sample.lst_Images.Insert(subSampleTreeNode.SampleIndex, imageAtIndex);
            }
            else
            {
                var selectedSampleIndex = ((CustomTreeNode)mainForm.treeViewSample.SelectedNode).SampleIndex;

                //IncreaseSampleIndexOnNodeAddition(selectedSampleIndex);

                //Add the node after selected node in the tree view...
                subSampleTreeNode.SampleIndex = lst_Samples.Count; //Sample index is the index of sample at lst_Sample list..
                mainForm.treeViewSample.SelectedNode.Nodes.Add(subSampleTreeNode);
                mainForm.treeViewSample.ExpandAll();

                //Insert a copy of the selected list in to multiple array list holder...
                var sampleAtIndex = Sample.lst_Samples.ElementAt(selectedSampleIndex);
                Sample.lst_Samples.Add(sampleAtIndex);

                var colorAtIndex = Sample.lst_Colors.ElementAt(selectedSampleIndex);
                Sample.lst_Colors.Add(colorAtIndex);

                var stateAtIndex = Sample.lst_State.ElementAt(selectedSampleIndex);
                Sample.lst_State.Add(stateAtIndex);

                var imageAtIndex = Sample.lst_Images.ElementAt(selectedSampleIndex);
                Sample.lst_Images.Add(imageAtIndex);
            }

            mainForm.UpdateStatus("A portion from " + mainForm.treeViewSample.SelectedNode.Text + " was taken and labelled as " + sampleName + "...");
        }
Ejemplo n.º 4
0
        //Seperates solution from the precipitate...
        public void CentrifugeAndSeperateSample(TreeNode treeNode)
        {
            var selectedSampleIndex = ((CustomTreeNode)treeNode).SampleIndex;

            var sampleToSeperate_States = Sample.lst_State.ElementAt(selectedSampleIndex);
            var sampleToSeperate_Sample = Sample.lst_Samples.ElementAt(selectedSampleIndex);
            var sampleToSeperate_Colors = Sample.lst_Colors.ElementAt(selectedSampleIndex);

            var arrayObj = SeperateSample(sampleToSeperate_States, sampleToSeperate_Sample, sampleToSeperate_Colors);


            List <string> tempLstSolution = arrayObj[0];
            List <string> tempLstPpt      = arrayObj[1];

            List <string> lstSolutionStates = arrayObj[2];
            List <string> lstPptStates      = arrayObj[3];

            List <string> lstSolutionColors = arrayObj[4];
            List <string> lstPptColors      = arrayObj[5];

            MediaOperator mop = new MediaOperator(mainForm);

            Bitmap bmp_Soln = mop.GetImage(tempLstSolution, lstSolutionStates, lstSolutionColors);

            Bitmap bmp_Ppt = mop.GetImage(tempLstPpt, lstPptStates, lstPptColors);



            if (tempLstPpt.Count == 0)
            {
                throw new Exception("You have nothing to seperate in this sample...!");
            }
            else
            {
                string nameOfSampleToBeSeperated = treeNode.Text;

                //Increase the sample indices of tree nodes after the selected node...
                //IncreaseSampleIndexOnNodeAddition(selectedSampleIndex);

                //Ammend the text of selected node for the supernatant..
                mainForm.treeViewSample.SelectedNode.Text += "_" + selectedSampleIndex.ToString() + "_1";

                //Create a new node for ppt..

                CustomTreeNode subSampleTreeNode = new CustomTreeNode();
                subSampleTreeNode.Text      = "Precipitate_" + selectedSampleIndex.ToString() + "_1";
                subSampleTreeNode.ForeColor = Color.Black;
                subSampleTreeNode.BackColor = Color.White;

                //Add the node after selected node in the tree view...
                subSampleTreeNode.SampleIndex = lst_Samples.Count;
                mainForm.treeViewSample.SelectedNode.Nodes.Add(subSampleTreeNode);
                mainForm.treeViewSample.ExpandAll();

                //Replace selected solution with supernatant...
                lst_Samples[selectedSampleIndex] = tempLstSolution;
                lst_Images[selectedSampleIndex]  = bmp_Soln;



                //Insert precipitate into the sample list after the supernatant...

                lst_Samples.Add(tempLstPpt);
                lst_Images.Add(bmp_Ppt);

                //Ammend color & state lists in similar manner...

                lst_Colors[selectedSampleIndex] = lstSolutionColors;

                lst_Colors.Add(lstPptColors);

                lst_State[selectedSampleIndex] = lstSolutionStates;

                lst_State.Add(lstPptStates);

                mainForm.UpdateStatus("Sample labelled as " + nameOfSampleToBeSeperated + " was centrifuged and seperated. The supernatant was labelled as " +
                                      mainForm.treeViewSample.SelectedNode.Text + " & the precipitate as " + subSampleTreeNode.Text + "...");
            }
        }