public void CanRedoWithoutMarkers() { var currentMark = new TimeMarker(10); var markers = new List <TimeMarker>(); var history = new Mock <ITimeline>(); { history.Setup(h => h.CanRollForward) .Returns(true); history.Setup(h => h.MarkersInTheFuture()) .Returns(markers); history.Setup(h => h.Current) .Returns(currentMark); } var project = new Mock <IProject>(); { project.Setup(p => p.History) .Returns(history.Object); } var projectFacade = new ProjectFacade(project.Object); var projectLink = new Mock <ILinkToProjects>(); { projectLink.Setup(p => p.ActiveProject()) .Returns(projectFacade); projectLink.Setup(p => p.HasActiveProject()) .Returns(true); } Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new RedoCommand(projectLink.Object, timerFunc); Assert.IsFalse(command.CanExecute(null)); }
public void OnSetTimeMarkerCommandExecuted(object parameter) { Appointment appointment = this.SelectedAppointment as Appointment; TimeMarker newTimeMarker = parameter as TimeMarker; IExceptionOccurrence exceptionToEdit = null; if (!(this.SelectedAppointment is Appointment)) { appointment = (this.SelectedAppointment as Occurrence).Master as Appointment; if (appointment.RecurrenceRule != null) { exceptionToEdit = appointment.RecurrenceRule.Exceptions.SingleOrDefault(e => (e.Appointment as IOccurrence) == ((Telerik.Windows.Controls.ScheduleView.Occurrence)(this.SelectedAppointment)).Appointment); if (exceptionToEdit != null) { appointment.RecurrenceRule.Exceptions.Remove(exceptionToEdit); (exceptionToEdit.Appointment as Appointment).TimeMarker = newTimeMarker; appointment.RecurrenceRule.Exceptions.Add(exceptionToEdit); } } } Appointment appointmentToEdit = (from app in this.Appointments where app.Equals(appointment) select app).FirstOrDefault(); if (exceptionToEdit == null) { appointmentToEdit.TimeMarker = newTimeMarker; } var index = this.Appointments.IndexOf(appointmentToEdit); this.Appointments.Remove(appointmentToEdit); this.Appointments.Insert(index, appointmentToEdit); }
public void RunWithMarkHistoryVertex() { var marker = new TimeMarker(10); var timeline = new Mock <ITimeline>(); { timeline.Setup(t => t.Mark()) .Returns(marker); } TimeMarker storedMarker = null; var schedule = BuildThreeVertexSchedule(new MarkHistoryVertex(3)); using (var info = new ScheduleExecutionInfo(new CurrentThreadTaskScheduler())) { using (var executor = new ScheduleExecutor( new List <IProcesExecutableScheduleVertices> { new StartVertexProcessor(), new EndVertexProcessor(), new MarkHistoryVertexProcessor(timeline.Object, m => storedMarker = m), }, ScheduleConditionStorage.CreateInstanceWithoutTimeline(), schedule, new ScheduleId(), info)) { var state = ScheduleExecutionState.None; executor.OnFinish += (s, e) => { state = e.State; }; executor.Start(); Assert.AreEqual(ScheduleExecutionState.Completed, state); Assert.AreEqual(marker, storedMarker); } } }
/// <summary> /// Adds a <see cref="TimeMarker"/> to the storage. /// </summary> /// <param name="marker">The time marker.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="marker"/> is <see langword="null" />. /// </exception> public void Add(TimeMarker marker) { { Lokad.Enforce.Argument(() => marker); } m_Markers.Add(marker); }
/// <summary> /// Initializes a new instance of the <see cref="TimelineMarkEventArgs"/> class. /// </summary> /// <param name="marker">The new marker.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="marker"/> is <see langword="null" />. /// </exception> public TimelineMarkEventArgs(TimeMarker marker) { { Lokad.Enforce.Argument(() => marker); } m_Marker = marker; }
public void Process() { var marker = new TimeMarker(10); var timeline = new Mock<ITimeline>(); { timeline.Setup(t => t.Mark()) .Returns(marker); } TimeMarker storedMarker = null; var processor = new MarkHistoryVertexProcessor(timeline.Object, m => storedMarker = m); using (var info = new ScheduleExecutionInfo()) { var state = processor.Process(new MarkHistoryVertex(1), info); Assert.AreEqual(ScheduleExecutionState.Executing, state); Assert.AreEqual(marker, storedMarker); } }
private void valueRepresenter_MouseMove_Measure(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { ValueRepresenter repr = sender as ValueRepresenter; Point pt = e.GetPosition(repr); Point ptr = e.GetPosition(ListViewMain); double PositionX = pt.X; marker2 = repr.GetNearestMarker(PositionX); if (marker2 == null) { marker2 = new TimeMarker(core.ScaleManager.GetTime(PositionX), PositionX); } LineMarker2.X1 = LineMarker2.X2 = ptr.X - PositionX + marker2.Offset; LineMarker2.Y1 = LineCursor.Y1; LineMarker2.Y2 = LineCursor.Y2; } }
public void Process() { var marker = new TimeMarker(10); var timeline = new Mock <ITimeline>(); { timeline.Setup(t => t.Mark()) .Returns(marker); } TimeMarker storedMarker = null; var processor = new MarkHistoryVertexProcessor(timeline.Object, m => storedMarker = m); using (var info = new ScheduleExecutionInfo()) { var state = processor.Process(new MarkHistoryVertex(1), info); Assert.AreEqual(ScheduleExecutionState.Executing, state); Assert.AreEqual(marker, storedMarker); } }
public void Undo() { var currentMark = new TimeMarker(10); var markers = new List <TimeMarker> { currentMark, new TimeMarker(1), }; var history = new Mock <ITimeline>(); { history.Setup(h => h.CanRollBack) .Returns(true); history.Setup(h => h.MarkersInThePast()) .Returns(markers); history.Setup(h => h.Current) .Returns(currentMark); history.Setup(h => h.RollBackTo(It.IsAny <TimeMarker>(), It.IsAny <TimelineTraveller>())) .Verifiable(); } var project = new Mock <IProject>(); { project.Setup(p => p.History) .Returns(history.Object); } var projectFacade = new ProjectFacade(project.Object); var projectLink = new Mock <ILinkToProjects>(); { projectLink.Setup(p => p.ActiveProject()) .Returns(projectFacade); projectLink.Setup(p => p.HasActiveProject()) .Returns(true); } Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new UndoCommand(projectLink.Object, timerFunc); command.Execute(null); history.Verify(h => h.RollBackTo(It.IsAny <TimeMarker>(), It.IsAny <TimelineTraveller>()), Times.Once()); }
private void valueRepresenter_MouseLeftButtonDown_Measure(object sender, MouseButtonEventArgs e) { LineCursor.Visibility = System.Windows.Visibility.Collapsed; LineMarker1.Visibility = System.Windows.Visibility.Visible; LineMarker2.Visibility = System.Windows.Visibility.Visible; ValueRepresenter repr = sender as ValueRepresenter; repr1 = repr; Point pt = e.GetPosition(repr); Point ptr = e.GetPosition(ListViewMain); double PositionX = pt.X; marker1 = repr.GetNearestMarker(PositionX); if (marker1 == null) { marker1 = new TimeMarker(core.ScaleManager.GetTime(PositionX), PositionX); } LineMarker1.X1 = LineMarker1.X2 = ptr.X - PositionX + marker1.Offset; LineMarker1.Y1 = LineCursor.Y1; LineMarker1.Y2 = LineCursor.Y2; }
public void CanUndoWithMarkers() { var currentMark = new TimeMarker(10); var markers = new List<TimeMarker> { currentMark, new TimeMarker(1), }; var history = new Mock<ITimeline>(); { history.Setup(h => h.CanRollBack) .Returns(true); history.Setup(h => h.MarkersInThePast()) .Returns(markers); history.Setup(h => h.Current) .Returns(currentMark); } var project = new Mock<IProject>(); { project.Setup(p => p.History) .Returns(history.Object); } var projectFacade = new ProjectFacade(project.Object); var projectLink = new Mock<ILinkToProjects>(); { projectLink.Setup(p => p.ActiveProject()) .Returns(projectFacade); projectLink.Setup(p => p.HasActiveProject()) .Returns(true); } Func<string, IDisposable> timerFunc = s => new MockDisposable(); var command = new UndoCommand(projectLink.Object, timerFunc); Assert.IsTrue(command.CanExecute(null)); }
public void SetTimeMarkerCommandExecuted(object parameter) { if (this.SelectedAppointment == null) { RadWindow.Alert("Please, select an appointment first."); } else { Appointment appointmentToEdit = null; TimeMarker t = parameter as TimeMarker; if (this.SelectedAppointment is Appointment) { appointmentToEdit = (from app in this.Appointments where app.Equals(this.SelectedAppointment) select app).FirstOrDefault(); appointmentToEdit.TimeMarker = t; } else { appointmentToEdit = this.Appointments.Where(a => a.Equals((this.SelectedAppointment as Occurrence).Master)).FirstOrDefault(); var exceptionAppointment = appointmentToEdit.RecurrenceRule.Exceptions.SingleOrDefault(a => a.Appointment.Equals((this.SelectedAppointment as Occurrence).Appointment)); if (exceptionAppointment != null) { appointmentToEdit.RecurrenceRule.Exceptions.Remove(exceptionAppointment); (exceptionAppointment.Appointment as Appointment).TimeMarker = t; appointmentToEdit.RecurrenceRule.Exceptions.Add(exceptionAppointment); } else { appointmentToEdit.TimeMarker = t; } } var index = this.Appointments.IndexOf(appointmentToEdit); this.Appointments.Remove(appointmentToEdit); this.Appointments.Insert(index, appointmentToEdit); } }
public TimeMarker GetNearestMarker(double offset) { double minDist = double.MaxValue;; TimeMarker res = null; foreach (TimeMarker marker in Markers) { double dist = Math.Abs(offset - marker.Offset); if (dist < minDist) { minDist = dist; res = marker; } } if (minDist <= MinimumMarkerDistance) { return(res); } else { return(null); } }
private void valueRepresenter_MouseLeftButtonUp_Measure(object sender, MouseButtonEventArgs e) { LineCursor.Visibility = System.Windows.Visibility.Visible; LineMarker1.Visibility = System.Windows.Visibility.Collapsed; LineMarker2.Visibility = System.Windows.Visibility.Collapsed; ValueRepresenter repr = sender as ValueRepresenter; repr2 = repr; Point pt = e.GetPosition(repr); Point ptr = e.GetPosition(ListViewMain); double PositionX = pt.X; marker2 = repr.GetNearestMarker(PositionX); if (marker2 == null) { marker2 = new TimeMarker(core.ScaleManager.GetTime(PositionX), PositionX); } TimeMeasureDataView1.Visibility = Visibility.Visible; if (marker1.Time != marker2.Time) { core.TimeMeasureList.Add(new TimeMeasureData(marker1, marker2, repr1.Variable, repr2.Variable)); } }
public DateCmpExpr(TimeMarker reference, VarExpr <Date> param1, VarExpr <Date>?param2 = null) { this.Kind = reference; this.Param1 = param1; this.Param2 = param2; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TimeMarker obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public void RunWithMarkHistoryVertex() { var marker = new TimeMarker(10); var timeline = new Mock<ITimeline>(); { timeline.Setup(t => t.Mark()) .Returns(marker); } TimeMarker storedMarker = null; var schedule = BuildThreeVertexSchedule(new MarkHistoryVertex(3)); using (var info = new ScheduleExecutionInfo(new CurrentThreadTaskScheduler())) { using (var executor = new ScheduleExecutor( new List<IProcesExecutableScheduleVertices> { new StartVertexProcessor(), new EndVertexProcessor(), new MarkHistoryVertexProcessor(timeline.Object, m => storedMarker = m), }, ScheduleConditionStorage.CreateInstanceWithoutTimeline(), schedule, new ScheduleId(), info)) { var state = ScheduleExecutionState.None; executor.OnFinish += (s, e) => { state = e.State; }; executor.Start(); Assert.AreEqual(ScheduleExecutionState.Completed, state); Assert.AreEqual(marker, storedMarker); } } }
public void AddToTimeMarkers(TimeMarker timeMarker) { base.AddObject("TimeMarkers", timeMarker); }
public void Undo() { var currentMark = new TimeMarker(10); var markers = new List<TimeMarker> { currentMark, new TimeMarker(1), }; var history = new Mock<ITimeline>(); { history.Setup(h => h.CanRollBack) .Returns(true); history.Setup(h => h.MarkersInThePast()) .Returns(markers); history.Setup(h => h.Current) .Returns(currentMark); history.Setup(h => h.RollBackTo(It.IsAny<TimeMarker>(), It.IsAny<TimelineTraveller>())) .Verifiable(); } var project = new Mock<IProject>(); { project.Setup(p => p.History) .Returns(history.Object); } var projectFacade = new ProjectFacade(project.Object); var projectLink = new Mock<ILinkToProjects>(); { projectLink.Setup(p => p.ActiveProject()) .Returns(projectFacade); projectLink.Setup(p => p.HasActiveProject()) .Returns(true); } Func<string, IDisposable> timerFunc = s => new MockDisposable(); var command = new UndoCommand(projectLink.Object, timerFunc); command.Execute(null); history.Verify(h => h.RollBackTo(It.IsAny<TimeMarker>(), It.IsAny<TimelineTraveller>()), Times.Once()); }
private void TimeMarkerControl_OnLoaded(object sender, RoutedEventArgs e) { _dc = (TimeMarker)DataContext; _dc.PropertyChanged += Dc_PropertyChanged; }
public static TimeMarker CreateTimeMarker(int timeMarkerID) { TimeMarker timeMarker = new TimeMarker(); timeMarker.TimeMarkerID = timeMarkerID; return timeMarker; }
/// <summary> /// 【日程类型】相关的标记类型 /// </summary> /// <param name="timeMarkerName"></param> /// <returns></returns> private static TimeMarker GetTimeMarker(string timeMarkerName) { switch (timeMarkerName) { case "Free": { var timeMarker = new TimeMarker("Free", new SolidColorBrush(ColorConverter.ColorFromString("#FF309B46"))); return timeMarker; } case "Tentative": { var timeMarker = new TimeMarker("Tentative", new SolidColorBrush(ColorConverter.ColorFromString("#FF41229B"))); return timeMarker; } case "Busy": { var timeMarker = new TimeMarker("Busy", new SolidColorBrush(ColorConverter.ColorFromString("#FFE61E26"))); return timeMarker; } case "OutOfOffice": { var timeMarker = new TimeMarker("OutOfOffice", new SolidColorBrush(ColorConverter.ColorFromString("#FFF1C700"))); return timeMarker; } default: return null; } }