コード例 #1
0
        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();
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
        /// <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();
        }
コード例 #4
0
ファイル: SystemFile.cs プロジェクト: rglamazda/cairoshell
        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);
            }
        }
コード例 #5
0
ファイル: SystemFile.cs プロジェクト: tufan2005/cairoshell
        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);
            }
        }
コード例 #6
0
        /// <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();
        }
コード例 #7
0
        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;
        }
コード例 #8
0
        /// <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);
            }
        }
コード例 #9
0
        /// <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();
        }