Example #1
0
        private void ToolBarButtonClick(object sender, EventArgs e)
        {
            var b = sender as ToolStripMenuItem;

            if (_log.Enabled)
            {
                _log.Debug(GetHashCode(), "ToolBarButtonClick " + b.Name);
            }

            if (_sessions.Count > 0)
            {
                var currentSession = ((ViewerForm)ActiveMdiChild).Session;

                switch (b.Name)
                {
                case "clearToolStripMenuItem":
                    currentSession.Viewer.Clear();
                    break;

                case "settingsToolStripMenuItem":
                    var f = new ConfigureSession(currentSession);
                    f.ShowDialog(this);
                    f.Dispose();
                    ActiveMdiChild.Text = currentSession.Title;
                    break;

                case "pauseToolStripMenuItem":
                    currentSession.Viewer.Paused = !currentSession.Viewer.Paused;
                    UpdatePauseButton();
                    break;

                case "actionsToolStripMenuItem":
                    var ma = new ManageActions((TextViewer)currentSession.Viewer);
                    ma.ShowDialog(this);
                    ma.Dispose();
                    break;

                case "wordWrapToolStripMenuItem":
                    currentSession.Viewer.WordWrap = !currentSession.Viewer.WordWrap;
                    UpdateWordWrapButton();
                    break;
                }
            }

            switch (b.Name)
            {
            case "newSessionToolStripMenuItem":
                StartListening();
                EnableButtons();
                break;

            case "aboutToolStripMenuItem":
                var a = new About();
                a.ShowDialog();
                break;
            }
        }
Example #2
0
        private void StartListening()
        {
            _log.Debug(GetHashCode(), "StartListening");

            var cf = new ConfigureSession();
            var showConfigWindow = true;

            cf.LoadDefaultSettings();

            if (_args.Length > 0)
            {
                //If there is anything on the commandline clear the listeners from the default session.
                cf.ClearListeners();

                var fileNum = 0;
                foreach (var file in _args)
                {
                    _log.Debug(GetHashCode(), "Argument #" + fileNum + " " + file);

                    if (File.Exists(file))
                    {
                        var fi = new FileInfo(file);
                        if (fi.Extension == ".exe")
                        {
                            cf.Session.Listeners.Add(new StdOutListener(file, "StdOut", false));
                        }
                        else if (fi.Extension == ".l4n")
                        {
                            showConfigWindow = false;
                            cf.loadConfiguration(file);
                        }
                        else
                        {
                            cf.Session.Listeners.Add(new FileListener(file, 3, "File" + fileNum, true));
                        }
                    }
                    else if (Directory.Exists(file))
                    {
                        cf.Session.Listeners.Add(new FolderListener(file, "Folder", true, false));
                    }

                    fileNum++;
                }
                cf.showConfiguration();
                _args = new string[] {};
            }

            if (showConfigWindow)
            {
                cf.ShowDialog();
            }
            else
            {
                cf.DialogResult = DialogResult.OK;
            }

            if (cf.DialogResult == DialogResult.OK)
            {
                var f = new ViewerForm(cf.Session)
                {
                    MdiParent = this
                };

                f.Show();
                f.WindowState = FormWindowState.Maximized;
                var session = f.Session;

                session.Start();
                _sessions.Add(session);
            }

            cf.Dispose();
        }