/// <summary> /// Launches the FileManager specified in the application Settings object to the specified directory. /// </summary> /// <param name="directoryPath">Directory to open.</param> private void openDir(String directoryPath) { if (!Interop.Shell.StartProcess(Environment.ExpandEnvironmentVariables(Settings.FileManager), "\"" + directoryPath + "\"")) { CairoMessage.Show("Unable to open the file browser.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnUninstallApps_Click(object sender, RoutedEventArgs e) { if (!ShellHelper.StartProcess("appwiz.cpl")) { CairoMessage.Show(DisplayString.sError_CantOpenAppWiz, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } }
private void Icon_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { Icon icon = sender as Icon; if (icon == null || icon.IsRenaming) { return; } e.Handled = true; ShellFile file = icon.DataContext as ShellFile; if (file == null || string.IsNullOrWhiteSpace(file.Path)) { CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); return; } if (!InvokeContextMenu(file, false)) { CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } }
private void LaunchProgramAdmin(object sender, RoutedEventArgs e) { MenuItem item = (MenuItem)sender; ApplicationInfo app = item.DataContext as ApplicationInfo; if (!app.IsStoreApp) { if (!app.AlwaysAdmin) { if (app.AskAlwaysAdmin) { app.AskAlwaysAdmin = false; bool?always = CairoMessage.Show("You've run " + app.Name + " as an administrator before. Would you like Cairo to automatically run it as an administrator every time?", "Always run as administrator?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (always == true) { app.AlwaysAdmin = true; } } else { app.AskAlwaysAdmin = true; } appGrabber.Save(); } Shell.StartProcess(app.Path, "", "runas"); } else { LaunchProgram(sender, e); } }
private void txtRename_LostKeyboardFocus(object sender, RoutedEventArgs e) { TextBox box = sender as TextBox; if (box == null || file == null) { return; } try { file.Rename(box.Text); } catch (Exception exception) { box.Text = file.FileName; CairoMessage.Show("The file was unable to be renamed because: " + exception.Message, "Unable to rename", MessageBoxButton.OK, CairoMessageImage.Error); } foreach (UIElement peer in (box.Parent as DockPanel).Children) { if (peer is Border) { peer.Visibility = Visibility.Visible; } } box.Visibility = Visibility.Collapsed; IsRenaming = false; }
private void btnUninstallApps_Click(object sender, RoutedEventArgs e) { if (!Interop.Shell.StartProcess("appwiz.cpl")) { CairoMessage.Show(Localization.DisplayString.sError_CantOpenAppWiz, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Checks that a single instance of the application is running, and if another is found it notifies the user and exits. /// </summary> /// <returns>Result of instance check.</returns> private static bool SingleInstanceCheck() { // get the list of all processes by that name Process[] processes = Process.GetProcessesByName(procName); // if there is more than one process... if (processes.Length > 1) { System.Threading.Thread.Sleep(1000); Process[] processes2 = Process.GetProcessesByName(procName); if (processes2.Length > 1) { System.Threading.Thread.Sleep(3000); Process[] processes3 = Process.GetProcessesByName(procName); if (processes3.Length > 1) { CairoMessage.ShowAlert("If it's not responding, end it from Task Manager before trying to run Cairo again.", "Cairo is already running!", MessageBoxImage.Stop); return(false); } else { return(true); } } else { return(true); } } else { return(true); } }
/// <summary> /// Launches the FileManager specified in the application Settings object to the specified directory. /// </summary> /// <param name="directoryPath">Directory to open.</param> private void openDir(string directoryPath, bool openWithShell) { if ((!openWithShell && !FolderHelper.OpenLocation(directoryPath)) || (openWithShell && !FolderHelper.OpenWithShell(directoryPath))) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Launches the FileManager specified in the application Settings object to the specified directory. /// </summary> /// <param name="directoryPath">Directory to open.</param> /// <param name="alwaysOpenWithShell">If true, user preferences will not be honored and the shell will always be used to open the directory.</param> internal void OpenDir(string directoryPath, bool alwaysOpenWithShell) { if ((!alwaysOpenWithShell && !FolderHelper.OpenLocation(directoryPath)) || (alwaysOpenWithShell && !FolderHelper.OpenWithShell(directoryPath))) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } }
/// <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()); }
private void btnUninstallApps_Click(object sender, RoutedEventArgs e) { if (!Interop.Shell.StartProcess("appwiz.cpl")) { CairoMessage.Show("Unable to open the Programs and Features control panel.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void miProgramsAddCategory_Click(object sender, RoutedEventArgs e) { MenuItem mi = sender as MenuItem; ApplicationInfo ai = mi.DataContext as ApplicationInfo; Common.MessageControls.Input inputControl = new Common.MessageControls.Input(); inputControl.Initialize(DisplayString.sAppGrabber_Untitled); CairoMessage.ShowControl(DisplayString.sProgramsMenu_AddCategoryInfo, DisplayString.sProgramsMenu_AddCategoryTitle, CairoMessageImage.Default, inputControl, DisplayString.sInterface_OK, DisplayString.sInterface_Cancel, (bool?result) => { if (result == true) { Category newCat = new Category(inputControl.Text); MenuBar._appGrabber.CategoryList.Add(newCat); ai.Category.Remove(ai); newCat.Add(ai); MenuBar._appGrabber.Save(); } MenuBar.ProgramsMenu.IsSubmenuOpen = true; }); }
/// <summary> /// Launches the FileManager specified in the application Settings object to the specified directory. /// </summary> /// <param name="directoryPath">Directory to open.</param> private void openDir(String directoryPath) { if (!FolderHelper.OpenLocation(directoryPath)) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void miPersonalization_Click(object sender, RoutedEventArgs e) { // doesn't work because Settings app requires Explorer :( if (!Shell.StartProcess("desk.cpl")) { CairoMessage.Show("Unable to open the Display control panel.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void cboLangSelect_DropDownClosed(object sender, EventArgs e) { if (Settings.Instance.Language != _language) { CairoMessage.Show(DisplayString.sWelcome_ChangingLanguageText, DisplayString.sWelcome_ChangingLanguage, MessageBoxButton.OK, MessageBoxImage.Information); Startup.Restart(); } }
private void OpenCloseCairoBox(object sender, RoutedEventArgs e) { bool?CloseCairoChoice = CairoMessage.ShowOkCancel("You will need to reboot or use the start menu shortcut in order to run Cairo again.", "Are you sure you want to exit Cairo?", "Resources/exitIcon.png", "Exit Cairo", "Cancel"); if (CloseCairoChoice.HasValue && CloseCairoChoice.Value) { shutdown(); } }
private void OpenShutDownBox(object sender, RoutedEventArgs e) { bool?ShutdownChoice = CairoMessage.ShowOkCancel("You will lose all unsaved documents and your computer will turn off.", "Are you sure you want to shut down now?", "Resources/shutdownIcon.png", "Shut Down", "Cancel"); if (ShutdownChoice.HasValue && ShutdownChoice.Value) { NativeMethods.Shutdown(); } }
private void OpenRebootBox(object sender, RoutedEventArgs e) { bool?RebootChoice = CairoMessage.ShowOkCancel("You will lose all unsaved documents and your computer will restart.", "Are you sure you want to restart now?", "Resources/restartIcon.png", "Restart", "Cancel"); if (RebootChoice.HasValue && RebootChoice.Value) { NativeMethods.Reboot(); } }
private void btnFile_Click(object sender, RoutedEventArgs e) { Button senderButton = sender as Button; if (senderButton != null && senderButton.CommandParameter != null) { string commandString = senderButton.CommandParameter as String; if (!string.IsNullOrWhiteSpace(commandString)) { // Determine if [SHIFT] key is held. Bypass Directory Processing, which will use the Shell to open the item. if (!KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey)) { // get the file attributes for file or directory FileAttributes attr = File.GetAttributes(commandString); bool isDirectory = (attr & FileAttributes.Directory) == FileAttributes.Directory; // if directory, perform special handling if (isDirectory && Settings.EnableDynamicDesktop && Window.GetWindow(senderButton)?.Name == "CairoDesktopWindow" && Startup.DesktopWindow != null) { Startup.DesktopWindow.Navigate(commandString); return; } else if (isDirectory) { FolderHelper.OpenLocation(commandString); return; } } System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.UseShellExecute = true; proc.StartInfo.FileName = commandString; if (Startup.DesktopWindow != null) { Startup.DesktopWindow.IsOverlayOpen = false; } try { proc.Start(); return; } catch { // No 'Open' command associated with this filetype in the registry Interop.Shell.ShowOpenWithDialog(proc.StartInfo.FileName); return; } } } CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); }
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(); } }
public void ExecuteOpenSearchResult(object sender, ExecutedRoutedEventArgs e) { var searchObj = (VistaSearchProvider.SearchResult)e.Parameter; if (!Shell.StartProcess(searchObj.Path)) { CairoMessage.Show("We were unable to open the search result.", "Uh Oh!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void OpenLogoffBox(object sender, RoutedEventArgs e) { bool?LogoffChoice = CairoMessage.ShowOkCancel("You will lose all unsaved documents and be logged off.", "Are you sure you want to log off now?", "Resources/logoffIcon.png", "Log Off", "Cancel"); if (LogoffChoice.HasValue && LogoffChoice.Value) { NativeMethods.Logoff(); } }
private void LaunchProgram(object sender, RoutedEventArgs e) { Button item = (Button)sender; if (!Interop.Shell.StartProcess(item.CommandParameter.ToString())) { CairoMessage.Show("The file could not be found. If you just removed this program, try removing it from the App Grabber to make the icon go away.", "Oops!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void OpenShutDownBox(object sender, RoutedEventArgs e) { bool?ShutdownChoice = CairoMessage.ShowOkCancel(Localization.DisplayString.sShutDown_Info, Localization.DisplayString.sShutDown_Title, "Resources/shutdownIcon.png", Localization.DisplayString.sShutDown_ShutDown, Localization.DisplayString.sInterface_Cancel); if (ShutdownChoice.HasValue && ShutdownChoice.Value) { NativeMethods.Shutdown(); } }
private void OpenCloseCairoBox(object sender, RoutedEventArgs e) { bool?CloseCairoChoice = CairoMessage.ShowOkCancel(Localization.DisplayString.sExitCairo_Info, Localization.DisplayString.sExitCairo_Title, "Resources/exitIcon.png", Localization.DisplayString.sExitCairo_ExitCairo, Localization.DisplayString.sInterface_Cancel); if (CloseCairoChoice.HasValue && CloseCairoChoice.Value) { Startup.Shutdown(); } }
public void ExecuteOpenSearchResult(object sender, ExecutedRoutedEventArgs e) { var searchObj = (SearchResult)e.Parameter; if (!Shell.StartProcess(searchObj.Path)) { CairoMessage.Show(Localization.DisplayString.sSearch_Error, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void OpenRebootBox(object sender, RoutedEventArgs e) { bool?RebootChoice = CairoMessage.ShowOkCancel(Localization.DisplayString.sRestart_Info, Localization.DisplayString.sRestart_Title, "Resources/restartIcon.png", Localization.DisplayString.sRestart_Restart, Localization.DisplayString.sInterface_Cancel); if (RebootChoice.HasValue && RebootChoice.Value) { NativeMethods.Reboot(); } }
private void OpenLogoffBox(object sender, RoutedEventArgs e) { bool?LogoffChoice = CairoMessage.ShowOkCancel(Localization.DisplayString.sLogoff_Info, Localization.DisplayString.sLogoff_Title, "Resources/logoffIcon.png", Localization.DisplayString.sLogoff_Logoff, Localization.DisplayString.sInterface_Cancel); if (LogoffChoice.HasValue && LogoffChoice.Value) { NativeMethods.Logoff(); } }
private void AboutCairo(object sender, RoutedEventArgs e) { System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; CairoMessage.ShowAlert( Localization.DisplayString.sAbout_Version + " " + version + " - " + Localization.DisplayString.sAbout_PreRelease + "\n\n" + String.Format(Localization.DisplayString.sAbout_Copyright, DateTime.Now.Year.ToString()), "Cairo Desktop Environment", MessageBoxImage.None); }
private void AboutCairo(object sender, RoutedEventArgs e) { System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; CairoMessage.ShowAlert( "Version " + version + " - Pre-release" + "\n\nCopyright © 2007-" + DateTime.Now.Year.ToString() + " Cairo Development Team and community contributors. All rights reserved.", "Cairo Desktop Environment", MessageBoxImage.None); }
/// <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(); }
/// <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(); }
/// <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(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.messageWindow = ((CairoDesktop.CairoMessage)(target)); return; case 2: this.MessageIconImage = ((System.Windows.Controls.Image)(target)); return; case 3: this.TitleContent = ((System.Windows.Controls.TextBlock)(target)); return; case 4: this.MessageContent = ((System.Windows.Controls.TextBlock)(target)); return; case 5: this.OkButton = ((System.Windows.Controls.Button)(target)); #line 92 "..\..\CairoMessage.xaml" this.OkButton.Click += new System.Windows.RoutedEventHandler(this.OkButton_Click); #line default #line hidden return; case 6: this.YesButton = ((System.Windows.Controls.Button)(target)); #line 99 "..\..\CairoMessage.xaml" this.YesButton.Click += new System.Windows.RoutedEventHandler(this.OkButton_Click); #line default #line hidden return; case 7: this.NoButton = ((System.Windows.Controls.Button)(target)); #line 105 "..\..\CairoMessage.xaml" this.NoButton.Click += new System.Windows.RoutedEventHandler(this.NoButton_Click); #line default #line hidden return; case 8: this.CancelButton = ((System.Windows.Controls.Button)(target)); return; } this._contentLoaded = true; }