public static IEnumerable<KeyValuePair<DateTime, double>> GetDataPoints( this IEnumerable<ITask> taskCollection, double initialLevel ) { double runningLevel = initialLevel; var dataPoints = new List<KeyValuePair<DateTime, double>>(); IList<ITask> collapsedTasks = taskCollection.Collapse(); if ( !collapsedTasks.Any() ) { return dataPoints; } DateTime lastEndTime = DateTime.MinValue; foreach ( ITask item in collapsedTasks ) { if ( item.DateRange.StartTime > lastEndTime ) { dataPoints.Add( new KeyValuePair<DateTime, double>( item.DateRange.StartTime, runningLevel ) ); } runningLevel += item.Quantity; dataPoints.Add( new KeyValuePair<DateTime, double>( item.DateRange.EndTime, runningLevel ) ); } return dataPoints; }
/// <summary> /// Проверяет два синтаксических дерева на сходство, игнорируя вертикальные "цепочки" и скобки. /// </summary> public static bool Same(this IParseTree tree1, IParseTree tree2) { tree1 = tree1.Collapse(); tree2 = tree2.Collapse(); if (tree1.ChildCount == 0 || tree2.ChildCount == 0) return tree1.GetText() == tree2.GetText(); if (tree1.ChildCount != tree2.ChildCount) return false; for (int i = 0; i < tree1.ChildCount; i++) { if (!tree1.GetChild(i).Same(tree2.GetChild(i))) return false; } return true; }
public static Task<TreeNode> AsyncAfterCollapse(this TreeNode n) { var t = new TaskCompletionSource<TreeNode>(); n.Collapse(); n.TreeView.AfterCollapse+= (sender, args) => { if (args.Node == n) { t.SetResult(n); n = null; } }; return t.Task; }
public static Wd.Range CollapseStart(this Wd.Range range) { range.Collapse(Wd.WdCollapseDirection.wdCollapseStart); return range; }
public static void TypeText(this Wd.Range range, string value) { range.Text = value; range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd); }
public static void RemoveFromEnd(this Wd.Range range, string value) { if (range.Text.EndsWith(value)) { range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd); range.MoveStart(Wd.WdUnits.wdCharacter, -value.Length); range.Delete(); } else if (range.Text.EndsWith(value + "\a") || range.Text.EndsWith(value + "\r\a")) { range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd); range.Move(Wd.WdUnits.wdCharacter, -1); range.MoveStart(Wd.WdUnits.wdCharacter, -value.Length); range.Delete(); } }
public static Wd.Range MoveToEndOfParagraph(this Wd.Range range) { range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd); range.MoveUntil("\r"); return range; }
public static void CollapseAndExtendToEnd(this Wd.Range range) { range.Collapse(Wd.WdCollapseDirection.wdCollapseEnd); range.End = range.Document.Range().End; }
///<summary>Appends a page break to a range, replacing any trailing whitespace.</summary> static void BreakPage(this Range range, bool forceOddPage) { range.Start = range.End - 1; while (range.Text.Trim().Length == 0) range.Start--; range.Start++; range.Text = ""; range.InsertBreak(forceOddPage ? WdBreakType.wdSectionBreakOddPage : WdBreakType.wdPageBreak); range.Collapse(WdCollapseDirection.wdCollapseEnd); }