Beispiel #1
0
        private int OpenFileSelection(string[] filenames)
        {
            if (_defaultTailConfig == null)
            {
                TailConfig tailConfig  = null;
                string     defaultPath = GetDefaultConfigPath();
                if (!string.IsNullOrEmpty(defaultPath))
                {
                    tailConfig = LoadSessionFile(defaultPath);
                }

                if (tailConfig != null && tailConfig.TailFiles.Count > 0)
                {
                    _defaultTailConfig       = tailConfig.TailFiles[0];
                    _defaultTailConfig.Title = null;
                }
                else
                {
                    _defaultTailConfig = new TailFileConfig();
                }
            }

            int filesOpened = 0;

            foreach (string filename in filenames)
            {
                string configPath = "";
                try
                {
                    if (string.IsNullOrEmpty(Path.GetDirectoryName(filename)))
                    {
                        configPath = Directory.GetCurrentDirectory();
                    }
                }
                catch
                {
                }

                TailForm       mdiForm    = new TailForm();
                TailFileConfig tailConfig = _defaultTailConfig;
                tailConfig.FilePath = filename;
                mdiForm.LoadConfig(tailConfig, configPath);
                if (mdiForm.IsDisposed)
                {
                    continue;
                }

                _mruMenu.AddFile(filename);

                mdiForm.MdiParent = this;
                mdiForm.Show();
                ++filesOpened;
                Application.DoEvents();
            }
            return(filesOpened);
        }
        public KeywordConfigForm(TailKeywordConfig keywordConfig, TailFileConfig tailFileConfig)
        {
            InitializeComponent();

            _tailFileConfig = tailFileConfig;

            if (keywordConfig != null)
                TailKeywordConfig = keywordConfig;
            else
            {
                TailKeywordConfig = new TailKeywordConfig();
                TailKeywordConfig.FormBackColor = Color.Red;
                TailKeywordConfig.FormTextColor = Color.White;
            }
        }
Beispiel #3
0
        public KeywordConfigForm(TailKeywordConfig keywordConfig, TailFileConfig tailFileConfig)
        {
            InitializeComponent();

            _tailFileConfig = tailFileConfig;

            if (keywordConfig != null)
            {
                TailKeywordConfig = keywordConfig;
            }
            else
            {
                TailKeywordConfig = new TailKeywordConfig();
                TailKeywordConfig.FormBackColor = Color.Red;
                TailKeywordConfig.FormTextColor = Color.White;
            }
        }
Beispiel #4
0
        public void SaveConfig(TailConfig tailConfig, string filepath)
        {
            if (string.IsNullOrEmpty(filepath))
            {
                string defaultPath = GetDefaultConfigPath();
                if (string.IsNullOrEmpty(defaultPath))
                {
                    defaultPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\SnakeTail\\";
                    if (!Directory.Exists(defaultPath))
                    {
                        Directory.CreateDirectory(defaultPath);
                    }

                    defaultPath += "SnakeTail.xml";
                }

                filepath = defaultPath;
            }

            XmlSerializer serializer = new XmlSerializer(typeof(TailConfig));

            try
            {
                using (XmlTextWriter writer = new XmlTextWriter(filepath, Encoding.UTF8))
                {
                    writer.Formatting = Formatting.Indented;
                    XmlSerializerNamespaces xmlnsEmpty = new XmlSerializerNamespaces();
                    xmlnsEmpty.Add("", "");
                    serializer.Serialize(writer, tailConfig, xmlnsEmpty);
                }

                _defaultTailConfig = null;  // Force reload incase we saved a new default config
            }
            catch (System.Exception ex)
            {
                string errorMsg = ex.Message;
                while (ex.InnerException != null)
                {
                    ex        = ex.InnerException;
                    errorMsg += "\n" + ex.Message;
                }
                MessageBox.Show(this, "Failed to save session xml file, please ensure it is valid location:\n\n   " + filepath + "\n\n" + errorMsg, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        public void SaveConfig(TailConfig tailConfig, string filepath)
        {
            if (string.IsNullOrEmpty(filepath))
            {
                string defaultPath = GetDefaultConfigPath();
                if (string.IsNullOrEmpty(defaultPath))
                {
                    defaultPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\SnakeTail\\";
                    if (!Directory.Exists(defaultPath))
                        Directory.CreateDirectory(defaultPath);

                    defaultPath += "SnakeTail.xml";
                }

                filepath = defaultPath;
            }

            XmlSerializer serializer = new XmlSerializer(typeof(TailConfig));
            try
            {
                using (XmlTextWriter writer = new XmlTextWriter(filepath, Encoding.UTF8))
                {
                    writer.Formatting = Formatting.Indented;
                    XmlSerializerNamespaces xmlnsEmpty = new XmlSerializerNamespaces();
                    xmlnsEmpty.Add("", "");
                    serializer.Serialize(writer, tailConfig, xmlnsEmpty);
                }

                _defaultTailConfig = null;  // Force reload incase we saved a new default config
            }
            catch(System.Exception ex)
            {
                string errorMsg = ex.Message;
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                    errorMsg += "\n" + ex.Message;
                }
                MessageBox.Show(this, "Failed to save session xml file, please ensure it is valid location:\n\n   " + filepath + "\n\n" + errorMsg, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        private int OpenFileSelection(string[] filenames)
        {
            if (_defaultTailConfig == null)
            {
                TailConfig tailConfig = null;
                string defaultPath = GetDefaultConfigPath();
                if (!string.IsNullOrEmpty(defaultPath))
                    tailConfig = LoadSessionFile(defaultPath);

                if (tailConfig != null && tailConfig.TailFiles.Count > 0)
                {
                    _defaultTailConfig = tailConfig.TailFiles[0];
                    _defaultTailConfig.Title = null;
                }
                else
                {
                    _defaultTailConfig = new TailFileConfig();
                }
            }

            int filesOpened = 0;
            foreach (string filename in filenames)
            {
                string configPath = "";
                try
                {
                    if (string.IsNullOrEmpty(Path.GetDirectoryName(filename)))
                        configPath = Directory.GetCurrentDirectory();
                }
                catch
                {
                }

                TailForm mdiForm = new TailForm();
                TailFileConfig tailConfig = _defaultTailConfig;
                tailConfig.FilePath = filename;
                mdiForm.LoadConfig(tailConfig, configPath);
                if (mdiForm.IsDisposed)
                    continue;

                _mruMenu.AddFile(filename);

                mdiForm.MdiParent = this;
                mdiForm.Show();
                ++filesOpened;
                Application.DoEvents();
            }
            return filesOpened;
        }
Beispiel #7
0
        private void SaveSession(string filepath)
        {
            TailConfig tailConfig = new TailConfig();
            if (_MDITabControl.Visible)
                tailConfig.SelectedTab = _MDITabControl.SelectedIndex;
            else
                tailConfig.SelectedTab = -1;
            tailConfig.WindowSize = Size;
            tailConfig.WindowPosition = DesktopLocation;
            tailConfig.MinimizedToTray = _trayIcon.Visible;
            tailConfig.AlwaysOnTop = TopMost;

            List<Form> childForms = new List<Form>();

            // We first loop through the tabpages to store in proper TabPage order
            foreach (TabPage tagPage in _MDITabControl.TabPages)
            {
                Form tailForm = tagPage.Tag as Form;
                if (tailForm != null)
                    childForms.Add(tailForm);
            }

            // Then we loop through all forms (includes free floating)
            foreach (Form childForm in Application.OpenForms)
            {
                if (childForms.IndexOf(childForm) == -1)
                    childForms.Add(childForm);
            }

            // Save all forms and store in proper order
            foreach (Form childForm in childForms)
            {
                ITailForm tailForm = childForm as ITailForm;
                if (tailForm != null)
                {
                    TailFileConfig tailFile = new TailFileConfig();
                    tailForm.SaveConfig(tailFile);
                    tailConfig.TailFiles.Add(tailFile);
                }
            }

            SaveConfig(tailConfig, filepath);

            if (String.IsNullOrEmpty(_currenTailConfig))
                _mruMenu.AddFile(filepath);
            else if (_currenTailConfig != filepath)
                _mruMenu.RenameFile(_currenTailConfig, filepath);

            _currenTailConfig = filepath;

            UpdateTitle();
        }
Beispiel #8
0
        private void configureViewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TailFileConfig configFile = new TailFileConfig();
            SaveConfig(configFile);
            TailConfigForm configForm = new TailConfigForm(configFile, true);
            switch (configForm.ShowDialog(this))
            {
                case DialogResult.OK:
                {
                    LoadConfig(configForm.TailFileConfig, _configPath);
                    break;
                }

                case DialogResult.Retry:
                {
                    // Apply Config To All
                    LoadConfig(configForm.TailFileConfig, _configPath);
                    configFile = new TailFileConfig();
                    SaveConfig(configFile);
                    TailConfigApplyAllForm configFormApply = new TailConfigApplyAllForm();
                    if (configFormApply.ShowDialog(this) == DialogResult.OK)
                    {
                        // Then we loop through all forms (includes free floating)
                        foreach (Form childForm in Application.OpenForms)
                        {
                            TailForm tailForm = childForm as TailForm;
                            if (tailForm != null && tailForm != this)
                            {
                                TailFileConfig configFileOther = new TailFileConfig();
                                tailForm.SaveConfig(configFileOther);
                                if (configFormApply._checkBoxColors.Checked)
                                {
                                    configFileOther.FormBackColor = configFile.FormBackColor;
                                    configFileOther.FormTextColor = configFile.FormTextColor;
                                    configFileOther.FormBookmarkBackColor = configFile.FormBookmarkBackColor;
                                    configFileOther.FormBookmarkTextColor = configFile.FormBookmarkTextColor;
                                }
                                if (configFormApply._checkBoxFont.Checked)
                                    configFileOther.FontInvariant = configFile.FontInvariant;
                                if (configFormApply._checkboxKeywords.Checked)
                                    configFileOther.KeywordHighlight = configFile.KeywordHighlight;
                                if (configFormApply._checkboxTools.Checked)
                                    configFileOther.ExternalTools = configFile.ExternalTools;
                                tailForm.LoadConfig(configFileOther, _configPath);
                            }
                        }
                    }
                    break;
                }
            }
        }
Beispiel #9
0
 public TailConfigForm(TailFileConfig tailFileConfig, bool displayFileTab)
 {
     InitializeComponent();
     TailFileConfig  = tailFileConfig;
     _displayFileTab = displayFileTab;
 }
Beispiel #10
0
 public void LoadFile(string filepath)
 {
     TailFileConfig tailConfig = new TailFileConfig();
     tailConfig.FilePath = filepath;
     LoadConfig(tailConfig, "");
 }
Beispiel #11
0
        public void SaveConfig(TailFileConfig tailConfig)
        {
            tailConfig.FormFont = _tailListView.Font;
            tailConfig.FormBackColor = _tailListView.BackColor;
            tailConfig.FormTextColor = _tailListView.ForeColor;

            tailConfig.FormBookmarkBackColor = _bookmarkBackColor;
            tailConfig.FormBookmarkTextColor = _bookmarkTextColor;

            tailConfig.KeywordHighlight = _keywordHighlight;

            tailConfig.ExternalTools = _externalTools;

            tailConfig.FileCacheSize = _logFileCache.Items.Count;
            tailConfig.EnumFileEncoding = _logTailStream.FileEncoding;
            tailConfig.FilePath = _logTailStream.FilePath;
            tailConfig.FileCheckInterval = _logTailStream.FileCheckInterval;
            tailConfig.FileChangeCheckInterval = _tailTimer.Interval;
            tailConfig.FileCheckPattern = _logTailStream.FileCheckPattern;
            tailConfig.TitleMatchFilename = _formTitleMatchFilename;
            tailConfig.Title = _formTitle;
            tailConfig.IconFile = _formIconFile;
            tailConfig.Modeless = MdiParent == null;
            tailConfig.WindowState = WindowState;
            if (WindowState == FormWindowState.Minimized)
            {
                tailConfig.WindowSize = RestoreBounds.Size;
                tailConfig.WindowPosition = RestoreBounds.Location;
            }
            else
            {
                tailConfig.WindowSize = Size;
                tailConfig.WindowPosition = DesktopLocation;
            }

            if (_taskMonitor != null)
                tailConfig.ServiceName = _taskMonitor.ServiceName;
            else
                tailConfig.ServiceName = "";

            tailConfig.DisplayTabIcon = _displayTabIcon;
        }
Beispiel #12
0
        private void switchToModelessToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TailForm newform = new TailForm();
            TailFileConfig tailConfig = new TailFileConfig();
            SaveConfig(tailConfig);
            if (this.MdiParent == null)
            {
                newform.MdiParent = MainForm.Instance;
                newform.ShowInTaskbar = false;
            }
            else
                newform.ShowInTaskbar = true;

            Close();

            newform.Show();
            newform._logFileCache = _logFileCache;
            newform._logFileStream = _logFileStream;
            newform._logTailStream = _logTailStream;
            newform._tailListView.VirtualListSize = _tailListView.VirtualListSize;
            newform.LoadConfig(tailConfig, _configPath);
            newform.BringToFront();
        }
Beispiel #13
0
        public void LoadConfig(TailFileConfig tailConfig, string configPath)
        {
            _configPath = configPath;

            try
            {
                new DirectoryInfo(Path.GetDirectoryName(Path.Combine(configPath, tailConfig.FilePath)));
            }
            catch (System.ArgumentException ex)
            {
                MessageBox.Show(this, String.Format("Failed to open file:\n\n{0}\n\nError:{1}", tailConfig.FilePath, ex.Message), "Invalid filename", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Close();
                return;
            }

            if (tailConfig.FileCacheSize <= 0)
                tailConfig.FileCacheSize = 1000;

            if (tailConfig.FormBackColor != null)
                _tailListView.BackColor = tailConfig.FormBackColor.Value;
            if (tailConfig.FormTextColor != null)
                _tailListView.ForeColor = tailConfig.FormTextColor.Value;

            if (tailConfig.FormFont != null)
                _tailListView.Font = tailConfig.FormFont;

            if (tailConfig.FormBookmarkBackColor != null)
                _bookmarkBackColor = tailConfig.FormBookmarkBackColor.Value;
            if (tailConfig.FormBookmarkTextColor != null)
                _bookmarkTextColor = tailConfig.FormBookmarkTextColor.Value;

            if (tailConfig.FileChangeCheckInterval > 0)
                _tailTimer.Interval = tailConfig.FileChangeCheckInterval;

            _externalTools = tailConfig.ExternalTools;
            externalToolsToolStripMenuItem.DropDownItems.Clear();
            externalToolsToolStripMenuItem.Enabled = false;
            if (_externalTools != null)
            {
                foreach (ExternalToolConfig externalTool in _externalTools)
                {
                    ToolStripMenuItem toolItem = externalToolsToolStripMenuItem.DropDownItems.Add(externalTool.Name) as ToolStripMenuItem;
                    if (toolItem != null)
                    {
                        toolItem.Tag = externalTool;
                        toolItem.Click += new EventHandler(externalToolMenuItem_Click);
                        if (externalTool.ShortcutKeyEnum.HasValue)
                            toolItem.ShortcutKeys = externalTool.ShortcutKeyEnum.Value;
                    }
                    externalToolsToolStripMenuItem.Enabled = true;
                }
            }

            _loghitCounter = -1;
            _keywordHighlight = tailConfig.KeywordHighlight;
            if (_keywordHighlight != null)
            {
                foreach (TailKeywordConfig keyword in _keywordHighlight)
                {
                    if (keyword.MatchRegularExpression)
                    {
                        if (keyword.MatchCaseSensitive)
                            keyword.KeywordRegex = new System.Text.RegularExpressions.Regex(keyword.Keyword);
                        else
                            keyword.KeywordRegex = new System.Text.RegularExpressions.Regex(keyword.Keyword, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                    }
                    else
                        keyword.KeywordRegex = null;

                    if (keyword.LogHitCounter)
                        _loghitCounter = 0;

                    if (!string.IsNullOrEmpty(keyword.ExternalToolName))
                    {
                        keyword.ExternalToolConfig = _externalTools.Find((externalTool) => string.Compare(externalTool.Name, keyword.ExternalToolName) == 0);
                        if (_threadPoolQueue == null)
                            _threadPoolQueue = new ThreadPoolQueue();   // Prepare the threadpool for use
                    }
                }
            }

            Encoding fileEncoding = tailConfig.EnumFileEncoding;

            if (_logTailStream != null)
                _logTailStream.Reset();

            if (_logFileStream == null || _logFileStream.FilePath != tailConfig.FilePath || _logFileStream.FileEncoding != fileEncoding || _logFileStream.FileCheckInterval != tailConfig.FileCheckInterval || _logFileStream.FileCheckPattern != tailConfig.FileCheckPattern)
            {
                if (_logFileStream != null)
                    _logFileStream.Dispose();
                _logFileStream = new LogFileStream(configPath, tailConfig.FilePath, fileEncoding, tailConfig.FileCheckInterval, tailConfig.FileCheckPattern);
            }
            if (_logTailStream == null || _logTailStream.FilePath != tailConfig.FilePath || _logTailStream.FileEncoding != fileEncoding || _logTailStream.FileCheckInterval != tailConfig.FileCheckInterval || _logTailStream.FileCheckPattern != tailConfig.FileCheckPattern)
            {
                if (_logTailStream != null)
                    _logTailStream.Dispose();
                _logTailStream = new LogFileStream(configPath, tailConfig.FilePath, fileEncoding, tailConfig.FileCheckInterval, tailConfig.FileCheckPattern);
                if (_logTailStream.Length > 500 * 1024 * 1024)
                {
                    if (MessageBox.Show(this, String.Format("The file is very large, sure you want to open it?\n\nFile Name: {0}\nFile Size: {1} Megabytes", _logTailStream.FilePath, _logTailStream.Length / 1024 / 1024), "Large file detected", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        Close();
                        return;
                    }
                }
                if (_logFileCache != null)
                {
                    _logFileCache.Reset();
                    _logFileCache = null;   // Reset Cache, as the file contents can have changed
                }
            }

            _logTailStream.FileReloadedEvent += new EventHandler(_logTailStream_FileReloadedEvent);

            if (_logFileCache != null)
                _logFileCache.Reset();

            if (_logFileCache == null || _logFileCache.Items.Count != tailConfig.FileCacheSize)
            {
                _logFileCache = new LogFileCache(tailConfig.FileCacheSize);
                _logFileCache.LoadingFileEvent += new EventHandler(_logFileCache_LoadingFileEvent);
                _logFileCache.FillCacheEvent += new EventHandler(_logFileCache_FillCacheEvent);
                // Add loading of cache while counting lines in file
                int lineCount = _logFileCache.FillTailCache(_logTailStream);
                _tailListView.VirtualListSize = lineCount;
            }
            else
            {
                _logFileCache.LoadingFileEvent += new EventHandler(_logFileCache_LoadingFileEvent);
                _logFileCache.FillCacheEvent += new EventHandler(_logFileCache_FillCacheEvent);
            }

            if (_taskMonitor != null)
            {
                _taskMonitor.Dispose();
                _taskMonitor = null;
            }
            if (!string.IsNullOrEmpty(tailConfig.ServiceName))
                _taskMonitor = new TaskMonitor(tailConfig.ServiceName);

            _formTitleMatchFilename = tailConfig.TitleMatchFilename;
            if (_formTitleMatchFilename)
                _formTitle = Path.GetFileName(_logTailStream.Name);
            else
            if (tailConfig.Title != null)
                _formTitle = tailConfig.Title;
            else
                _formTitle = Path.GetFileName(tailConfig.FilePath);

            UpdateFormTitle(true);

            _displayTabIcon = tailConfig.DisplayTabIcon;

            if (!string.IsNullOrEmpty(tailConfig.IconFile))
            {
                _formIconFile = tailConfig.IconFile;
                string formIconFilePathAbsolute = System.IO.Path.Combine(configPath, _formIconFile);
                try
                {
                    _formCustomIcon = System.Drawing.Icon.ExtractAssociatedIcon(formIconFilePathAbsolute);
                    _formMaximizedIcon = Icon;
                    Icon = _formCustomIcon;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Failed to load icon\n\n   " + formIconFilePathAbsolute + "\n\n" + ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            UpdateFormTitle(true);

            if (Visible)
            {
                if (_tailListView.VirtualListSize > 0)
                {
                    _tailListView.EnsureVisible(_tailListView.VirtualListSize - 1);
                    _tailListView.FocusedItem = _tailListView.Items[_tailListView.VirtualListSize - 1];
                    _tailListView.SelectedIndices.Add(_tailListView.VirtualListSize - 1);
                    _tailListView.Invalidate();
                    _tailListView.Update();
                }
            }
        }
Beispiel #14
0
        private void SaveSession(string filepath)
        {
            TailConfig tailConfig = new TailConfig();

            if (_MDITabControl.Visible)
            {
                tailConfig.SelectedTab = _MDITabControl.SelectedIndex;
            }
            else
            {
                tailConfig.SelectedTab = -1;
            }
            tailConfig.WindowSize      = Size;
            tailConfig.WindowPosition  = DesktopLocation;
            tailConfig.MinimizedToTray = _trayIcon.Visible;
            tailConfig.AlwaysOnTop     = TopMost;

            List <Form> childForms = new List <Form>();

            // We first loop through the tabpages to store in proper TabPage order
            foreach (TabPage tagPage in _MDITabControl.TabPages)
            {
                Form tailForm = tagPage.Tag as Form;
                if (tailForm != null)
                {
                    childForms.Add(tailForm);
                }
            }

            // Then we loop through all forms (includes free floating)
            foreach (Form childForm in Application.OpenForms)
            {
                if (childForms.IndexOf(childForm) == -1)
                {
                    childForms.Add(childForm);
                }
            }

            // Save all forms and store in proper order
            foreach (Form childForm in childForms)
            {
                ITailForm tailForm = childForm as ITailForm;
                if (tailForm != null)
                {
                    TailFileConfig tailFile = new TailFileConfig();
                    tailForm.SaveConfig(tailFile);
                    tailConfig.TailFiles.Add(tailFile);
                }
            }

            SaveConfig(tailConfig, filepath);

            if (String.IsNullOrEmpty(_currenTailConfig))
            {
                _mruMenu.AddFile(filepath);
            }
            else if (_currenTailConfig != filepath)
            {
                _mruMenu.RenameFile(_currenTailConfig, filepath);
            }

            _currenTailConfig = filepath;

            UpdateTitle();
        }
Beispiel #15
0
 public TailConfigForm(TailFileConfig tailFileConfig, bool displayFileTab)
 {
     InitializeComponent();
     TailFileConfig = tailFileConfig;
     _displayFileTab = displayFileTab;
 }
Beispiel #16
0
 public void LoadFile(string eventLogFile)
 {
     TailFileConfig tailConfig = new TailFileConfig();
     tailConfig.FilePath = eventLogFile;
     LoadConfig(tailConfig, null);
 }
Beispiel #17
0
 private void _configTextToolStripMenuItem_Click(object sender, EventArgs e)
 {
     TailFileConfig configFile = new TailFileConfig();
     SaveConfig(configFile);
     TailConfigForm configForm = new TailConfigForm(configFile, false);
     if (configForm.ShowDialog(this) == DialogResult.OK)
         LoadConfig(configForm.TailFileConfig, null);
 }
Beispiel #18
0
        public void LoadConfig(TailFileConfig tailConfig, string configPath)
        {
            try
            {
                _eventLog = new EventLog(tailConfig.FilePath);
                _eventLog.EntryWritten += new EntryWrittenEventHandler(_eventLog_EntryWritten);
                _eventLog.EndInit();
                if (_eventLog.Entries.Count == -1)
                    return; // Crazy check just to ensure we have permissions to read the log
            }
            catch (System.Security.SecurityException ex)
            {
                MessageBox.Show(this, "Access denied when opening log: " + tailConfig.FilePath + "\n\n" + ex.Message);
                Close();
                return;
            }

            _messageLookup = new EventLogMesageLookup(_eventLog);

            if (tailConfig.FormBackColor != null)
                _eventListView.BackColor = tailConfig.FormBackColor.Value;
            if (tailConfig.FormTextColor != null)
                _eventListView.ForeColor = tailConfig.FormTextColor.Value;

            if (tailConfig.FormFont != null)
            {
                _eventListView.Font = tailConfig.FormFont;
                _eventMessageText.Font = tailConfig.FormFont;
            }

            if (tailConfig.Title != null)
                _formTitle = tailConfig.Title;
            else
                _formTitle = "EventLog - " + _eventLog.LogDisplayName;

            TabPage parentTab = this.Tag as TabPage;
            if (parentTab != null)
                parentTab.Text = _formTitle;

            if (tailConfig.ColumnFilters != null)
            {
                foreach (List<string> filter in tailConfig.ColumnFilters)
                {
                    List<Regex> columnFilter = new List<Regex>();
                    foreach (string regexPattern in filter)
                    {
                        if (!string.IsNullOrEmpty(regexPattern))
                            columnFilter.Add(new Regex(regexPattern));
                        else
                            columnFilter.Add(null);
                    }
                    _columnFilters.Add(columnFilter);
                }
            }

            _filterActive = tailConfig.ColumnFilterActive;
            _displayTabIcon = tailConfig.DisplayTabIcon;

            if (Visible)
            {
                ConfigureColumnFilter(_filterActive);
            }
        }
Beispiel #19
0
        private void switchWindowModeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EventLogForm newform = new EventLogForm();
            TailFileConfig tailConfig = new TailFileConfig();
            SaveConfig(tailConfig);
            if (this.MdiParent == null)
            {
                newform.MdiParent = MainForm.Instance;
                newform.ShowInTaskbar = false;
            }
            else
                newform.ShowInTaskbar = true;

            Close();

            newform.LoadConfig(tailConfig, null);
            newform.Show();
            newform.BringToFront();
        }
Beispiel #20
0
        public void SaveConfig(TailFileConfig tailConfig)
        {
            tailConfig.BackColor = ColorTranslator.ToHtml(_eventListView.BackColor);
            tailConfig.TextColor = ColorTranslator.ToHtml(_eventListView.ForeColor);

            tailConfig.FormFont = _eventListView.Font;
            tailConfig.FilePath = _eventLog.Log;
            tailConfig.Title = _formTitle;
            tailConfig.Modeless = MdiParent == null;
            tailConfig.WindowState = WindowState;
            if (WindowState == FormWindowState.Minimized)
            {
                tailConfig.WindowSize = RestoreBounds.Size;
                tailConfig.WindowPosition = RestoreBounds.Location;
            }
            else
            {
                tailConfig.WindowSize = Size;
                tailConfig.WindowPosition = DesktopLocation;
            }
            tailConfig.ColumnFilters = new List<List<string>>();
            foreach (List<Regex> filter in _columnFilters)
            {
                List<string> columnFilter = new List<string>();
                foreach(Regex regexPattern in filter)
                {
                    if (regexPattern!=null)
                        columnFilter.Add(regexPattern.ToString());
                    else
                        columnFilter.Add("");
                }
                tailConfig.ColumnFilters.Add(columnFilter);
            }
            tailConfig.ColumnFilterActive = _filterActive;
            tailConfig.DisplayTabIcon = _displayTabIcon;
        }