コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: Icon.xaml.cs プロジェクト: curoviyxru/cairoshell
        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;
        }
コード例 #3
0
ファイル: Cairo.xaml.cs プロジェクト: rhaedyr/cairoshell
 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);
     }
 }
コード例 #4
0
 /// <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);
     }
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
ファイル: Cairo.xaml.cs プロジェクト: Lin-Buo-Ren/cairoshell
 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);
     }
 }
コード例 #7
0
 /// <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);
     }
 }
コード例 #8
0
 /// <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);
     }
 }
コード例 #9
0
 /// <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);
     }
 }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
 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);
     }
 }
コード例 #12
0
 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();
     }
 }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
ファイル: MenuBar.xaml.cs プロジェクト: oxysoft/cairoshell
        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);
            }
        }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
        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.Show(
                Localization.DisplayString.sAbout_Version + " " + version + " - " + Localization.DisplayString.sAbout_PreRelease
                + "\n\n" + String.Format(Localization.DisplayString.sAbout_Copyright, DateTime.Now.Year.ToString()), "Cairo Desktop Environment", CairoMessageImage.Default);
        }
コード例 #18
0
        private void LaunchProgram(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;

            try {
                System.Diagnostics.Process.Start(item.CommandParameter.ToString());
            } catch {
                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);
            }
        }
コード例 #19
0
        private void btnUninstallApps_Click(object sender, RoutedEventArgs e)
        {
            // Buttons capture the mouse; need to release so that mouse events go to the intended recipient after closing
            Mouse.Capture(null);

            if (!ShellHelper.StartProcess("appwiz.cpl"))
            {
                CairoMessage.Show(DisplayString.sError_CantOpenAppWiz, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error);
            }
        }
コード例 #20
0
ファイル: Cairo.xaml.cs プロジェクト: Lin-Buo-Ren/cairoshell
        private void btnFile_Click(object sender, RoutedEventArgs e)
        {
            if (sender != null)
            {
                Button senderButton = sender as Button;
                if (senderButton != null && senderButton.CommandParameter != null)
                {
                    // get the file attributes for file or directory
                    FileAttributes attr = File.GetAttributes(senderButton.CommandParameter as String);

                    // if directory, perform special handling
                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory && Settings.EnableDynamicDesktop && Window.GetWindow(senderButton) != null && Window.GetWindow(senderButton).Name == "CairoDesktopWindow" && Startup.DesktopWindow != null)
                    {
                        Startup.DesktopWindow.Navigate(senderButton.CommandParameter as String);

                        return;
                    }
                    else if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        FolderHelper.OpenLocation(senderButton.CommandParameter as String);

                        return;
                    }

                    System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    proc.StartInfo.UseShellExecute = true;
                    proc.StartInfo.FileName        = senderButton.CommandParameter as String;
                    try
                    {
                        if (Startup.DesktopWindow != null)
                        {
                            Startup.DesktopWindow.IsOverlayOpen = false;
                        }

                        proc.Start();

                        return;
                    }
                    catch
                    {
                        if (Startup.DesktopWindow != null)
                        {
                            Startup.DesktopWindow.IsOverlayOpen = false;
                        }

                        // No 'Open' command associated with this filetype in the registry
                        Interop.Shell.ShowOpenWithDialog(proc.StartInfo.FileName);

                        return;
                    }
                }
            }

            CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error);
        }
コード例 #21
0
        private void AboutCairo(object sender, RoutedEventArgs e)
        {
            CairoMessage.Show(
                // Replace next line with the Version
                "Version 0.0.1.11 - Milestone 2 Preview 3"
                + "\nCopyright © 2007-2010 Cairo Development Team and community contributors.  All rights reserved."
                // +
                // Replace next line with the ID Key
//"Not for redistribution."
                , "Cairo Desktop Environment", MessageBoxButton.OK, MessageBoxImage.None);
        }
コード例 #22
0
 private void miPersonalization_Click(object sender, RoutedEventArgs e)
 {
     // doesn't work when shell because Settings app requires Explorer :(
     if (!Shell.StartProcess("desk.cpl"))
     {
         CairoMessage.Show("Unable to open Personalization settings.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else if (IsOverlayOpen)
     {
         IsOverlayOpen = false;
     }
 }
コード例 #23
0
ファイル: Welcome.xaml.cs プロジェクト: curoviyxru/cairoshell
 private void cboLangSelect_DropDownClosed(object sender, EventArgs e)
 {
     if (Settings.Instance.Language != _initialLanguage)
     {
         CairoMessage.Show(DisplayString.sWelcome_ChangingLanguageText, DisplayString.sWelcome_ChangingLanguage, MessageBoxButton.OK, CairoMessageImage.Information,
                           result =>
         {
             if (result == true)
             {
                 _cairoApplication?.RestartCairo();
             }
         });
     }
 }
コード例 #24
0
 public void InitializeSystemTray()
 {
     try
     {
         trayDelegate = new SystrayDelegate(SysTrayCallback);
         hooksWrapper.SetSystrayCallback(trayDelegate);
         hooksWrapper.InitializeSystray();
         hooksWrapper.Run();
     }
     catch (Exception ex)
     {
         CairoMessage.Show("Error initializing the system tray component.\n\n" + ex.ToString() + "\n\nIf this error continues please report it (including a screen shot of this message) to the Cairo Development Team. \nThank you.", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);
     }
 }
コード例 #25
0
ファイル: Startup.cs プロジェクト: rglamazda/cairoshell
 /// <summary>
 /// Executes the first run sequence.
 /// </summary>
 private static void FirstRun()
 {
     try
     {
         if (Settings.Instance.IsFirstRun || isTour)
         {
             Welcome welcome = new Welcome();
             welcome.Show();
         }
     }
     catch (Exception ex)
     {
         CairoMessage.Show(string.Format("Whoops! Something bad happened in the startup process.\nCairo will probably run, but please report the following details (preferably as a screen shot...)\n\n{0}", ex),
                           "Unexpected error!",
                           CairoMessageImage.Error);
     }
 }
コード例 #26
0
        private void ShowGoToFolderDialog()
        {
            Common.MessageControls.Input inputControl = new Common.MessageControls.Input();
            inputControl.InputField.Text = NavigationManager.CurrentItem.Path;
            inputControl.InputField.SelectAll();
            inputControl.InputField.Focus();

            CairoMessage.ShowControl(Localization.DisplayString.sDesktop_GoToFolderMessage,
                                     Localization.DisplayString.sDesktop_GoToFolderTitle,
                                     CairoMessageImage.Default,
                                     inputControl,
                                     Localization.DisplayString.sInterface_Go,
                                     Localization.DisplayString.sInterface_Cancel,
                                     (bool?result) =>
            {
                string path = inputControl.InputField.Text;
                if (result != true || string.IsNullOrEmpty(path))
                {
                    return;
                }

                // Check if this is a valid folder
                ShellFolder shellFolder = new ShellFolder(path, IntPtr.Zero);
                bool valid = shellFolder.Loaded;
                shellFolder.Dispose();

                if (valid)
                {
                    NavigationManager.NavigateTo(path);
                }
                else
                {
                    CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo,
                                      Localization.DisplayString.sError_OhNo,
                                      MessageBoxButton.OK,
                                      CairoMessageImage.Error, (bool?errResult) =>
                    {
                        ShowGoToFolderDialog();
                    });
                }
            });
        }
コード例 #27
0
ファイル: Startup.cs プロジェクト: kleopatra999/cairoshell
 /// <summary>
 /// Executes the first run sequence.
 /// </summary>
 /// <param name="app">References to the app object.</param>
 private static void FirstRun(App app)
 {
     try
     {
         if (Properties.Settings.Default.IsFirstRun == true)
         {
             Properties.Settings.Default.IsFirstRun    = false;
             Properties.Settings.Default.EnableTaskbar = true;
             Properties.Settings.Default.Save();
             AppGrabber.AppGrabber.Instance.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         CairoMessage.Show(string.Format("Woops! Something bad happened in the startup process.\nCairo will probably run, but please report the following details (preferably as a screen shot...)\n\n{0}", ex),
                           "Unexpected error!",
                           MessageBoxButton.OK,
                           MessageBoxImage.Error);
     }
 }
コード例 #28
0
        private void LaunchProgram(object sender, RoutedEventArgs e)
        {
            MenuItem        item = (MenuItem)sender;
            ApplicationInfo app  = item.DataContext as ApplicationInfo;

            // so that we only prompt to always run as admin if it's done consecutively
            if (app.AskAlwaysAdmin)
            {
                app.AskAlwaysAdmin = false;
                appGrabber.Save();
            }

            if (!app.IsStoreApp && app.AlwaysAdmin)
            {
                Shell.StartProcess(app.Path, "", "runas");
            }
            else if (!Shell.StartProcess(app.Path))
            {
                CairoMessage.Show("The file could not be found.  If you just removed this program, try removing it using the right-click menu to make the icon go away.", "Oops!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #29
0
        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);
        }
コード例 #30
0
        public void ExecuteOpenSearchResult(object sender, ExecutedRoutedEventArgs e)
        {
            // Get parameter (e.Parameter as T)
            // Try shell execute...
            // TODO: Determine which app to start the file as and boom!
            var searchObj = (VistaSearchProvider.SearchResult)e.Parameter;

            Process p = new Process();

            p.StartInfo.UseShellExecute = true;
            p.StartInfo.FileName        = searchObj.Path; // e.Parameter as T.x
            p.StartInfo.Verb            = "Open";

            try
            {
                p.Start();
            }
            catch (Exception ex)
            {
                CairoMessage.Show("Woops, it seems we had some trouble opening the search result you chose.\n\n The error we received was: " + ex.Message, "Uh Oh!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }