private void ctxProgramsItem_Opened(object sender, RoutedEventArgs e) { if (KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey)) { ContextMenu menu = (sender as ContextMenu); foreach (Control item in menu.Items) { if (item.Name == "miProgramsItemRunAs") { item.Visibility = Visibility.Visible; return; } } } else { ContextMenu menu = (sender as ContextMenu); foreach (Control item in menu.Items) { if (item.Name == "miProgramsItemRunAs") { item.Visibility = Visibility.Collapsed; return; } } } }
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 ShellMenuCommandBuilder GetFileCommandBuilder(ShellFile file) { if (file == null) { return(new ShellMenuCommandBuilder()); } ShellMenuCommandBuilder builder = new ShellMenuCommandBuilder(); if (file.IsNavigableFolder) { if (Settings.Instance.EnableDynamicDesktop && Settings.Instance.FoldersOpenDesktopOverlay && Settings.Instance.EnableDesktop && !GroupPolicyHelper.NoDesktop) { builder.AddCommand(new ShellMenuCommand { Flags = MFT.BYCOMMAND, // enable this entry always Label = DisplayString.sStacks_OpenOnDesktop, UID = (uint)CairoContextMenuItem.OpenOnDesktop }); // If the [SHIFT] key is held, don't change the default action to ours // Only set as the default action for filesystem items because we don't support all shell views if (file.IsFileSystem && !KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey)) { builder.DefaultItemUID = (uint)CairoContextMenuItem.OpenOnDesktop; } } if (StacksManager.Instance.StackLocations.All(i => i.Path != file.Path)) { builder.AddCommand(new ShellMenuCommand { Flags = MFT.BYCOMMAND, // enable this entry always Label = DisplayString.sInterface_AddToStacks, UID = (uint)CairoContextMenuItem.AddToStacks }); } else { builder.AddCommand(new ShellMenuCommand { Flags = MFT.BYCOMMAND, // enable this entry always Label = DisplayString.sInterface_RemoveFromStacks, UID = (uint)CairoContextMenuItem.RemoveFromStacks }); } builder.AddSeparator(); } return(builder); }
private void OpenCloseCairoBox(object sender, RoutedEventArgs e) { CairoMessage.ShowOkCancel(Localization.DisplayString.sExitCairo_Info, Localization.DisplayString.sExitCairo_Title, CairoMessageImage.Default, Localization.DisplayString.sExitCairo_ExitCairo, Localization.DisplayString.sInterface_Cancel, result => { if (result == true) { if (KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey)) { _cairoApplication.RestartCairo(); } else { _cairoApplication.ExitCairo(); } } }); }
private void btnFile_Click(object sender, RoutedEventArgs e) { Button senderButton = sender as Button; if (senderButton != null && senderButton.DataContext != null) { SystemFile file = senderButton.DataContext as SystemFile; if (!string.IsNullOrWhiteSpace(file.FullName)) { // 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)) { // if directory, perform special handling if (file.IsDirectory && Settings.EnableDynamicDesktop && Window.GetWindow(senderButton)?.Name == "CairoDesktopWindow" && Startup.DesktopWindow != null) { Startup.DesktopWindow.Navigate(file.FullName); return; } else if (file.IsDirectory) { FolderHelper.OpenLocation(file.FullName); return; } } if (Startup.DesktopWindow != null) { Startup.DesktopWindow.IsOverlayOpen = false; } Shell.ExecuteProcess(file.FullName); return; } } CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); }
private void execute() { if (!currentlyRenaming) { if (file != null) { if (!string.IsNullOrWhiteSpace(file.FullName)) { // 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)) { // if directory, perform special handling if (file.IsDirectory && Location == "Desktop" && Settings.Instance.EnableDynamicDesktop && DesktopManager.IsEnabled) { _desktopManager.NavigationManager.NavigateTo(file.FullName); return; } else if (file.IsDirectory) { FolderHelper.OpenLocation(file.FullName); return; } } _desktopManager.IsOverlayOpen = false; ShellHelper.ExecuteProcess(file.FullName); return; } } CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } }
private void ContextMenu_Opened(object sender, RoutedEventArgs e) { ContextMenu menu = sender as ContextMenu; foreach (Control item in menu.Items) { ApplicationInfo app = item.DataContext as ApplicationInfo; switch (item.Name) { case "miProgramsItemAdmin": item.Visibility = app.AllowRunAsAdmin ? Visibility.Visible : Visibility.Collapsed; break; case "miProgramsItemRunAs": item.Visibility = KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey) && !app.IsStoreApp ? Visibility.Visible : Visibility.Collapsed; break; default: break; } } }
private void Open_Click(object sender, RoutedEventArgs e) { if (sender == null) { return; } Close(); ParentContainer?.OpenDir((sender as ICommandSource).CommandParameter.ToString(), KeyboardUtilities.IsKeyDown(System.Windows.Forms.Keys.ShiftKey)); }