Exemple #1
0
 /// <summary>
 /// 向右滑动一页
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //最大的偏移量,以负数为基准
         double limit = -(this.spMain.ActualWidth - this.scro.ActualWidth);
         //向右偏移一页,减去一页的宽度
         horLLLeft -= horOffset;
         //创建一个动画
         TomAnimation tom = new TomAnimation();
         //如果偏移量大于所限制的量,则进行调整
         if (horLLLeft < limit)
         {
             //调整到临界点
             horLLLeft = limit;
             //偏移到临界点
             tom.MovingX(spMain, horLLLeft, 0.2);
         }
         else
         {
             //向右滑动(指定位移)
             tom.MovingX(spMain, horLLLeft, 0.5);
             IntNow++;
         }
     }
     catch (Exception ex)
     {
         MethodLb.CreateLog(this.GetType().FullName, "Button_Click", ex.ToString(), sender, e);
     }
     finally
     {
     }
 }
Exemple #2
0
        /// <summary>
        /// 向左滑动一页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                //实例化一个动画类
                TomAnimation tom = new TomAnimation();

                //如果剩余的宽度大于或等于0,,
                if (horLLLeft >= 0)
                {
                    //设置偏移量为0
                    horLLLeft = 0;
                    //快速移动到0的位置(最左侧),一种校准的方式
                    tom.MovingX(spMain, horLLLeft, 0.2);
                }
                else
                {
                    //向左滑动
                    tom.MovingX(spMain, horLLLeft += horOffset, 0.5);
                    IntNow--;
                }
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "Button_Click_1", ex.ToString(), sender, e);
            }
            finally
            {
            }
        }
Exemple #3
0
        /// <summary>
        /// 滚动鼠标轮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void LeftToRight1_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            try
            {
                //每一页所要滑动的宽度标准
                double limit = -(this.spMain.ActualWidth - this.scro.ActualWidth);

                //如果偏移量为最左或最右的临界点则不再执行
                if (horLLLeft < limit || horLLLeft > 0)
                {
                    return;
                }
                //创建一个动画
                TomAnimation tom = new TomAnimation();
                //获取偏移量
                horLLLeft += e.Delta;

                //(两个极端)
                //如果偏移量大于所限制的量,则进行调整
                if (horLLLeft < limit)
                {
                    //调整到右侧临界点
                    horLLLeft = limit;
                    //偏移到右侧临界点
                    tom.MovingX(spMain, horLLLeft, 0.2);
                }
                else if (horLLLeft >= 0)
                {
                    //设置偏移量为0
                    horLLLeft = 0;
                    //快速移动到0的位置(最左侧),一种校准的方式
                    tom.MovingX(spMain, horLLLeft, 0.2);
                }
                else
                {
                    //水平移动(向左或向右)
                    tom.MovingX(spMain, horLLLeft, 0.5);
                }

                //翻页信息
                if (this.scro.ActualWidth != 0)
                {
                    IntNow = (int)(horLLLeft / -this.scro.ActualWidth) + 1;
                }
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "LeftToRight1_PreviewMouseWheel", ex.ToString(), sender, e);
            }
            finally
            {
            }
        }
Exemple #4
0
        void ItemToPostion(ListBoxItem listboxItem)
        {
            int selecInt = 0;

            ///获取到导航标题
            if (listboxItem.Content != null && int.TryParse(listboxItem.Content.ToString(), out selecInt))
            {
                //获取偏移位置
                horLLLeft = -(selecInt - 1) * this.scro.ActualWidth;

                //horLLLeft =

                //创建一个动画
                TomAnimation tom = new TomAnimation();
                tom.MovingX(spMain, horLLLeft, 0.2);

                IntNow = selecInt;
            }
        }