Example #1
0
        /// <summary>
        /// Method to invoke when the OpenRecentlyUsedItem command is executed.
        /// </summary>
        private async Task OnOpenRecentlyUsedItemExecuteAsync(string parameter)
        {
            var failed = false;

            try
            {
                // TODO replace following line with actual load logic
                failed = !_fileService.Exists(parameter);
            }
            catch (Exception)
            {
                failed = true;
            }

            if (failed)
            {
                if (await _messageService.ShowAsync("The file does not exist or has been removed. Would you like to remove it from the recently used list?", "Remove from recently used items?", MessageButton.YesNo) == MessageResult.Yes)
                {
                    var recentlyUsedItem = _recentlyUsedItemsService.Items.FirstOrDefault(x => string.Equals(x.Name, parameter));
                    if (recentlyUsedItem != null)
                    {
                        _recentlyUsedItemsService.RemoveItem(recentlyUsedItem);
                    }
                }
            }
        }
Example #2
0
 protected override void Execute(object parameter)
 {
     try
     {
         var projectToDel = _recentlyUsedItemsService.Items.Items
                            .FirstOrDefault(project => project.Name == parameter?.ToString());
         if (projectToDel != null)
         {
             _recentlyUsedItemsService.RemoveItem(projectToDel);
         }
     }
     catch (Exception ex)
     {
         _loggerService.LogString(ex.Message, Logtype.Error);
         _loggerService.LogString("Failed to delete recent project", Logtype.Error);
     }
 }
Example #3
0
 private void DeleteProject(string parameter)
 {
     try
     {
         var projectToDel = _recentlyUsedItemsService.Items.Items
                            .FirstOrDefault(project => project.Name == parameter);
         if (projectToDel != null)
         {
             _recentlyUsedItemsService.RemoveItem(projectToDel);
         }
     }
     catch (Exception ex)
     {
         _loggerService.Error(ex.Message);
         _loggerService.Error("Failed to delete recent project");
     }
 }