Exemple #1
0
        private void testToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ZedGraph.GraphPane     graphPane1 = zedGraphControl1.GraphPane;
            ZedGraph.PointPairList pointPairs = new ZedGraph.PointPairList();

            pointPairs.Add(0.5, 0);
            pointPairs.Add(0.5, Function1(0.5));
            pointPairs.Add(0, Function1(0.5));

            ZedGraph.LineItem lineItemResult1 = graphPane1.AddCurve("Альтернатива 1", pointPairs, Color.Blue, ZedGraph.SymbolType.None);

            zedGraphControl1.Invalidate();
        }
Exemple #2
0
        private void CreateGraph(ZedGraph.ZedGraphControl zgc)
        {
            //get a reference to the graphpane
            ZedGraph.GraphPane myPane = zgc.GraphPane;

            myPane.Title.Text = "First Graph";

            // generate some data for the graph
            double x, y1, y2;
            ZedGraph.PointPairList list1 = new ZedGraph.PointPairList();
            ZedGraph.PointPairList list2 = new ZedGraph.PointPairList();

            for( int i=0; i<36; i++)
            {
                x = (double)i+5;
                y1 = 1.5*Math.Sin((double)i*0.2);
                y2 = 1.5+(3.0*Math.Sin((double)i*0.2));
                list1.Add(x, y1);
                list2.Add(x, y2);

            }

            ZedGraph.LineItem myCurve = myPane.AddCurve("Seth", list1, Color.Red, ZedGraph.SymbolType.Diamond);
            ZedGraph.LineItem myCurve2 = myPane.AddCurve("Obi", list2, Color.Blue, ZedGraph.SymbolType.Circle);

            zgc.AxisChange();
        }
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            // Get a reference to the GraphPane instance in the ZedGraphControl
            ZedGraph.GraphPane pn = this.zgcGraph.GraphPane;
            pn.CurveList.Clear();

            // Set the titles and axis labels
            pn.Title.Text = "Demonstration of Dual Y Graph";
            pn.XAxis.Title.Text = "Level";
            pn.YAxis.Title.Text = "?";
            //pn.Y2Axis.Title.Text = "Parameter B";

            // Make up some data points based on the Sine function
            ZedGraph.PointPairList list = new ZedGraph.PointPairList();
            //ZedGraph.PointPairList list2 = new ZedGraph.PointPairList();
            //ZedGraph.PointPairList list3 = new ZedGraph.PointPairList();
            PersonBasics person = new PersonBasics(Class.Mage, 1);

            double max_value = 0;
            int max_level = (int)this.nudMaxLevel.Value;
            for (int i = 1; i <= max_level; i++){
                max_value = (double)person.MaxExpirience;
                list.Add((double)i, max_value);
                person.Level++;
            }
            ZedGraph.LineItem curve = pn.AddCurve("Experience", list, Color.Red, ZedGraph.SymbolType.Diamond);
            // Fill the symbols with white
            curve.Symbol.Fill = new ZedGraph.Fill(Color.White);
            // Show the x axis grid
            pn.XAxis.MajorGrid.IsVisible = true;

            // Make the Y axis scale red
            //pn.YAxis.Scale.FontSpec.FontColor = Color.Red;
            //pn.YAxis.Title.FontSpec.FontColor = Color.Red;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            pn.YAxis.MajorTic.IsOpposite = false;
            pn.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            pn.YAxis.MajorGrid.IsZeroLine = false;
            // Align the Y axis labels so they are flush to the axis
            pn.YAxis.Scale.Align = ZedGraph.AlignP.Inside;
            // Manually set the axis range
            pn.YAxis.Scale.Min = 0;
            pn.YAxis.Scale.Max = (double)max_value;

            pn.XAxis.Scale.Min = 0;
            pn.XAxis.Scale.Max = (double)max_level;

            this.zgcGraph.AxisChange();
            this.zgcGraph.Invalidate();
            return;
        }
Exemple #4
0
        private void ByMonths(object sender, EventArgs e)
        {
            try
            {
                System.Data.SqlClient.SqlCommand mnth = Statistics.Purchases.ByMonths();
                mnth.Connection = this.connection;
                System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(mnth);
                System.Data.DataTable st = new System.Data.DataTable("Summary");
                sda.Fill(st);

                ZedGraph.GraphPane pane = this.zgcStatistics.GraphPane;
                pane.CurveList.Clear();
                pane.GraphObjList.Clear();

                pane.YAxis.Title.Text = "Сумма, р";
                ZedGraph.PointPairList list = new ZedGraph.PointPairList();
                foreach (System.Data.DataRow row in st.Rows)
                {
                    int year = 1970;
                    int month = 1;
                    if(!System.Convert.IsDBNull(row["Year"]) &&
                       !System.Convert.IsDBNull(row["Month"]) ){
                        year = (int)row["Year"];
                        month = (int)row["Month"];
                        System.DateTime dt = new DateTime(year, month, 1);
                        ZedGraph.XDate xDate = new ZedGraph.XDate(dt);
                        decimal val = (decimal)row["Summary"];
                        list.Add(xDate.XLDate, (double)val);
                    }
                }
                ZedGraph.BarItem curve = pane.AddBar("", list, Color.Blue);

                // Для оси X установим календарный тип
                pane.XAxis.Type = ZedGraph.AxisType.Date;

                // pretty it up a little
                pane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
                pane.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);

                // Tell ZedGraph to calculate the axis ranges
                this.zgcStatistics.AxisChange();
                this.zgcStatistics.Invalidate();
            }catch (System.Exception ex){
                MessageBox.Show(ex.Message);
            }
            return;
        }
Exemple #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            double x0 = Double.Parse(textBox1.Text);//Начальное значение x
            double y0 = Double.Parse(textBox2.Text);//конечное значение x
            int n = Int32.Parse(textBox3.Text);//количество шагов
            //double _h = Double.Parse(textBox4.Text);

            double k1, k2, k3, k4, l1, l2, l3, l4, _h = 0.02, y1, y2, x1, x2;

            zedGraphControl1.MasterPane.PaneList.Clear();
            ZedGraph.GraphPane pane = new ZedGraph.GraphPane();
            pane.CurveList.Clear();
            ZedGraph.PointPairList list = new ZedGraph.PointPairList();

            do
            {
                y0 = y0 + _h;

                k1 = _h * fvx(y0, x0);
                l1 = _h * fvy(y0, x0);
                k2 = _h * fvx(y0 + l1 / 2, x0 + k1 / 2);
                l2 = _h * fvy(y0 + l1 / 2, x0 + k1 / 2);

                x1 = x0 + (k1 + k2) / 2;
                y1 = y0 + (l1 + l2) / 2;
                x0 = x1; y0 = y1;

                listBox1.Items.Add(x1);
                listBox1.Items.Add(y1);
                list.Add(x1, y1);
                //i++;
                //printf("\n %lf", x1);
                //printf("\n %lf", y1);
            }

            while (y0 > 0.02); // ((y0 > -0.00001));//(x1 <= n);
            ZedGraph.LineItem MyCurve = pane.AddCurve("func", list, Color.Blue);
            zedGraphControl1.MasterPane.Add(pane);
            using (Graphics g = CreateGraphics())
            {
                zedGraphControl1.MasterPane.SetLayout(g, ZedGraph.PaneLayout.ExplicitCol12);
            }
            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
        }
Exemple #6
0
        /// <summary>
        /// Loads the historical modeling data for the currently selected
        /// distributed server.  Typically called in reponse to the user changing
        /// the combo box selection for which server to view.
        /// </summary>
        private void LoadDataForPopComplexityGraph()
        {
            for (int Generation = 0; Generation < m_ServerData.Generations; Generation++)
            {
                int ComplexityMin  = m_ServerData[m_ModelingSelectedServer, Generation].ComplexityMinimum;
                int ComplexityMax  = m_ServerData[m_ModelingSelectedServer, Generation].ComplexityMaximum;
                int ComplexityAve  = m_ServerData[m_ModelingSelectedServer, Generation].ComplexityAverage;
                int ComplexityBest = m_ServerData[m_ModelingSelectedServer, Generation].BestComplexity;

                m_ptListComplexityMin.Add(Generation + 1, ComplexityMin);
                m_ptListComplexityMax.Add(Generation + 1, ComplexityMax);
                m_ptListComplexityAve.Add(Generation + 1, ComplexityAve);
                m_ptListComplexityBestOf.Add(Generation + 1, ComplexityBest);
            }
            //
            // Tell the graph to update itself
            graphPopulationComplexity.GraphPane.AxisChange(this.CreateGraphics());
            graphPopulationComplexity.Invalidate();
        }
Exemple #7
0
        /// <summary>
        /// Loads the historical modeling data for the currently selected
        /// distributed server.  Typically called in reponse to the user changing
        /// the combo box selection for which server to view.
        /// </summary>
        private void LoadDataForPopFitnessGraph()
        {
            for (int Generation = 0; Generation < m_ServerData.Generations; Generation++)
            {
                double FitnessMin = m_ServerData[m_ModelingSelectedServer, Generation].FitnessMinimum;
                double FitnessMax = m_ServerData[m_ModelingSelectedServer, Generation].FitnessMaximum;
                double FitnessAve = m_ServerData[m_ModelingSelectedServer, Generation].FitnessAverage;
                FitnessMax = Math.Min(FitnessMax, FitnessMin * 5);
                FitnessAve = Math.Min(FitnessAve, FitnessMin * 3);

                m_ptListPopFitnessMin.Add(Generation + 1, FitnessMin);
                m_ptListPopFitnessMax.Add(Generation + 1, FitnessMax);
                m_ptListPopFitnessAve.Add(Generation + 1, FitnessAve);
            }

            //
            // Tell the graph to update itself
            graphPopulationFitness.GraphPane.AxisChange(this.CreateGraphics());
            graphPopulationFitness.Invalidate();
        }
        /// <summary>
        /// Determines the points used to create the graphs
        /// </summary>
        public void CreateGraph()
        {
            list1 = new ZedGraph.PointPairList();
            list2 = new ZedGraph.PointPairList();
            list3 = new ZedGraph.PointPairList();
            list4 = new ZedGraph.PointPairList();
            list5 = new ZedGraph.PointPairList();

            double p       = 0;
            double q       = 0;
            double AA      = 0;
            double Aa      = 0;
            double aa      = 0;
            int    AAcount = 0;
            int    Aacount = 0;
            int    aacount = 0;
            int    AAnext  = 0;
            int    Aanext  = 0;
            int    aanext  = 0;
            double offset  = 0;
            double A_COUNT = 0;
            double a_COUNT = 0;
            int    psize   = 0;
            int    times   = 1;

            p = this.initAlleleFrequency.Value - (this.mutationRate.Value * this.initAlleleFrequency.Value);
            q = 1 - p;

            AA = Math.Pow(p, 2) * this.popSize.Value * this.fitnessAA.Value;
            Aa = 2 * p * q * this.popSize.Value * this.fitnessAa.Value;
            aa = Math.Pow(q, 2) * this.popSize.Value * this.fitnessaa.Value;

            //Console.WriteLine(((Math.Pow(p,2))+(Math.Pow(q,2))+(2*p*q)).ToString());

            /*Console.WriteLine((Math.Pow(q,2)).ToString());
             * Console.WriteLine((2*p*q).ToString());*/

            AAcount = (int)Math.Round(AA);
            Aacount = (int)Math.Round(Aa);
            aacount = (int)Math.Round(aa);

            /*Console.WriteLine(AA.ToString());
             * Console.WriteLine(Aa.ToString());
             * Console.WriteLine(aa.ToString());
             * Console.WriteLine(AAcount.ToString());
             * Console.WriteLine(Aacount.ToString());
             * Console.WriteLine(aacount.ToString());*/

            //offset = Math.Pow(p,2)*AA*this.fitnessAA.Value + Math.Pow(q,2)*aa*this.fitnessaa.Value + 2*p*q*Aa*this.fitnessAa.Value;

            //AA = ((Math.Pow(p,2)))/offset;
            //Aa = (2*p*q)/offset;
            //aa = ((Math.Pow(q,2)))/offset;

            //Console.WriteLine(Convert.ToString(AA)+" HERE");
            //Console.WriteLine(Convert.ToString(Aa));
            //Console.WriteLine(Convert.ToString(aa));

            list1.Add(0, p);
            list2.Add(0, p);
            list3.Add(0, p);
            list4.Add(0, p);
            list5.Add(0, p);

            while (times < 5)
            {
                p = this.initAlleleFrequency.Value - (this.mutationRate.Value * this.initAlleleFrequency.Value);
                q = 1 - p;

                AA = Math.Pow(p, 2) * this.popSize.Value * this.fitnessAA.Value;
                Aa = 2 * p * q * this.popSize.Value * this.fitnessAa.Value;
                aa = Math.Pow(q, 2) * this.popSize.Value * this.fitnessaa.Value;

                //Console.WriteLine(((Math.Pow(p,2))+(Math.Pow(q,2))+(2*p*q)).ToString());

                /*Console.WriteLine((Math.Pow(q,2)).ToString());
                 * Console.WriteLine((2*p*q).ToString());*/

                AAcount = (int)Math.Round(AA);
                Aacount = (int)Math.Round(Aa);
                aacount = (int)Math.Round(aa);

                //AA = ((Math.Pow(p,2)));
                //Aa = (2*p*q);
                //aa = ((Math.Pow(q,2)));

                for (int i = 1; i < 100; i++)
                {
                    psize  = AAcount + Aacount + aacount;
                    AAnext = 0;
                    Aanext = 0;
                    aanext = 0;

                    #region Generate New Population
                    for (int k = 0; k < this.popSize.Value; k++)
                    {
                        int r = rand.Next(psize);

                        //Console.WriteLine((psize+1).ToString());
                        //Console.WriteLine(r.ToString());

                        string first;
                        string second;

                        if (0 <= r && r < AAcount)
                        {
                            first = "AA";
                        }
                        else if (AAcount <= r && r < AAcount + Aacount)
                        {
                            first = "Aa";
                        }
                        else
                        {
                            first = "aa";
                        }

                        r = rand.Next(psize);

                        if (0 <= r && r < AAcount)
                        {
                            second = "AA";
                        }
                        else if (AAcount <= r && r < AAcount + Aacount)
                        {
                            second = "Aa";
                        }
                        else
                        {
                            second = "aa";
                        }

                        if (first == "AA")
                        {
                            switch (second)
                            {
                            case "AA":
                                AAnext++;
                                break;

                            case "Aa":
                                if (rand.Next(2) == 0)
                                {
                                    AAnext++;
                                }
                                else
                                {
                                    Aanext++;
                                }
                                break;

                            case "aa":
                                Aanext++;
                                break;
                            }
                        }
                        else if (first == "Aa")
                        {
                            switch (second)
                            {
                            case "AA":
                                if (rand.Next(2) == 0)
                                {
                                    AAnext++;
                                }
                                else
                                {
                                    Aanext++;
                                }
                                break;

                            case "Aa":
                                switch (rand.Next(4))
                                {
                                case 0:
                                    AAnext++;
                                    break;

                                case 1:
                                    aanext++;
                                    break;

                                default:
                                    Aanext++;
                                    break;
                                }
                                break;

                            case "aa":
                                if (rand.Next(2) == 0)
                                {
                                    Aanext++;
                                }
                                else
                                {
                                    aanext++;
                                }
                                break;
                            }
                        }
                        else
                        {
                            switch (second)
                            {
                            case "AA":
                                Aanext++;
                                break;

                            case "Aa":
                                if (rand.Next(2) == 0)
                                {
                                    aanext++;
                                }
                                else
                                {
                                    Aanext++;
                                }
                                break;

                            case "aa":
                                aanext++;
                                break;
                            }
                        }
                    }
                    #endregion

                    /*AAnext *= 2;
                    *  Aanext *= 2;
                    *  aanext *= 2;*/

                    if (AAnext + Aanext + aanext != this.popSize.Value)
                    {
                        //Console.WriteLine("Broken");
                    }

                    p = (2 * AAnext + Aanext) / (2 * this.popSize.Value);

                    if (times == 1)
                    {
                        list1.Add(i, p);
                    }
                    else if (times == 2)
                    {
                        list2.Add(i, p);
                    }
                    else if (times == 3)
                    {
                        list3.Add(i, p);
                    }
                    else if (times == 4)
                    {
                        list4.Add(i, p);
                    }
                    else if (times == 5)
                    {
                        list5.Add(i, p);
                    }

                    p = p - (this.mutationRate.Value * p);
                    q = 1 - p;

                    AA = Math.Pow(p, 2) * this.popSize.Value * this.fitnessAA.Value;
                    Aa = 2 * p * q * this.popSize.Value * this.fitnessAa.Value;
                    aa = Math.Pow(q, 2) * this.popSize.Value * this.fitnessaa.Value;

                    AAcount = (int)Math.Round(AA);
                    Aacount = (int)Math.Round(Aa);
                    aacount = (int)Math.Round(aa);

                    //offset = Math.Pow(p,2)*AA*this.fitnessAA.Value + Math.Pow(q,2)*aa*this.fitnessaa.Value + 2*p*q*Aa*this.fitnessAa.Value;

                    //AA = ((Math.Pow(p,2)))/offset;
                    //Aa = (2*p*q)/offset;
                    //aa = ((Math.Pow(q,2)))/offset;

                    /*while(AAcount+Aacount+aacount < this.popSize.Value)
                     * {
                     * double r = rand.Next((int)this.popSize.Value);
                     *
                     *      if(0 <= r && r < AAcount)
                     *      {
                     *              AAcount++;
                     *      }
                     *      else if(AAcount <= r && r < AAcount+Aacount)
                     *      {
                     *              Aacount++;
                     *      }
                     *      else
                     *      {
                     *              aacount++;
                     *      }
                     * }*/

                    if (AAcount + Aacount + aacount != this.popSize.Value)
                    {
                        //Console.WriteLine((AAcount+Aacount+aacount).ToString());
                    }
                }

                times++;
            }
        }
Exemple #9
0
        public void Calculate(string str)
        {
            Random random = new Random();

            //----------------------------------------ЗАПОЛНЕНИЕ МАТРИЦ
            #region ЗАПОЛНЕНИЕ МАТРИЦ

            KritAlts = new List <double[, ]>();

            if (str == "example")
            {
                KritAlts.Add(new double[, ] {
                    { 1, 3, 2 }, { 0.33, 1, 0.33 }, { 0.5, 3, 1 }
                });
                KritAlts.Add(new double[, ] {
                    { 1, 0.25, 6 }, { 4, 1, 5 }, { 0.16, 0.2, 1 }
                });
                KritAlts.Add(new double[, ] {
                    { 1, 0.33, 2 }, { 3, 1, 5 }, { 0.5, 0.2, 1 }
                });
                KritCompares = new double[, ] {
                    { 1, 2, 3 }, { 0.5, 1, 4 }, { 0.33, 0.25, 1 }
                };
            }
            else
            {
                double[,] krits = new double[AltsCount, AltsCount];

                for (int count = 0; count < AltsCount; count++)
                {
                    krits = new double[AltsCount, AltsCount];

                    for (int i = 0; i < AltsCount; i++)
                    {
                        for (int j = 0; j < AltsCount; j++)
                        {
                            if (i == j)
                            {
                                krits[i, j] = 1;
                            }
                            else if (i < j)
                            {
                                int ch = random.Next(2);
                                if (ch == 0)
                                {
                                    krits[i, j] = random.Next(1, 6);
                                }
                                else
                                {
                                    krits[i, j] = random.NextDouble();
                                }
                            }
                            else
                            {
                                krits[i, j] = 1 / krits[j, i];
                            }
                        }
                    }

                    KritAlts.Add(krits);
                }


                KritCompares = new double[KritsCount, KritsCount];
                for (int i = 0; i < KritsCount; i++)
                {
                    for (int j = 0; j < KritsCount; j++)
                    {
                        if (i == j)
                        {
                            KritCompares[i, j] = 1;
                        }
                        else if (i < j)
                        {
                            int ch = random.Next(2);
                            if (ch == 0)
                            {
                                KritCompares[i, j] = random.Next(1, 6);
                            }
                            else
                            {
                                KritCompares[i, j] = random.NextDouble();
                            }
                        }
                        else
                        {
                            KritCompares[i, j] = 1 / KritCompares[j, i];
                        }
                    }
                }
            }

            #region Вывод матриц

            foreach (double[,] d in KritAlts)
            {
                string strn = "Сравнение алтернатив по критериям\r\n";
                for (int i = 0; i < d.GetLength(0); i++)
                {
                    for (int j = 0; j < d.GetLength(1); j++)
                    {
                        strn += $"{d[i, j]:0.00}\t";
                    }
                    strn += "\r\n";
                }
                MessageBox.Show(strn);
            }

            string strnK = "Сравнение критериев\r\n";
            for (int i = 0; i < KritCompares.GetLength(0); i++)
            {
                for (int j = 0; j < KritCompares.GetLength(1); j++)
                {
                    strnK += $"{KritCompares[i, j]:0.00}\t";
                }
                strnK += "\r\n";
            }
            MessageBox.Show(strnK);

            #endregion

            #endregion

            //---------------------------------РАСЧЁТ МАТРИЦ
            #region  АСЧЁТ МАТРИЦ

            KritNormals = new List <double[]>();

            foreach (double[,] d in KritAlts)
            {
                double   Sum  = 0;
                double[] sums = new double[d.GetLength(0)];
                for (int i = 0; i < d.GetLength(0); i++)
                {
                    double rowSum = 0;
                    for (int j = 0; j < d.GetLength(1); j++)
                    {
                        rowSum += d[i, j];
                    }
                    sums[i] = rowSum;
                    Sum    += rowSum;
                }

                for (int i = 0; i < sums.Length; i++)
                {
                    sums[i] /= Sum;
                }

                KritNormals.Add(sums);

                #region Вывод нормированных критериев

                string ts1 = $"Общая сумма: {Sum:0.00}\r\n";
                foreach (double db in sums)
                {
                    ts1 += $"{db:0.00}\t";
                }

                MessageBox.Show(ts1);

                #endregion
            }

            double sumsWeights = 0;
            KritWeigths = new double[KritsCount];

            for (int i = 0; i < KritCompares.GetLength(0); i++)
            {
                double Sum = 0;
                for (int j = 0; j < KritCompares.GetLength(1); j++)
                {
                    Sum += KritCompares[i, j];
                }
                KritWeigths[i] = Sum;
                sumsWeights   += Sum;
            }

            for (int i = 0; i < KritWeigths.Length; i++)
            {
                KritWeigths[i] /= sumsWeights;
            }

            #region Вывод весов

            string ts2 = $"Веса критериев, общая сумма: {sumsWeights:0.00}\r\n";
            foreach (double d in KritWeigths)
            {
                ts2 += $"{d:0.00}\t";
            }

            MessageBox.Show(ts2);

            #endregion

            #endregion

            //----------------------------------РАСЧЁТ ФУНКЦИЙ ПОЛЕЗНОСТИ И ЦЕН
            #region  АСЧЁТ ФУНКЦИЙ ПОЛЕЗНОСТИ И ЦЕН

            Functions = new double[AltsCount];
            MessageBox.Show("РАСЧЁТ ФУНКЦИЙ ПОЛЕЗНОСТИ");
            for (int i = 0; i < AltsCount; i++)
            {
                double sum = 0;
                for (int normals = 0; normals < KritNormals.Count; normals++)
                {
                    double res = KritNormals[normals][i] * KritWeigths[normals];
                    sum += res;
                    MessageBox.Show($"RES: {res:0.00}; FIRST: {KritNormals[normals][i]:0.00}; SECOND: {KritWeigths[normals]:0.00}");
                }
                Functions[i] = sum;
                MessageBox.Show($"Альтернатива {i + 1} : {sum:0.000}");
            }


            if (str == "example")
            {
                Prices = new int[] { 10000, 15000, 8000 };
            }
            else
            {
                Prices = new int[AltsCount];
                for (int i = 0; i < AltsCount; i++)
                {
                    Prices[i] = random.Next(5000, 20000);
                }
            }


            #region Вывод цен

            string ts3 = "Цены\r\n";
            foreach (int i in Prices)
            {
                ts3 += $"{i}\t";
            }
            ts3 += $"\r\nОбщая сумма: {Prices.Sum():0.00}";
            MessageBox.Show(ts3);

            #endregion

            #endregion

            PricesNorm = new double[AltsCount];
            for (int i = 0; i < AltsCount; i++)
            {
                double PricesSum = Prices.Sum();
                double pr        = Prices[i];
                PricesNorm[i] = pr / PricesSum;
                MessageBox.Show($"Нормаль цены {i + 1} : {PricesNorm[i]:0.000}");
            }

            Alters = new List <Alternatives>();
            risks  = new List <Risks>();

            for (int i = 0; i < AltsCount; i++)
            {
                double cmpr = Functions[i] / PricesNorm[i];
                Alters.Add(new Alternatives()
                {
                    Compare = cmpr, Name = $"Альтернатива {i + 1}"
                });

                double rk = Function1(PricesNorm[i]) + Function2(PricesNorm[i]) + Function3(PricesNorm[i]);
                risks.Add(new Risks()
                {
                    Compare = rk, Name = $"Альтернатива {i + 1}"
                });

                ZedGraph.GraphPane     graphPane1 = zedGraphControl1.GraphPane;
                ZedGraph.PointPairList pointPairs = new ZedGraph.PointPairList();

                pointPairs.Add(PricesNorm[i], 0);
                pointPairs.Add(PricesNorm[i], Function1(PricesNorm[i]));
                pointPairs.Add(0, Function1(PricesNorm[i]));

                ZedGraph.LineItem lineItemResult1 = graphPane1.AddCurve($"Альтернатива {i + 1}", pointPairs, Color.Blue, ZedGraph.SymbolType.None);
                zedGraphControl1.Invalidate();


                ZedGraph.GraphPane     graphPane2  = zedGraphControl2.GraphPane;
                ZedGraph.PointPairList pointPairs2 = new ZedGraph.PointPairList();

                pointPairs2.Add(PricesNorm[i], 0);
                pointPairs2.Add(PricesNorm[i], Function2(PricesNorm[i]));
                pointPairs2.Add(0, Function2(PricesNorm[i]));

                ZedGraph.LineItem lineItemResult2 = graphPane2.AddCurve($"Альтернатива {i + 1}", pointPairs2, Color.Green, ZedGraph.SymbolType.None);
                zedGraphControl2.Invalidate();


                ZedGraph.GraphPane     graphPane3  = zedGraphControl3.GraphPane;
                ZedGraph.PointPairList pointPairs3 = new ZedGraph.PointPairList();

                pointPairs3.Add(PricesNorm[i], 0);
                pointPairs3.Add(PricesNorm[i], Function3(PricesNorm[i]));
                pointPairs3.Add(0, Function3(PricesNorm[i]));

                ZedGraph.LineItem lineItemResult3 = graphPane3.AddCurve($"Альтернатива {i + 1}", pointPairs3, Color.Purple, ZedGraph.SymbolType.None);
                zedGraphControl3.Invalidate();
            }


            Alters.Sort(delegate(Alternatives a1, Alternatives a2)
            {
                if (a1.Compare > a2.Compare)
                {
                    return(-1);
                }
                else if (a1.Compare < a2.Compare)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            });

            risks.Sort(delegate(Risks a1, Risks a2)
            {
                if (a1.Compare > a2.Compare)
                {
                    return(-1);
                }
                else if (a1.Compare < a2.Compare)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            });

            string answer = "Ответ:\r\n";
            foreach (Alternatives al in Alters)
            {
                answer += al.ToString() + "\r\n";
            }

            answer += "\r\n";
            foreach (Risks r in risks)
            {
                answer += r.ToString() + "\r\n";
            }
            MessageBox.Show(answer);
        }
Exemple #10
0
        public void DrawGraphs()
        {
            ZedGraph.GraphPane     graphPane1  = zedGraphControl1.GraphPane;
            ZedGraph.PointPairList pointPairs1 = new ZedGraph.PointPairList();

            graphPane1.CurveList.Clear();
            graphPane1.Title.Text = "График 1";

            for (double x = 0; x <= 1; x += 0.01)
            {
                pointPairs1.Add(x, Function1(x));
            }

            ZedGraph.LineItem lineItemResult1 = graphPane1.AddCurve("График 1", pointPairs1, Color.Red, ZedGraph.SymbolType.None);

            graphPane1.XAxis.Scale.Min = 0;
            graphPane1.XAxis.Scale.Max = 1;
            graphPane1.YAxis.Scale.Min = 0;
            graphPane1.YAxis.Scale.Max = 1;

            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();



            ZedGraph.GraphPane     graphPane2  = zedGraphControl2.GraphPane;
            ZedGraph.PointPairList pointPairs2 = new ZedGraph.PointPairList();

            graphPane2.CurveList.Clear();
            graphPane2.Title.Text = "График 2";

            for (double x = 0; x <= 1; x += 0.01)
            {
                pointPairs2.Add(x, Function2(x));
            }

            ZedGraph.LineItem lineItemResult2 = graphPane2.AddCurve("График 2", pointPairs2, Color.Red, ZedGraph.SymbolType.None);

            graphPane2.XAxis.Scale.Min = 0;
            graphPane2.XAxis.Scale.Max = 1;
            graphPane2.YAxis.Scale.Min = 0;
            graphPane2.YAxis.Scale.Max = 1;

            zedGraphControl2.AxisChange();
            zedGraphControl2.Invalidate();



            ZedGraph.GraphPane     graphPane3  = zedGraphControl3.GraphPane;
            ZedGraph.PointPairList pointPairs3 = new ZedGraph.PointPairList();

            graphPane3.CurveList.Clear();
            graphPane3.Title.Text = "График 3";

            for (double x = 0; x <= 1; x += 0.01)
            {
                pointPairs3.Add(x, Function3(x));
            }

            ZedGraph.LineItem lineItemResult3 = graphPane3.AddCurve("График 3", pointPairs3, Color.Red, ZedGraph.SymbolType.None);

            graphPane3.XAxis.Scale.Min = 0;
            graphPane3.XAxis.Scale.Max = 1;
            graphPane3.YAxis.Scale.Min = 0;
            graphPane3.YAxis.Scale.Max = 1;

            zedGraphControl3.AxisChange();
            zedGraphControl3.Invalidate();
        }
        private void calculation()
        {
            if (_Station == null || Sensor == null)
            {
                zedGraphControl1.GraphPane.CurveList.Clear();
                zedGraphControl2.GraphPane.CurveList.Clear();

                zedGraphControl1.AxisChange();
                zedGraphControl1.Invalidate();

                zedGraphControl2.AxisChange();
                zedGraphControl2.Invalidate();

                if (_Station == null)
                {
                    userControl_RingLaserOrientation1.SiteLocation = null;
                }

                if (Sensor == null)
                {
                    userControl_RingLaserOrientation1.NormalVector = null;
                }

                return;
            }

            myPane1.CurveList.Clear();
            myPane2.CurveList.Clear();

            richTextBox1.Clear();
            richTextBox1.Text  = "Location        : " + StationName + Environment.NewLine;
            richTextBox1.Text += " Longitude [°]  : " + _Station.Location.Longitude.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine;
            richTextBox1.Text += " Latitude  [°]  : " + _Station.Location.Latitude.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine + Environment.NewLine;

            richTextBox1.Text += "Instrument      : " + Sensor.Name + Environment.NewLine;
            richTextBox1.Text += " Azimuth     [°]: " + Sensor.Azimut.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine;
            richTextBox1.Text += " Dip         [°]: " + Sensor.Dip.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine;
            richTextBox1.Text += " Side length [m]: " + Sensor.RingLaser.SideLength.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine;
            richTextBox1.Text += " Shape          : " + Sensor.RingLaser.Shape.ToString() + Environment.NewLine;
            richTextBox1.Text += " Lambda     [Hz]: " + Sensor.RingLaser.Lambda.ToString("0.0000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine + Environment.NewLine;

            richTextBox1.Text += "Calculations    :" + Environment.NewLine;

            // -------------------------------------------------------------------------------------------------
            RingLaserPrediction rlg = new RingLaserPrediction()
            {
                SiteLocation = new RingLaserPrediction.Location(_Station.Name,
                                                                _Station.Location.Longitude,
                                                                _Station.Location.Latitude,
                                                                _Station.Location.Height),
                SideLength = Sensor.RingLaser.SideLength,
                Lambda     = (Sensor.RingLaser.Lambda * 1e-9),
            };

            userControl_RingLaserOrientation1.NormalVector = new UserControl_RingLaserOrientation.Vector_AzimuthDip(Sensor.Azimut, Sensor.Dip);

            if (radioButtonTriangular.Checked)
            {
                rlg.ScaleFactor = rlg.ScaleFactorTriangle();
            }
            else if (radioButtonSquared.Checked)
            {
                rlg.ScaleFactor = rlg.ScaleFactorSquare();
            }

            richTextBox1.Text += " Scale factor   : " + rlg.ScaleFactor.ToString("0.000000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine;

            /* ************************************************************
            * **** Test calculation / validation for "G" *****************
            * Steps:
            *  1. Definition of the orientation in local Coordinate System.
            *     x = to South direction
            *     y = to East direction
            *     z = opposite to g-vector, parallel to Earth radius
            * Loop over the azimuth:
            *  2. Transformation from sperical to cartesian coordinates.
            *  3. Rotation of the local coordinate system around z-axis
            *     (vertical-axis) adjusting the local orientation against
            *     North.
            *  4. Rotation of the local coordinate system around y-axis
            *     with the co-latutude of the location into the global
            *     system.
            *  5. Rotation of the glogal system to the right latitude of
            *     the location.
            *  6. Calculation of the nominal Sagnac-frequency of the
            *     triangular ring, using the given parameter.
            * ************************************************************/

            // Definition of the orientation of "G" within the local coordinate system, normal vector parallel to z-axis
            RingLaserPrediction.Coordinate_Sperical RL_LocalOrientationSperical = new RingLaserPrediction.Coordinate_Sperical()
            {
                R     = 1,
                Theta = RingLaserPrediction.RAD(90.0 - Sensor.Dip),
                Phi   = RingLaserPrediction.RAD(Sensor.Azimut + 180.0),
            };

            // Conversion from sperical to cartesien coordinates
            RingLaserPrediction.Coordinate_Cartesian RL_LocalOrientationCartesien = rlg.CoordinateTransformation_SphericalToCartesion(RL_LocalOrientationSperical);

            if (checkBoxRotateAroundVertical.Checked && checkBoxRotateAroundVertical.Enabled)
            {
                string tmp = Environment.NewLine;
                tmp += "        Lobal orientation" + Environment.NewLine;
                tmp += "             of normal " + Environment.NewLine;
                tmp += "Alpha   Latitude  Longitude  Sagnac-frequency" + Environment.NewLine;
                tmp += "  [°]        [°]        [°]              [Hz]" + Environment.NewLine;

                ZedGraph.PointPairList calcsSagnac = new ZedGraph.PointPairList();
                ZedGraph.PointPairList calcsCoords = new ZedGraph.PointPairList();

                for (double alpha = 0; alpha < 360.0; alpha++)
                {
                    // Locale Rotation arround the vertical for azimuth of rings
                    RingLaserPrediction.Coordinate_Cartesian RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_LocalOrientationCartesien, RingLaserPrediction.RAD(alpha), RingLaserPrediction.RotationAround.Z);

                    // Rotation around co-latitude
                    RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_GlobalOrientationCartesien, RingLaserPrediction.RAD(90.0 - rlg.SiteLocation.Latitude), RingLaserPrediction.RotationAround.Y);

                    // Rotation around longitude - Not nesseccary, but well for proofing
                    RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_GlobalOrientationCartesien, RingLaserPrediction.RAD(-rlg.SiteLocation.Longitude), RingLaserPrediction.RotationAround.Z);

                    // Conversion from cartesien to sperical coordinates
                    RingLaserPrediction.Coordinate_Sperical RL_GlobalOrientationSperical = rlg.CoordinateTransformation_CartesionToSpherical(RL_GlobalOrientationCartesien);

                    // Calculation of Sagnac-frequency of "G": 'Scale factor' * 'Earth rotation' * Cos('co-latitude of normal vector within the global coordinate system')
                    double Sagnac = (rlg.ScaleFactor * RingLaserPrediction.EarthRotationIERS * Math.Abs(Math.Cos(RingLaserPrediction.RAD(90.0) - RL_GlobalOrientationSperical.Theta)));

                    // Output
                    tmp += String.Format(PreAnalyseExtended.Constants.NumberFormatEN,
                                         "{0,5:0} {1,10:0.0000} {2,10:0.0000} {3,17:0.000}" + Environment.NewLine,
                                         alpha,
                                         RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Phi),
                                         RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Theta),
                                         Sagnac);

                    calcsSagnac.Add(alpha, Sagnac);
                    calcsCoords.Add(RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Phi), RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Theta));
                }

                ZedGraph.LineItem myCurve1 = myPane1.AddCurve(null, calcsSagnac, Color.Red, ZedGraph.SymbolType.None);
                ZedGraph.LineItem myCurve2 = myPane2.AddCurve("Coordinate path of normal vector", calcsCoords, Color.Red, ZedGraph.SymbolType.Diamond);
                myCurve2.Line.IsVisible = false;

                calcsCoords = new ZedGraph.PointPairList();
                if (rlg.SiteLocation.Longitude > 0)
                {
                    calcsCoords.Add(rlg.SiteLocation.Longitude, rlg.SiteLocation.Latitude);
                }
                else
                {
                    calcsCoords.Add(360 + rlg.SiteLocation.Longitude, rlg.SiteLocation.Latitude);
                }

                myCurve2 = myPane2.AddCurve("Site location", calcsCoords, Color.Blue, ZedGraph.SymbolType.XCross);
                myCurve2.Line.IsVisible = false;

                richTextBox1.Text += tmp;
            }
            else
            {
                // Rotation around co-latitude
                RingLaserPrediction.Coordinate_Cartesian RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_LocalOrientationCartesien, RingLaserPrediction.RAD(90.0 - rlg.SiteLocation.Latitude), RingLaserPrediction.RotationAround.Y);

                // Rotation around longitude - Not nesseccary, but well for proofing
                RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_GlobalOrientationCartesien, RingLaserPrediction.RAD(-rlg.SiteLocation.Longitude), RingLaserPrediction.RotationAround.Z);

                // Conversion from cartesien to sperical coordinates
                RingLaserPrediction.Coordinate_Sperical RL_GlobalOrientationSperical = rlg.CoordinateTransformation_CartesionToSpherical(RL_GlobalOrientationCartesien);

                // Calculation of Sagnac-frewquency of "G": 'Scale factor' * 'Earth rotation' * Cos('co-latitude of normal vector within the global coordinate system')
                double Sagnac = (rlg.ScaleFactor * RingLaserPrediction.EarthRotationIERS * Math.Abs(Math.Cos(RingLaserPrediction.RAD(90.0) - RL_GlobalOrientationSperical.Theta)));

                // Output
                richTextBox1.Text += String.Format(PreAnalyseExtended.Constants.NumberFormatEN,
                                                   " Global orientation of ring laser normal: " + Environment.NewLine +
                                                   "  Longitude: {1,7:0.0000}" + Environment.NewLine +
                                                   "  Latitude : {0,7:0.0000}" + Environment.NewLine,
                                                   RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Theta),
                                                   RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Phi));
                richTextBox1.Text += String.Format(PreAnalyseExtended.Constants.NumberFormatEN, "Nominal Sagnac-frequency [Hz]: {0,10:0.000}", Sagnac) + Environment.NewLine;

                ZedGraph.LineItem myCurve2 = myPane2.AddCurve("Coordinate path of normal vector", null, Color.Red, ZedGraph.SymbolType.Diamond);
                myCurve2.Line.IsVisible = false;
                ZedGraph.PointPairList calcsCoords = new ZedGraph.PointPairList();
                if (rlg.SiteLocation.Longitude > 0)
                {
                    calcsCoords.Add(rlg.SiteLocation.Longitude, rlg.SiteLocation.Latitude);
                }
                else
                {
                    calcsCoords.Add(360 + rlg.SiteLocation.Longitude, rlg.SiteLocation.Latitude);
                }

                myCurve2 = myPane2.AddCurve("Site location", calcsCoords, Color.Blue, ZedGraph.SymbolType.XCross);
                myCurve2.Line.IsVisible = false;
            }

            // Calculate the Axis Scale Ranges
            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();

            zedGraphControl2.AxisChange();
            zedGraphControl2.Invalidate();
        }
Exemple #12
0
        private void GenerateGraph()
        {
            zedGraphControl.GraphPane.CurveList.Clear();
            var sim = new Simulator(Activities);
            //figure out any points where the graph potentially changes slope:
            var xValues = sim.GetActivitiesAndNormalizations()
                .SelectMany(x => new[] {x.ActivityTime, x.ActivityTime + x.Onset})
                .Union(new[] {TimeSpan.FromHours(0), TimeSpan.FromHours(24)})
                .Distinct()
                .OrderBy(x => x)
                .ToList();

            //Add any starting or ending points for glycation, when blood sugar crosses 150:
            var crossovers = new List<TimeSpan>();
            for (int i = 0; i + 1 < xValues.Count; i++) {
                if (Math.Sign(sim.GetBloodSugar(xValues[i]) - 150) != Math.Sign(sim.GetBloodSugar(xValues[i + 1]) - 150)) {
                    var fractionOfTime = (150 - sim.GetBloodSugar(xValues[i])) / (sim.GetBloodSugar(xValues[i + 1]) - sim.GetBloodSugar(xValues[i]));
                    crossovers.Add(xValues[i] + TimeSpan.FromMinutes(fractionOfTime * (xValues[i + 1] - xValues[i]).TotalMinutes));
                }
            }
            xValues = xValues.Union(crossovers).Distinct().OrderBy(x => x).ToList();

            var bloodSugar = new ZedGraph.PointPairList();
            foreach (var time in xValues) {
                double sugar = sim.GetBloodSugar(time);
                bloodSugar.Add(new ZedGraph.PointPair(time.TotalHours, sugar));
            }

            var glycation = new ZedGraph.PointPairList();
            foreach (var time in xValues) {
                double gly = sim.GetCumulativeGlycation(time);
                glycation.Add(new ZedGraph.PointPair(time.TotalHours, gly));
            }

            var foodEvents = new ZedGraph.PointPairList();
            foreach (var time in Activities.OfType<FoodActivity>().Select(x => x.ActivityTime)) {
                double point = sim.GetBloodSugar(time);
                foodEvents.Add(new ZedGraph.PointPair(time.TotalHours, point));
            }

            var exerciseEvents = new ZedGraph.PointPairList();
            foreach (var time in Activities.OfType<ExerciseActivity>().Select(x => x.ActivityTime)) {
                double point = sim.GetBloodSugar(time);
                exerciseEvents.Add(new ZedGraph.PointPair(time.TotalHours, point));
            }

            var threshold = new ZedGraph.PointPairList(new[] {0.0, 24.0}, new[] {150.0, 150.0});

            zedGraphControl.GraphPane.AddCurve("Blood Sugar", bloodSugar, Color.Green, ZedGraph.SymbolType.None);
            zedGraphControl.GraphPane.AddCurve("Cumulative Glycation", glycation, Color.Red, ZedGraph.SymbolType.None);
            var line = zedGraphControl.GraphPane.AddCurve("Glycation threshold", threshold, Color.Red,
                ZedGraph.SymbolType.HDash);
            line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            var food = zedGraphControl.GraphPane.AddCurve("", foodEvents, Color.Red, ZedGraph.SymbolType.Triangle);
            food.Line.IsVisible = false;
            food.Symbol.Fill.Type = ZedGraph.FillType.Solid;
            var exercise = zedGraphControl.GraphPane.AddCurve("", exerciseEvents, Color.Green,
                ZedGraph.SymbolType.TriangleDown);
            exercise.Line.IsVisible = false;
            exercise.Symbol.Fill.Type = ZedGraph.FillType.Solid;
            zedGraphControl.RestoreScale(zedGraphControl.GraphPane);
        }
        private void LoadGraph()
        {
            if (lineProductionDatas.Count <= 0)
            {
                MessageBox.Show("Unable to load data from server.", "Line efficiency daily graph", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var bufferList = new List <ArticleProductionData>();

            var pane = new ZedGraph.GraphPane();

            pane.Title.Text               = "EFF con " + Line + "  (" + Department + ")";
            pane.YAxis.Title.Text         = "EFF %";
            pane.XAxis.Title.Text         = Month.ToString() + "/" + Year.ToString();
            pane.XAxis.MajorTic.IsAllTics = true;
            pane.XAxis.Scale.MajorStep    = 1;
            pane.XAxis.Scale.Min          = 1;
            pane.XAxis.Scale.Max          = 31;

            pane.Fill = new ZedGraph.Fill(Brushes.WhiteSmoke);

            ZedGraph.PointPairList list = new ZedGraph.PointPairList();

            foreach (var lineProduction in lineProductionDatas)
            {
                var workEff = Math.Round((lineProduction.Qty / lineProduction.Producibili) * 100.0, 1);

                list.Add(lineProduction.Datex.Day, workEff);
            }

            pane.GraphObjList.Clear();
            zedGraph.GraphPane.CurveList.Clear();

            var curve = new ZedGraph.LineItem("EFF %", list, Color.SteelBlue, ZedGraph.SymbolType.Circle);

            curve.Line.IsVisible     = true;
            curve.Symbol.Fill.Color  = Color.SteelBlue;
            curve.Symbol.Fill.Type   = ZedGraph.FillType.Solid;
            curve.Symbol.Size        = 10;
            curve.Line.Width         = 4;
            curve.Symbol.IsAntiAlias = true;
            curve.Line.IsSmooth      = false;
            curve.Line.IsAntiAlias   = true;
            curve.Line.Fill          = new ZedGraph.Fill(Color.White,
                                                         Color.LightSkyBlue, -45F);

            curve.Symbol.Size = 8.0F;
            curve.Symbol.Fill = new ZedGraph.Fill(Color.White);
            curve.Line.Width  = 2.0F;

            pane.XAxis.MajorTic.IsBetweenLabels = true;

            pane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(250, 250, 250), 90F);
            pane.Fill       = new ZedGraph.Fill(Color.FromArgb(250, 250, 250));

            zedGraph.GraphPane    = pane;
            pane.Legend.IsVisible = false;
            ZedGraph.PointPairList articleRangeList = new ZedGraph.PointPairList();
            ZedGraph.LineItem      articleVertCurve = new ZedGraph.LineItem("");

            for (var i = 0; i <= curve.Points.Count - 1; i++)
            {
                ZedGraph.PointPair pt = curve.Points[i];

                ZedGraph.TextObj text = new ZedGraph.TextObj(pt.Y.ToString("f1"), pt.X, pt.Y,
                                                             ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center);
                text.ZOrder = ZedGraph.ZOrder.D_BehindAxis;
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible   = false;
                text.FontSpec.Angle            = 90;
                pane.GraphObjList.Add(text);

                var art = articleProductions.LastOrDefault(x => x.Day == pt.X);
                var buf = bufferList.FirstOrDefault(x => x.Article == art.Article || x.Day == art.Day);


                if (art != null && buf == null)
                {
                    bufferList.Add(art);

                    ZedGraph.TextObj textArt = new ZedGraph.TextObj(art.Article, pt.X + 0.2f, pane.YAxis.Scale.Min + pt.Y / 2,
                                                                    ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center);

                    textArt.ZOrder = ZedGraph.ZOrder.D_BehindAxis;
                    textArt.FontSpec.Border.IsVisible = false;
                    textArt.FontSpec.Fill.IsVisible   = false;
                    textArt.FontSpec.Size             = 9;
                    textArt.FontSpec.FontColor        = Color.Black;

                    var lastArt = articleProductions.LastOrDefault(x => x.Day == pt.X - 1);
                    var nextArt = articleProductions.FirstOrDefault(x => x.Day == pt.X + 2);

                    if (lastArt != null && lastArt.Article != art.Article || nextArt != null && nextArt.Article != art.Article)
                    {
                        textArt.FontSpec.Angle = 90;
                    }
                    else
                    {
                        textArt.FontSpec.Angle = 0;
                    }

                    pane.GraphObjList.Add(textArt);

                    articleRangeList = new ZedGraph.PointPairList();
                    articleRangeList.Add(pt.X, pt.Y);
                    articleRangeList.Add(pt.X, pane.YAxis.Scale.Min);

                    var ac = new ZedGraph.LineItem(art.Article);
                    ac.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                    ac            = pane.AddCurve(art.Article, articleRangeList, Color.Orange, ZedGraph.SymbolType.None);
                }
            }

            zedGraph.GraphPane.CurveList.Add(curve);
            zedGraph.AxisChange();
            zedGraph.Refresh();

            zedGraph.IsShowPointValues = true;
            zedGraph.PointValueFormat  = "0";
            zedGraph.Invalidate();
        }
Exemple #14
0
        public static Image GetAnnotatedImage(string argPeptide, MSScan argScan, List <MSPoint> argPeaks, GlycanStructure argStructure)
        {
            float MaxX = argStructure.Root.FetchAllGlycanNode().OrderByDescending(o => o.IDMass).ToList()[0].IDMass;

            if (MaxX + 100 > 2000.0)
            {
                MaxX = 2000.0f;
            }
            else
            {
                MaxX = MaxX + 100;
            }
            ZedGraph.GraphPane Pane = new ZedGraph.GraphPane(new RectangleF(0.0f, 0.0f, 2000.0f, 1500.0f), argScan.ScanNo.ToString(), "Mass", "Intensity");
            //ZedGraph.MasterPane Pane = new ZedGraph.MasterPane(argTitle,new RectangleF(0.0f, 0.0f, 2400.0f, 1800.0f) );
            Pane.XAxis.MajorTic.IsInside = false;
            Pane.XAxis.MinorTic.IsInside = false;
            Pane.Legend.IsVisible        = false;
            ZedGraph.PointPairList Peaks = new ZedGraph.PointPairList();


            double MaxIntensity = 0.0;

            /////////////////
            //Peaks
            ////////////////
            foreach (MSPoint p in argPeaks)
            {
                if (p.Intensity > MaxIntensity && p.Mass <= MaxX)
                {
                    MaxIntensity = p.Intensity;
                }
            }
            foreach (MSPoint p in argPeaks)
            {
                if (p.Mass <= MaxX)
                {
                    Peaks.Add(p.Mass, (p.Intensity / MaxIntensity) * 100.0);
                }
            }
            Pane.AddStick("Peaks", Peaks, Color.Red);

            //////////////////
            //Y1 text object
            //////////////////

            /* ZedGraph.TextObj txtY1 = new ZedGraph.TextObj("Y1", argStructure.Y1.MZ, 102);
             * txtY1.FontSpec.Size = txtY1.FontSpe.cSize*0.5f;
             * txtY1.FontSpec.Border.IsVisible = false;
             * Pane.GraphObjList.Insert(0, txtY1);*/

            /////////////////
            //Structure
            ////////////////
            GlycansDrawer GS;
            double        previousBoundary = 0;



            foreach (GlycanTreeNode t in argStructure.Root.FetchAllGlycanNode().OrderBy(o => o.IDMass).ToList())
            {
                GS = new GlycansDrawer(t.IUPACFromRoot, false);
                double glycopeptideMZ = t.IDMass;
                //double glycopeptideMZ =argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfHexNac * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.HexNAc, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfHex*GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.Hex, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfDeHex * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.DeHex, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfNeuAc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuAc, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfNeuGc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuGc, FGS.Charge);
                Image imgStructure = GlycanImage.RotateImage(GS.GetImage(), 270);

                ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 131);


                double PositionX = glycopeptideMZ;

                if (previousBoundary >= PositionX)
                {
                    PositionX = previousBoundary + 20;
                }

                if (imgStructure.Width > txtGlycanMz.Location.Width)
                {
                    previousBoundary = imgStructure.Width + PositionX;
                }
                else
                {
                    previousBoundary = (float)txtGlycanMz.Location.Width + PositionX;
                }
                ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width + 20, imgStructure.Height);

                glycan.IsScaled        = false;
                glycan.Location.AlignV = ZedGraph.AlignV.Bottom;

                txtGlycanMz.Location.X                = glycan.Location.X + (float)glycan.Image.Width / 2 - (float)txtGlycanMz.Location.Width / 2;
                txtGlycanMz.FontSpec.Size             = txtGlycanMz.FontSpec.Size * 0.3f;
                txtGlycanMz.FontSpec.Border.IsVisible = false;

                Pane.GraphObjList.Add(txtGlycanMz);
                Pane.GraphObjList.Add(glycan);

                double interval = 100000;
                int    idx      = 0;
                for (int i = 0; i < Peaks.Count; i++)
                {
                    if (Math.Abs(Peaks[i].X - glycopeptideMZ) < interval)
                    {
                        interval = Math.Abs((float)Peaks[i].X - glycopeptideMZ);
                        idx      = i;
                    }
                }
                string           mzLabelwPPM = Peaks[idx].X.ToString("0.000");// + "\n(" + Math.Abs(glycopeptideMZ - (float)Peaks[idx].X).ToString("0") + "da)";
                ZedGraph.TextObj PeakLabel   = new ZedGraph.TextObj(mzLabelwPPM, Peaks[idx].X, Peaks[idx].Y + 3.0);
                PeakLabel.FontSpec.Size             = PeakLabel.FontSpec.Size * 0.3f;
                PeakLabel.FontSpec.Border.IsVisible = false;
                PeakLabel.FontSpec.Fill.IsVisible   = false;
                Pane.GraphObjList.Add(PeakLabel);
            }
            Pane.AxisChange();

            Pane.YAxis.Scale.Max = 145;
            Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100);
            Pane.XAxis.Scale.Max = Peaks[Peaks.Count - 1].X + 100;
            ////////////
            //Glycan Structure
            ////////////
            GS = new GlycansDrawer(argStructure.IUPACString, false);
            Image imgStruc = RotateImage(GS.GetImage(), 180);

            ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, Pane.XAxis.Scale.Min + 20, 140, imgStruc.Width + 20, imgStruc.Height);
            fullStructure.IsScaled = false;
            Pane.GraphObjList.Add(fullStructure);
            ///////////////
            //Glycan M/Z
            //////////////
            double glycopeptidemz = GlycanMass.GetGlycanMasswithCharge(argStructure.Root.GlycanType, argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge);

            ZedGraph.TextObj txtGlycanMZ = new ZedGraph.TextObj("\n              Precursor:" + argScan.ParentMZ.ToString("0.000") + "(" + argScan.ParentCharge.ToString() + ")" +
                                                                "\nPeptide Sequence:" + argPeptide
                                                                , Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2, 140);
            txtGlycanMZ.FontSpec.Size             = txtGlycanMZ.FontSpec.Size * 0.3f;
            txtGlycanMZ.FontSpec.Border.IsVisible = false;
            txtGlycanMZ.FontSpec.Fill.IsVisible   = false;
            Pane.GraphObjList.Add(txtGlycanMZ);
            Image tmp = (Image)Pane.GetImage();

            return(tmp);
        }
		private void RefreshChart(UnaryFunction func,double xmin, double xmax) {
			this.Chart.GraphPane.CurveList.Clear();
			double pas=(xmax-xmin)/100.0;
			ZedGraph.PointPairList points=new ZedGraph.PointPairList();
			for(int i=0; i<100; i++) points.Add(new ZedGraph.PointPair(i*pas,func(i*pas)));
			this.Chart.GraphPane.AddCurve(this.textBox1.Text, points, Color.Red, ZedGraph.SymbolType.None);
			this.Chart.AxisChange();
			this.Chart.Refresh();
		}
        private void addPlot(DataTable plotData, Color lineColor, string Title, double NoDV,  double upBnd, double lBnd, int yearstoadd=0, bool isY2Axis = false )
        {
            int numRows = plotData.Rows.Count;
            ZedGraph.PointPairList ptList;  //collection of points for the Time Series line
            ZedGraph.LineItem tsCurve; //Line object -> Time Series line that is added to the plot
            DateTime curDate; //Date of the current item -> x-value for the current point
            double? curValue; //Value of the curren item -> y-value for the current point
            ptList = new ZedGraph.PointPairList();

            for (int i = 0; i <= numRows - 1; i++)
            {
                try
                {
                    curDate = ((DateTime)plotData.Rows[i].ItemArray[3]).AddYears(yearstoadd);//["LocalDateTime"];
                    try
                    {
                        curValue = (double)plotData.Rows[i].ItemArray[4];//["DataValue"];
                        //if value should not be plotted set it to null
                        if (curValue == NoDV || curValue < lBnd ||curValue > upBnd )
                        {
                            curValue = null;
                            ptList.Add(curDate.ToOADate(), curValue ?? double.NaN);
                        }
                        else
                            ptList.Add(curDate.ToOADate(), curValue.Value);
                    }
                    catch (Exception ex)
                    {
                        curValue = null;
                        ptList.Add(curDate.ToOADate(), curValue ?? double.NaN);
                    }

                }
                catch (Exception ex){
                }

            }
            //don't draw line if datavalues have been deleted( where gap is greater than 1 day)
            clsRemoveDataGaps.missingValues(ref ptList);

            List<object> tmplist = plotData.AsEnumerable().Select(x => x["DataValue"]).Distinct().ToList();

            //get a list of all sections of code we dontwant to plot. > 1 day of the same data values
            foreach (clsInterval inter in clsRemoveDataGaps.calcGaps(ref tmplist, ref ptList))
            {
                for (int j = inter.Start; j < inter.End; j++)
                {
                    ptList[j].Y = double.NaN;
                }
            }

            tsCurve = new ZedGraph.LineItem(Title);

            tsCurve = gPane.AddCurve(Title, ptList, lineColor, ZedGraph.SymbolType.None);
            tsCurve.Line.Width = 5;
            if(isY2Axis)
                tsCurve.IsY2Axis = true;
        }
Exemple #17
0
        public static Image GetAnnotatedImage(string argPeptide, MSScan argScan, List<MSPoint> argPeaks, GlycanStructure argStructure)
        {
            float MaxX = argStructure.Root.FetchAllGlycanNode().OrderByDescending(o => o.IDMass).ToList()[0].IDMass;
            if (MaxX + 100 > 2000.0)
            {
                MaxX = 2000.0f;
            }
            else
            {
                MaxX = MaxX + 100;
            }
            ZedGraph.GraphPane Pane = new ZedGraph.GraphPane(new RectangleF(0.0f, 0.0f, 2000.0f, 1500.0f), argScan.ScanNo.ToString(), "Mass", "Intensity");
            //ZedGraph.MasterPane Pane = new ZedGraph.MasterPane(argTitle,new RectangleF(0.0f, 0.0f, 2400.0f, 1800.0f) );
            Pane.XAxis.MajorTic.IsInside = false;
            Pane.XAxis.MinorTic.IsInside = false;
            Pane.Legend.IsVisible = false;
            ZedGraph.PointPairList Peaks = new ZedGraph.PointPairList();

            double MaxIntensity = 0.0;
            /////////////////
            //Peaks
            ////////////////
            foreach (MSPoint p in argPeaks)
            {
                if (p.Intensity > MaxIntensity && p.Mass<=MaxX)
                {
                    MaxIntensity = p.Intensity;
                }
            }
            foreach (MSPoint p in argPeaks)
            {
                if (p.Mass <= MaxX)
                {
                    Peaks.Add(p.Mass, (p.Intensity/MaxIntensity)*100.0);
                }
            }
            Pane.AddStick("Peaks", Peaks, Color.Red);

            //////////////////
            //Y1 text object
            //////////////////
            /* ZedGraph.TextObj txtY1 = new ZedGraph.TextObj("Y1", argStructure.Y1.MZ, 102);
             txtY1.FontSpec.Size = txtY1.FontSpe.cSize*0.5f;
             txtY1.FontSpec.Border.IsVisible = false;
             Pane.GraphObjList.Insert(0, txtY1);*/

            /////////////////
            //Structure
            ////////////////
            GlycansDrawer GS;
            double previousBoundary = 0;

            foreach (GlycanTreeNode t in argStructure.Root.FetchAllGlycanNode().OrderBy(o => o.IDMass).ToList())
            {

                GS = new GlycansDrawer(t.IUPACFromRoot, false);
                double glycopeptideMZ = t.IDMass;
                //double glycopeptideMZ =argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfHexNac * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.HexNAc, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfHex*GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.Hex, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfDeHex * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.DeHex, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfNeuAc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuAc, FGS.Charge);
                //glycopeptideMZ = glycopeptideMZ +
                //                 FGS.NoOfNeuGc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuGc, FGS.Charge);
                Image imgStructure = GlycanImage.RotateImage(GS.GetImage(), 270);

                ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 131);

                double PositionX = glycopeptideMZ;

                if (previousBoundary >= PositionX)
                {
                    PositionX = previousBoundary + 20;
                }

                if (imgStructure.Width > txtGlycanMz.Location.Width)
                {
                    previousBoundary = imgStructure.Width + PositionX;
                }
                else
                {
                    previousBoundary = (float)txtGlycanMz.Location.Width + PositionX;
                }
                ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width + 20, imgStructure.Height);

                glycan.IsScaled = false;
                glycan.Location.AlignV = ZedGraph.AlignV.Bottom;

                txtGlycanMz.Location.X = glycan.Location.X + (float)glycan.Image.Width / 2 - (float)txtGlycanMz.Location.Width / 2;
                txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.3f;
                txtGlycanMz.FontSpec.Border.IsVisible = false;

                Pane.GraphObjList.Add(txtGlycanMz);
                Pane.GraphObjList.Add(glycan);

                double interval = 100000;
                int idx = 0;
                for (int i = 0; i < Peaks.Count; i++)
                {
                    if (Math.Abs(Peaks[i].X - glycopeptideMZ) < interval)
                    {
                        interval = Math.Abs((float)Peaks[i].X - glycopeptideMZ);
                        idx = i;
                    }
                }
                string mzLabelwPPM = Peaks[idx].X.ToString("0.000");// + "\n(" + Math.Abs(glycopeptideMZ - (float)Peaks[idx].X).ToString("0") + "da)";
                ZedGraph.TextObj PeakLabel = new ZedGraph.TextObj(mzLabelwPPM, Peaks[idx].X, Peaks[idx].Y + 3.0);
                PeakLabel.FontSpec.Size = PeakLabel.FontSpec.Size * 0.3f;
                PeakLabel.FontSpec.Border.IsVisible = false;
                PeakLabel.FontSpec.Fill.IsVisible = false;
                Pane.GraphObjList.Add(PeakLabel);
            }
            Pane.AxisChange();

            Pane.YAxis.Scale.Max = 145;
            Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100);
            Pane.XAxis.Scale.Max = Peaks[Peaks.Count - 1].X + 100;
            ////////////
            //Glycan Structure
            ////////////
            GS = new GlycansDrawer(argStructure.IUPACString, false);
            Image imgStruc = RotateImage( GS.GetImage() ,180);
            ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, Pane.XAxis.Scale.Min + 20, 140, imgStruc.Width + 20, imgStruc.Height);
            fullStructure.IsScaled = false;
            Pane.GraphObjList.Add(fullStructure);
            ///////////////
            //Glycan M/Z
            //////////////
            double glycopeptidemz = GlycanMass.GetGlycanMasswithCharge(argStructure.Root.GlycanType,argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge);
            ZedGraph.TextObj txtGlycanMZ = new ZedGraph.TextObj("\n              Precursor:" + argScan.ParentMZ.ToString("0.000")+"(" +argScan.ParentCharge.ToString()+")"+
                                                                                                                "\nPeptide Sequence:" + argPeptide
                    , Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2, 140);
            txtGlycanMZ.FontSpec.Size = txtGlycanMZ.FontSpec.Size * 0.3f;
            txtGlycanMZ.FontSpec.Border.IsVisible = false;
            txtGlycanMZ.FontSpec.Fill.IsVisible = false;
            Pane.GraphObjList.Add(txtGlycanMZ);
            Image tmp = (Image)Pane.GetImage();

            return tmp;
        }
Exemple #18
0
        public static void FilterData(ZedGraph.PointPairList data, ref ZedGraph.PointPairList filter, double speed_max, double alfa_max, double alfa_null, int periodInMin)
        {
            if (data != null)
            {
                if (filter == null || filter.Count < 2)
                {
                    filter = new ZedGraph.PointPairList();
                    filter.Add(data[0]);
                    filter.Add(data[1]);
                }

                ZedGraph.PointPairList filterPoints = new ZedGraph.PointPairList();

                for (int i = filter.Count; i < data.Count; i++)
                {
                    filterPoints.Clear();
                    ZedGraph.PointPair notFilteredMeasure = data[i];
                    for (int j = filter.Count-1; j > 0 ; j--)
                    {
                        if (DateTime.FromOADate(notFilteredMeasure.X).Subtract(new TimeSpan(0, periodInMin, 0)) < DateTime.FromOADate(filter[j].X))
                        {
                            filterPoints.Add(filter[j]);
                        }
                        else
                            break;
                    }
                    double midX = filterPoints.Average(value => value.X);
                    double midY = filterPoints.Average(value => value.Y);
                    double alfa = 0.0;
                    double nominalSpeed = speed_max / 2.0;
                    //raschet skorosti
                    TimeSpan interval = DateTime.FromOADate(notFilteredMeasure.X) - DateTime.FromOADate(midX);
                    double speed = Math.Abs(notFilteredMeasure.Y - midY) / (0.5 * interval.TotalSeconds);
                    //alfa ot v
                    if (speed < nominalSpeed)
                    {
                        alfa = (alfa_max - alfa_null) * speed / nominalSpeed + alfa_null;
                    }
                    else if (speed >= nominalSpeed && speed < speed_max)
                    {
                        alfa = alfa_max;
                    }
                    else if (speed >= speed_max && speed < 2 * speed_max)
                    {
                        alfa = 2 - speed / speed_max;
                    }
                    else if (speed > 2 * speed_max)
                    {
                        alfa = 0;
                    }

                    //vichislenie skorrekt urovnia
                    double skor_uroven = notFilteredMeasure.Y * alfa + (1 - alfa) * midY;
                    //skor_uroven = Math.Round(skor_uroven, 2);
                    //vichislenie skorrekt urovnia

                    filter.Add(new ZedGraph.PointPair(notFilteredMeasure.X, skor_uroven));
                }
                if (filter.Count > 3)
                {
                    filter[0].Y = filter[2].Y;
                    filter[1].Y = filter[2].Y;
                }
            }
        }
 private static ZedGraph.PointPairList ReflectogramDataToPointPairList(double[] refldata)
 {
     try
     {
         ZedGraph.PointPairList result = new ZedGraph.PointPairList();
         int count = 0;
         foreach (double point in refldata)
         {
             result.Add(count, point);
             count++;
         }
         return result;
     }
     catch (Exception ex)
     {
         FileWorker.WriteEventFile(DateTime.Now, "DatabaseWorker", "ReflectogramDataToPointPairList", ex.Message);
         return null;
     }
 }
Exemple #20
0
        public void DrawsequencingGraph(GlycanStructure argStructure)
        {
            zedSequence.GraphPane.GraphObjList.Clear();
            zedSequence.GraphPane.Legend.IsVisible = false;
            List <String> tmp = argStructure.Root.GetSequencingMapList();

            if (tmp.Count == 0)
            {
                return;
            }
            float Xmin = Convert.ToSingle(tmp[0].Split('-')[0]);
            float Xmax = Convert.ToSingle(tmp[tmp.Count - 1].Split('-')[2]);

            if (Xmax == 0.0f)
            {
                Xmax = scan.MSPeaks[scan.MSPeaks.Count - 1].MonoMass;
            }
            double YMax = 0.0;

            ZedGraph.PointPairList pplPeak = new ZedGraph.PointPairList();
            for (int i = 0; i < GS.FilteredPeaks.Count; i++)
            {
                if (GS.FilteredPeaks[i].Mass >= Xmin + 10.0f && GS.FilteredPeaks[i].Mass <= Xmax + 10.0f)
                {
                    if (GS.FilteredPeaks[i].Intensity > YMax)
                    {
                        YMax = GS.FilteredPeaks[i].Intensity;
                    }
                }
            }
            for (int i = 0; i < GS.FilteredPeaks.Count; i++)
            {
                if (GS.FilteredPeaks[i].Mass >= Xmin + 10.0f && GS.FilteredPeaks[i].Mass <= Xmax + 10.0f)
                {
                    pplPeak.Add(GS.FilteredPeaks[i].Mass, GS.FilteredPeaks[i].Intensity / YMax * 100.0f);
                }
            }

            ZedGraph.GraphPane Pane = zedSequence.GraphPane;


            Pane.XAxis.MajorTic.IsInside = false;
            Pane.XAxis.MinorTic.IsInside = false;
            Pane.CurveList.Clear();
            Pane.AddStick("Peaks", pplPeak, Color.Red);
            //Pane.XAxis.Scale.Min = Xmin - 10;
            //Pane.XAxis.Scale.Max = Xmax + 10;
            Pane.Title.Text = "No. " + txtScanNo.Text + "; Y1 m/z:" + argStructure.Y1.Mass.ToString("0.000");//+ "  Structure:" + Convert.ToString(dgView.Rows[e.RowIndex].Cells[0].Value);
            Pane.AxisChange();
            double YLevel = YMax;
            double outX, outY, outY2, diff;

            Pane.ReverseTransform(new Point(100, 100), out outX, out outY);
            Pane.ReverseTransform(new Point(100, 110), out outX, out outY2);
            diff = outY - outY2;
            GlycanTreeNode GT = argStructure.Root;//GS.GlycanTrees[e.RowIndex];

            //Peak Interval
            //List<string> SeqList = new List<string>();
            //for (int i = 0; i < GT.GetSequencingMapList().Count; i++)
            //{
            //    //Split the string
            //    string[] strArray = GT.GetSequencingMapList()[i].Split('-');
            //    ZedGraph.TextObj TxtObg = new ZedGraph.TextObj();
            //    TxtObg.Text = strArray[1];
            //    double Start = Convert.ToDouble(strArray[0]);
            //    double End = Convert.ToDouble(strArray[2]);

            //    System.Drawing.Drawing2D.DashStyle LineStyle = DashStyle.Solid;
            //    if (Start == 0)
            //    {
            //        if (strArray[1] == "HexNAc")
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge);
            //        }
            //        else if (strArray[1] == "DeHex")
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge);
            //        }
            //        else if (strArray[1] == "Hex")
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge);
            //        }
            //        else if (strArray[1] == "NeuAc")
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge);
            //        }
            //        else
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge);
            //        }
            //        TxtObg.Text = TxtObg.Text + "?";
            //        LineStyle = DashStyle.Dash;
            //    }
            //    else
            //    {
            //        if (strArray[1] == "HexNAc")
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge);
            //        }
            //        else if (strArray[1] == "DeHex")
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge);
            //        }
            //        else if (strArray[1] == "Hex")
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge);
            //        }
            //        else if (strArray[1] == "NeuAc")
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge);
            //        }
            //        else
            //        {
            //            Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge);
            //        }
            //    }
            //    if (End == 0)
            //    {
            //        if (strArray[1] == "HexNAc")
            //        {
            //            End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge);
            //        }
            //        else if (strArray[1] == "DeHex")
            //        {
            //            End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge);
            //        }
            //        else if (strArray[1] == "Hex")
            //        {
            //            End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge);
            //        }
            //        else if (strArray[1] == "NeuAc")
            //        {
            //            End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge);
            //        }
            //        else
            //        {
            //            End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge);
            //        }
            //        TxtObg.Text = TxtObg.Text + "?";
            //        LineStyle = DashStyle.Dash;
            //    }
            //    //Determine the Y level
            //    int Ylevel = 0;
            //    if (SeqList.Count == 0)
            //    {
            //        SeqList.Add(Start.ToString() + "," + End.ToString() + ",0");
            //    }
            //    else
            //    {

            //        for (int j = i - 1; j >= 0; j--)
            //        {
            //            double PreStart = Convert.ToDouble(SeqList[j].Split(',')[0]);
            //            double PreEnd = Convert.ToDouble(SeqList[j].Split(',')[1]);
            //            int Prelevel = Convert.ToInt32(SeqList[j].Split(',')[2]);
            //            if ((PreStart <= Start && Start <= PreEnd))
            //            {
            //                if (Math.Abs(PreEnd - Start) <= 10.0)
            //                {
            //                    Ylevel = Prelevel;
            //                    break;
            //                }
            //                else
            //                {
            //                    Ylevel = Prelevel + 1;
            //                    break;
            //                }
            //            }
            //        }
            //        SeqList.Add(Start.ToString() + "," + End.ToString() + "," + Ylevel.ToString());
            //    }
            //    TxtObg.FontSpec.Size = TxtObg.FontSpec.Size * 0.8f;
            //    YLevel = YMax + diff * Ylevel;
            //    ZedGraph.LineObj Lne = new ZedGraph.LineObj(Start, YLevel + diff, Start, YLevel - diff); //Left V Line
            //    Pane.GraphObjList.Add(Lne);

            //    Lne = new ZedGraph.LineObj(End, YLevel + diff, End, YLevel - diff); //Right V Line
            //    Pane.GraphObjList.Add(Lne);

            //    Lne = new ZedGraph.LineObj(Start, YLevel, End, YLevel);  //Add Line
            //    Lne.Line.Style = LineStyle;
            //    Pane.GraphObjList.Add(Lne);

            //    //ZedGraph.ArrowObj arr= new ZedGraph.ArrowObj(Start, YLevel, End, YLevel);
            //    //arr.IsArrowHead = true;
            //    //arr.Line.Style = LineStyle;
            //    //Pane.GraphObjList.Add(arr);

            //    TxtObg.Location = new ZedGraph.Location(((Start + End) / 2), (double)YLevel, ZedGraph.CoordType.AxisXYScale);
            //    TxtObg.FontSpec.Border.IsVisible = false;
            //    TxtObg.Location.AlignH = ZedGraph.AlignH.Center;
            //    TxtObg.Location.AlignV = ZedGraph.AlignV.Center;
            //    Pane.GraphObjList.Insert(0, TxtObg);
            //}


            /////Annotation
            GlycansDrawer GDraw;
            double        previousX2 = 0;

            List <GlycanTreeNode> Fragements = argStructure.Root.FetchAllGlycanNode();

            Fragements.Sort(delegate(GlycanTreeNode T1, GlycanTreeNode T2) { return(Comparer <float> .Default.Compare(T1.IDMass, T2.IDMass)); });
            foreach (GlycanTreeNode FGS in Fragements)
            {
                string Exp = argStructure.GetIUPACfromParentToNodeID(FGS.NodeID);
                //Queue<string> tmpQue = new Queue<string>();
                //for (int i = 0; i < Exp.Length; i++)
                //{
                //    int NodeID = 0;
                //    if (Exp[i].StartsWith("(") || Exp[i].StartsWith(")"))
                //    {
                //        NodeID = Convert.ToInt32(Exp[i].Split(',')[0].Substring(1));
                //    }
                //    else
                //    {
                //        NodeID = Convert.ToInt32(Exp[i].Split(',')[0]);
                //    }
                //    if (NodeID > FGS.NodeID)
                //    {
                //        if (Exp[i].StartsWith("(") || Exp[i].StartsWith(")"))
                //        {
                //            tmpQue.Enqueue(Exp[i].Substring(0, 1));  //
                //        }
                //    }
                //    else
                //    {
                //        tmpQue.Enqueue(Exp[i]);
                //    }
                //}
                //string IUPAC = "";

                //do
                //{
                //    string tmp =tmpQue.Dequeue();
                //    if(tmp == "(" && tmpQue.Peek() == ")" )
                //    {
                //    }



                //}while(tmpQue.Count!=0)

                string tmpIUPAC = argStructure.GetSequqncedIUPACwNodeID(FGS.NodeID);
                GDraw = new GlycansDrawer(tmpIUPAC);
                float glycopeptideMZ = FGS.IDMass;
                if (double.IsNaN(glycopeptideMZ))
                {
                    continue;
                }
                Image imgStructure = RotateImage(GDraw.GetImage(), 270);

                double PositionX = glycopeptideMZ;
                if (previousX2 >= PositionX)
                {
                    PositionX = previousX2 + 20;
                }

                ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width * 0.3f, imgStructure.Height * 0.3f);

                glycan.IsScaled        = true;
                glycan.Location.AlignV = ZedGraph.AlignV.Bottom;
                Pane.GraphObjList.Add(glycan);

                ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 140);
                txtGlycanMz.Location.X                = Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X1 + (Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2 - Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X1) / 2;
                txtGlycanMz.FontSpec.Size             = txtGlycanMz.FontSpec.Size * 0.5f;
                txtGlycanMz.FontSpec.Border.IsVisible = false;
                Pane.GraphObjList.Add(txtGlycanMz);

                if (Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2 > Pane.GraphObjList[Pane.GraphObjList.Count - 2].Location.X2)
                {
                    previousX2 = Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2;
                }
                else
                {
                    previousX2 = Pane.GraphObjList[Pane.GraphObjList.Count - 2].Location.X2;
                }
            }
            Pane.AxisChange();

            Pane.YAxis.Scale.Max = 145;
            Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100);
            Pane.XAxis.Scale.Max = pplPeak[pplPeak.Count - 1].X + 100;


            ////////////
            //Glycan Structure on the Right Top Header
            ////////////
            GDraw = new GlycansDrawer(argStructure.IUPACString, false);
            Image imgStruc = GDraw.GetImage();

            ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, 0.01f, 0.01f, imgStruc.Width, imgStruc.Height);

            fullStructure.IsScaled = false;
            Pane.GraphObjList.Add(fullStructure);

            Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.CoordinateFrame = ZedGraph.CoordType.PaneFraction;
            zedSequence.AxisChange();
            zedSequence.Refresh();
        }