private void HandleCommandArgs(CommandEventArgs args)
        {
            switch (args.CommandName.ToLowerInvariant())
            {
            case "cancel":
                ModeChanging.InvokeAsync(new FormViewModeEventArgs()
                {
                    NewMode = DefaultMode
                }).GetAwaiter().GetResult();
                CurrentMode = DefaultMode;
                break;

            case "edit":
                ModeChanging.InvokeAsync(new FormViewModeEventArgs()
                {
                    NewMode = FormViewMode.Edit
                }).GetAwaiter().GetResult();
                CurrentMode = FormViewMode.Edit;
                break;

            case "delete":
                Exception caughtException = null;
                try {
                    OnItemDeleting.InvokeAsync(new FormViewDeleteEventArgs(Position)).GetAwaiter().GetResult();
                } catch (Exception ex) {
                    caughtException = ex;
                }
                // do we do the deletion?
                OnItemDeleted.InvokeAsync(new FormViewDeletedEventArgs(Position, caughtException)).GetAwaiter().GetResult();
                CurrentMode = DefaultMode;
                Position    = (Position == 0) ? 0 : Position - 1;
                break;

            case "insert":
                OnItemInserting.InvokeAsync(new FormViewInsertEventArgs("insert")
                {
                }).GetAwaiter().GetResult();
                ModeChanging.InvokeAsync(new FormViewModeEventArgs()
                {
                    NewMode = FormViewMode.Insert
                }).GetAwaiter().GetResult();
                OnItemInserted.InvokeAsync(new FormViewInsertEventArgs("insert")
                {
                }).GetAwaiter().GetResult();
                CurrentMode = FormViewMode.Insert;
                break;

            case "update":
                OnItemUpdating.InvokeAsync(new FormViewUpdateEventArgs("update")).GetAwaiter().GetResult();
                ModeChanging.InvokeAsync(new FormViewModeEventArgs()
                {
                    NewMode = DefaultMode
                }).GetAwaiter().GetResult();
                OnItemUpdated.InvokeAsync(new FormViewUpdatedEventArgs(0, null)).GetAwaiter().GetResult();
                CurrentMode = DefaultMode;
                break;
            }

            StateHasChanged();
        }
Beispiel #2
0
 public void OnListItemDelete()
 {
     if (m_ActiveFunctionJob.id > 0)
     {
         OnItemDeleted?.Invoke(m_ActiveFunctionJob);
     }
 }
Beispiel #3
0
        public async Task OnDeleteItem(Item item)
        {
            if (ConfirmDeleteFunction != null)
            {
                if (!await ConfirmDeleteFunction(item))
                {
                    return;
                }
            }

            else if (ConfirmDelete)
            {
                var result = await modalService.ShowDialogAsync(new Components.Modals.DialogOptions
                {
                    MainText     = "Are you sure you want to delete?",
                    IconElements = InternalIcons.Alert_triangle,
                    StatusColor  = TablerColor.Danger
                });

                if (!result)
                {
                    return;
                }
            }

            Items.Remove(item);
            await OnItemDeleted.InvokeAsync(item);

            await CloseEdit();
        }
        public async Task DeleteItem(Income item)
        {
            await Init();

            await database.DeleteAsync(item);

            OnItemDeleted?.Invoke(this, item);
        }
        public async Task DeleteItem(TodoItem item)
        {
            await CreateConnection();

            await connection.DeleteAsync(item);

            OnItemDeleted?.Invoke(this, item);
        }
        public async Task RemoveItem(HealtCareItem item)
        {
            await CreateConnection();

            await connection.DeleteAsync(item);

            OnItemDeleted?.Invoke(this, item);
        }
Beispiel #7
0
        public async Task OnDeleteItem(Item item)
        {
            //var result = await AppService.ShowDialog("", title: L.GetString(x => x.DeleteConfirmItem), DialogType.Warning);
            //if (result.Ok)
            //{
            Items.Remove(item);
            await OnItemDeleted.InvokeAsync(item);

            //}
            await CloseEdit();
        }
        public async Task DeleteItem(TodoItem item)
        {
            //throw new NotImplementedException();
            await CreateConnection();

            await connection.DeleteAsync(item);

            // After an item has been deleted from the table,
            // we invoke the OnItemDeleted event to notify any subscribers
            OnItemDeleted?.Invoke(this, item);
        }
        private void DeleteEntry()
        {
            var xml = new XmlSerializer(typeof(List <Security>));

            using (var file = File.Open(WatchListPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                var list = (List <Security>)xml.Deserialize(file);
                //remove from file
                list.RemoveWhere(sec => sec.Seccode == SelectedItem.Seccode && sec.Board == SelectedItem.Board);
                //and from table in memory
                SecList.Remove(SelectedItem);
                file.SetLength(0);
                xml.Serialize(file, list);
            }
            OnItemDeleted?.Invoke();
        }
        public void Delete()
        {
            if (selectedIndex == -1)
            {
                return;
            }

            int removalIndex = selectedIndex;

            selectedIndex = -1;
            Destroy(transform.GetChild(removalIndex).gameObject);
            T item = items[removalIndex];

            items.RemoveAt(removalIndex);
            DeleteItem(item);

            SubDelete(removalIndex, item);
            OnItemDeleted?.Invoke(removalIndex, item);
        }
Beispiel #11
0
 public static void InvokeOnItemDeleted(Item item)
 {
     OnItemDeleted?.Invoke(item);
 }
Beispiel #12
0
 private void UiNetTypeItemOnOnDeleteClicked(UIComponent component, int index)
 {
     OnItemDeleted?.Invoke(this, index);
 }
Beispiel #13
0
        public Library(Account accountViewModel)
        {
            this.accountViewModel = accountViewModel;
            Sort     = new Command <LibrarySort>(p => LibrarySort = p);
            Manage   = new Command(() => manage());
            Download = new Command <LibraryItem>(async p => await DownloadItem(p, true),
                                                 p => { return(p != null && !p.IsLocal && p.DownloadStatus != DownloadStatus.Downloading); });
            CancelDownload = new Command <LibraryItem>(p => cancelDownload(p),
                                                       p => { return(p != null && !p.IsLocal && p.DownloadStatus == DownloadStatus.Downloading); });
            Play = new Command <LibraryItem>(async p => await play(p),
                                             p => { return(p != null && (p.IsLocal || p.LocalItem != null)); });
            Delete = new Command <LibraryItem>(async p =>
            {
                if (p == null)
                {
                    return;
                }

                var message = string.Empty;
                if (p.IsLocal)
                {
                    message = "Are you sure you want to delete this recording from your device?" +
                              Environment.NewLine + "It is no longer available to download from the cloud.";
                    LibraryItem cloudRecording = null;
                    if (CloudItems != null)
                    {
                        cloudRecording = CloudItems.ToList().FirstOrDefault(c => c.ID == p.ID);
                    }

                    if (cloudRecording != null)
                    {
                        var timeLeft = cloudRecording.Expires.ToLocalTime().Subtract(DateTime.Now);
                        message      = "Are you sure you want to delete this recording from your device?" +
                                       Environment.NewLine + "You can download it again from the cloud within the next " +
                                       Math.Round(timeLeft.TotalDays) + " days.";
                    }
                }
                else
                {
                    message = "Are you sure you want to delete this recording from the cloud?" + Environment.NewLine +
                              "You will need to record it again to download and watch on any device.";
                    LibraryItem localRecording = null;
                    if (LocalItems != null)
                    {
                        localRecording = LocalItems.ToList().FirstOrDefault(l => l.ID == p.ID);
                    }

                    if (localRecording != null)
                    {
                        message = "Are you sure you want to delete this recording from the cloud?" +
                                  Environment.NewLine + "It will no longer be available for download on any device.";
                    }
                }

                if (await Application.Current.MainPage.DisplayAlert("Delete Recording", message, "Yes", "No"))
                {
                    try
                    {
                        CancelDownload?.Execute(p);

                        IsLoading = true;
                        if (!await delete(p))
                        {
                            await Application.Current.MainPage.DisplayAlert("Error Deleting",
                                                                            "Unable to delete the selected recording.", "OK");
                        }
                        else
                        {
                            OnItemDeleted?.Invoke(this, null);
                        }

                        IsLoading = false;
                    }
                    catch (Exception ex)
                    {
                        LoggerService.Instance.Log("ERROR: Library.DeleteCommand: " + ex);
                    }
                }
            },
                                               p => { return(p != null && p.Storage != LibraryItemStorage.iTunes); });

            DownloadChecked = new Command(async() => await downloadChecked(),
                                          () => { return(selectedView == LibraryViewMode.Cloud); });
            ManageDone    = new Command(() => manageDone());
            DeleteChecked = new Command(async() =>
            {
                IEnumerable <LibraryItem> items = null;
                if (selectedView == LibraryViewMode.Cloud)
                {
                    items = CloudItems.Where(l => l.Checked);
                }
                else
                {
                    items = LocalItems.Where(l => l.Checked);
                }

                if (items == null || !items.Any())
                {
                    await Application.Current.MainPage.DisplayAlert("Delete Recordings",
                                                                    "Please select one or more recordings to delete.", "OK");
                    return;
                }

                if (await Application.Current.MainPage.DisplayAlert("Delete Recordings",
                                                                    "Are you sure you want to delete the selected recordings?", "Yes", "No"))
                {
                    if (!await deleteMultipleItems(items.ToArray()))
                    {
                        await Application.Current.MainPage.DisplayAlert("Error Deleting",
                                                                        "Unable to delete all of the selected recordings.", "OK");
                    }
                }

                Edit = false;
            });

            RefreshCloudItems = new Command(async() =>
            {
                Edit = false;
                await getItems(true);
                try
                {
                    var clouds = cloudItems.ToList();
                    foreach (var cloudItem in clouds)
                    {
                        if (!string.IsNullOrEmpty(cloudItem.SmallThumbnailUri))
                        {
                            await ImageService.Instance.InvalidateCacheEntryAsync(cloudItem.SmallThumbnailUri,
                                                                                  CacheType.All);
                        }

                        if (!string.IsNullOrEmpty(cloudItem.LargeThumbnailUri))
                        {
                            await ImageService.Instance.InvalidateCacheEntryAsync(cloudItem.LargeThumbnailUri,
                                                                                  CacheType.All);
                        }

                        cloudItem.RefreshImages();
                    }
                }
                catch (Exception ex)
                {
                    //XXX : Handle error
                    LoggerService.Instance.Log("ERROR: Library.RefreshCloudItems: " + ex);
                }

                IsRefreshing = false;
            });

            RefreshLocalItems = new Command(async() =>
            {
                Edit = false;
                await updateLocalItems();
                IsRefreshing = false;
            });

            itemDownloader = ItemDownloaderService.Instance;
            itemDownloader.DownloadProgress += ItemDownloaderOnDownloadProgress;
            itemDownloader.DownloadComplete += ItemDownloaderOnDownloadComplete;
        }