コード例 #1
0
        public void UpdateSpeedPowerSavingsColl(double meanDraft)
        {
            var records = PowerRecords.Where(rec => rec.Draft == meanDraft);

            if (!records.Any())
            {
                MessageBox.Show("No data exists for given draft.");
                return;
            }

            var speeds    = records.Select(x => x.Speed).Distinct().OrderBy(y => y);
            var speedList = new ObservableCollection <PowerSavingsForSpeed>();

            foreach (var speed in speeds)
            {
                var speedRow        = new PowerSavingsForSpeed();
                var filteredRecords = records.Where(x => x.Speed == speed).OrderBy(x => x.Trim);
                foreach (var rec in filteredRecords)
                {
                    speedRow.Savings.Add(String.Format("{0:N2}", rec.PowerSavings));
                }
                speedList.Add(speedRow);
            }
            PowerSavingsForSpeedColl = speedList;
            var trims      = records.Select(x => x.Trim).Distinct().OrderBy(x => x);
            var headerlist = new ObservableCollection <string>();

            foreach (var item in trims)
            {
                headerlist.Add(String.Format("{0:N2}", item));
            }
            HeadersList = headerlist;
        }
コード例 #2
0
        public void UpdateSpeedPowerSavingsColl(double meanDraft)
        {
            var records = PowerRecords.Where(rec => rec.Draft == meanDraft);
            if (!records.Any()) {
                MessageBox.Show("No data exists for given draft.");
                return;
            }

            var speeds = records.Select(x => x.Speed).Distinct().OrderBy(y => y);
            var speedList = new ObservableCollection<PowerSavingsForSpeed>();
            foreach (var speed in speeds) {
                var speedRow = new PowerSavingsForSpeed();
                var filteredRecords = records.Where(x => x.Speed == speed).OrderBy(x => x.Trim);
                foreach (var rec in filteredRecords)
                    speedRow.Savings.Add(String.Format("{0:N2}", rec.PowerSavings));
                speedList.Add(speedRow);
            }
            PowerSavingsForSpeedColl = speedList;
            var trims = records.Select(x => x.Trim).Distinct().OrderBy(x => x);
            var headerlist = new ObservableCollection<string>();
            foreach (var item in trims) {
                headerlist.Add(String.Format("{0:N2}", item));
            }
            HeadersList = headerlist;
        }