Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new SettableStopwatch with a custom inital time
 /// </summary>
 /// <param name="ticks">The initial time in ticks</param>
 public SettableStopwatch(long ticks = 0)
 {
     time            = new TimeSpan(ticks);
     timer.AutoReset = false;
     timer.Stop();
     timer.Elapsed += (sender, e) => { ThresholdReached?.Invoke(this, EventArgs.Empty); };
 }
Ejemplo n.º 2
0
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            // dY > 0 means scroll down
            if (dy > 0)
            {
                TotalItemCount          = LayoutManager.ItemCount;
                LastVisibleItemPosition = LayoutManager.FindLastCompletelyVisibleItemPosition();

                // as the number of items passed equals to LastVisibleItemPosition + 1
                PassedItemCount = LastVisibleItemPosition + 1;

                // Check the presence of loading item
                int indexSubstitution = RecyclerViewAdapter.IsLoadingMore ? 1 : 0;

                // reach threshold
                if (PassedItemCount + TriggerThreshold == (TotalItemCount - indexSubstitution))
                {
                    if (!triggerLock)
                    {
                        ThresholdReached?.Invoke(this, EventArgs.Empty);

                        triggerLock = true;
                    }
                }
                else
                {
                    triggerLock = false;
                }
            }

            bool isOnTop = LayoutManager.FindFirstCompletelyVisibleItemPosition() == 0 || TotalItemCount == 0;

            Scroll?.Invoke(this, new ScrollEventArgs(isOnTop));
        }
Ejemplo n.º 3
0
 public void Add(int x)
 {
     total += x;
     if (total >= threshold)
     {
         ThresholdReached?.Invoke(this, EventArgs.Empty);
     }
 }
 public CurrentTimeArgs(int hours, int minutes, int seconds, int currentRound,
                        ThresholdReached threshold = ThresholdReached.NotSet)
 {
     this.Hours        = hours;
     this.Minutes      = minutes;
     this.Seconds      = seconds;
     this.CurrentRound = currentRound;
     this.Threshold    = threshold;
 }
Ejemplo n.º 5
0
            public void Increment()
            {
                _count++;

                if (_count >= _threshold)
                {
                    ThresholdReached?.Invoke(this, EventArgs.Empty);
                }
            }
Ejemplo n.º 6
0
    private void OnLevelReached(LevelThreshold levelThreshold)
    {
        levelThreshold.LevelReached -= OnLevelReached;
        ThresholdReached?.Invoke(levelThreshold);

        _currentLevel++;
        _distanceBetweenThreshold  += _heightIncreasement;
        _currentThresholdPositionY += _distanceBetweenThreshold;
        SpawnThreshold(_currentThresholdPositionY, _currentLevel);
    }
Ejemplo n.º 7
0
        public decimal ConvertToDollars(decimal euroAmount)
        {
            decimal result;

            if (euroAmount > 10000)
            {
                ThresholdReached.Invoke();
            }
            result = euroAmount * (decimal)1.10;
            return(result);
        }
Ejemplo n.º 8
0
        public decimal  ConvertToEuro(decimal dollarsAmount)
        {
            decimal result;

            if (dollarsAmount > 10000)
            {
                ThresholdReached.Invoke();
            }
            result = dollarsAmount * (decimal)0.91;
            return(result);
        }
 public void UpdateCounter()
 {
     if (Counter >= threshold)
     {
         if (ThresholdReached != null)
         {
             ThresholdReached.Invoke(this, EventArgs.Empty);
         }
     }
     Counter++;
 }
Ejemplo n.º 10
0
 public void IncreaseCount()
 {
     this.count += 1;
     if (this.count >= this.threshold)
     {
         ThresholdReached?.Invoke(this, new ThresholdReachedEventArgs()
         {
             Message = $"{this.count} is past the {this.threshold} threshold"
         });
         //EventPublisherThresholdReached(new Counter_ThresholdReachedEventArgs() { Message = $"{this.count} is past the {this.threshold} threshold" });
     }
 }
Ejemplo n.º 11
0
        public void Add(int value)
        {
            total += value;
            if (total >= THRESHOLD)
            {
                //
                var args = new ThresholdReachedEventArgs();
                args.Threshold   = THRESHOLD;
                args.TimeReached = DateTime.Now;

                ThresholdReached?.Invoke(this, args);
            }
        }
Ejemplo n.º 12
0
 protected virtual void OnThresholdReached(ThresholdReachedEventArgs e)
 {
     /*
      * // C# 5.0
      * EventHandler<ThresholdReachedEventArgs> handler = ThresholdReached;
      * if (handler != null)
      * {
      *  handler(this, e);
      * }
      */
     // C# 6.0
     ThresholdReached?.Invoke(this, e);
 }
Ejemplo n.º 13
0
 protected virtual void OnThresholdReached(ThresholdReachedEventArgs e)
 {
     ThresholdReached?.Invoke(this, e);
     //等价于
     // //创建一个委托变量handler,受EventHandler<ThresholdReachedEventArgs>约束
     // //handler获得事件ThresholdReached,handler可以在事件发生时调用事件订阅者方法
     // EventHandler<ThresholdReachedEventArgs> handler = ThresholdReached;
     ////事件订阅者如果不为空
     // if (handler != null)
     // {
     //     //间接调用事件订阅者的事件处理器方法。
     //     handler(this, args);
     // }
 }
Ejemplo n.º 14
0
        protected virtual void OnThresholdReached(EventArgs e)
        {
            //This line actually fires the event and any listening methods will be invoked
            ThresholdReached?.Invoke(this, e);

            /*The below are older ways of doing the above */

            //EventHandler handler = ThresholdReached;
            //handler?.Invoke(this, e);

            //EventHandler handler = ThresholdReached;
            //if (handler != null)
            //{
            //    handler(this, e);
            //}
        }
Ejemplo n.º 15
0
 private void OnThresholdReached(int threshold)
 {
     ThresholdReached?.Invoke(threshold);
 }
Ejemplo n.º 16
0
 private void OnThresholdReached(ThresholdReachedEventArgs args)
 {
     ThresholdReached?.Invoke(this, args);
 }
Ejemplo n.º 17
0
 protected virtual void OnThresholdReached(string message)
 {
     ThresholdReached?.Invoke(this, new  SendEventArg(message));
 }
Ejemplo n.º 18
0
 private void OnThresholdreached(ThresholdEventArgs threshold)
 {
     ThresholdReached?.Invoke(this, threshold);
 }
Ejemplo n.º 19
0
 protected virtual void OnThresholdReached(ThresholdReachedEventArgs e)
 {
     ThresholdReached?.Invoke(this, e);
 }
Ejemplo n.º 20
0
 public void Handle(ThresholdReached data)
 {
     context.Queue.Add(new DataGetTaskSchedule(data.Peer));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Publish the ThresholdReached event when the threshold has been reached
 /// </summary>
 /// <param name="args"></param>
 private void PublishThresholdReachedEvent(ThresholdReachedEventArgs args)
 {
     ThresholdReached?.Invoke(this, args);
 }
 public virtual void OnThresholdReached(EventArgs e)
 {
     ThresholdReached?.Invoke(this, e);
 }
Ejemplo n.º 23
0
 private void OnThresholdReached(ChatEventHandler handler)
 {
     ThresholdReached?.Invoke(this, handler);
 }