Exemplo n.º 1
0
        public void Move(bool d)
        {
            var s = d ? Current.Finish() : Current.Cancel();

            if (s == 0)
            {
                return;
            }
            Progress += s;
            if (Progress < 0)
            {
                Progress = 0;
                Cancelled?.Invoke(this, EventArgs.Empty);
                return;
            }
            if (Progress > Steps.Count - 1)
            {
                Progress = Steps.Count - 1;
                Finished?.Invoke(this, EventArgs.Empty);
                return;
            }
            Current.Init(s);
            if (Current.WillRecreate)
            {
                var type = Current.GetType();
                Steps[Progress] = new Lazy <Step>(() => (Step)Activator.CreateInstance(type));
                Current.Init(s);
            }
        }
Exemplo n.º 2
0
 private void UpdaterWindow_DeleteEvent(object o, DeleteEventArgs args)
 {
     if (active)
     {
         Cancelled?.Invoke(this, EventArgs.Empty);
     }
 }
Exemplo n.º 3
0
 private void UpdaterWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (active)
     {
         Cancelled?.Invoke(sender, e);
     }
 }
Exemplo n.º 4
0
        private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEventArgs asyncCompletedEventArgs)
        {
            if (asyncCompletedEventArgs.Cancelled)
            {
                if (Exists())
                {
                    Delete();
                }
                Cancelled?.Invoke(this, new EventArgs());
                return;
            }

            if (asyncCompletedEventArgs.Error != null)
            {
                DownloadFailed?.Invoke(this, new DownloadFailEvent(asyncCompletedEventArgs.Error));

                AppLogger.Log.Error("Problem downloading file ", asyncCompletedEventArgs.Error);
                return;
            }


            if (Exists())
            {
                Downloaded?.Invoke(this, new EventArgs());
            }
        }
Exemplo n.º 5
0
        private void InterstitialAdInterstitialAdMain_Cancelled(object sender, object e)
        {
            // Events
            HockeyClient.Current.TrackEvent("Ads cancelled");

            Cancelled?.Invoke();
        }
Exemplo n.º 6
0
 /// <summary>Когда операция отменяется</summary>
 /// <param name="e">Аргумент события</param>
 protected virtual void OnCancelled(EventArgs?e)
 {
     if (!_IsDisposed)
     {
         Cancelled?.Invoke(this, e ?? EventArgs.Empty);
     }
 }
        private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEventArgs asyncCompletedEventArgs)
        {
            if (asyncCompletedEventArgs.Cancelled)
            {
                if (Exists())
                {
                    Delete();
                }
                Cancelled.Handle(h => h(this));
                return;
            }

            if (asyncCompletedEventArgs.Error != null)
            {
                DownloadFailed.Handle(h => h(this, asyncCompletedEventArgs.Error));

                Trace.Write(asyncCompletedEventArgs.Error);
                return;
            }


            if (Exists())
            {
                Downloaded.Handle(h => h(this));
            }
        }
        private void Tick(object state)
        {
            var position = _gazePointProvider.CurrentPosition;

            if (position == null)
            {
                return;
            }
            var pNew = position.Value;
            var now  = _clock.Time;

            if (_point == null)
            {
                _point = new Timestamped <Point>(now, pNew);
                return;
            }
            var pOld = _point.Value.Value;

            if (Math.Abs(pOld.X - pNew.X) + Math.Abs(pOld.Y - pNew.Y) > _cursorMovementTolerance)
            {
                _point = new Timestamped <Point>(now, pNew);
                if (_cancellable && _inTrial)
                {
                    Cancelled?.Invoke(this, EventArgs.Empty);
                }
                return;
            }
            if (_inTrial || _clock.Unit.ToMilliseconds(Math.Abs(now - _point.Value.Timestamp)) < _dwellToSelectDelay)
            {
                return;
            }
            _point   = new Timestamped <Point>(now, pNew);
            _inTrial = true;
            Triggered?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 9
0
 public void Cancel()
 {
     if (Stop())
     {
         OnCancelled();
         Cancelled?.Invoke(this);
     }
 }
 /// <summary>
 /// Triggers the <see cref="Cancelled"/> event.
 /// </summary>
 /// <param name="args">Authorization operation arguments.</param>
 /// <param name="authzUri">The full Uri used for calling the authorization endpoint.</param>
 protected void OnCancelled(A args, Uri authzUri)
 {
     Cancelled?.Invoke(this, new AuthorizationCancelledEventArgs()
     {
         AuthzArgs = args,
         AuthzUri  = authzUri
     });
 }
 private void OnCancelled()
 {
     if (AcquiringUI.AreHardwareButtonsAvailable)
     {
         HardwareButtons.BackPressed -= OnBackPressed;
     }
     Cancelled?.Invoke();
 }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        protected virtual void OnCancelled()
        {
            count        = 0;
            previousTask = Task.FromResult(true);
            tokenSource  = new CancellationTokenSource();

            Cancelled?.Invoke(this, new EventArgs());
        }
Exemplo n.º 13
0
 private void _progressDialog_Cancelled(object sender, EventArgs e)
 {
     if (Cancelled != null)
     {
         Cancelled.Invoke(this, null);                 //REVIEW jh wesay
     }
     _currentCommand.Cancel();
 }
Exemplo n.º 14
0
        public async Task Cancel()
        {
            await Plugin.Geolocator.CrossGeolocator.Current.StopListeningAsync();

            await Reset();

            Cancelled?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 15
0
        /// <summary>
        ///    Cancels the FlightTask.
        /// </summary>
        public void Cancel()
        {
            Assert.AreEqual(State, FlightTaskState.Active, "Attempted to cancel inactive FlightTask.");

            State = FlightTaskState.Cancelled;
            Cancelled?.Invoke(this);

            Invalidate();
        }
Exemplo n.º 16
0
 public GamePlayEvents()
 {
     JobCancelled  = new Cancelled();
     JobDelivered  = new Delivered();
     FinedEvent    = new Fined();
     TollgateEvent = new Tollgate();
     TrainEvent    = new Transport();
     FerryEvent    = new Transport();
 }
Exemplo n.º 17
0
 private void bCancel_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to cancel?", "Cancel", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
     {
         bCancel.Enabled = false;
         this.Text       = "Cancelling...";
         Cancelled?.Invoke(this, new CancelEventArgs(true));
     }
 }
Exemplo n.º 18
0
        private void CancelBtn_Click(object sender, EventArgs e)
        {
            // Set some property values
            Cancelling        = true;
            labelContent.Text = "Aborting operation...";

            // Call cancel event
            Cancelled?.Invoke(this, null);
        }
Exemplo n.º 19
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (_possibleMultiJump)
     {
         MultiJumpCancelled?.Invoke();
     }
     else
     {
         Cancelled?.Invoke();
     }
 }
        public void Cancel()
        {
            if (Status == ProductSubscriptionStatus.Cancelled)
            {
                throw new ProductSubscriptionWasAlreadyCancelledException();
            }

            Status = ProductSubscriptionStatus.Cancelled;

            Cancelled?.Invoke(this, new ProductSubscriptionCancelledEventArgs());
        }
Exemplo n.º 21
0
        public IDownloadTask GetFetchEntriesSinceTask(DateTime startDate, CancellationToken cancellationToken)
        {
            var random       = new Random(DateTime.Now.Millisecond);
            var delay        = random.Next(0, 26) / 10d;
            var downloadTask = new MockDownloadTask(TimeSpan.FromSeconds(delay), startDate, posts => {
                Success?.Invoke(this, new ServerSuccessEventArgs(posts));
            }, () => {
                Cancelled?.Invoke(this, new EventArgs());
            }, cancellationToken);

            return(downloadTask);
        }
        public async void Cancel()
        {
            if (Busy)
            {
                return;
            }

            Busy = true;

            Cancelled?.Invoke(this, EventArgs.Empty);
            Device.StartTimer(TimeSpan.FromSeconds(1), Wait);
        }
Exemplo n.º 23
0
        private async void PointAnimation_Cancelled(object sender, EventArgs e)
        {
            try
            {
                await _calibrator.CancelAsync();
            }
            catch (Exception ex)
            {
                // TODO ex
            }

            Cancelled?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 24
0
        /// <summary>
        ///     CancelBlocker a task :
        ///     remove a task from either To do or in progress
        /// </summary>
        /// <param name="task"></param>
        public void Cancel(SymuTask task)
        {
            if (task == null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            if (!task.IsAssigned)
            {
                return;
            }

            var todo       = ToDo.Contains(task);
            var inProgress = InProgress.Contains(task);

            if (todo)
            {
                ToDo.Remove(task);
            }
            else if (inProgress)
            {
                InProgress.Remove(task);
            }
            else
            {
                return;
            }

            task.Cancel();
            if (_debug)
            {
                Cancelled.Add(task);
            }

            // We don't want to track message as Task
            if (task.Parent is Message)
            {
                return;
            }

            if (todo)
            {
                TaskResult.ToDo--;
            }
            else
            {
                TaskResult.InProgress--;
            }

            TaskResult.Cancelled++;
        }
Exemplo n.º 25
0
        private void SingleBasicConsumerCancelled(BasicConsumer consumer)
        {
            if (cancelledConsumer == null)
            {
                cancelledConsumer = new HashSet <BasicConsumer>();
            }
            cancelledConsumer.Add(consumer);

            if (cancelledConsumer.Count == basicConsumers.Count)
            {
                cancelledConsumer = null;
                Cancelled?.Invoke(this);
            }
        }
    public void should_add_slot_again_if_booking_was_cancelled()
    {
        var scheduled = new Scheduled(Guid.NewGuid().ToString(), _now, _tenMinutes);
        var booked    = new Booked(scheduled.SlotId, "patient-123");
        var cancelled = new Cancelled(scheduled.SlotId, "No longer needed");

        Given(scheduled, booked, cancelled);
        Then(
            new List <AvailableSlot> {
            new AvailableSlot(scheduled.SlotId, scheduled.StartTime, scheduled.Duration)
        },
            _repository.GetSlotsAvailableOn(_now.Date)
            );
    }
    [Fact] // empty
    public void should_return_a_slot_if_was_cancelled()
    {
        var scheduled = new Scheduled(Guid.NewGuid().ToString(), _now, _tenMinutes);
        var booked    = new Booked(scheduled.SlotId, _patientId);
        var cancelled = new Cancelled(scheduled.SlotId, "No longer needed");

        Given(scheduled, booked, cancelled);
        Then(
            new List <PatientSlot> {
            new PatientSlot(scheduled.SlotId, scheduled.StartTime, scheduled.Duration, "cancelled")
        },
            _repository.GetPatientSlots(_patientId)
            );
    }
Exemplo n.º 28
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (Class != null)
                {
                    hashCode = hashCode * 59 + Class.GetHashCode();
                }
                if (Actions != null)
                {
                    hashCode = hashCode * 59 + Actions.GetHashCode();
                }

                hashCode = hashCode * 59 + Blocked.GetHashCode();

                hashCode = hashCode * 59 + Buildable.GetHashCode();

                hashCode = hashCode * 59 + Id.GetHashCode();

                hashCode = hashCode * 59 + InQueueSince.GetHashCode();
                if (Params != null)
                {
                    hashCode = hashCode * 59 + Params.GetHashCode();
                }

                hashCode = hashCode * 59 + Stuck.GetHashCode();
                if (Task != null)
                {
                    hashCode = hashCode * 59 + Task.GetHashCode();
                }
                if (Url != null)
                {
                    hashCode = hashCode * 59 + Url.GetHashCode();
                }
                if (Why != null)
                {
                    hashCode = hashCode * 59 + Why.GetHashCode();
                }

                hashCode = hashCode * 59 + Cancelled.GetHashCode();
                if (Executable != null)
                {
                    hashCode = hashCode * 59 + Executable.GetHashCode();
                }
                return(hashCode);
            }
        }
Exemplo n.º 29
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            PlayerIndex playerIndex;

            if (menuSelect.Occurred(input, ControllingPlayer, out playerIndex))
            {
                Accepted?.Invoke(this, new PlayerIndexEventArgs(playerIndex));
                ExitScreen();
            }
            else if (menuCancel.Occurred(input, ControllingPlayer, out playerIndex))
            {
                Cancelled?.Invoke(this, new PlayerIndexEventArgs(playerIndex));
                ExitScreen();
            }
        }
Exemplo n.º 30
0
            public async Task EnactCommand(Order order, Cancel cancel)
            {
                var cancelled = new Cancelled();

                order.RecordEvent(cancelled);

                var command = new NotifyOrderCanceled
                {
                    OrderNumber = order.OrderNumber
                };

                await scheduler.Schedule(
                    order.CustomerId,
                    command,
                    deliveryDependsOn : cancelled);
            }