/// <summary> /// 範囲にラベルを設定します。 /// </summary> /// <param title="label">設定されるラベル</param> /// <param title="keepWrittenLabel">すでに設定されたラベルを保持するか</param> public void SetLabel(ICSLabel label, bool keepWrittenLabel) { int beforeEndIndex = GetLabelIndexAt(label.EndTime); int beforeBeginIndex = GetLabelIndexAt(label.BeginTime); string endLabel = ""; if (beforeEndIndex != -1) { endLabel = _labelBorders.Values[beforeEndIndex]; } if (keepWrittenLabel) { var innerEmpty = _labelBorders.Skip(beforeBeginIndex + 1).Take(beforeEndIndex - beforeBeginIndex).Where(p => p.Value == null || p.Value == "").Select(p => p.Key).ToList(); foreach (var empty in innerEmpty) { if (empty < label.EndTime) { _labelBorders[empty] = label.LabelText; } } if (endLabel == "" || endLabel == null) { _labelBorders[label.EndTime] = endLabel; } if (beforeBeginIndex == -1 || _labelBorders.Values[beforeBeginIndex] == "" || _labelBorders.Values[beforeBeginIndex] == null) { _labelBorders[label.BeginTime] = label.LabelText; } } else { if (beforeEndIndex != beforeBeginIndex) { var removes = _labelBorders.Keys.Skip(beforeBeginIndex + 1).Take(beforeEndIndex - beforeBeginIndex).ToList(); foreach (var rm in removes) { _labelBorders.Remove(rm); } } _labelBorders[label.BeginTime] = label.LabelText; _labelBorders[label.EndTime] = endLabel; } }
/// <summary> /// 範囲にラベルを設定します。 /// </summary> /// <param title="label">設定されるラベル</param> public void SetLabel(ICSLabel label) { this.SetLabel(label, false); }