Run() public method

public Run ( ) : int
return int
示例#1
0
        private static bool FinishLoading()
        {
            Core.Started += (EventHandler)DispatchService.GuiDispatch(new EventHandler(Core_Started));

            if (tmpSettings.FirstRun)
            {
                Core.LoggingService.LogDebug("First run");

                // Generate key
                if (!tmpSettings.HasKey)
                {
                    GenerateKeyDialog keyDialog = new GenerateKeyDialog(null);
                    keyDialog.Run();
                    tmpSettings.SetKey(keyDialog.Key);
                }

                /* Init the core */
                if (!Core.Init(tmpSettings))
                {
                    throw new Exception("Core failed to init on first run!");
                }

                /* Show change password dialog */
                var dialog = new ChangeKeyPasswordDialog(splashWindow.Window);
                dialog.Run();

                splashWindow.Close();

                PreferencesDialog preferences = new PreferencesDialog();
                if (preferences.Run() != (int)ResponseType.Ok)
                {
                    // Abort !!
                    Gtk.Application.Quit();
                    Environment.Exit(1);
                    return(false);
                }
                Core.ReloadSettings();
            }
            else
            {
                /* Init the core */

                Core.PasswordPrompt += delegate {
                    var dialog = new FileFind.Meshwork.GtkClient.Windows.UnlockKeyDialog(splashWindow.Window);
                    dialog.Run();
                };

                bool didInit = Core.Init(tmpSettings);
                if (!didInit)
                {
                    // Right now this means the password dialog was aborted, or already running.
                    Gtk.Application.Quit();
                    Environment.Exit(1);
                    return(false);
                }
            }

            tmpSettings = null;

            Core.AvatarManager = (IAvatarManager) new AvatarManager();

            /* Load the gui */
            Gui.MainWindow = new MainWindow();

            Gdk.Screen screen = Gdk.Screen.Default;

            /*
             * if (Common.OSName == "Linux") {
             *      Gdk.Colormap colormap = screen.RgbaColormap;
             *      if (colormap != null) {
             *              Widget.DefaultColormap = colormap;
             *              Gtk.Widget.PushColormap(colormap);
             *      }
             * }
             */

            splashWindow.Close();

            if ((!Gui.Settings.StartInTray && options.MainWindowState != "hidden") ||
                (Gui.Settings.StartInTray && (options.MainWindowState == "shown" | options.MainWindowState == "iconified")))
            {
                Gui.MainWindow.Show();
                if (options.MainWindowState == "iconified")
                {
                    Gui.MainWindow.Iconify();
                }
            }

            Thread thread = new Thread(delegate() {
                Core.Start();
            });

            thread.Start();

            return(false);
        }
示例#2
0
        private static bool FinishLoading()
        {
            Core.Started += (EventHandler)DispatchService.GuiDispatch(new EventHandler(Core_Started));

            if (tmpSettings.FirstRun) {
                LoggingService.LogDebug("First run");

                // Generate key
                if (!tmpSettings.HasKey) {
                    GenerateKeyDialog keyDialog = new GenerateKeyDialog (null);
                    keyDialog.Run();
                    tmpSettings.SetKey(keyDialog.Key);
                }

                /* Init the core */
                if (!Core.Init(tmpSettings)) {
                    throw new Exception("Core failed to init on first run!");
                }

                /* Show change password dialog */
                var dialog = new ChangeKeyPasswordDialog(splashWindow.Window);
                dialog.Run();

                splashWindow.Close();

                PreferencesDialog preferences = new PreferencesDialog ();
                if (preferences.Run () != (int)ResponseType.Ok) {
                    // Abort !!
                    Gtk.Application.Quit();
                    Environment.Exit(1);
                    return false;
                }
                Core.ReloadSettings();
            } else {
                /* Init the core */

                Core.PasswordPrompt += delegate {
                    var dialog = new FileFind.Meshwork.GtkClient.Windows.UnlockKeyDialog(splashWindow.Window);
                    dialog.Run();
                };

                bool didInit = Core.Init(tmpSettings);
                if (!didInit) {
                    // Right now this means the password dialog was aborted, or already running.
                    Gtk.Application.Quit();
                    Environment.Exit(1);
                    return false;
                }
            }

            tmpSettings = null;

            Core.AvatarManager = (IAvatarManager) new AvatarManager();

            /* Load the gui */
            Gui.MainWindow = new MainWindow ();

            Gdk.Screen screen = Gdk.Screen.Default;

            /*
            if (Common.OSName == "Linux") {
                Gdk.Colormap colormap = screen.RgbaColormap;
                if (colormap != null) {
                    Widget.DefaultColormap = colormap;
                    Gtk.Widget.PushColormap(colormap);
                }
            }
            */

            splashWindow.Close();

            if ((!Gui.Settings.StartInTray && options.MainWindowState != "hidden") ||
                (Gui.Settings.StartInTray && (options.MainWindowState == "shown" | options.MainWindowState == "iconified"))) {
                Gui.MainWindow.Show();
                if (options.MainWindowState == "iconified") {
                    Gui.MainWindow.Iconify();
                }
            }

            Thread thread = new Thread(delegate () {
                Core.Start();
            });
            thread.Start();

            return false;
        }