/// <summary> /// Creates a new SystemDirectory object for the given directory path. /// </summary> public SystemDirectory(string pathToDirectory, Dispatcher dispatcher) { try { this.dispatcher = dispatcher; files = new InvokingObservableCollection <SystemFile>(this.dispatcher); DirectoryInfo = new DirectoryInfo(pathToDirectory); fileWatcher.IncludeSubdirectories = false; fileWatcher.Filter = ""; fileWatcher.NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName; createdHandler = new FileSystemEventHandler(fileWatcher_Created); deletedHandler = new FileSystemEventHandler(fileWatcher_Deleted); renamedHandler = new RenamedEventHandler(fileWatcher_Renamed); fileWatcher.Created += createdHandler; fileWatcher.Deleted += deletedHandler; fileWatcher.Renamed += renamedHandler; fileWatcher.EnableRaisingEvents = true; } catch (UnauthorizedAccessException) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Displays the Cairo Message Dialog with custom control, OK/Cancel buttons, implicit settings, custom image and button text. /// </summary> /// <param name="message">The message to display.</param> /// <param name="title">The title of the dialog.</param> /// <param name="image">The path to the image for the dialog.</param> /// <param name="control">The custom control to embed within the dialog.</param> /// <param name="OkButtonText">The text for the OK button.</param> /// <param name="CancelButtonText">The text for the cancel button.</param> /// <param name="resultCallback">The delegate to execute upon user action.</param> /// <returns>void</returns> public static void ShowControl(string message, string title, CairoMessageImage image, UserControl control, string OkButtonText, string CancelButtonText, DialogResultDelegate resultCallback) { if (string.IsNullOrEmpty(CancelButtonText)) { CancelButtonText = Localization.DisplayString.sInterface_Cancel; } if (string.IsNullOrEmpty(OkButtonText)) { OkButtonText = Localization.DisplayString.sInterface_OK; } CairoMessage msgDialog = new CairoMessage(); msgDialog.Message = message; msgDialog.Title = title; msgDialog.Buttons = MessageBoxButton.OKCancel; msgDialog.Image = image; msgDialog.ResultCallback = resultCallback; msgDialog.OkButton.Content = OkButtonText; msgDialog.CancelButton.Content = CancelButtonText; msgDialog.ContentPanel.Children.Add(control); control.Focus(); msgDialog.Show(); }
/// <summary> /// Displays the Cairo Message Dialog with OK/Cancel buttons, implicit settings, custom image and button text. /// </summary> /// <param name="message">The message to display.</param> /// <param name="title">The title of the dialog.</param> /// <param name="ImageSource">The path to the image for the dialog.</param> /// <param name="OkButtonText">The text for the OK button.</param> /// <param name="CancelButtonText">The text for the cancel button.</param> /// <returns>Nullable bool indicating the user response.</returns> public static bool?ShowOkCancel(string message, string title, string ImageSource, string OkButtonText, string CancelButtonText) { if (string.IsNullOrEmpty(CancelButtonText)) { CancelButtonText = "Cancel"; } if (string.IsNullOrEmpty(OkButtonText)) { OkButtonText = "OK"; } if (string.IsNullOrEmpty(ImageSource)) { ImageSource = "Resources/cairoIcon.png"; } CairoMessage msgDialog = new CairoMessage(); msgDialog.Message = message; msgDialog.Title = title; msgDialog.Buttons = MessageBoxButton.OKCancel; msgDialog.OkButton.Content = OkButtonText; msgDialog.CancelButton.Content = CancelButtonText; msgDialog.MessageIconImage.Source = new BitmapImage(new System.Uri(ImageSource, System.UriKind.RelativeOrAbsolute)); return(msgDialog.ShowDialog()); }
public static void Show(string message, string title, ImageSource imageSource, bool useShadow) { CairoMessage msgDialog = new CairoMessage { Message = message, Title = title, Buttons = MessageBoxButton.OK }; msgDialog.MessageIconImage.Source = imageSource; if (useShadow) { msgDialog.MessageIconImage.Effect = new DropShadowEffect { Color = Colors.Black, Direction = 270, ShadowDepth = 2, BlurRadius = 10, Opacity = 0.5 }; } msgDialog.Show(); }
public bool Rename(string newFilename) { try { InteractiveRenameRequested = false; // get the file attributes for file or directory FileAttributes attr = File.GetAttributes(FullName); string newFilePathName = Path.GetDirectoryName(FullName) + "\\" + newFilename; if (newFilePathName != FullName) { //detect whether its a directory or file if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { Directory.Move(FullName, newFilePathName); } else { File.Move(FullName, newFilePathName); } } return(true); } catch (Exception ex) { CairoMessage.Show("The file was unable to be renamed because: " + ex.Message, "Unable to rename", MessageBoxButton.OK, CairoMessageImage.Error); return(false); } }
public static bool RenameFile(string oldFilePathName, string newFilename) { try { // get the file attributes for file or directory FileAttributes attr = File.GetAttributes(oldFilePathName); string newFilePathName = Path.GetDirectoryName(oldFilePathName) + "\\" + newFilename; if (newFilePathName != oldFilePathName) { //detect whether its a directory or file if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { Directory.Move(oldFilePathName, newFilePathName); } else { File.Move(oldFilePathName, newFilePathName); } } return(true); } catch (Exception ex) { CairoMessage.Show("The file was unable to be renamed because: " + ex.Message, "Unable to rename", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); return(false); } }
private static void ShowActionConfirmation(string message, string title, string imageSource, string okButtonText, string cancelButtonText, Action systemAction) { bool?actionChoice = CairoMessage.ShowOkCancel(message, title, imageSource, okButtonText, cancelButtonText); if (actionChoice.HasValue && actionChoice.Value) { systemAction(); } }
/// <summary> /// Displays the Cairo Message Dialog with the default Ok/Cancel button and Icon. /// </summary> /// <param name="message">The message to display.</param> /// <param name="title">The title of the dialog.</param> /// <returns>Nullable bool indicating user response.</returns> public static bool?Show(string message, string title) { CairoMessage msgDialog = new CairoMessage(); msgDialog.Message = message; msgDialog.Title = title; msgDialog.Image = MessageBoxImage.None; msgDialog.Buttons = MessageBoxButton.OKCancel; return(msgDialog.ShowDialog()); }
/// <summary> /// Displays the Cairo Message Dialog with implicit settings. /// </summary> /// <param name="message">The message to display.</param> /// <param name="title">The title of the dialog.</param> /// <param name="buttons">The buttons configuration to use.</param> /// <param name="image">The image to display.</param> /// <returns>Nullable bool indicating user response.</returns> public static bool?Show(string message, string title, MessageBoxButton buttons, MessageBoxImage image) { CairoMessage msgDialog = new CairoMessage(); msgDialog.Message = message; msgDialog.Title = title; msgDialog.Image = image; msgDialog.Buttons = buttons; return(msgDialog.ShowDialog()); }
private static void ShowActionConfirmation(string message, string title, CairoMessageImage image, string okButtonText, string cancelButtonText, Action systemAction) { CairoMessage.ShowOkCancel(message, title, image, okButtonText, cancelButtonText, result => { if (result == true) { systemAction(); } }); }
/// <summary> /// Displays the Cairo Message Dialog with implicit settings. /// </summary> /// <param name="message">The message to display.</param> /// <param name="title">The title of the dialog.</param> /// <param name="buttons">The buttons configuration to use.</param> /// <param name="image">The image to display.</param> /// <param name="resultCallback">The delegate to execute upon user action.</param> /// <returns>void</returns> public static void Show(string message, string title, MessageBoxButton buttons, CairoMessageImage image, DialogResultDelegate resultCallback) { CairoMessage msgDialog = new CairoMessage { Message = message, Title = title, Image = image, Buttons = buttons, ResultCallback = resultCallback }; msgDialog.Show(); }
public static void ShowAlert(string message, string title, MessageBoxImage image) { CairoMessage msgDialog = new CairoMessage(); msgDialog.Message = message; msgDialog.Title = title; msgDialog.Image = image; msgDialog.Buttons = MessageBoxButton.OK; msgDialog.Show(); return; }
/// <summary> /// Creates a new SystemDirectory object for the given directory path. /// </summary> public SystemDirectory(string pathToDirectory, Dispatcher dispatcher, bool isAsync = true) { try { this.dispatcher = dispatcher; initAsync = isAsync; DirectoryInfo = new DirectoryInfo(pathToDirectory); fileOperationWorker.DoWork += fileOperationWorker_DoWork; } catch (UnauthorizedAccessException) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } }
/// <summary> /// Displays the Cairo Message Dialog with custom control, OK/Cancel buttons, implicit settings, custom image and button text. /// </summary> /// <param name="message">The message to display.</param> /// <param name="title">The title of the dialog.</param> /// <param name="imageSource">The image source to display.</param> /// <param name="useShadow">Enable a drop shadow if the image may blend with the background.</param> /// <param name="control">The custom control to embed within the dialog.</param> /// <param name="OkButtonText">The text for the OK button.</param> /// <param name="CancelButtonText">The text for the cancel button.</param> /// <param name="resultCallback">The delegate to execute upon user action.</param> /// <returns>void</returns> public static void ShowControl(string message, string title, ImageSource imageSource, bool useShadow, UserControl control, string OkButtonText, string CancelButtonText, DialogResultDelegate resultCallback) { if (string.IsNullOrEmpty(CancelButtonText)) { CancelButtonText = Localization.DisplayString.sInterface_Cancel; } if (string.IsNullOrEmpty(OkButtonText)) { OkButtonText = Localization.DisplayString.sInterface_OK; } CairoMessage msgDialog = new CairoMessage(); msgDialog.Message = message; msgDialog.Title = title; msgDialog.Buttons = MessageBoxButton.OKCancel; msgDialog.MessageIconImage.Source = imageSource; if (useShadow) { msgDialog.MessageIconImage.Effect = new DropShadowEffect { Color = Colors.Black, Direction = 270, ShadowDepth = 2, BlurRadius = 10, Opacity = 0.5 }; } msgDialog.ResultCallback = resultCallback; msgDialog.OkButton.Content = OkButtonText; msgDialog.CancelButton.Content = CancelButtonText; msgDialog.ContentPanel.Children.Add(control); control.Focus(); msgDialog.Show(); }