Esempio n. 1
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this.PART_Content      = GetTemplateChild(TGP_PART_CONTENT) as TransitionElement;
     this.PART_CarouselList = GetTemplateChild(TGP_PART_CAROUSELLIST) as ItemsControl;
     if (this.PART_CarouselList != null)
     {
         if (this.ItemsSource.Count < 5)
         {
             throw new ArgumentException("用户播放的集合大小不能小于5");
         }
         this.PART_CarouselList.ItemsSource = this.ItemsSource;
     }
     if (this.AutomaticAnimation)
     {
         Task.Factory.StartNew(() =>
         {
             //定时器轮播处理, 间隔时间 2s
             Int32 interval = 3000;
             CarouselTimer.Start <Object>(interval, OnTimerCallback, "Object");
         });
     }
     //设置命令
     this.OnBindingCommand();
 }
Esempio n. 2
0
        /// <summary>
        /// 停止定时器
        /// </summary>
        /// <param name="timerID">定时器编号</param>
        public static void Stop(String timerID)
        {
            CarouselTimer tiemr = null;

            if (container.TryGetValue(timerID, out tiemr))
            {
                tiemr.mTimer.Dispose();
                tiemr = null;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 启动一个定时器,并返回一个定时器编号
 /// </summary>
 /// <typeparam name="T">参数类型</typeparam>
 /// <param name="interval"></param>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static String Start <T>(Int32 interval, TimerCallback callback, T obj)
 {
     lock (lockObj)
     {
         CarouselTimer carousel = new CarouselTimer(interval, callback, obj);
         String        timerID  = Guid.NewGuid().ToString("N").ToUpper();
         CurrentTimerID = timerID;
         container.Add(timerID, carousel);
         return(timerID);
     }
 }
Esempio n. 4
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     CarouselTimer.Stop();
 }