Example #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource is Button button)
            {
                switch (button.Name)
                {
                case "buttonEdit":
                    EditCommand?.Execute(null);
                    break;

                case "buttonDelete":
                    DeleteCommand?.Execute(null);
                    break;

                case "buttonCancel":
                    CancelCommand?.Execute(null);
                    break;

                case "buttonSave":
                    SaveCommand?.Execute(null);
                    break;

                case "buttonAdd":
                    AddCommand?.Execute(null);
                    break;
                }
            }
        }
        private async Task LoadChromecasts()
        {
            try
            {
                LoadingChromecasts = true;
                var ip = LocalIPAddress().ToString();
                var foundChromecasts = await _chromecastService.StartLocatingDevices(ip);

                foreach (var foundChromecast in foundChromecasts)
                {
                    Chromecasts.Add(foundChromecast);
                }

                LoadingChromecasts = false;
                AnyChromecast      = Chromecasts.Any();
            }
            catch (Exception ex)
            {
                LoadingChromecasts = false;
                AnyChromecast      = false;
                Logger.Error(ex);
                Messenger.Default.Send(
                    new UnhandledExceptionMessage(
                        new PopcornException(LocalizationProviderHelper.GetLocalizedValue <string>("CastFailed"))));
                CancelCommand.Execute(null);
                CloseCommand.Execute(null);
            }
        }
        protected async void OnOkCommand()
        {
            try
            {
                await _SemaphoreSlimOnOkCommand.WaitAsync();

                UpdateOptionSettings();
                _loggerService?.LogEvent(nameof(OnOkCommand));
                ImageAction Action      = OverwriteFiles ? ImageAction.Save : ImageAction.SaveAs;
                bool        successfull = await ResizeImages(Action);

                if (successfull && _localSettings.Settings.ClearImageListAfterSuccess && ImageFiles?.Count != 0)
                {
                    CancelCommand?.Execute(ImageFiles);
                }
                //if the app was started from command line exit the app after resize
                if (AppStartType.CommandLine.Equals(_appStartType))
                {
                    _applicationService.Exit();
                }
            }
            catch (Exception e)
            {
                _loggerService?.LogException(nameof(OnOkCommand), e);
            }
            finally
            {
                _SemaphoreSlimOnOkCommand.Release();
            }
        }
 private void SaveAction(object obj)
 {
     try
     {
         if (this.context.Save(Selected))
         {
             if (Message.QuestionYesNo("Data Berhasil Disimpan, Print Faktur ?"))
             {
                 Selected.NamaCustomer = Selected.Customer.NamaCustomer;
                 Selected.KodeCustomer = Selected.Customer.KodeCustomer;
                 var layout = "MainApp.Reports.Layouts.FakturPernjualan.rdlc";
                 if (Selected.Pembayaran == StatusPembayaran.Kredit)
                 {
                     layout = "MainApp.Reports.Layouts.FakturPernjualanKredit.rdlc";
                 }
                 HelperPrint.PrintWithFormActionTwoSource("Print Preview",
                                                          new ReportDataSource {
                     Name = "Header", Value = new List <Penjualan> {
                         Selected
                     }
                 },
                                                          new ReportDataSource {
                     Name = "DataSet1", Value = Selected.Details.ToList()
                 },
                                                          layout, null);
             }
             BarangSourceView.Refresh();
             CancelCommand.Execute(null);
         }
     }
     catch (Exception ex)
     {
         Message.Error(ex.Message);
     }
 }
        public DownloadingViewModel(IUnityContainer container) : base(container)
        {
            PauseAllCommand = new RelayCommand(() =>
            {
                foreach (var task in TransferTasks)
                {
                    if (PauseCommand.CanExecute(task))
                    {
                        PauseCommand.Execute(task);
                    }
                }
            },
                                               () => TransferTasks?.Any() ?? false);

            CancelAllCommand = new RelayCommand(() =>
            {
                foreach (var task in TransferTasks)
                {
                    if (CancelCommand.CanExecute(task))
                    {
                        CancelCommand.Execute(task);
                    }
                }
            },
                                                () => TransferTasks?.Any() ?? false);
        }
Example #6
0
 private void Cancel()
 {
     if (CancelCommand != null)
     {
         CancelCommand.Execute(new object());
     }
 }
Example #7
0
 private void maininput_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.Escape)
         {
             if (string.IsNullOrEmpty(maininput.Text))
             {
                 if (CancelCommand != null)
                 {
                     CancelCommand.Execute(null);
                 }
             }
             else
             {
                 SearchText = "";
                 e.Handled  = true;
             }
         }
         if (e.Key == Key.Enter)
         {
             if (AcceptCommand != null)
             {
                 AcceptCommand.Execute(maininput.Text);
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex);
     }
 }
        public void AddToCart()
        {
            if (_navigationService.HostScreen.CurrentUser != null)
            {
                if (CurrentUserCard != null && CurrentUserCard.Activated != false)
                {
                    ILoansService _loans = IoC.ServiceProvider.GetService <ILoansService>();

                    _loans.LoanCart.Add(currentBook);
                    _dialog.Alert("Varukorg", $"Tillagd i varukorgen");
                    if (currentBook.Category == 1)
                    {
                        currentBook.Quantity--;
                    }

                    CancelCommand.Execute(null);
                }
                else
                {
                    _dialog.Alert("Lånekort", "Du har inget Lånekort registrerat eller aktiverat \nVänligen kontakta personalen");
                }
            }
            else
            {
                _dialog.Alert("Login", "Vänligen logga in för att låna");
            }
        }
Example #9
0
 /// <summary>
 /// Requests cancellation of the command.
 /// </summary>
 public void Cancel()
 {
     if (CancelCommand.CanExecute())
     {
         CancelCommand.Execute();
     }
 }
        private async void DoLogin()
        {
            if (string.IsNullOrWhiteSpace(Login) || string.IsNullOrWhiteSpace(Password))
            {
                return;
            }

            IsWorking = true;
            CanLogin  = false;

            try
            {
                await AccountManager.LoginLastFm(Login, Password);

                CancelCommand.Execute(null);
            }
            catch (LastFmLoginException ex)
            {
                LoggingService.Log(ex.ToString());

                LoginError = ErrorResources.LoginErrorInvalidClient;
                CanLogin   = true;
                IsWorking  = false;
            }
            catch (Exception ex)
            {
                LoggingService.Log(ex.ToString());

                CanLogin  = true;
                IsWorking = false;
            }
        }
Example #11
0
 private void OnClosing(object sender, CancelEventArgs e)
 {
     if (!Cancelled && Operation != Operation.Help)
     {
         CancelCommand.Execute(null);
         e.Cancel = !Cancelled;
     }
 }
 private void OnCancel(object sender, EventArgs e)
 {
     Text = null;
     ResignFirstResponder();
     if (CancelCommand != null)
     {
         CancelCommand.Execute(null);
     }
 }
Example #13
0
        private async Task DeletePayment()
        {
            await paymentService.DeletePayment(SelectedPayment);

#pragma warning disable 4014
            backupService.EnqueueBackupTask();
#pragma warning restore 4014
            CancelCommand.Execute(null);
        }
Example #14
0
        public void Cancel()
        {
            if (CancelCommand != null)
            {
                CancelCommand.Execute(new object());
            }

            RaiseCanceledEvent();
        }
        private void Cancel_Internal()
        {
            if (CancelCommand?.CanExecute(null) ?? false)
            {
                CancelCommand.Execute(null);
            }

            Cancel();
        }
Example #16
0
 private void StopOtherWork()
 {
     lock (this) {
         if (_isInProcess)
         {
             CancelCommand.Execute();
         }
         _isInProcess = true;
     }
     _currenTokenSource = new CancellationTokenSource();
 }
        protected override async Task SaveAccount()
        {
            await crudServices.UpdateAndSaveAsync(SelectedAccount);

            if (!crudServices.IsValid)
            {
                await dialogService.ShowMessage(Strings.GeneralErrorTitle, crudServices.GetAllErrors());
            }

            CancelCommand.Execute(null);
        }
        async Task CreateAccount()
        {
            var content = new StringContent(JsonConvert.SerializeObject(User));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var response = await client.PostAsync("https://localhost:44347/api/User", content);

            if (response.IsSuccessStatusCode)
            {
                CancelCommand.Execute(null);
            }
        }
Example #19
0
 private void ExecuteCancelWizard()
 {
     RaiseRoutedEvent(Wizard.CancelEvent);
     if (CancelCommand?.CanExecute(CanCancel) == true)
     {
         CancelCommand?.Execute(CanCancel);
     }
     if (CancelButtonClosesWindow)
     {
         CloseParentWindow(false);
     }
 }
 private void CancelClick(object sender, RoutedEventArgs e)
 {
     if (CancelCommand != null)
     {
         CancelCommand.Execute(null);
     }
     else
     {
         DialogResult = false;
         Close();
     }
 }
Example #21
0
        public void QueueCancel_Execute_ReturnsNotFoundMessage()
        {
            var command = new CancelCommand(_console, LoggerMock.GetLogger <CancelCommand>().Object, _projectService.Object, _jobDefinitionService.Object, _jobQueueService.Object)
            {
                Project = "Project 1",
                Number  = "2"
            };

            var resultMessage = command.Execute();

            Assert.Equal("Failed to cancel queue 2. Make sure the project name and queue number are correct.", resultMessage);
        }
Example #22
0
        public void QueueCancel_Execute_CannotCancel()
        {
            var command = new CancelCommand(_console, LoggerMock.GetLogger <CancelCommand>().Object, _projectService.Object, _jobDefinitionService.Object, _jobQueueService.Object)
            {
                Project = "Project 1",
                Number  = "1"
            };

            var resultMessage = command.Execute();

            Assert.Equal("Cannot cancel queue 1 with status QUEUED", resultMessage);
        }
Example #23
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (_result == MessageBoxResult.OK || _result == MessageBoxResult.Yes)
            {
                ConfirmCommand?.Execute(e);
            }
            else if (_result == MessageBoxResult.Cancel)//alt +f4 && close button && cancel button 고로 취소 버튼 외의 것 에서 취소를 할 때에 대한 확인 작업 필요
            {
                CancelCommand?.Execute(e);
            }

            base.OnClosing(e);
        }
 private void CancelButton_Clicked(object sender, EventArgs e)
 {
     if (CancelCommand == null)
     {
         this.Hide();
     }
     else
     {
         if (CancelCommand.CanExecute(null))
         {
             CancelCommand.Execute(null);
         }
     }
 }
Example #25
0
        private void CancelClick(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToState(this, "ReadyState", true);

            foreach (var editableItemsControl in _containedEditableItemsControls)
            {
                editableItemsControl.AddingItem = Activator.CreateInstance(editableItemsControl.AddingItem.GetType());
            }

            if (CancelCommand != null && CancelCommand.CanExecute(Content))
            {
                CancelCommand.Execute(Content);
            }
        }
        public void Cancellation()
        {
            DelayAsyncCommand mainCommand   = new DelayAsyncCommand();
            CancelCommand     cancelCommand = new CancelCommand(mainCommand);

            mainCommand.Execute();
            Assert.AreEqual(true, mainCommand.IsRunning);
            Assert.AreEqual(true, mainCommand.IsPhase1Reached);

            cancelCommand.Execute();
            Thread.Sleep(10000);

            Assert.AreEqual(false, mainCommand.IsRunning);
            Assert.AreEqual(false, mainCommand.IsPhase2Reached);
        }
Example #27
0
 private void mainpanel_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         UIElement element = EditFields.LastOrDefault() as UIElement;
         if (SubmitCommand != null && element != null && (element.IsFocused || element.IsKeyboardFocused || element.IsKeyboardFocusWithin))
         {
             SubmitCommand.Execute(EditFields);
         }
     }
     else if (e.Key == Key.Escape)
     {
         CancelCommand.Execute(null);
     }
 }
        public ConfirmIdentityDialog(MessageRecord record)
        {
            this.InitializeComponent();
            this._messageRecord = record;

            if (record.MismatchedIdentities == null)
            {
                CancelCommand.Execute(null);
            }

            if (record.MismatchedIdentities != null)
            {
                mismatch = record.MismatchedIdentities[0];
            }
        }
Example #29
0
        /// <summary>
        /// Cancels the current changes in the TextBox.
        /// </summary>
        public void Cancel()
        {
            BindingExpression expression = GetBindingExpression(TextProperty);
            if (expression != null)
                expression.UpdateTarget();

            ClearUndoStack();

            var cancelledArgs = new RoutedEventArgs(CancelledEvent);
            OnCancelled();
            RaiseEvent(cancelledArgs);

            if (CancelCommand != null && CancelCommand.CanExecute(CancelCommandParameter))
                CancelCommand.Execute(CancelCommandParameter);
        }
Example #30
0
 private void SaveAction(object obj)
 {
     try
     {
         if (this.barangContext.Save(Selected))
         {
             Message.Info("Data Berhasil Disimpan");
             BarangSourceView.Refresh();
             CancelCommand.Execute(null);
         }
     }
     catch (Exception ex)
     {
         Message.Error(ex.Message);
     }
 }