public OpenEventLogDialog()
        {
            InitializeComponent();
            Icon = Properties.Resources.SnakeIcon;

            List <string> logfiles = EventLogForm.GetEventLogFiles();

            foreach (string logfile in logfiles)
            {
                _listView.Items.Add(logfile);
                if (logfile == "Application")
                {
                    _listView.SelectedIndices.Add(_listView.Items.Count - 1);
                }
            }
        }
Exemple #2
0
        private bool LoadSession(string filepath)
        {
            TailConfig tailConfig = LoadSessionFile(filepath);

            if (tailConfig == null)
            {
                return(false);
            }

            _mruMenu.AddFile(filepath);

            if (!tailConfig.MinimizedToTray)
            {
                Size            = tailConfig.WindowSize;
                DesktopLocation = tailConfig.WindowPosition;
            }

            UpdateTitle();

            List <string> eventLogFiles = EventLogForm.GetEventLogFiles();

            Application.DoEvents();

            foreach (TailFileConfig tailFile in tailConfig.TailFiles)
            {
                Form mdiForm = null;

                int index = eventLogFiles.FindIndex(delegate(string arrItem) { return(arrItem.Equals(tailFile.FilePath)); });
                if (index >= 0)
                {
                    mdiForm = new EventLogForm();
                }
                else
                {
                    mdiForm = new TailForm();
                }

                if (mdiForm != null)
                {
                    ITailForm tailForm       = mdiForm as ITailForm;
                    string    tailConfigPath = Path.GetDirectoryName(filepath);

                    mdiForm.Text = tailFile.Title;
                    if (!tailFile.Modeless)
                    {
                        mdiForm.MdiParent     = this;
                        mdiForm.ShowInTaskbar = false;
                        AddMdiChildTab(mdiForm);
                        if (tailForm != null)
                        {
                            tailForm.LoadConfig(tailFile, tailConfigPath);
                        }
                        if (mdiForm.IsDisposed)
                        {
                            _MDITabControl.TabPages.Remove(mdiForm.Tag as TabPage);
                            continue;
                        }
                    }
                    mdiForm.Show();

                    if (tailConfig.SelectedTab == -1 || tailFile.Modeless)
                    {
                        if (tailFile.WindowState != FormWindowState.Maximized)
                        {
                            mdiForm.DesktopLocation = tailFile.WindowPosition;
                            mdiForm.Size            = tailFile.WindowSize;
                        }
                        if (mdiForm.WindowState != tailFile.WindowState)
                        {
                            mdiForm.WindowState = tailFile.WindowState;
                        }
                    }

                    if (tailFile.Modeless)
                    {
                        if (tailForm != null)
                        {
                            tailForm.LoadConfig(tailFile, tailConfigPath);
                        }
                    }
                }
                Application.DoEvents();
            }

            if (tailConfig.SelectedTab != -1 && _MDITabControl.TabPages.Count > 0)
            {
                foreach (Form childForm in MdiChildren)
                {
                    childForm.WindowState = FormWindowState.Minimized;
                }

                _MDITabControl.SelectedIndex = tailConfig.SelectedTab;
                _MDITabControl.Visible       = true;
                (_MDITabControl.SelectedTab.Tag as Form).WindowState = FormWindowState.Maximized;
            }

            if (tailConfig.MinimizedToTray)
            {
                _trayIcon.Visible = true;
                WindowState       = FormWindowState.Minimized;
                Visible           = false;
            }
            else if (tailConfig.AlwaysOnTop)
            {
                alwaysOnTopToolStripMenuItem.Checked = true;
                TopMost = true;
            }

            return(true);
        }