internal void OnAppended(TimelinePoint point) { lock (_updateLock) { _latestAppended = point.Position; } }
internal async Task <TimelinePoint> WriteFromApp(Event e) { var eventType = _area.Events[e.GetType()]; _queryType.ExpectObserves(eventType); _currentPosition = _currentPosition.Next(); var point = new TimelinePoint( _currentPosition, TimelinePosition.None, eventType, e.When, Event.Traits.WhenOccurs.Get(e), Event.Traits.EventId.Get(e), Event.Traits.CommandId.Get(e), Event.Traits.UserId.Get(e), null, eventType.GetRoutes(e, Event.IsScheduled(e)).ToMany(), () => e); await _observer.OnNext(point); return(point); }
private void draw_cell(Graphics g, Guid element_id, TimelinePoint tlp, Rectangle rect) { RectangleF rect1 = this.rect_for_cell(this.fTimeline.ElementIDs.IndexOf(element_id), this.fTimeline.Points.IndexOf(tlp), rect); rect1.Offset(1f, 1f); rect1.Inflate(-1f, -1f); ArrayList arrayList = new ArrayList(); foreach (TimelineItem timelineItem in tlp.Items) { if (timelineItem.ElementID == element_id) arrayList.Add((object)timelineItem.Annotation); } if (arrayList.Count != 0) { int count = arrayList.Count; bool selected = element_id == this.fSelectedElementID && tlp == this.fSelectedPoint; g.FillRectangle(selected ? SystemBrushes.Highlight : SystemBrushes.Window, rect1); for (int index = 0; index != arrayList.Count; ++index) { Annotation a = arrayList[index] as Annotation; int height = (int)((double)rect1.Height / (double)arrayList.Count); int y = (int)((double)rect1.Y + (double)(height * index)); Rectangle rect2 = new Rectangle((int)rect1.X, y, (int)rect1.Width, height); Annotations.Render(a, rect2, this.Font, g, selected, false); } } else { bool flag = element_id == this.fSelectedElementID && tlp == this.fSelectedPoint; g.FillRectangle(flag ? SystemBrushes.Highlight : SystemBrushes.ControlLight, rect1); if (!(element_id == this.fHoverElementID) || tlp != this.fHoverPoint) return; g.DrawRectangle(SystemPens.Highlight, rect1.X, rect1.Y, rect1.Width, rect1.Height); } }
protected override bool MouseDown(Event evt, WindowState state) { if (state.IsCurrentEditingASequencerTextField()) { return(false); } m_ActiveRect = TimelineWindow.instance.sequenceContentRect; if (!m_ActiveRect.Contains(evt.mousePosition)) { return(false); } if (!CanStartRectangle(evt)) { return(false); } if (enableAutoPan) { m_TimeAreaAutoPanner = new TimeAreaAutoPanner(state); } m_StartPoint = new TimelinePoint(state, evt.mousePosition); m_EndPixel = evt.mousePosition; state.AddCaptured(this); return(true); }
internal void OnNext(TimelinePoint point) { if (!_appendedEventIds.TryRemove(point.EventId, out _)) { _expectQueue.Enqueue(point); } }
public void UpdateUI() { Element selectedElement = this.TimelineGrid.SelectedElement; TimelinePoint selectedPoint = this.TimelineGrid.SelectedPoint; Annotation annotation = this.get_annotation(selectedElement, selectedPoint); this.TimelineNewAnnotation.Enabled = selectedElement != null && selectedPoint != null && annotation == null; this.TimelineDeleteAnnotation.Enabled = selectedElement != null && selectedPoint != null && annotation != null; this.TimelineAnnotationProperties.Enabled = annotation != null; this.TimelineOpenElement.Enabled = selectedElement != null; this.TimelineDeleteElement.Enabled = selectedElement != null; this.TimelineElementProperties.Enabled = selectedElement != null; this.TimelineNewPoint.Enabled = true; this.TimelineDeletePoint.Enabled = selectedPoint != null; this.TimelinePointProperties.Enabled = selectedPoint != null; this.PropertiesBtn.Enabled = true; this.PrintBtn.Enabled = true; this.PrintPreviewBtn.Enabled = true; this.MoveLeftBtn.Enabled = !this.fTimeline.Sorting && selectedPoint != null && this.fTimeline.Points.Count != 0 && selectedPoint != this.fTimeline.Points[0]; this.MoveRightBtn.Enabled = !this.fTimeline.Sorting && selectedPoint != null && this.fTimeline.Points.Count != 0 && selectedPoint != this.fTimeline.Points[this.fTimeline.Points.Count - 1]; this.MoveUpBtn.Enabled = selectedElement != null && this.fTimeline.ElementIDs.Count != 0 && selectedElement.ID != this.fTimeline.ElementIDs[0]; this.MoveDownBtn.Enabled = selectedElement != null && this.fTimeline.ElementIDs.Count != 0 && selectedElement.ID != this.fTimeline.ElementIDs[this.fTimeline.ElementIDs.Count - 1]; this.ExportBtn.Enabled = true; this.ZoomInBtn.Enabled = true; this.ZoomOutBtn.Enabled = this.fZoom != 0; }
internal async Task OnNext(TimelinePoint point) { if (_commandsById.TryGetValue(point.CommandId, out var command)) { await command.OnNext(point); } }
private void TimelineGrid_DoubleClick(object sender, EventArgs e) { Element selectedElement = this.TimelineGrid.SelectedElement; TimelinePoint selectedPoint = this.TimelineGrid.SelectedPoint; if (selectedElement != null && selectedPoint != null) { if (this.get_annotation(selectedElement, selectedPoint) != null) { this.TimelineAnnotationProperties_Click(sender, e); } else { this.TimelineAddAnnotation_Click(sender, e); } } else if (selectedElement != null && selectedPoint == null) { this.TimelineOpenElement_Click(sender, e); } else if (selectedElement == null && selectedPoint != null) { this.TimelinePointProperties_Click(sender, e); } else { this.TimelineAddPoint_Click(sender, e); } }
bool TryReadImmediateGiven(Event e, EventType type, out FlowCall.Given call) { call = null; var routes = type.GetRoutes(e).ToMany(); if (routes.Contains(_topicKey) && TryGetObservation(type, out var observation) && observation.HasGiven(Event.IsScheduled(e))) { var point = new TimelinePoint( _newPosition, _cause, type, e.When, Event.Traits.WhenOccurs.Get(e), Event.Traits.EventId.Get(e), Event.Traits.CommandId.Get(e), Event.Traits.UserId.Get(e), _topicKey, routes, () => e); call = new FlowCall.Given(point, observation); } return(call != null); }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); this.fHoverElementID = Guid.Empty; this.fHoverPoint = (TimelinePoint)null; this.Refresh(); }
public void CallGiven(Flow flow, TimelinePoint point) { foreach (var given in Given.SelectMethods(point)) { given.Call(flow, point.Event); } }
bool TryGetImmediateGiven(Event e, TimelinePosition position, out FlowCall.Given given) { given = null; if (TryGetObservation(e, out var observation)) { var routes = observation.EventType.GetRoutes(e).ToMany(); if (routes.Contains(Key)) { var point = new TimelinePoint( position, Point.Position, observation.EventType, e.When, Event.Traits.WhenOccurs.Get(e), Event.Traits.EventId.Get(e), Event.Traits.CommandId.Get(e), Event.Traits.UserId.Get(e), Key, routes, () => e); given = new FlowCall.Given(point, observation); } } return(given != null); }
public Timeline BuildTimeline(IEnumerable <Submission> submissions, int plotHeight = 600) { var solvedProblemsByContestant = new Dictionary <User, int>(); var allContestants = new HashSet <User>(); var points = new List <TimelinePoint>(); foreach (var s in submissions.Where(x => x.Result.Verdict == GenericVerdict.Accepted.ToString()).OrderBy(x => x.SubmittedAt)) { var p = new TimelinePoint { Contestant = s.Author, Problem = s.Problem, SolvedProblemCount = GetDefaulted(solvedProblemsByContestant, s.Author), Minute = MinutesFromContestBeginning(s), PenaltyTime = MinutesFromContestBeginning(s) //TODO: прикрутить нормальное определение штрафного времени }; points.Add(p); Increment(solvedProblemsByContestant, s.Author); allContestants.Add(s.Author); } GeneratePens(allContestants); var plot = GeneratePlot(points); var legend = GenerateLegend(); return(new Timeline { Plot = plot.Item1, Legend = legend, Tooltips = plot.Item2 }); }
public async Task OnNext(TimelinePoint point) { LogNext(point); await _flows.OnNext(point); await _schedule.OnNext(point); }
public async Task CallWhen(Flow flow, TimelinePoint point, IDependencySource dependencies) { var e = Get(point.EventType.Key, strict: false); if (e != null) { await e.CallWhen(flow, point, dependencies); } }
public void CallGiven(Flow flow, TimelinePoint point) { var e = Get(point.EventType.Key, strict: false); if (e != null) { e.CallGiven(flow, point); } }
// // IClientObserver // Task IClientObserver.OnNext(TimelinePoint point) { if (!_appendedEventIds.TryRemove(point.EventId, out _)) { _expectQueue.Enqueue(point); } return(Task.CompletedTask); }
public async Task CallWhen(Flow flow, TimelinePoint point, IDependencySource dependencies) { CallGiven(flow, point); foreach (var when in When.SelectMethods(point)) { await when.Call(flow, point.Event, dependencies); } }
internal async Task OnNext(TimelinePoint point) { foreach (var route in point.Routes) { if (!Ignore(point, route)) { await Enqueue(point, route); } } }
Task ITimelineObserver.OnNext(TimelinePoint point) { if (!_appendedEventIds.TryRemove(point.EventId, out var _)) { _nextPoints.Enqueue(point); _pendingExpect?.Continue(); } return(Task.CompletedTask); }
async Task Enqueue(TimelinePoint point, FlowKey route) { if (!_flowsByKey.TryGetValue(route, out var flow)) { flow = AddFlow(route); await ConnectFlow(flow); } flow.Enqueue(point); }
// // After writing new events // async Task WriteCheckpointAfterNewEvents(TimelinePoint point) { try { await WriteCheckpoint(); } catch (Exception error) { await StopAfterNewEvents(point, error); } }
async Task WriteScheduledEvent(IDisposable timer, TimelinePoint cause) { try { timer?.Dispose(); await _db.WriteScheduledEvent(cause); } catch (Exception error) { Log.Error(error, "[timeline] Failed to write scheduled event: {Cause}", cause); } }
private Annotation get_annotation(Element e, TimelinePoint tlp) { if (e != null && tlp != null) { foreach (TimelineItem timelineItem in tlp.Items) { if (timelineItem.ElementID == e.ID) { return((Annotation)timelineItem.Annotation); } } } return((Annotation)null); }
// // Points // public void Enqueue(TimelinePoint point) { lock (_queue) { if (_resumeQueue == null && _pendingDequeue != null) { _pendingDequeue.SetResult(point); _pendingDequeue = null; } else { _queue.Enqueue(point); } } }
internal Task OnNext(TimelinePoint point) { var whenOccurs = Event.GetWhenOccurs(point.Event); if (whenOccurs != null) { var timer = null as IDisposable; timer = Observable .Timer(whenOccurs.Value, TaskPoolScheduler.Default) .Take(1) .Subscribe(_ => Task.Run(() => WriteScheduledEvent(timer, point))); } return(Task.CompletedTask); }
public async Task WriteCheckpoint(Flow flow, TimelinePoint point) { var result = await _context.AppendToCheckpoint(flow); if (flow.Context.IsNew) { await TryWriteInitialMetadata(flow); } if (flow.Context.IsDone) { await TryWriteDoneMetadata(flow, result.NextExpectedVersion); } await TryWriteToClient(flow, point); }
// // Points // bool Ignore(TimelinePoint point, FlowKey route) { if (!_ignored.Contains(route)) { return(false); } else if (route.Type.Observations.Get(point.Type).CanBeFirst) { _ignored.Remove(route); return(false); } else { return(true); } }
private void ItemPointProperties_Click(object sender, EventArgs e) { TimelineItem selectedItem = this.SelectedItem; if (selectedItem == null) { return; } TimelinePoint parentPoint = this.get_parent_point(selectedItem); if (parentPoint == null || new TimelinePointDlg(parentPoint).ShowDialog() != DialogResult.OK) { return; } this.UpdateData(); this.OnTimelineModified(new TimelineEventArgs(this.get_parent(selectedItem))); }
public void RecalculateHover() { this.fHoverElementID = Guid.Empty; this.fHoverPoint = (TimelinePoint)null; if (this.fTimeline != null && this.fTimeline.Points.Count != 0 && this.fTimeline.ElementIDs.Count != 0) { Point client = this.PointToClient(Cursor.Position); int index1 = (int)((double)client.X / (double)this.fCellSize.Width) - 1; int index2 = (int)((double)client.Y / (double)this.fCellSize.Height) - 1; if (index1 >= 0 && index2 >= 0 && (index1 < this.fTimeline.Points.Count && index2 < this.fTimeline.ElementIDs.Count)) { this.fHoverElementID = this.fTimeline.ElementIDs[index2]; this.fHoverPoint = this.fTimeline.Points[index1]; } } this.Refresh(); }