Exemplo n.º 1
0
 public CrashDialog(NodeController.CrashType crashType, Action nodeStarter, Action logOpener)
 {
     InitializeComponent();
     _nodeStarter = nodeStarter;
     _logOpener = logOpener;
     _crashType = crashType;
 }
Exemplo n.º 2
0
        private void CrashDialog_Load(object sender, EventArgs e)
        {
            IconBox.Image = SystemIcons.Exclamation.ToBitmap();

            var additional = "\n" + strings.AdditionalCrashInfo + " ";

            switch (_crashType)
            {
            case NodeController.CrashType.WrapperFileNotFound:
                additional += string.Format(strings.WrapperFileNotFound, NodeController.WrapperFilename());
                break;

            case NodeController.CrashType.PathTooLong:
                additional += strings.PathTooLong;
                break;

            case NodeController.CrashType.WrapperCrashed:
                additional = "";
                break;
            }

            crashMessageLabel.Text += additional;
        }
Exemplo n.º 3
0
        private void FindNode()
        {
            while (true)
            {
                try
                {
                    _node = new NodeController();
                    break;
                }
                catch (FileNotFoundException e)
                {
                    Log.Error(e);
                }
                catch (DirectoryNotFoundException e)
                {
                    Log.Error(e);
                }
                catch (NodeController.MissingConfigValueException e)
                {
                    // If the configuration files exist but are missing required
                    // values it is sufficiently surprising to warrant an error
                    // dialog.
                    Log.Error(strings.MalformedConfig, e.Filename, e.Value);
                    MessageBox.Show(String.Format(strings.MalformedConfig, e.Filename, e.Value), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // TODO: Explain what happened to prompt a custom location?
                try
                {
                    PreferencesWindow.PromptCustomLocation(this);
                }
                catch (OperationCanceledException)
                {
                    /* User exited the file browser. */
                    Application.Exit();
                    return;
                }
            }

            _node.OnStarted += NodeStarted;
            _node.OnStopped += NodeStopped;
            _node.OnCrashed += NodeCrashed;

            foreach (var menuItem in new[]
            {
                openFreenetMenuItem,
                startFreenetMenuItem,
                stopFreenetMenuItem,
                downloadsMenuItem,
                viewLogsMenuItem,
                preferencesMenuItem,
                hideIconMenuItem,
            })
            {
                menuItem.Enabled = true;
            }

            // Set menu up for whether there is an existing node.
            RefreshMenu(_node.IsRunning());

            ReadCommandLine();
        }
Exemplo n.º 4
0
        private void FindNode()
        {
            while (true)
            {
                try
                {
                    _node = new NodeController();
                    break;
                }
                catch (FileNotFoundException e)
                {
                    Log.Error(e);
                }
                catch (DirectoryNotFoundException e)
                {
                    Log.Error(e);
                }
                catch (NodeController.MissingConfigValueException e)
                {
                    // If the configuration files exist but are missing required
                    // values it is sufficiently surprising to warrant an error
                    // dialog.
                    Log.Error(strings.MalformedConfig, e.Filename, e.Value);
                    MessageBox.Show(String.Format(strings.MalformedConfig, e.Filename, e.Value), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // TODO: Explain what happened to prompt a custom location?
                try
                {
                    PreferencesWindow.PromptCustomLocation(this);
                }
                catch (OperationCanceledException)
                {
                    /* User exited the file browser. */
                    Application.Exit();
                    return;
                }
            }

            _node.OnStarted += NodeStarted;
            _node.OnStopped += NodeStopped;
            _node.OnCrashed += NodeCrashed;

            foreach (var menuItem in new[]
            {
                openFreenetMenuItem,
                startFreenetMenuItem,
                stopFreenetMenuItem,
                downloadsMenuItem,
                viewLogsMenuItem,
                preferencesMenuItem,
                hideIconMenuItem,
            })
            {
                menuItem.Enabled = true;
            }

            // Set menu up for whether there is an existing node.
            RefreshMenu(_node.IsRunning());

            ReadCommandLine();
        }
Exemplo n.º 5
0
 private void NodeCrashed(NodeController.CrashType crashType)
 {
     RefreshMenu(false);
     BeginInvoke(new Action(new CrashDialog(crashType, Start, ViewLogs).Show));
 }