本文整理汇总了C#中IErrorService.ShowMessageBox方法的典型用法代码示例。如果您正苦于以下问题:C# IErrorService.ShowMessageBox方法的具体用法?C# IErrorService.ShowMessageBox怎么用?C# IErrorService.ShowMessageBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IErrorService
的用法示例。
在下文中一共展示了IErrorService.ShowMessageBox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsWritable
/// <summary>
/// Simple way of checking if a directory is writeable.
/// </summary>
/// <param name="dirPath">Path to check</param>
/// <param name="createDirectoryPrompt">
/// Prompt to create directory if it doesn't exist.
/// </param>
/// <param name="errorService">
/// An instance of the error service to allow prompting.
/// </param>
/// <returns>True if writable</returns>
public static bool IsWritable(string dirPath, bool createDirectoryPrompt, IErrorService errorService)
{
try
{
if (!Directory.Exists(dirPath))
{
MessageBoxResult result = errorService.ShowMessageBox(string.Format(Resources.DirectoryUtils_CreateFolderMsg, dirPath), Resources.DirectoryUtils_CreateFolder, MessageBoxButton.YesNo, MessageBoxImage.Question);
if (MessageBoxResult.Yes == result)
{
Directory.CreateDirectory(dirPath);
}
}
using (File.Create(Path.Combine(dirPath, Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose))
{
}
return true;
}
catch
{
return false;
}
}
示例2: RecoverQueue
/// <summary>
/// Recover a queue from file.
/// </summary>
/// <param name="encodeQueue">
/// The encode Queue.
/// </param>
/// <param name="errorService">
/// The error Service.
/// </param>
/// <returns>
/// The <see cref="bool"/>.
/// </returns>
public static bool RecoverQueue(IQueueProcessor encodeQueue, IErrorService errorService, bool silentRecovery)
{
string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
List<string> queueFiles = CheckQueueRecovery();
MessageBoxResult result = MessageBoxResult.None;
if (!silentRecovery)
{
if (queueFiles.Count == 1)
{
result =
errorService.ShowMessageBox(
"HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?",
"Queue Recovery Possible",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
}
else if (queueFiles.Count > 1)
{
result =
errorService.ShowMessageBox(
"HandBrake has detected multiple unfinished queue files. These will be from multiple instances of HandBrake running. Would you like to recover all unfinished jobs?",
"Queue Recovery Possible",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
}
}
else
{
result = MessageBoxResult.Yes;
}
if (result == MessageBoxResult.Yes)
{
bool isRecovered = false;
foreach (string file in queueFiles)
{
// Skip over the file if it belongs to another HandBrake instance.
Match m = Regex.Match(file, @"([0-9]+).xml");
if (m.Success)
{
int processId = int.Parse(m.Groups[1].ToString());
if (processId != GeneralUtilities.ProcessId && GeneralUtilities.IsPidACurrentHandBrakeInstance(processId))
{
continue;
}
}
// Recover the Queue
encodeQueue.RestoreQueue(appDataPath + file);
isRecovered = true;
// Cleanup
if (!file.Contains(GeneralUtilities.ProcessId.ToString(CultureInfo.InvariantCulture)))
{
try
{
// Once we load it in, remove it as we no longer need it.
File.Delete(Path.Combine(appDataPath, file));
}
catch (Exception)
{
// Keep quite, nothing much we can do if there are problems.
// We will continue processing files.
}
}
}
return isRecovered;
}
else
{
foreach (string file in queueFiles)
{
if (File.Exists(Path.Combine(appDataPath, file)))
{
// Check that the file doesn't belong to another running instance.
Match m = Regex.Match(file, @"([0-9]+).xml");
if (m.Success)
{
int processId = int.Parse(m.Groups[1].ToString());
if (GeneralUtilities.IsPidACurrentHandBrakeInstance(processId))
{
continue;
}
}
// Delete it if it doesn't
File.Delete(Path.Combine(appDataPath, file));
//.........这里部分代码省略.........
示例3: RecoverQueue
/// <summary>
/// Recover a queue from file.
/// </summary>
/// <param name="encodeQueue">
/// The encode Queue.
/// </param>
/// <param name="errorService">
/// The error Service.
/// </param>
public static void RecoverQueue(IQueueProcessor encodeQueue, IErrorService errorService)
{
string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
List<string> queueFiles = CheckQueueRecovery();
MessageBoxResult result = MessageBoxResult.None;
if (queueFiles.Count == 1)
{
result = errorService.ShowMessageBox(
"HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?",
"Queue Recovery Possible", MessageBoxButton.YesNo, MessageBoxImage.Question);
}
else if (queueFiles.Count > 1)
{
result = MessageBox.Show(
"HandBrake has detected multiple unfinished queue files. These will be from multiple instances of HandBrake running. Would you like to recover all unfinished jobs?",
"Queue Recovery Possible", MessageBoxButton.YesNo, MessageBoxImage.Question);
}
if (result == MessageBoxResult.Yes)
{
foreach (string file in queueFiles)
{
encodeQueue.QueueManager.RestoreQueue(appDataPath + file); // Start Recovery
}
}
else
{
if (GeneralUtilities.IsMultiInstance) return; // Don't tamper with the files if we are multi instance
foreach (string file in queueFiles)
{
if (File.Exists(Path.Combine(appDataPath, file)))
File.Delete(Path.Combine(appDataPath, file));
}
}
}