Exemple #1
0
        void flp_MouseUp(object sender, EventArgs e)
        {
            SessionVariable v = ((Control)sender).Tag as SessionVariable;

            if (v != null)
            {
                bool          newVar        = false;
                GraphVariable graphVariable = this.DisplayOptions.GraphVariables.FirstOrDefault(gv => gv.Variable == v.Name);
                if (graphVariable == null)
                {
                    newVar        = true;
                    graphVariable = new GraphVariable()
                    {
                        Variable = v.Name,
                        Name     = v.Alias
                    };
                }
                GraphVariableForm gvf = new GraphVariableForm(graphVariable);
                if (DialogResult.OK == gvf.ShowDialog())
                {
                    Control panel = (Control)sender;
                    if (sender is Label)
                    {
                        panel = ((Control)sender).Parent;
                    }
                    this.AddGraphVariable(graphVariable, panel, newVar);
                }

                /*
                 * GaugeWindow gw = new GaugeWindow(session, v);
                 * session.LogLineRead += new ME7LoggerSession.LogLineReadDel(gw.Refresh);
                 * gw.Show(this);
                 */
            }
        }
Exemple #2
0
        void flp_MouseUp(object sender, EventArgs e)
        {
            SessionVariable v = ((Control)sender).Tag as SessionVariable;

            if (v != null)
            {
                bool          newVar        = false;
                GraphVariable graphVariable = this.DisplayOptions.GraphVariables.FirstOrDefault(gv => gv.Variable == v.Name);
                if (graphVariable == null)
                {
                    newVar        = true;
                    graphVariable = new GraphVariable()
                    {
                        Variable = v.Name,
                        Name     = v.Alias
                    };
                }
                GraphVariableForm gvf = new GraphVariableForm(graphVariable);
                if (DialogResult.OK == gvf.ShowDialog())
                {
                    Control panel = (Control)sender;
                    if (sender is Label)
                    {
                        panel = ((Control)sender).Parent;
                    }
                    this.AddGraphVariable(graphVariable, panel, newVar);
                }
            }
        }
 private void btnAddGraphVariable_Click(object sender, EventArgs e)
 {
     this.GraphVariableEditMode = EditModes.Add;
     this.SelectedGraphVariable = new GraphVariable();
     LoadSelectedGraphVariable();
     this.SwitchUI();
 }
Exemple #4
0
 public GraphVariableForm(GraphVariable variable)
 {
     InitializeComponent();
     this.cmbGraphVariableStyle.DataSource = Enum.GetValues(typeof(ChartDashStyle));
     this.GraphVariable = variable;
     this.LoadVariable();
     this.SwitchUI();
 }
 private void ReadGraphVariables(XElement ele)
 {
     foreach (XElement e in ele.Elements())
     {
         GraphVariable v = new GraphVariable();
         v.Read(e);
         GraphVariables.Add(v);
     }
 }
        public GraphVariable Clone()
        {
            GraphVariable clone = new GraphVariable();

            clone.Active        = this.Active;
            clone.Variable      = this.Variable;
            clone.Name          = this.Name;
            clone.Min           = this.Min;
            clone.Max           = this.Max;
            clone.LineColor     = this.LineColor;
            clone.LineThickness = this.LineThickness;
            clone.LineStyle     = this.LineStyle;
            return(clone);
        }
Exemple #7
0
        void AddGraphVariable(GraphVariable graphVariable, Control panel, bool isNew)
        {
            if (isNew)
            {
                this.DisplayOptions.GraphVariables.Add(graphVariable);
            }
            this.BuildChart();

            Font f = panel.Controls[0].Font;

            f = new Font(f, graphVariable.Active ? FontStyle.Bold : FontStyle.Regular);
            foreach (Control c in panel.Controls)
            {
                if (c is Label)
                {
                    c.Font = f;
                }
                else if (c is CheckBox)
                {
                    ((CheckBox)c).Checked = graphVariable.Active;
                }
            }
        }
Exemple #8
0
        void graphed_Click(object sender, EventArgs e)
        {
            CheckBox        c = (CheckBox)sender;
            SessionVariable v = c.Tag as SessionVariable;

            if (v != null)
            {
                bool          newVar        = false;
                GraphVariable graphVariable = this.DisplayOptions.GraphVariables.FirstOrDefault(gv => gv.Variable == v.Name);
                if (graphVariable == null)
                {
                    newVar        = true;
                    graphVariable = new GraphVariable()
                    {
                        Variable = v.Name,
                        Name     = v.Alias
                    };
                }
                graphVariable.Active = c.Checked;

                this.AddGraphVariable(graphVariable, c.Parent, newVar);
            }
        }
 private void lstGraphVariables_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.SelectedGraphVariable = (GraphVariable)lstGraphVariables.SelectedItem;
     this.LoadSelectedGraphVariable();
 }
Exemple #10
0
        void HighlightPoints(bool highlight = true)
        {
            if (highlight && (SeriesChartType)cmbChartType.SelectedItem == SeriesChartType.FastLine)
            {
                SetChartType(SeriesChartType.Line);
            }
            else if (!highlight)
            {
                SetChartType((SeriesChartType)cmbChartType.SelectedItem);
            }

            foreach (Series s in chart1.Series)
            {
                double    size       = chart1.ChartAreas["Default"].AxisX.ScaleView.Size;
                double    pos        = chart1.ChartAreas["Default"].AxisX.ScaleView.Position;
                bool      zoomed     = chart1.ChartAreas["Default"].AxisX.ScaleView.IsZoomed;
                DataPoint lowest     = null;
                DataPoint highest    = null;
                int       currentPos = 0;
                foreach (DataPoint p in s.Points)
                {
                    p.Label = null;

                    if (!zoomed || (currentPos >= pos && currentPos <= pos + size))
                    {
                        if (p.YValues[0] > 0 && (lowest == null || p.YValues[0] <= lowest.YValues[0]))
                        {
                            lowest = p;
                        }

                        if (highest == null || p.YValues[0] >= highest.YValues[0])
                        {
                            highest = p;
                        }
                    }
                    currentPos++;
                }

                if (highlight)
                {
                    if (lowest != null)
                    {
                        Variable v = lowest.Tag as Variable;
                        if (v != null)
                        {
                            GraphVariable graphVar = this.DisplayOptions.GraphVariables.FirstOrDefault(gv => gv.Variable.Equals(v.SessionVariable.Name, StringComparison.InvariantCultureIgnoreCase));
                            lowest.Label          = string.Format("{0}: {1} {2}", graphVar != null ? graphVar.Name : v.SessionVariable.Name, v.Value, v.SessionVariable.Unit);
                            lowest.LabelForeColor = Color.White;
                        }
                    }

                    if (highest != null)
                    {
                        Variable v = highest.Tag as Variable;
                        if (v != null)
                        {
                            GraphVariable graphVar = this.DisplayOptions.GraphVariables.FirstOrDefault(gv => gv.Variable.Equals(v.SessionVariable.Name, StringComparison.InvariantCultureIgnoreCase));
                            highest.Label          = string.Format("{0}: {1} {2}", graphVar != null ? graphVar.Name : v.SessionVariable.Name, v.Value, v.SessionVariable.Unit);
                            highest.LabelForeColor = Color.White;
                        }
                    }
                }
            }
        }
Exemple #11
0
        void AddAxis()
        {
            this.ClearAxis();

            int i = 0;

            foreach (var group in this.DisplayOptions.GraphVariables.Where(v => v.Active && v.ShowAxis && v.Min < v.Max).GroupBy(v => new { v.Min, v.Max }))
            {
                GraphVariable firstVar = group.First();
                Guid          g        = Guid.NewGuid();
                ChartArea     ca       = new ChartArea(g.ToString());
                ca.AxisY.Minimum = (double)firstVar.Min;
                ca.AxisY.Maximum = (double)firstVar.Max;
                ca.Tag           = firstVar;

                ca.BackColor = Color.Transparent;
                foreach (Axis a in ca.Axes)
                {
                    a.LineWidth = 3;
                    a.LineColor = firstVar.LineColor;
                }

                ca.AxisY.LabelAutoFitStyle           = LabelAutoFitStyles.DecreaseFont;
                ca.InnerPlotPosition.Height          = 95;
                ca.InnerPlotPosition.Width           = 100;
                ca.InnerPlotPosition.X               = 100;
                ca.InnerPlotPosition.Y               = 0;
                ca.AxisY.LabelStyle.TruncatedLabels  = false;
                ca.AxisY.LabelStyle.ForeColor        = Color.White;
                ca.AxisY.MajorTickMark.TickMarkStyle = TickMarkStyle.AcrossAxis;
                ca.AxisY.MajorTickMark.LineWidth     = 2;
                ca.AxisY.MajorTickMark.LineColor     = firstVar.LineColor;
                ca.AxisX.MajorTickMark.Enabled       = false;

                ca.Position.X      = (i++ *4);
                ca.Position.Y      = 2;
                ca.Position.Width  = 4f;
                ca.Position.Height = 97;

                Series s = new Series();
                s.IsVisibleInLegend = false;
                s.ChartArea         = g.ToString();
                s.Points.Add();

                chart1.Series.Add(s);
                chart1.ChartAreas.Add(ca);

                axis.Add(ca);
            }

            ChartArea _default = chart1.ChartAreas["Default"];

            _default.InnerPlotPosition.Height = 95;
            _default.InnerPlotPosition.Width  = 96f;
            _default.InnerPlotPosition.X      = 2;
            _default.InnerPlotPosition.Y      = 0;

            _default.Position.X      = (axis.Count * 4) - (axis.Count == 0 ? 0 : 2 - (axis.Count * .10f));
            _default.Position.Y      = 2;
            _default.Position.Width  = 100 - (axis.Count * 4);
            _default.Position.Height = 97;
        }
Exemple #12
0
        private void Init()
        {
            System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;
            doInit = false;

            BeginControlUpdate(this);

            flpVariables.Controls.Clear();

            dataGridView1.Rows.Clear();
            dataGridView1.Columns.Clear();
            dataGridView1.Columns.Add("Timestamp", "TIME");

            IEnumerable <SessionVariable> vars = session.Variables.Values;

            if (DisplayOptions.DisplayOrder == DisplayOptions.DisplayOrders.AlphaByAlias)
            {
                vars = session.Variables.Values.OrderBy(v => v.Alias);
            }
            else if (DisplayOptions.DisplayOrder == DisplayOptions.DisplayOrders.AlphaByName)
            {
                vars = session.Variables.Values.OrderBy(v => v.Name);
            }

            foreach (SessionVariable v in vars)
            {
                GraphVariable var = this.DisplayOptions.GraphVariables.FirstOrDefault(gv => gv.Variable == v.Name && gv.Active);
                dataGridView1.Columns.Add(v.Name, string.IsNullOrEmpty(v.Alias) ? v.Name : v.Alias);

                FlowLayoutPanel flp = new FlowLayoutPanel();
                flp.Name          = v.Name;
                flp.FlowDirection = FlowDirection.LeftToRight;
                flp.WrapContents  = false;
                flp.AutoSize      = true;
                flp.Margin        = new Padding(0, 1, 0, 1);
                flp.Tag           = v;
                flp.MouseUp      += flp_MouseUp;


                Label name = new Label();
                Font  f    = new Font(name.Font.FontFamily, name.Font.Size + 1, var != null ? FontStyle.Bold : FontStyle.Regular);

                name.Name        = v.Name;
                name.Height      = 20;
                name.Text        = v.ToString();
                name.BorderStyle = BorderStyle.Fixed3D;
                name.TextAlign   = ContentAlignment.MiddleLeft;
                name.Font        = f;
                name.RightToLeft = System.Windows.Forms.RightToLeft.No;
                name.Tag         = v;
                name.MouseUp    += flp_MouseUp;
                name.ForeColor   = var != null ? var.LineColor : Color.White;
                name.BackColor   = Color.FromArgb(64, 64, 64);

                Label value = new Label();
                value.Name        = v.Name;
                value.TextAlign   = ContentAlignment.MiddleLeft;
                value.Height      = 20;
                value.BorderStyle = BorderStyle.Fixed3D;
                value.Font        = f;
                value.RightToLeft = System.Windows.Forms.RightToLeft.No;
                value.Tag         = v;
                value.MouseUp    += flp_MouseUp;
                value.ForeColor   = var != null ? var.LineColor : Color.White;
                value.BackColor   = Color.FromArgb(64, 64, 64);

                string tipText = v.ToString();
                if (var != null)
                {
                    tipText += $"\r\nMin: {var.Min}{v.Unit} - Max: {var.Max}{v.Unit}";
                }
                ToolTip tt = new ToolTip();
                tt.SetToolTip(flp, tipText);
                tt.SetToolTip(name, tipText);
                tt.SetToolTip(value, tipText);

                flp.Controls.Add(value);
                flp.Controls.Add(name);
                flpVariables.Controls.Add(flp);
            }
            flpVariables_Resize(null, null);

            if (this.session.SessionType == ME7LoggerSession.SessionTypes.LogFile)
            {
                this.scrollbar.Minimum = 0;
                this.scrollbar.Maximum = (int)this.session.Log.TotalFileSize;
                this.scrollbar.Value   = 0;
            }

            EndControlUpdate(this);

            this.BuildChart();
        }