private void RecalculateColumn() { ResetTotals(); for (int row = 0; row < 10; row++) { switch (_board[_cellNumber, row]) { case '0': NumberOf0s++; break; case '1': NumberOf1s++; break; default: NumberOfGaps++; Gaps.Add(row); break; } AsText += _board[_cellNumber, row]; } }
private IEnumerable <Interval> AllIntervalsIn() { var occupiedIntervals = Combination.Select(selection => new Interval(selection.Occupation)); var coveredGapIntervals = Gaps.Select(gap => new Interval(gap.Start, gap.End)); return(occupiedIntervals.LazilyAssertForAll(interval => !interval.IsEmpty) .Concat(coveredGapIntervals)); }
private void ResetTotals() { NumberOf0s = 0; NumberOf1s = 0; NumberOfGaps = 0; AsText = string.Empty; Gaps.Clear(); }
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var mbi = value as ObservableCollection <MarketBookInformation>; if (mbi == null) { return(null); } SolidColorBrush BlueColor = Brushes.Blue; SolidColorBrush BlackColor = Brushes.Black; SolidColorBrush PurpleColor = Brushes.Purple; var a = mbi.Last().CasesAnalisys; Gaps gaps = Gaps.empty; if (a[TradeCases.BL1B2].Gap == 0 && a[TradeCases.BL2B1].Gap == 0) { gaps = Gaps.none; } if (gaps != Gaps.none && a[TradeCases.BL1B2].Gap < 2 && a[TradeCases.BL2B1].Gap < 2) { gaps = Gaps.one; } if (gaps == Gaps.empty) { gaps = Gaps.more; } switch (gaps) { case Gaps.one: return(BlueColor); case Gaps.more: return(PurpleColor); default: return(BlackColor); } }
private void AddGap(DateTime startDate, DateTime endDate) { if (HasGap(startDate, endDate)) { //Gap in data would be created. Fill with MissingValue throw new NotImplementedException("TODO: Resolve Overlapping gaps"); } Debug.WriteLine($"UNTESTED - {this.ToString()} GAP: {startDate} - {endDate}"); if (Gaps == null) { Gaps = new SortedDictionary <DateTime, DateTime>(); } if (Gaps.ContainsKey(startDate)) { var existingEnd = Gaps[startDate]; if (existingEnd < endDate) { Gaps[startDate] = endDate; } } Gaps.Add(startDate, endDate); }
private void EraseGap(DateTime startDate, DateTime endDate) { if (HasGap(startDate, endDate)) { if (Gaps.Contains(new KeyValuePair <DateTime, DateTime>(startDate, endDate))) { Gaps.Remove(startDate); } else { if (!AntiGaps.Contains(new KeyValuePair <DateTime, DateTime>(startDate, endDate))) { AntiGaps.Add(startDate, endDate); // TODO - make sense of this } else { if (AntiGaps[startDate] < endDate) { AntiGaps[startDate] = endDate; } } } } }
public void AddWrongAnswer(Gaps gap, string wrongAnswer) { switch (gap) { case Gaps.Infinitive: InfinitiveAnswer.AddWrongAnswer(wrongAnswer); break; case Gaps.Preterit: PreteritAnswer.AddWrongAnswer(wrongAnswer); break; case Gaps.PresentPerfect: PresentPerfectAnswer.AddWrongAnswer(wrongAnswer); break; case Gaps.Translation: TranslationAnswer.AddWrongAnswer(wrongAnswer); break; case Gaps.All: throw new Exception("Cannot add a wrong answer to all verb forms."); } }
public void AnsweredCorrectly(Gaps gap, string goodAnswer) { switch (gap) { case Gaps.Infinitive: InfinitiveAnswer.AnsweredCorrectly = true; break; case Gaps.Preterit: PreteritAnswer.AnsweredCorrectly = true; break; case Gaps.PresentPerfect: PresentPerfectAnswer.AnsweredCorrectly = true; break; case Gaps.Translation: TranslationAnswer.AnsweredCorrectly = true; break; case Gaps.All: throw new Exception("Cannot 'answer correctly' to all verb forms."); } }
private void RecalculateRow() { ResetTotals(); for (int column = 0; column < 10; column++) { switch (_board[column, _cellNumber]) { case '0': NumberOf0s++; break; case '1': NumberOf1s++; break; default: NumberOfGaps++; Gaps.Add(column); break; } AsText += _board[column, _cellNumber]; } }
private void UpdateGrid() { SolidColorBrush BlueColor = Brushes.Blue; SolidColorBrush BlackColor = Brushes.Black; SolidColorBrush PurpleColor = Brushes.Purple; int i = 0; List <string> keys = MarketInformationDict.Select(x => x.MarketId).ToList(); foreach (string key in keys) { string suffix; if (MarketsAreInMonitoring.ContainsKey(key) && key != "") { suffix = " *"; } else { suffix = ""; } var i1 = i; Grid[i, 0].Dispatcher.Invoke(() => Grid[i1, 0].Text = key + suffix); var m = MarketInformationDict.Where(x => x.MarketId == key).FirstOrDefault(); int idx = MarketInformationDict.IndexOf(m); var a = MarketInformationDict[idx].Mbi.Last().CasesAnalisys; Gaps gaps = Gaps.empty; if (a[TradeCases.BL1B2].Gap == 0 && a[TradeCases.BL2B1].Gap == 0) { gaps = Gaps.none; } if (gaps != Gaps.none && a[TradeCases.BL1B2].Gap < 2 && a[TradeCases.BL2B1].Gap < 2) { gaps = Gaps.one; } if (gaps == Gaps.empty) { gaps = Gaps.more; } switch (gaps) { case Gaps.one: var i2 = i; Grid[i, 1].Dispatcher.Invoke(() => Grid[i2, 1].Foreground = BlueColor); break; case Gaps.more: var i3 = i; Grid[i, 1].Dispatcher.Invoke(() => Grid[i3, 1].Foreground = PurpleColor); break; default: var i4 = i; Grid[i, 1].Dispatcher.Invoke(() => Grid[i4, 1].Foreground = BlackColor); break; } string str = MarketInformationDict[idx].TotalMatched.ToString("N0", CultureInfo.CurrentCulture); var i5 = i; Grid[i, 1].Dispatcher.Invoke(() => Grid[i5, 1].Text = str); i++; } }
/// <summary> /// Convert CompletenessReport to CSV string /// </summary> /// <param name="separator">Seperatur char for CSV items. By default is ';'</param> /// <param name="headerLine">Shows header of columns in return string?</param> /// <param name="lineTerminator">This value goes to end of every line. By default is "\\n"</param> /// <returns></returns> public string ToCSV(string separator = ";", bool headerLine = true, string lineTerminator = "\\n") { StringBuilder builder = new StringBuilder(); if (headerLine) { var headerColumns = new List <string>() { "Startdatum", "Enddatum", "MeLo", "MaLo", "Messung", "MSB", "Profil-Nr.", "Profil-Typ", "Zeitbereich in dem kein wahrer Wert vorhanden ist von", "Zeitbereich in dem kein wahrer Wert vorhanden ist bis", "Anzahl fehlende Werte", "Prozentuale Vollständigkeit", "Status" }; builder.Append(string.Join(separator, headerColumns) + lineTerminator); } var columns = new List <string> { this.ReferenceTimeFrame.Startdatum.Value.ToString("yyyy-MM-ddTHH:mm:ssZ"), this.ReferenceTimeFrame.Enddatum.Value.ToString("yyyy-MM-ddTHH:mm:ssZ") }; if (BO4E.BO.Messlokation.ValidateId(LokationsId)) { columns.Add(LokationsId); // melo columns.Add(string.Empty); // malo } else if (BO.Marktlokation.ValidateId(LokationsId)) { columns.Add(string.Empty); //melo columns.Add(LokationsId); //malo } else { // fallback only columns.Add(LokationsId); columns.Add(LokationsId); } columns.Add(imsysRegex.Match(Obiskennzahl).Success ? "IMS" : "RLM"); // messung columns.Add("MSB"); // MSB if (this.UserProperties.TryGetValue("profil", out var profil)) { columns.Add(profil.ToString()); } else { columns.Add(string.Empty); } if (this.UserProperties.TryGetValue("profilRolle", out var profilRolle)) { columns.Add(profilRolle.ToString()); } else { columns.Add(string.Empty); } if (Gaps != null && Gaps.Any()) { DateTime minGap = this.Gaps.Min(x => x.Startdatum); // OrderBy(x => x.Startdatum).First().Startdatum; DateTime maxGap = this.Gaps.Max(x => x.Enddatum); // OrderByDescending(x => x.Enddatum).First().Enddatum; columns.Add(minGap.ToString("yyyy-MM-ddTHH:mm:ssZ")); columns.Add(maxGap.ToString("yyyy-MM-ddTHH:mm:ssZ")); var gapsHours = (maxGap - minGap).TotalHours; columns.Add(((gapsHours * 4)).ToString()); } else { columns.Add(string.Empty); columns.Add(string.Empty); columns.Add(string.Empty); } if (this.Coverage.HasValue) { columns.Add((this.Coverage.Value * 100).ToString("0.####") + " %"); } else { columns.Add(string.Empty); } columns.Add("Status"); builder.Append(string.Join(separator, columns) + lineTerminator);; return(builder.ToString()); }