Uses Gtk to allow users to interact with CliCommands.
This class manages a GUI thread with an independent message queue. Invoking methods on the right thread is handled automatically.
Inheritance: NanoByte.Common.Tasks.DialogTaskHandler, ICommandHandler
コード例 #1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static int Main(string[] args)
        {
            ProgramUtils.Init();
            Application.Init();

            using (var handler = new GuiCommandHandler())
                return((int)ProgramUtils.Run(ExeName, args, handler));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: 0install/0install-win
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static int Main(string[] args)
        {
            ProgramUtils.Init();
            Application.Init();

            using (var handler = new GuiCommandHandler())
                return (int)ProgramUtils.Run(ExeName, args, handler);
        }
コード例 #3
0
        /// <summary>
        /// Runs the application (called by main method or by embedding process).
        /// </summary>
        public static ExitCode Run(string[] args)
        {
            Log.Debug("Zero Install Command GTK GUI started with: " + args.JoinEscapeArguments());

            using (var handler = new GuiCommandHandler())
            {
                try
                {
                    var command = CommandFactory.CreateAndParse(args, handler);
                    return(command.Execute());
                }
                #region Error handling
                catch (OperationCanceledException)
                {
                    return(ExitCode.UserCanceled);
                }
                catch (OptionException ex)
                {
                    var builder = new StringBuilder(ex.Message);
                    if (ex.InnerException != null)
                    {
                        builder.Append("\n" + ex.InnerException.Message);
                    }
                    builder.Append("\n" + string.Format(Resources.TryHelp, ExeName));
                    Msg.Inform(null, builder.ToString(), MsgSeverity.Warn);
                    return(ExitCode.InvalidArguments);
                }
                catch (FormatException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.InvalidArguments);
                }
                catch (WebException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.WebError);
                }
                catch (NotSupportedException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.NotSupported);
                }
                catch (IOException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.IOError);
                }
                catch (UnauthorizedAccessException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.AccessDenied);
                }
                catch (InvalidDataException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.InvalidData);
                }
                catch (SignatureException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.InvalidSignature);
                }
                catch (DigestMismatchException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, Resources.DownloadDamaged, MsgSeverity.Error);
                    return(ExitCode.DigestMismatch);
                }
                catch (SolverException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.SolverError);
                }
                catch (ExecutorException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.ExecutorError);
                }
                catch (ConflictException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return(ExitCode.Conflict);
                }
                #endregion

                finally
                {
                    handler.CloseUI();
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: modulexcite/0install-win
        /// <summary>
        /// Runs the application (called by main method or by embedding process).
        /// </summary>
        public static ExitCode Run(string[] args)
        {
            Log.Debug("Zero Install Command GTK GUI started with: " + args.JoinEscapeArguments());

            using (var handler = new GuiCommandHandler())
            {
                try
                {
                    var command = CommandFactory.CreateAndParse(args, handler);
                    return command.Execute();
                }
                    #region Error handling
                catch (OperationCanceledException)
                {
                    return ExitCode.UserCanceled;
                }
                catch (OptionException ex)
                {
                    var builder = new StringBuilder(ex.Message);
                    if (ex.InnerException != null) builder.Append("\n" + ex.InnerException.Message);
                    builder.Append("\n" + string.Format(Resources.TryHelp, ExeName));
                    Msg.Inform(null, builder.ToString(), MsgSeverity.Warn);
                    return ExitCode.InvalidArguments;
                }
                catch (FormatException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.InvalidArguments;
                }
                catch (WebException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.WebError;
                }
                catch (NotSupportedException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.NotSupported;
                }
                catch (IOException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.IOError;
                }
                catch (UnauthorizedAccessException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.AccessDenied;
                }
                catch (InvalidDataException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.InvalidData;
                }
                catch (SignatureException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.InvalidSignature;
                }
                catch (DigestMismatchException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.DigestMismatch;
                }
                catch (SolverException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.SolverError;
                }
                catch (ExecutorException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.ExecutorError;
                }
                catch (ConflictException ex)
                {
                    handler.DisableUI();
                    Log.Error(ex);
                    Msg.Inform(null, ex.Message, MsgSeverity.Error);
                    return ExitCode.Conflict;
                }
                    #endregion

                finally
                {
                    handler.CloseUI();
                }
            }
        }