Beispiel #1
0
 /// <summary>
 /// S'assure que les zoom opérations existent.
 /// </summary>
 /// <param name="zoomable">The zoomable.</param>
 /// <param name="chart">The chart.</param>
 private void EnsureOperations(IZoommerGantt zoomable, KGanttChartView chart)
 {
     if (_zoomOperations == null)
     {
         _zoomOperations = new Subject <ZoomAction>();
         _zoomOperations
         .BufferWithInactivity(TimeSpan.FromMilliseconds(200))
         .Take(1)
         .ObserveOnDispatcher()
         .Subscribe(actions =>
         {
             ExecuteZoomActions(zoomable, chart, actions);
             _zoomOperations.OnCompleted();
             _zoomOperations.Dispose();
             _zoomOperations = null;
         });
     }
 }
Beispiel #2
0
        /// <summary>
        /// Execute les différentes actions de zoom mise en file.
        /// </summary>
        /// <param name="zoomable">Le gantt.</param>
        /// <param name="chart">Le chart.</param>
        /// <param name="actions">Les actions.</param>
        private void ExecuteZoomActions(IZoommerGantt zoomable, KGanttChartView chart, IEnumerable <ZoomAction> actions)
        {
            double zoomX            = zoomable.ZoomX;
            double zoomY            = zoomable.ZoomY;
            double verticalOffset   = chart.ScrollVerticalOffset;
            double horizontalOffset = chart.ScrollHorizontalOffset;
            bool   scrollHorizontal = false;
            bool   scrollVertical   = false;

            foreach (var action in actions)
            {
                switch (action.Action)
                {
                case ZoomActionEnum.ZoomXIn:
                {
                    double delta = zoomX * 1.2 - zoomX;
                    zoomX            += delta;
                    horizontalOffset += action.MousePosition.X * delta;
                    scrollHorizontal  = true;
                }
                break;

                case ZoomActionEnum.ZoomXOut:
                {
                    double delta = zoomX / 1.2 - zoomX;
                    zoomX            += delta;
                    horizontalOffset += action.MousePosition.X * delta;
                    scrollHorizontal  = true;
                }
                break;

                case ZoomActionEnum.ZoomYIn:
                {
                    double delta = zoomY * 1.2 - zoomY;
                    zoomY          += delta;
                    verticalOffset += action.MousePosition.Y * delta;
                    scrollVertical  = true;
                }
                break;

                case ZoomActionEnum.ZoomYOut:
                {
                    double delta = zoomY / 1.2 - zoomY;
                    zoomY          += delta;
                    verticalOffset += action.MousePosition.Y * delta;
                    scrollVertical  = true;
                }
                break;

                case ZoomActionEnum.ScrollRight:
                    horizontalOffset += 48;
                    scrollHorizontal  = true;
                    break;

                case ZoomActionEnum.ScrollLeft:
                    horizontalOffset -= 48;
                    scrollHorizontal  = true;
                    break;

                default:
                    throw new ArgumentOutOfRangeException("action");
                }
            }

            ApplyZoom(zoomX, zoomY);
            if (scrollHorizontal)
            {
                chart.DeferScrollToHorizontalOffset(horizontalOffset);
            }
            if (scrollVertical)
            {
                chart.DeferScrollToVerticalOffset(verticalOffset);
            }

            SetBusy(false, chart);
        }