Exemplo n.º 1
0
        /* triple wave building codesnippet
         *
         * int length = (int)(SampleRate * BlockAlign * duration);
         * byte[] buffer = new byte[length];
         *
         * double A = frequency * 2 * Math.PI / (double)SampleRate;
         * for (int i = 0; i < length; i++)
         * {
         *  if (i > 1) buffer[i] = (byte)(2 * Math.Cos(A) * buffer[i - 1] - buffer[i - 2]);
         *  else if (i > 0) buffer[i] = (byte)(2 * Math.Cos(A) * buffer[i - 1] - (Math.Cos(A)));
         *  else buffer[i] = (byte)(2 * Math.Cos(A) * Math.Cos(A) - Math.Cos(2 * A));
         * }
         *
         * public double CalculateGoertzel(byte[] sample, double frequency, int samplerate)
         * {
         * double Skn, Skn1, Skn2;
         * Skn = Skn1 = Skn2 = 0;
         * for (int i = 0; i < sample.Length; i++)
         * {
         *  Skn2 = Skn1;
         *  Skn1 = Skn;
         *  Skn = 2 * Math.Cos(2 * Math.PI * frequency / samplerate) * Skn1 - Skn2 + sample[i];
         * }
         *
         * double WNk = Math.Exp(-2 * Math.PI * frequency / samplerate);
         *
         * return 20 * Math.Log10(Math.Abs((Skn - WNk * Skn1)));
         * }
         *
         * public int TestGoertzel(int frequency, byte[] sample, int samplerate)
         * {
         * int stepsize = frequency / 5;
         * Dictionary<int, double> res = new Dictionary<int, double>();
         * for (int i = 0; i < 10; i++)
         * {
         *  int freq = stepsize * i;
         *  res.Add(freq, CalculateGoertzel(sample, freq, samplerate));
         * }
         * }
         */
        private void BuildDiagram(ZedGraph.ZedGraphControl zg, byte[] _data)
        {
            ZedGraph.GraphPane myPane = zg.GraphPane;
            ZedGraph.LineItem  curve  = null;

            if (myPane.CurveList.Count >= 1)
            {
                curve = myPane.CurveList[0] as ZedGraph.LineItem;
                curve.Clear();
            }
            else
            {
                curve = new ZedGraph.LineItem("SPS");
            }

            // Make sure that the curvelist has at least one curve
            for (int i = 0; i < _data.Length; i++)
            {
                curve.AddPoint(i, _data[i]);
            }

            ZedGraph.IPointList list = curve.Points as ZedGraph.IPointList;

            if (myPane.CurveList.Count == 0)
            {
                myPane.AddCurve("Wave", list, Color.DimGray, ZedGraph.SymbolType.None);
            }

            zg.AxisChange();
            zg.Invalidate();
        }
Exemplo n.º 2
0
        private void Graphic_Load(object sender, EventArgs e)
        {
            MainForm mf   = new MainForm();
            Class1   math = new Class1();

            z1 = zedGraphControl1;
            z1.IsShowPointValues     = true;
            z1.GraphPane.Title       = String.Format(format: "График функции " + Data.formula.ToString());
            z1.GraphPane.XAxis.Title = "x";
            z1.GraphPane.YAxis.Title = "f(x)";

            int    n = 100;
            double a = Data.ans - n / 2 - 1;

            double[] x = new double[n];
            double[] y = new double[n];

            double[] xp = new double[1];

            double[] yp = new double[1];


            for (int i = 0; i < n; i++)
            {
                x[i] = (double)(a + i) / 10;
                y[i] = math.func(x[i]);
            }
            xp[0] = Data.ans;
            yp[0] = math.func(Data.ans);

            z1.GraphPane.AddCurve("y(x)", x, y, Color.Red, ZedGraph.SymbolType.None);
            z1.GraphPane.AddCurve("", xp, yp, Color.SkyBlue, ZedGraph.SymbolType.Circle);
            z1.AxisChange();
            z1.Invalidate();
        }
Exemplo n.º 3
0
 private void PlotChromatograms(ZedGraph.ZedGraphControl graph)
 {
     foreach (var msrun in _analysisResults.Results)
     {
         foreach (var chromatogram in msrun.Chromatograms)
         {
             var ChromLine = graph.GraphPane.AddCurve(String.Format("{0} ({1}): [{2}] - {3}", chromatogram.Peptide, chromatogram.IsotopeLabelType, chromatogram.PrecursorMZ, "PosMatch"),
                                                      chromatogram.RetentionTimes,
                                                      //chromatogram.SumOfNegativeMatch, // .SumOfPositiveMatch,
                                                      chromatogram.IonInjectionTimes,
                                                      Color.Green);
             ChromLine.Symbol.IsVisible = false;
         }
     }
     graph.GraphPane.Legend.IsVisible = true;
     graph.AxisChange();
     graph.Refresh();
 }
Exemplo n.º 4
0
        private void drawGraphic(Session selectedSession)
        {
            try
            {
                zGraph.IsShowPointValues = true;// ПОКАЗ ЗНАЧЕНИЙ ТОЧЕК
                List <double> listX = new List <double>();
                List <double> listY = new List <double>();

                foreach (KeyValuePair <int, int> keyValue in selectedSession.dictionaryTimeBlockClicks)
                {
                    listX.Add(keyValue.Key);
                    listY.Add(keyValue.Value);
                }

                zGraph.GraphPane.CurveList.Clear();
                zGraph.GraphPane.AddCurve("Успеваемость", listX.ToArray(), listY.ToArray(), Color.Red);
                zGraph.AxisChange();
                zGraph.Invalidate();  // ПЕРЕРИСОВЫВАЕТ
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Пользователи загружаются..");
            }
        }
Exemplo n.º 5
0
        public void CreateChart(ZedGraph.ZedGraphControl zgc, ref CW_PeakRegs[] IR)
        {
            EventHandler method = null;

            try
            {
                zgc.GraphPane = this.myPane;
                zgc.GraphPane.CurveList.Clear();
                zgc.GraphPane.GraphObjList.Clear();
                this.RedLimit                = (double)this.RedNumericUpDown.Value;
                this.BlueLimit               = (double)this.BlueNumericUpDown.Value;
                this.GreenLimit              = (double)this.GreenNumericUpDown.Value;
                this.myPane.Title.Text       = "CW Interference Detection";
                this.myPane.YAxis.Title.Text = "Power dB/Hz";
                this.myPane.XAxis.Title.Text = "Frequency (from L1 center)";
                this.myPane.BarSettings.Type = ZedGraph.BarType.Overlay;
                int num  = 0;
                int num2 = 0;
                int num3 = 0;
                for (int i = 0; i < 8; i++)
                {
                    if (IR[i].magD >= this.GreenLimit)
                    {
                        if (IR[i].magD >= this.RedLimit)
                        {
                            num++;
                        }
                        if ((IR[i].magD >= this.BlueLimit) && (IR[i].magD < this.RedLimit))
                        {
                            num2++;
                        }
                        if (IR[i].magD < this.BlueLimit)
                        {
                            num3++;
                        }
                    }
                }
                double[] x         = new double[num];
                double[] y         = new double[num];
                double[] numArray3 = new double[num3];
                double[] numArray4 = new double[num3];
                double[] numArray5 = new double[num2];
                double[] numArray6 = new double[num2];
                int      index     = -1;
                int      num6      = -1;
                int      num7      = -1;
                for (int j = 0; j < 8; j++)
                {
                    try
                    {
                        if (IR[j].magD >= this.GreenLimit)
                        {
                            if ((num > 0) && (IR[j].magD >= this.RedLimit))
                            {
                                index++;
                                x[index] = IR[j].freqD;
                                y[index] = IR[j].magD;
                            }
                            if (((num2 > 0) && (IR[j].magD >= this.BlueLimit)) && (IR[j].magD < this.RedLimit))
                            {
                                num6++;
                                numArray5[num6] = IR[j].freqD;
                                numArray6[num6] = IR[j].magD;
                            }
                            if ((num3 > 0) && (IR[j].magD < this.BlueLimit))
                            {
                                num7++;
                                numArray3[num7] = IR[j].freqD;
                                numArray4[num7] = IR[j].magD;
                            }
                        }
                    }
                    catch (IndexOutOfRangeException exception)
                    {
                        string str = exception.ToString();
                        string msg = "### Interference Report GUI handler error -- " + str;
                        this.comm.WriteApp(msg);
                    }
                }
                if (num > 0)
                {
                    string label = string.Format(">{0:F1}", this.RedLimit);
                    this.myPane.AddBar(label, x, y, Color.Red);
                }
                if (num2 > 0)
                {
                    string str4 = string.Format(">{0:F1}", this.BlueLimit);
                    this.myPane.AddBar(str4, numArray5, numArray6, Color.Blue);
                }
                if (num3 > 0)
                {
                    string str5 = string.Format("<{0:F1}", this.GreenLimit);
                    this.myPane.AddBar(str5, numArray3, numArray4, Color.Green);
                }
                AddlabelToBars(this.myPane, x, y);
                AddlabelToBars(this.myPane, numArray5, numArray6);
                AddlabelToBars(this.myPane, numArray3, numArray4);
                this.myPane.Chart.Fill          = new ZedGraph.Fill(Color.White, Color.LightGoldenrodYellow, 45f);
                this.myPane.YAxis.Scale.MaxAuto = false;
                this.myPane.YAxis.Scale.MinAuto = false;
                this.myPane.XAxis.Scale.MaxAuto = false;
                this.myPane.XAxis.Scale.MinAuto = false;
                this.myPane.YAxis.Scale.Max     = 100.0;
                this.myPane.YAxis.Scale.Min     = 0.0;
                this.myPane.XAxis.Scale.Min     = 1.57E+15;
                this.myPane.XAxis.Scale.Max     = 1.58E+15;
                this.myPane.BarSettings.ClusterScaleWidthAuto = false;
                this.myPane.BarSettings.ClusterScaleWidth     = 1000000000000;
                zgc.AxisChange();
                this.myPane.Fill = new ZedGraph.Fill(Color.WhiteSmoke);
                if (method == null)
                {
                    method = delegate {
                        zgc.Refresh();
                        zgc.Update();
                    };
                }
                base.Invoke(method);
                zgc.Size = new Size(base.ClientRectangle.Width - 0x19, base.ClientRectangle.Height - 90);
            }
            catch (Exception exception2)
            {
                string str6 = exception2.ToString();
                string str7 = "### Interference Report GUI handler error -- " + str6;
                this.comm.WriteApp(str7);
            }
        }
Exemplo n.º 6
0
        void OnUpdateTarget(GXDLMSObject value)
        {
            m_Target = (GXDLMSProfileGeneric)value;
            m_MyPane.GraphPane.CurveList.Clear();
            GXDLMSObject obj;
            int          index = 0;

            if (m_Target != null)
            {
                m_MyPane.GraphPane.Title.Text = m_Target.Description;
                DataTable table = ProfileGenericView.DataSource as DataTable;
                ProfileGenericView.DataSource = null;
                ProfileGenericView.Columns.Clear();
                DataTable dt = new DataTable();
                foreach (var it in m_Target.CaptureObjects)
                {
                    DataColumn dc = dt.Columns.Add(index.ToString());
                    dc.Caption = it.Key.Description;
                    int pos = ProfileGenericView.Columns.Add(index.ToString(), it.Key.Description);
                    ProfileGenericView.Columns[pos].DataPropertyName = index.ToString();
                    ++index;
                }
                foreach (object[] it in m_Target.Buffer)
                {
                    dt.LoadDataRow(it, true);
                }

                ProfileGenericView.DataSource = dt;
                if (m_Target.CaptureObjects.Count != 0 && m_Target.CaptureObjects[0].Value.AttributeIndex != 0)
                {
                    //We can show graph only tables that are date based.
                    if (m_Target.CaptureObjects[0].Key.GetUIDataType(m_Target.CaptureObjects[0].Value.AttributeIndex) == DataType.DateTime)
                    {
                        for (int col = 0; col < m_Target.CaptureObjects.Count; ++col)
                        {
                            //Do not shown Status' or Events
                            index = m_Target.CaptureObjects[col].Value.AttributeIndex;
                            if (index > 0 && ((index & 0x8) != 0 || (m_Target.CaptureObjects[col].Value.AttributeIndex & 0x10) != 0))
                            {
                                continue;
                            }
                            obj = m_Target.CaptureObjects[col].Key;
                            GXGraphItem item = GraphItems.Find(obj.LogicalName, index);
                            if (item != null && item.Enabled && GXHelpers.IsNumeric(obj.GetUIDataType(index)))
                            {
                                ZedGraph.DataSourcePointList dspl = new ZedGraph.DataSourcePointList();
                                dspl.DataSource  = m_Target.Buffer;
                                dspl.XDataMember = m_Target.CaptureObjects[0].Key.Description;
                                dspl.YDataMember = obj.Description;
                                ZedGraph.LineItem myCurve = m_MyPane.GraphPane.AddCurve(obj.Description, dspl, item.Color);
                            }
                        }
                        m_MyPane.GraphPane.XAxis.Title.Text = m_Target.CaptureObjects[0].Key.LogicalName;
                        // Tell ZedGraph to refigure the axes since the data have changed
                        m_MyPane.AxisChange();
                    }
                }
            }
            else
            {
                ProfileGenericView.DataSource = null;
            }

            //Set initial values...
            ReadFromRB.Enabled = ReadLastRB.Enabled = ReadEntryBtn.Enabled = m_Target.CaptureObjects.Count != 0;
            ReadFromRB.Checked = ReadLastRB.Checked = ReadEntryBtn.Checked = false;
            StartEntry.Value   = 0;
            EndEntry.Value     = 1;
            ReadLastTB.Value   = 0;
            StartPick.Value    = ToPick.Value = DateTime.Now;
            if (!ReadFromRB.Enabled)
            {
                return;
            }
            index = m_Target.CaptureObjects[0].Value.AttributeIndex;
            obj   = m_Target.CaptureObjects[0].Key;
            if (index != 0 &&
                obj.GetUIDataType(index) != DataType.DateTime)
            {
                ReadFromRB.Enabled      = ReadLastRB.Enabled = false;
                m_Target.AccessSelector = AccessRange.Entry;
                m_Target.From           = 0;
                m_Target.To             = 1;
            }
            else
            {
                ReadFromRB.Enabled = ReadLastRB.Enabled = true;
            }
            if (m_Target.AccessSelector == AccessRange.Entry)
            {
                StartEntry.Value     = Convert.ToInt32(m_Target.From);
                EndEntry.Value       = Convert.ToInt32(m_Target.To);
                ReadEntryBtn.Checked = true;
            }
            else if (m_Target.AccessSelector == AccessRange.Last)
            {
                TimeSpan diff = (DateTime)m_Target.To - (DateTime)m_Target.From;
                ReadLastTB.Value   = diff.Days - 1;
                ReadLastRB.Checked = true;
            }
            else
            {
                if ((DateTime)m_Target.From == DateTime.MinValue)
                {
                    StartPick.Checked = false;
                }
                else
                {
                    StartPick.Value = (DateTime)m_Target.From;
                }
                if ((DateTime)m_Target.To == DateTime.MaxValue)
                {
                    ToPick.Checked = false;
                }
                else
                {
                    ToPick.Value = (DateTime)m_Target.To;
                }
                ReadFromRB.Checked = true;
            }
        }
Exemplo n.º 7
0
 public void Draw()
 {
     SetRanColor();
     zedGraphControl1.AxisChange();
     zedGraphControl1.Invalidate();
 }