public override async Task <bool> SaveChangesAsync(ListedItem item)
        {
            while (true)
            {
                using DynamicDialog dialog = DynamicDialogFactory.GetFor_PropertySaveErrorDialog();
                try
                {
                    if (BaseProperties is FileProperties fileProps)
                    {
                        await fileProps.SyncPropertyChangesAsync();
                    }
                    return(true);
                }
                catch
                {
                    await dialog.TryShowAsync();

                    switch (dialog.DynamicResult)
                    {
                    case DynamicDialogResult.Primary:
                        break;

                    case DynamicDialogResult.Secondary:
                        return(true);

                    case DynamicDialogResult.Cancel:
                        return(false);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Tries to save changed properties to file.
        /// </summary>
        /// <returns>Returns true if properties have been saved successfully.</returns>
        public async Task <bool> SaveChangesAsync()
        {
            while (true)
            {
                using DynamicDialog dialog = DynamicDialogFactory.GetFor_PropertySaveErrorDialog();
                try
                {
                    await(BaseProperties as FileProperties).SyncPropertyChangesAsync();
                    return(true);
                }
                catch
                {
                    await dialog.ShowAsync();

                    switch (dialog.DynamicResult)
                    {
                    case DynamicDialogResult.Primary:
                        break;

                    case DynamicDialogResult.Secondary:
                        return(true);

                    case DynamicDialogResult.Cancel:
                        return(false);
                    }
                }

                // Wait for the current dialog to be closed before continuing the loop
                // and opening another dialog (attempting to open more than one ContentDialog
                // at a time will throw an error)
                while (dialog.IsLoaded)
                {
                }
            }
        }
        /// <summary>
        /// Tries to save changed properties to file.
        /// </summary>
        /// <returns>Returns true if properties have been saved successfully.</returns>
        public async Task <bool> SaveChangesAsync()
        {
            while (true)
            {
                using DynamicDialog dialog = DynamicDialogFactory.GetFor_PropertySaveErrorDialog();
                try
                {
                    await(BaseProperties as FileProperties).SyncPropertyChangesAsync();
                    return(true);
                }
                catch
                {
                    // Attempting to open more than one ContentDialog
                    // at a time will throw an error)
                    if (UIHelpers.IsAnyContentDialogOpen())
                    {
                        return(false);
                    }
                    await dialog.ShowAsync();

                    switch (dialog.DynamicResult)
                    {
                    case DynamicDialogResult.Primary:
                        break;

                    case DynamicDialogResult.Secondary:
                        return(true);

                    case DynamicDialogResult.Cancel:
                        return(false);
                    }
                }
            }
        }
Exemple #4
0
 private async void RecentFilesWidget_RecentFileInvoked(object sender, UserControls.PathNavigationEventArgs e)
 {
     try
     {
         var directoryName = Path.GetDirectoryName(e.ItemPath);
         await AppInstance.InteractionOperations.InvokeWin32ComponentAsync(e.ItemPath, workingDir : directoryName);
     }
     catch (UnauthorizedAccessException)
     {
         DynamicDialog dialog = DynamicDialogFactory.GetFor_ConsentDialog();
         await dialog.ShowAsync();
     }
     catch (ArgumentException)
     {
         if (new DirectoryInfo(e.ItemPath).Root.ToString().Contains(@"C:\"))
         {
             AppInstance.ContentFrame.Navigate(FolderSettings.GetLayoutType(e.ItemPath), new NavigationArguments()
             {
                 AssociatedTabInstance = AppInstance,
                 NavPathParam          = e.ItemPath
             });
         }
         else
         {
             foreach (DriveItem drive in Enumerable.Concat(App.DrivesManager.Drives, AppSettings.CloudDrivesManager.Drives))
             {
                 if (drive.Path.ToString() == new DirectoryInfo(e.ItemPath).Root.ToString())
                 {
                     AppInstance.ContentFrame.Navigate(FolderSettings.GetLayoutType(e.ItemPath), new NavigationArguments()
                     {
                         AssociatedTabInstance = AppInstance,
                         NavPathParam          = e.ItemPath
                     });
                     return;
                 }
             }
         }
     }
     catch (COMException)
     {
         await DialogDisplayHelper.ShowDialogAsync(
             "DriveUnpluggedDialog/Title".GetLocalized(),
             "DriveUnpluggedDialog/Text".GetLocalized());
     }
 }