GoBack() public static method

public static GoBack ( ) : void
return void
Exemplo n.º 1
0
        private void RunProcess()
        {
            if (string.IsNullOrWhiteSpace(CommandLine.Text))
            {
                return;
            }

            StdOutputScroller.ChangeView(null, StdOutputScroller.ScrollableHeight, null, true);

            AddToCommandHistory(CommandLine.Text);
            currentCommandLine       = commandLineHistory.Count;
            isProcessingAdminCommand = false;

            Run cmdLineRun = new Run
            {
                Foreground = GraySolidColorBrush,
                FontWeight = FontWeights.Bold,
                Text       = "\n" + WorkingDirectory.Text + " " + CommandLine.Text + "\n"
            };

            var commandLineText = CommandLine.Text.Trim();

            EnableCommandLineTextBox(false);
            CommandLine.Text = string.Empty;
            MainParagraph.Inlines.Add(cmdLineRun);
            totalOutputSize += cmdLineRun.Text.Length;

            if (commandLineText.Equals("cls", StringComparison.CurrentCultureIgnoreCase) ||
                commandLineText.Equals("clear", StringComparison.CurrentCultureIgnoreCase))
            {
                ClearOutput();
            }
            else if (commandLineText.StartsWith("cd ", StringComparison.CurrentCultureIgnoreCase) || commandLineText.StartsWith("chdir ", StringComparison.CurrentCultureIgnoreCase))
            {
                ShowError(resourceLoader.GetString("CdNotSupported"));
                EnableCommandLineTextBox(true, WorkingDirectory);
            }
            else if (commandLineText.Equals("exit", StringComparison.CurrentCultureIgnoreCase))
            {
                NavigationUtils.GoBack();
            }
            else if (commandLineText.StartsWith("RunAsAdmin", StringComparison.CurrentCultureIgnoreCase))
            {
                RunAdminCommand(commandLineText);
            }
            else
            {
                LaunchCmdProcess(commandLineText);
            }
        }
Exemplo n.º 2
0
 private void BackButton_Clicked(object sender, RoutedEventArgs e)
 {
     NavigationUtils.GoBack();
 }
Exemplo n.º 3
0
        private async Task RunProcess()
        {
            if (string.IsNullOrWhiteSpace(CommandLine.Text))
            {
                return;
            }

            commandLineHistory.Add(CommandLine.Text);
            currentCommandLine = commandLineHistory.Count;

            bool isCmdAuthorized = true;
            Run  cmdLineRun      = new Run();

            cmdLineRun.Foreground = new SolidColorBrush(Windows.UI.Colors.LightGray);
            cmdLineRun.FontWeight = FontWeights.Bold;
            cmdLineRun.Text       = currentDirectory + "> " + CommandLine.Text + "\n";

            Run stdOutRun = new Run();
            Run stdErrRun = new Run();

            stdErrRun.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);

            var commandLineText = CommandLine.Text.Trim();

            if (commandLineText.Equals("cls", StringComparison.CurrentCultureIgnoreCase))
            {
                StdOutputText.Blocks.Clear();
                return;
            }
            else if (commandLineText.StartsWith("cd ", StringComparison.CurrentCultureIgnoreCase) || commandLineText.Equals("cd", StringComparison.CurrentCultureIgnoreCase))
            {
                stdErrRun.Text = resourceLoader.GetString("CdNotSupported");
            }
            else if (commandLineText.Equals("exit", StringComparison.CurrentCultureIgnoreCase))
            {
                NavigationUtils.GoBack();
            }
            else
            {
                var standardOutput = new InMemoryRandomAccessStream();
                var standardError  = new InMemoryRandomAccessStream();
                var options        = new ProcessLauncherOptions
                {
                    StandardOutput = standardOutput,
                    StandardError  = standardError
                };

                try
                {
                    var args   = "/C \"cd \"" + currentDirectory + "\" & " + commandLineText + "\"";
                    var result = await ProcessLauncher.RunToCompletionAsync(CommandLineProcesserExe, args, options);

                    // First write std out
                    using (var outStreamRedirect = standardOutput.GetInputStreamAt(0))
                    {
                        using (var dataReader = new DataReader(outStreamRedirect))
                        {
                            await ReadText(dataReader, stdOutRun);
                        }
                    }

                    // Then write std err
                    using (var errStreamRedirect = standardError.GetInputStreamAt(0))
                    {
                        using (var dataReader = new DataReader(errStreamRedirect))
                        {
                            await ReadText(dataReader, stdErrRun);
                        }
                    }
                }
                catch (UnauthorizedAccessException uex)
                {
                    isCmdAuthorized = false;
                    var errorMessage = uex.Message + "\n\n" + resourceLoader.GetString("CmdNotEnabled");
                    stdErrRun.Text = errorMessage;
                }
                catch (Exception ex)
                {
                    var errorMessage = ex.Message + "\n" + ex.StackTrace + "\n";
                    stdErrRun.Text = errorMessage;
                }
            }

            await CoreWindow.GetForCurrentThread().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Paragraph paragraph = new Paragraph();

                paragraph.Inlines.Add(cmdLineRun);
                paragraph.Inlines.Add(stdOutRun);
                paragraph.Inlines.Add(stdErrRun);

                if (!isCmdAuthorized)
                {
                    InlineUIContainer uiContainer = new InlineUIContainer();
                    Button cmdEnableButton        = new Button();
                    cmdEnableButton.Content       = resourceLoader.GetString("EnableCmdText");
                    cmdEnableButton.Click        += AccessButtonClicked;
                    uiContainer.Child             = cmdEnableButton;
                    paragraph.Inlines.Add(uiContainer);
                }

                StdOutputText.Blocks.Add(paragraph);
            });
        }
Exemplo n.º 4
0
 private void BackButton_Tapped(object sender, TappedRoutedEventArgs e)
 {
     NavigationUtils.GoBack();
 }