Exemplo n.º 1
0
        /// <summary>
        /// Return true if the user wants to recover from the deserialization
        /// failure.
        /// </summary>
        private static bool TellUserAboutDsrFailure()
        {
            String msg = "The " + KwmStrings.Kwm + " data is corrupted. " +
                         "Do you want to delete the corrupted data? " +
                         "Warning: you will lose all your " + KwmStrings.Kwses + "!";

            return(WmUi.TellUser(msg, KwmStrings.Kwm + " data corrupted", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method is executed when the application has started and the
        /// message loop is running.
        /// </summary>
        private static void Bootstrap()
        {
            // Determine the other process state.
            WmOtherProcess other = new WmOtherProcess();

            other.FindOtherProcess();

            // Another KWM we own is running in our session.
            if (other.State == WmOtherProcessState.OurInCurrentSession)
            {
                // Send the other KWM a message to import the credentials.
                if (ImportKwsPath != "")
                {
                    SendMsgToOtherKwm(other, ImportKwsMsgID, ImportKwsPath);
                }

                // Show the instance of the other KWM.
                SendMsgToOtherKwm(other, ForegroundMsgID, "");

                // We're done.
                RequestAppExit();
            }

            // Warn the user.
            else if (other.State == WmOtherProcessState.NotOurInCurrentSession ||
                     other.State == WmOtherProcessState.OurInOtherSession)
            {
                String error = (other.State == WmOtherProcessState.NotOurInCurrentSession) ?
                               "A " + KwmStrings.Kwm + " started by another user is already running." :
                               "A " + KwmStrings.Kwm + " started by another user is already running.";
                WmUi.TellUser(error, "Cannot start " + KwmStrings.Kwm, MessageBoxButtons.OK, MessageBoxIcon.Error);
                RequestAppExit();
            }

            // Enter the main mode.
            else
            {
                try
                {
                    if (!EnterMainMode())
                    {
                        RequestAppExit();
                    }
                }

                catch (Exception ex)
                {
                    KBase.HandleException(ex, true);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parse the command line and exit the process as needed.
        /// </summary>
        private static void ParseCmdLine(string[] args)
        {
            try
            {
                int c = 0;
                while ((c = GetOpt.GetOptions(args, "e:i:M:S:")) != -1)
                {
                    switch ((char)c)
                    {
                    // Export switch.
                    case 'e':
                        ExportKwsPath = GetOpt.Text;
                        if (ExportKwsPath == "" || ExportKwsPath == null)
                        {
                            throw new Exception("empty export path");
                        }
                        break;

                    // Import switch.
                    case 'i':
                        ImportKwsPath = GetOpt.Text;
                        if (ImportKwsPath == "" || ImportKwsPath == null)
                        {
                            throw new Exception("empty import path");
                        }
                        break;

                    // Fatal error message switch.
                    case 'M':
                        WmUi.TellUser(GetOpt.Text, KwmStrings.Kwm + " fatal error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Environment.Exit(0);
                        break;

                    case '?':
                    case ':':
                    default:
                        throw new Exception("invalid option");
                    }
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine("Option error: " + ex.Message);
                usage();
                Environment.Exit(1);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Queue and execute the request.
        /// </summary>
        private void InternalQueue()
        {
            // Queue the request.
            GerQueue.Enqueue(this);

            // Bail out, there is another request already executing.
            if (GerQueue.Count > 1)
            {
                return;
            }

            // Increment the UI entry count.
            WmUi.OnUiEntry();

            // Execute all the pending requests.
            while (GerQueue.Count > 0)
            {
                GerQueue.Peek().Run();
                GerQueue.Dequeue();
            }

            // Decrement the UI entry count.
            WmUi.OnUiExit();
        }
Exemplo n.º 5
0
 public override void Run()
 {
     WmUi.TellUser(ErrorMsg.Ex.Message, KwmStrings.Kwm, MessageBoxButtons.OK, MessageBoxIcon.Error);
 }