Esempio n. 1
0
        private void UpdateVisibleColumns(SummaryColumnFlags visibleColumns)
        {
            lvFieldList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            lvFieldList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            lvFieldList.Columns[(int)FieldListColumns.Value].Width =
                (visibleColumns.HasFlag(SummaryColumnFlags.Value) ? DefaultSummaryColumnWidth : 0);
            lvFieldList.Columns[(int)FieldListColumns.LapMin].Width =
                (visibleColumns.HasFlag(SummaryColumnFlags.LapMin) ? DefaultSummaryColumnWidth : 0);
            lvFieldList.Columns[(int)FieldListColumns.LapMax].Width =
                (visibleColumns.HasFlag(SummaryColumnFlags.LapMax) ? DefaultSummaryColumnWidth : 0);
            lvFieldList.Columns[(int)FieldListColumns.LapAvg].Width =
                (visibleColumns.HasFlag(SummaryColumnFlags.LapAvg) ? DefaultSummaryColumnWidth : 0);

            int totalVisibleColumnWidth = 0;

            foreach (ColumnHeader column in lvFieldList.Columns)
            {
                totalVisibleColumnWidth += column.Width;
            }
            Console.WriteLine($"ListView width: {lvFieldList.Width} totalVisibleColumnWidth: {totalVisibleColumnWidth}");

            int scrollBarMargin = 5; // to get rid of scroll bar at bottom of ListView

            lvFieldList.Size = new Size(totalVisibleColumnWidth + scrollBarMargin, lvFieldList.Height);
            splitContainer1.SplitterDistance = totalVisibleColumnWidth + scrollBarMargin;
        }
        /// <summary>
        /// Sets the individual listView column widths based on the visibleColumns settings.
        /// </summary>
        /// <param name="visibleColumns">SummaryColumnFlags</param>
        private void UpdateVisibleColumns(SummaryColumnFlags visibleColumns)
        {
            Array fieldColumns = Enum.GetValues(typeof(FieldListColumns));

            // skip first two (Field Name, Value) and last (Unit). These columns are always displayed.
            for (int i = 1; i < fieldColumns.GetLength(0) - 1; i++)
            {
                FieldListColumns   fieldColumnsEnumValue  = (FieldListColumns)fieldColumns.GetValue(i);
                SummaryColumnFlags summaryColumnFlagValue = fieldColumnsEnumValue.GetSummaryFieldColumn();

                lvFieldList.Columns[(int)fieldColumnsEnumValue].Width =
                    (visibleColumns.HasFlag(summaryColumnFlagValue) ?
                     DefaultSummaryColumnWidth :
                     0);
            }
        }
        private FrameFieldValues GetFrameFieldValues(SummaryColumnFlags flags, int lapIdx, int frameIdx, int fieldIdx, float?minWarning, float?maxWarning)
        {
            IEnumerable <TelemetryValues> lapFieldValues = TelemetryData.GetLapFieldValues(lapIdx, fieldIdx).ToList();

            FrameFieldValues ffv;

            if (lapFieldValues.Count() == 0)
            {
                ffv = new FrameFieldValues(false);
            }
            else
            {
                ffv = new FrameFieldValues(true);

                ffv.Value = lapFieldValues.FirstOrDefault(v => v.FrameIdx == frameIdx).Value.GetValueOrDefault();

                IEnumerable <float> lapValues = lapFieldValues.Select(v => v.Value.GetValueOrDefault());

                var lapMin = lapValues.Min();
                var lapMax = lapValues.Max();

                if (flags.HasFlag(SummaryColumnFlags.LapMin))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.LapMin, lapMin);
                }

                if (flags.HasFlag(SummaryColumnFlags.LapMax))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.LapMax, lapMax);
                }

                if (flags.HasFlag(SummaryColumnFlags.LapDelta))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.LapDelta, lapMax - lapMin);
                }

                if (flags.HasFlag(SummaryColumnFlags.LapMode))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.LapMode, lapValues.Mode());
                }

                if (flags.HasFlag(SummaryColumnFlags.LapAvg))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.LapAvg, lapValues.Average());
                }

                if (flags.HasFlag(SummaryColumnFlags.LapStdDev))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.LapStdDev, lapValues.StandardDeviation());
                }

                IEnumerable <TelemetryValues> sessionFieldValues = TelemetryData.GetSessionFieldValues(fieldIdx);

                IEnumerable <float> sessionValues = sessionFieldValues.Select(v => v.Value.GetValueOrDefault());

                var sessionMin = sessionValues.Min();
                var sessionMax = sessionValues.Max();

                if (flags.HasFlag(SummaryColumnFlags.SessionMin))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.SessionMin, sessionMin);
                }

                if (flags.HasFlag(SummaryColumnFlags.SessionMax))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.SessionMax, sessionMax);
                }

                if (flags.HasFlag(SummaryColumnFlags.SessionDelta))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.SessionDelta, sessionMax - sessionMin);
                }

                if (flags.HasFlag(SummaryColumnFlags.SessionMode))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.SessionMode, sessionValues.Mode());
                }

                if (flags.HasFlag(SummaryColumnFlags.SessionAvg))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.SessionAvg, sessionValues.Average());
                }

                if (flags.HasFlag(SummaryColumnFlags.SessionStdDev))
                {
                    ffv.SummaryValues.Add(SummaryColumnFlags.SessionStdDev, sessionValues.StandardDeviation());
                }

                if (maxWarning.HasValue)
                {
                    ffv.MaxWarning = ffv.Value >= maxWarning.Value;
                }

                if (minWarning.HasValue)
                {
                    ffv.MinWarning = ffv.Value <= minWarning.Value;
                }
            }

            return(ffv);
        }