Exemple #1
0
 /// <summary>
 /// 重置播放器
 /// </summary>
 private void ReSet()
 {
     TrendLine.Margin = new Thickness(0, -10, 0, 0);
     TimeLineScrollViewer.ScrollToHorizontalOffset(0);
     ScaleBarScrollViewer.ScrollToHorizontalOffset(0);
     CurrentSpeedTime = BaseSpeedTime;
     timer.Interval   = new TimeSpan(0, 0, 0, 0, CurrentSpeedTime);
     CurrentLocation  = 0;
     currentTime      = 0;
     tempTime         = -1.0;
     RefreshTimer();
 }
Exemple #2
0
 private void EventSetter_OnHandler(object sender, MouseButtonEventArgs e)
 {
     if (IsPlaying)
     {
         return;
     }
     if (SelectedTaskItem != null)
     {
         TimeLineScrollViewer.ScrollToHorizontalOffset(SelectedTaskItem.StartTime * BaseWidth);
         ScaleBarScrollViewer.ScrollToHorizontalOffset(SelectedTaskItem.StartTime * BaseWidth);
     }
 }
Exemple #3
0
        /// <summary>
        /// 拖拽TaskBar与滚动条联动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TaskBar_OnMoveThumebChanged(object sender, RoutedEventArgs e)
        {
            TaskBar taskBar       = e.OriginalSource as TaskBar;
            double  offSet        = taskBar.EndTime * taskBar.BaseWidth;
            double  leftOffSet    = taskBar.StartTime * taskBar.BaseWidth;
            double  currentOffset = TimeLineScrollViewer.HorizontalOffset + ticksGrid.ActualWidth;

            if (offSet >= TimeLineScrollViewer.HorizontalOffset + ticksGrid.ActualWidth)
            {
                TimeLineScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset + taskBar.BaseWidth);
                ScaleBarScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset + taskBar.BaseWidth);
            }
            else if (leftOffSet <= TimeLineScrollViewer.HorizontalOffset)
            {
                TimeLineScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset - taskBar.BaseWidth);
                ScaleBarScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset - taskBar.BaseWidth);
            }
        }
Exemple #4
0
        private void TicksPanel_OnMouseMove(object sender, MouseEventArgs e)
        {
            if (IsPlaying)
            {
                return;
            }
            if (TaskItemSource == null || TaskItemSource.Count == 0)//防止ScaleBarScrollViewer出现滚动显示BUG
            {
                return;
            }
            if (isDragging)
            {
                pressUpX = e.GetPosition(this.ticksGrid).X;
                double offSet = pressUpX - pressDownX;
                if (Math.Abs(offSet) >= BaseWidth)//一格一格滚动
                {
                    if (offSet < 0)
                    {
                        TimeLineScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset - Math.Floor(offSet / BaseWidth) * BaseWidth);
                        ScaleBarScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset - Math.Floor(offSet / BaseWidth) * BaseWidth);
                    }
                    else
                    {
                        TimeLineScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset - Math.Floor(offSet / BaseWidth) * BaseWidth);
                        ScaleBarScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset - Math.Floor(offSet / BaseWidth) * BaseWidth);
                    }
                    pressDownX = e.GetPosition(this.ticksGrid).X;
                }

                /* 平滑移动
                 * double offSet = TimeLineScrollViewer.HorizontalOffset - (pressUpX - pressDownX);
                 * if (offSet < 0)
                 * {
                 *  offSet = 0;
                 * }
                 * else if (offSet > TimeLineWidth)
                 * {
                 *  TimeLineWidth = offSet;
                 * }
                 * TimeLineScrollViewer.ScrollToHorizontalOffset(offSet);
                 * pressDownX = e.GetPosition(this.ticksGrid).X;
                 */
            }
        }
Exemple #5
0
        /// <summary>
        /// 播放处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartPlay(object sender, EventArgs e)
        {
            Thickness thickness   = TrendLine.Margin;
            double    currentLeft = thickness.Left;

            if (TimeLineScrollViewer.HorizontalOffset + thickness.Left > ExistLastTime * BaseWidth)
            {
                Play_Stop.IsChecked = false;
                CurrentSpeedTime    = BaseSpeedTime;//回到常规速度
                return;
            }

            if (TimeLineScrollViewer.HorizontalOffset + currentLeft < 0.001)//0秒单独处理
            {
                RespondEvent(0);
                RefreshTimer();
            }

            if (thickness.Left >= TrendLineMoveWidth)
            {
                TimeLineScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset + MoveUnit);
                ScaleBarScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset + MoveUnit);
            }
            else
            {
                currentLeft      = thickness.Left + MoveUnit;
                TrendLine.Margin = new Thickness(currentLeft, -10, 0, 0);
            }

            CurrentLocation = TimeLineScrollViewer.HorizontalOffset + currentLeft;
            currentTime     = Math.Round(CurrentLocation / BaseWidth);

            if (Math.Abs(CurrentLocation - currentTime * BaseWidth) < distanceCompareNum)
            {
                //Task.Factory.StartNew(() =>
                //{
                RespondEvent(currentTime);
                RefreshTimer();
                //});
            }
        }
Exemple #6
0
        /// <summary>
        /// 刻度滚轮滚动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TicksPanel_OnMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (IsPlaying)
            {
                return;
            }
            if (TaskItemSource == null || TaskItemSource.Count == 0)//防止ScaleBarScrollViewer出现滚动显示BUG
            {
                return;
            }
            bool handle = (Keyboard.Modifiers & ModifierKeys.Control) > 0;

            if (handle)
            {
                if (e.Delta > 0)
                {
                    Shrink_OnClick(null, null);
                }
                else if (e.Delta < 0)
                {
                    Enlarge_OnClick(null, null);
                }
            }
            else
            {
                if (e.Delta < 0)
                {
                    TimeLineScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset + ScaleBaseWidth);
                    ScaleBarScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset + ScaleBaseWidth);
                }
                else
                {
                    TimeLineScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset - ScaleBaseWidth);
                    ScaleBarScrollViewer.ScrollToHorizontalOffset(TimeLineScrollViewer.HorizontalOffset - ScaleBaseWidth);
                }
            }
        }