Пример #1
0
        public void UpdateIntervalCollection(TimeIntervalCollection intervalCollection, TimeSpan duration)
        {
            this.intervalCollection = intervalCollection;
            this.duration           = duration;

            gridCutSections.Children.Clear();
            if (intervalCollection?.Count > 0)
            {
                foreach (var timeInterval in intervalCollection)
                {
                    Border b = new Border();
                    b.Style = borderStyle;
                    double max         = duration.TotalSeconds;
                    double leftMargin  = timeInterval.Start.TotalSeconds * ActualWidth / max;
                    double rightMargin = (max - timeInterval.End.TotalSeconds) * ActualWidth / max;
                    b.Margin  = new Thickness(leftMargin, 0, rightMargin, 0);
                    b.ToolTip = $"{timeInterval.Start.ToFormattedString(true)} - {timeInterval.End.ToFormattedString(true)}";
                    gridCutSections.Children.Add(b);
                }
            }
            else
            {
                Border b = new Border();
                b.Style  = borderStyle;
                b.Margin = new Thickness(0, 0, 0, 0);
                gridCutSections.Children.Add(b);
            }
        }
        public void Deactivate()
        {
            if (ExternalTabControl != null)
            {
                foreach (XtraTabPage parentTab in ExternalTabControl.Controls)
                {
                    var basePlugin = FindUserControlBasePlugin(parentTab);
                    foreach (Control control in basePlugin.Controls)
                    {
                        GridControl mainEventControl = FindMainEventControl <GridControl>(control);
                        DeactivateControlEvents(mainEventControl);
                    }
                }
            }

            FreeTimeCalculator.IntervalFound      -= FreeTimeCalc_IntervalFound;
            dateNavigator.CustomDrawDayNumberCell -= DateNavigator_CustomDrawDayNumberCell;
            if (_AvailableTimeIntervals != null)
            {
                _AvailableTimeIntervals.Clear();
            }
            _AvailableTimeIntervals = null;
            dateNavigator.InvokeIfRequired(dtN =>
            {
                dtN.Invalidate();
            });
        }
        AppointmentBaseCollection PrepareAppointmentsToSelect(XPAppointment[] rows)
        {
            AppointmentBaseCollection appoitnments = new AppointmentBaseCollection();

            for (int i = 0; i < rows.Length; i++)
            {
                Appointment apt = FindAppointmentByRow(rows[i]);
                if (apt != null)
                {
                    switch (apt.Type)
                    {
                    case AppointmentType.Pattern:
                        TimeIntervalCollection    tiCollection  = schedulerControl1.ActiveView.GetVisibleIntervals();
                        OccurrenceCalculator      calc          = OccurrenceCalculator.CreateInstance(apt.RecurrenceInfo);
                        AppointmentBaseCollection aptCollection = calc.CalcOccurrences(tiCollection.Interval, apt);
                        appoitnments.AddRange(aptCollection);
                        break;

                    case AppointmentType.DeletedOccurrence:
                        break;

                    default:
                        appoitnments.Add(apt);
                        break;
                    }
                }
            }
            return(appoitnments);
        }
Пример #4
0
        private void schedulerControl1_MoreButtonClicked(object sender, MoreButtonClickedEventArgs e)
        {
            TimeIntervalCollection newIntervalCollection = new TimeIntervalCollection();

            newIntervalCollection.Add(new TimeInterval(DateTime.Now.AddDays(-7), DateTime.Now.AddDays(7)));
            schedulerControl1.ActiveView.SetVisibleIntervals(newIntervalCollection);
            e.Handled = true;
        }
Пример #5
0
        private void CreateDoctorEventAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            IObjectSpace                objectSpace = Application.CreateObjectSpace();
            TimeIntervalCollection      intervalCol = activeView.GetVisibleIntervals();
            CreateDoctorEventParameters parameters  = new CreateDoctorEventParameters(intervalCol.Start);

            e.View = Application.CreateDetailView(objectSpace, parameters, true);
        }
Пример #6
0
        // Установка текущей недели
        private void SetDefaultInterval()
        {
            TimeIntervalCollection intervals = new TimeIntervalCollection();
            DateTime today         = DateTime.Today;
            int      dayOfWeek     = (int)today.DayOfWeek;
            DateTime currentMonday = today.DayOfWeek == DayOfWeek.Sunday ? today.AddDays(-6) : today.AddDays(1 - dayOfWeek);

            intervals.SetContent(new TimeInterval(currentMonday, TimeSpan.FromDays(5)));
            activeView.SetVisibleIntervals(intervals);
        }
Пример #7
0
        private void CloneDoctorEventAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
        {
            Doctor doctor = FilterDoctorEventAction.SelectedItem.Data as Doctor;
            // Форма параметров
            CloneDoctorEventParameters parameters = (CloneDoctorEventParameters)e.PopupWindowViewCurrentObject;

            using (IObjectSpace os = Application.CreateObjectSpace())
            {
                TimeIntervalCollection intervalCol = activeView.GetVisibleIntervals();
                DateTime clonedWeekDateIn          = intervalCol.Start;
                Dictionary <int, List <DoctorEvent> > clonedWeek = new Dictionary <int, List <DoctorEvent> >();
                DateTime start = clonedWeekDateIn; int i = 1;
                // Копируем в буфер неделю, которую мы хотим скопировать
                while (start < clonedWeekDateIn.AddDays(7))
                {
                    clonedWeek[i] = new List <DoctorEvent>(os.GetObjects <DoctorEvent>(
                                                               DoctorEvent.Fields.AssignedTo == os.GetObject(doctor) &
                                                               DoctorEvent.Fields.StartOn >= start.Date &
                                                               DoctorEvent.Fields.EndOn < start.Date.AddDays(1)));
                    start = start.AddDays(1);
                    i++;
                }

                int weekIndex = 0; start = clonedWeekDateIn.Date.AddDays(7);
                while (weekIndex < parameters.NextWeeksCount)
                {
                    int dayIndex = 1;
                    while (dayIndex <= 7)
                    {
                        foreach (DoctorEvent clonedEvent in clonedWeek[dayIndex])
                        {
                            var newEvent = os.CreateObject <DoctorEvent>();
                            newEvent.AssignedTo = clonedEvent.AssignedTo;
                            newEvent.Label      = clonedEvent.Label;
                            newEvent.StartOn    = start.AddHours(clonedEvent.StartOn.Hour).AddMinutes(clonedEvent.StartOn.Minute);
                            newEvent.EndOn      = start.AddHours(clonedEvent.EndOn.Hour).AddMinutes(clonedEvent.EndOn.Minute);
                        }
                        dayIndex++;
                        start = start.AddDays(1);
                    }
                    weekIndex++;
                }

                // Отключение аудита
                Session session = ((XPObjectSpace)os).Session;
                AuditTrailService.Instance.EndSessionAudit(session);
                os.CommitChanges();
            }

            // Обновление списочного представления
            if (rootListView != null && rootListView.ObjectSpace != null && rootListView.CollectionSource != null)
            {
                rootListView.CollectionSource.Reload();
            }
        }
Пример #8
0
 internal override void ComputeCurrentFillInterval(TimeIntervalCollection parentIntervalCollection,
                                                   TimeSpan beginTime, TimeSpan endTime, Duration period,
                                                   double appliedSpeedRatio, double accelRatio, double decelRatio,
                                                   bool isAutoReversed)
 {
     _currentIntervals.Clear();
     parentIntervalCollection.ProjectPostFillZone(ref _currentIntervals,
                                                  beginTime, endTime,
                                                  period, appliedSpeedRatio,
                                                  accelRatio, decelRatio, isAutoReversed);
 }
Пример #9
0
 internal override void ComputeCurrentIntervals(TimeIntervalCollection parentIntervalCollection,
                                                TimeSpan beginTime, TimeSpan?endTime,
                                                Duration fillDuration, Duration period,
                                                double appliedSpeedRatio, double accelRatio, double decelRatio,
                                                bool isAutoReversed)
 {
     _currentIntervals.Clear();
     parentIntervalCollection.ProjectOntoPeriodicFunction(ref _currentIntervals,
                                                          beginTime, endTime,
                                                          fillDuration, period, appliedSpeedRatio,
                                                          accelRatio, decelRatio, isAutoReversed);
 }
Пример #10
0
        /// <summary>
        /// Activates this root clock.
        /// </summary>
        internal void RootActivate()
        {
            Debug.Assert(IsTimeManager, "Invalid call to RootActivate for a non-root Clock");
            Debug.Assert(_timeManager != null);  // RootActivate should be called by our own TimeManager

            // Reset the state of the timing tree
            TimeIntervalCollection currentIntervals = TimeIntervalCollection.CreatePoint(_timeManager.InternalCurrentGlobalTime);

            currentIntervals.AddNullPoint();
            _timeManager.InternalCurrentIntervals = currentIntervals;

            ComputeTreeState();
        }
Пример #11
0
    private static TimeIntervalCollection GetAvailabilitiesForResource(string resourceId)
    {
        DataTable table = GetAvailabilitiesTable();
        DataView  view  = new DataView(table, string.Format("ResourceId = '{0}'", resourceId), string.Empty, DataViewRowState.CurrentRows);
        TimeIntervalCollection result = new TimeIntervalCollection();

        for (int i = 0; i < view.Count; i++)
        {
            result.Add(new TimeInterval(Convert.ToDateTime(view[i]["StartTime"]), Convert.ToDateTime(view[i]["EndTime"])));
        }

        return(result);
    }
Пример #12
0
    public static bool IsIntervalAvailableForResource(string resourceId, TimeInterval timeInterval)
    {
        TimeIntervalCollection availabilities = GetAvailabilitiesForResource(resourceId.ToString());
        bool result = false;

        for (int i = 0; i < availabilities.Count; i++)
        {
            if (availabilities[i].Contains(timeInterval))
            {
                result = true;
                break;
            }
        }

        return(result);
    }
Пример #13
0
        private void PopulateGrid()
        {
            if (splitContainerControl2.IsPanelCollapsed)
            {
                return;
            }

            try
            {
                if (_initializing)
                {
                    return;
                }

                DateTime m = DateTime.MinValue;

                TimeIntervalCollection l = schedulerControl1.ActiveView.GetVisibleIntervals();


                foreach (TimeInterval item in l)
                {
                    if (item.End.Date > m)
                    {
                        DateTime t = item.End.Date.AddMonths(1);
                        t = new DateTime(t.Year, t.Month, 1);
                        m = t;//.AddDays(-1);
                    }
                }


                gridControl1.DataSource = GetAttivita(m);


                try
                {
                    gridControl1.MainView.SaveLayoutToXml(fileLayout);
                }
                catch (Exception)
                {
                    //non fa nulla
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Show(ex);
            }
        }
Пример #14
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            schedulerControl1.BeginUpdate();
            TimeIntervalCollection tic = new TimeIntervalCollection();

            tic.Add(new TimeInterval(DateTime.Today, DateTime.Today.AddDays(1)));
            tic.Add(new TimeInterval(DateTime.Today.AddDays(7), DateTime.Today.AddDays(8)));
            tic.Add(new TimeInterval(DateTime.Today.AddDays(14), DateTime.Today.AddDays(15)));
            schedulerControl1.DayView.SetVisibleIntervals(tic);
            schedulerControl1.EndUpdate();
            //schedulerControl1.FirstDayOfWeek
            //schedulerControl1.DayView.TopRowTime = DateTime.Now;
            //schedulerControl1.DayView.TimeScale = TimeSpan.FromMinutes(15);
            //schedulerStorage1.GetAppointments(DateTime.Now.AddYears(-1),DateTime.Now.AddYears(1))[0].LabelId = 3;
            //schedulerStorage1.Appointments.Items.FindAll(RequiredApt)[0].LabelId = 3;
            //MessageBox.Show(DevExpress.XtraScheduler.Native.SchedulerTimeZoneHelper.Instance.CurrentTimeZone.Id.ToString());
        }
 private void ShowAvailableDatesBehaviourPlugin_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     if (sender is GridView view)
     {
         if (view.GetRow(view.FocusedRowHandle) is IEntityWithDuration durationEnt)
         {
             selectedExternalEntity = durationEnt;
             //the duration looked for from the selected entity
             TimeSpan findDuration = TimeSpan.FromHours(durationEnt.Duration);
             //get the date from when a slot will be looked for
             DateTime fromStart = dateNavigator.SelectionStart;
             //Set the wide range interval where an interval will be looked for
             TimeInterval wideRange = new TimeInterval(fromStart, fromStart.AddDays((int)PluginSettings[DAYS_INTERVAL]));
             _AvailableTimeIntervals = FindFreeIntervals(wideRange, findDuration);
             dateNavigator.InvokeIfRequired(dtN =>
             {
                 dtN.Invalidate();
             });
         }
     }
 }
        private bool NeedDateCorrection(TimeIntervalCollection timeIntervalCollection)
        {
            TimeInterval firstWeekInterval = timeIntervalCollection[0];

            return(firstWeekInterval.Start.Day != 1 && firstWeekInterval.Start.Month == firstWeekInterval.End.Month);
        }
Пример #17
0
        /// <summary>
        /// Moves the clock forward to the current time and updates the state of
        /// all timing objects based on the time change.
        /// </summary>
        /// <remarks>
        /// The associated reference clock is used to determine the current time.
        /// The new position of the clock will be equal to the difference between the
        /// starting system time and the current system time. The time manager requires
        /// the system time to move forward.
        /// </remarks>
        //[CodeAnalysis("AptcaMethodsShouldOnlyCallAptcaMethods")] //Tracking
        public void Tick()
        {
            try
            {
#if DEBUG
                // On a regular interval, clean up our tables of known
                // timelines and clocks
                if (++_frameCount >= 1000) // Should be about once every 10s
                {
                    Timeline.CleanKnownTimelinesTable();
                    System.Windows.Media.Animation.Clock.CleanKnownClocksTable();
                    _frameCount = 0;
                }
#endif // DEBUG
                // Don't need to worry about needing a tick sooner
                _nextTickTimeQueried = false;

                // Mark the tree as clean immediately. If any changes occur during
                // processing of the tick, the tree will be marked as dirty again.
                _isDirty = false;

                // No effect unless we are in the running state
                if (_timeState == TimeState.Running)
                {
                    // Figure out the current time
                    _globalTime = GetCurrentGlobalTime();

                    // Start the tick
                    _isInTick = true;
                }

                // Trace the start of the tick and pass along the absolute time to which
                // we are ticking.
                EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnimation | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WClientTimeManagerTickBegin, (_startTime + _globalTime).Ticks / TimeSpan.TicksPerMillisecond);

                // Run new property querying logic on the timing tree
                if (_lastTimeState == TimeState.Stopped && _timeState == TimeState.Stopped)  // We were stopped the whole time
                {
                    _currentTickInterval = TimeIntervalCollection.CreateNullPoint();
                }
                else  // We were not stopped at some time, so process the tick interval
                {
                    _currentTickInterval = TimeIntervalCollection.CreateOpenClosedInterval(_lastTickTime, _globalTime);

                    // If at either tick we were stopped, add the null point to represent that
                    if (_lastTimeState == TimeState.Stopped || _timeState == TimeState.Stopped)
                    {
                        _currentTickInterval.AddNullPoint();
                    }
                }

                // Compute the tree state, using _currentTickInterval to compute the events that occured
                _timeManagerClock.ComputeTreeState();

                // Cache TimeManager state at this time
                _lastTimeState = _timeState;

                // When the tick is done, we raise timing events
                RaiseEnqueuedEvents();
            }
            finally
            {
                _isInTick = false;

                // Cache the tick time
                _lastTickTime = _globalTime;

                //trace the end of the tick
                EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnimation | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WClientTimeManagerTickEnd);
            }

            // At the end of every tick clean up GC'ed clocks, if necessary
            CleanupClocks();
        }
 public HijriCalendarHelper()
 {
     this.hijriCal       = new HijriCalendar();
     this.monthIntervals = new TimeIntervalCollection();
     this.monthIntervals.UniquenessProviderType = DXCollectionUniquenessProviderType.MaximizePerformance;
 }
Пример #19
0
 /// <summary>
 /// Writes the availability intervals of this object.  If the <topic name="Cesium">Cesium</topic> client
 /// knows an object to be available but it does not yet have that data itself, it may wait for the data to
 /// arrive before allowing animation to proceed.
 /// </summary>
 /// <param name="availability">The availability intervals of the object.</param>
 public void WriteAvailability(TimeIntervalCollection availability)
 {
     IList<TimeInterval> availabilityAsList = availability;
     WriteAvailability(availabilityAsList);
 }
Пример #20
0
 /// <summary>
 /// 获取有效时间段集合
 /// </summary>
 /// <param name="consideredIntervals"></param>
 /// <returns></returns>
 public override TimeIntervalCollection GetAvailabilityIntervals(TimeIntervalCollection consideredIntervals)
 {
     return(this.m_position.GetAvailabilityIntervals(consideredIntervals));
 }