Beispiel #1
0
 private void AddHeatMapToForm(LiveCharts.WinForms.CartesianChart chart, Point location)
 {
     chart.Location  = location;
     chart.AutoSize  = false;
     chart.Size      = new Size(570, 480);
     chart.BackColor = System.Drawing.Color.Transparent;
     chart.Parent    = graphsPanel;
     graphsPanel.SendToBack();
     chart.BackgroundImageLayout = ImageLayout.None;
     graphsPanel.Controls.Add(chart);
     chart.BringToFront();
 }
Beispiel #2
0
        public void AddBarChart(string header, IEnumerable <string> headers, IEnumerable <double> values)
        {
            IChartValues value = new ChartValues <double>();

            foreach (var i in values)
            {
                value.Add(i);
            }

            var ctrl = new LiveCharts.WinForms.CartesianChart
            {
                Location          = new Point(96, 46),
                Size              = new Size(200, 100),
                DataTooltip       = null,
                DisableAnimations = true,
                Tag    = CurrentPage,
                Series = new SeriesCollection
                {
                    new ColumnSeries()
                    {
                        Values = value
                    }
                },
                AxisX = new AxesCollection()
                {
                    new Axis
                    {
                        Separator = new Separator()
                        {
                            Step = 1,
                        },
                        Title  = header,
                        Labels = headers.ToArray()
                    }
                }
            };

            pnControls.Controls.Add(ctrl);

            ctrl.BackColor   = Color.Transparent;
            ctrl.MouseEnter += control_MouseEnter;
            ctrl.MouseLeave += control_MouseLeave;
            ctrl.MouseDown  += control_MouseDown;
            ctrl.MouseMove  += control_MouseMove;
            ctrl.MouseUp    += control_MouseUp;

            ctrl.BringToFront();
            SelectedControl = ctrl;
            pnControls.Invalidate();
            OnContentChanged(new EventArgs());
        }
Beispiel #3
0
        private void ShowGraph(string noOfClicked, string mesValue, string type, string date, string product, string user)
        {
            lbTitle.Text = "Ölçüm No: " + noOfClicked + " - " + date;
            lbN.Text     = mesValue + " N";
            if (type == "Eğilme")
            {
                lbNmm2.Text = (Double.Parse(mesValue) * Settings.Default.BendCoef).ToString() + " N/mm²";
            }
            else if (type == "Basınç")
            {
                lbNmm2.Text = (Double.Parse(mesValue) * Settings.Default.PresCoef).ToString() + " N/mm²";
            }
            else
            {
                lbNmm2.Text = "Ölçüm tipi belli değil";
            }
            lbType.Text = product + " " + type + " Testi (" + user + ")";

            int LocX = pnChart.Width / 50;
            int LocY = pnChart.Height / 8;

            crtVls = new ChartValues <MeasureModel>();

            #region InitChart
            cartesianChart1 = new LiveCharts.WinForms.CartesianChart
            {
                Anchor = AnchorStyles.Top | AnchorStyles.Bottom
                         | AnchorStyles.Left
                         | AnchorStyles.Right,
                Location        = new Point(LocX, LocY),
                Margin          = new Padding(30),
                Name            = "cartesianChart1",
                Size            = new Size(pnChart.Width - (LocX * 2), pnChart.Height - LocY * 3),
                TabIndex        = 57,
                Text            = "cartesianChart1",
                BackColor       = System.Drawing.Color.FromArgb(0, 86, 168),
                AnimationsSpeed = TimeSpan.FromMilliseconds(250),
                Hoverable       = false,
                Series          = new SeriesCollection
                {
                    new LineSeries
                    {
                        Values            = crtVls,
                        PointGeometrySize = 4,
                        StrokeThickness   = 2,

                        Fill = new LinearGradientBrush(
                            System.Windows.Media.Color.FromArgb(0xcc, 0xff, 0xff, 0xff),
                            System.Windows.Media.Color.FromArgb(0x64, 0xff, 0xff, 0xff),
                            90),
                        Stroke = new SolidColorBrush(
                            System.Windows.Media.Color.FromArgb(0xff, 0xff, 0xff, 0xff))
                    }
                }
            };

            cartesianChart1.AxisX.Add(new Axis
            {
                LabelFormatter = value => new TimeSpan((long)value)
                                 .TotalMilliseconds.ToString() + "ms",
                Separator = new Separator
                {
                    Step = TimeSpan.FromMilliseconds(500).Ticks
                },
                MinValue = 0
            });
            cartesianChart1.AxisY.Add(new Axis
            {
                MinValue = 0
            });
            #endregion

            pnChart.Controls.Add(cartesianChart1);
            cartesianChart1.BringToFront();
            pnChart.Enabled = true;
            pnChart.Visible = true;

            try
            {
                var models = new MeasureModel[0];

                #region SQLite Reading
                connection.Open();
                string query = "SELECT * FROM graf WHERE \"No\" IS " + noOfClicked;
                using (SQLiteCommand command = new SQLiteCommand(query, connection))
                {
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Array.Resize(ref models, models.Length + 1);
                            models[models.Length - 1] = new MeasureModel
                            {
                                Time  = TimeSpan.FromTicks(reader.GetInt64(2)),
                                Value = reader.GetFloat(1)
                            };
                        }
                        reader.Close();
                    }
                }
                connection.Close();
                #endregion


                crtVls.AddRange(models);
                cartesianChart1.AxisX[0].MaxValue = models.Last().Time.Ticks
                                                    + TimeSpan.FromMilliseconds(100).Ticks;
                models = null;
            }
            catch (Exception ex)
            {
                connection.Close();
                MessageBox.Show(ex.Message);
            }
        }