public void LoadFiles(string[] fileNames) { _logger.Info("Loading files into existing LogTabWindow"); LogTabWindow logWin = this.windowList[this.windowList.Count - 1]; logWin.Invoke(new MethodInvoker(logWin.SetForeground)); logWin.LoadFiles(fileNames); }
public void NewWindowWorker(string[] fileNames) { _logger.Info("Creating new LogTabWindow"); LogTabWindow logWin = new LogTabWindow(fileNames.Length > 0 ? fileNames : null, logWindowIndex++, true); logWin.LogExpertProxy = this; AddWindow(logWin); logWin.Show(); logWin.Activate(); }
public void WindowClosed(LogTabWindow logWin) { RemoveWindow(logWin); if (this.windowList.Count == 0) { _logger.Info("Last LogTabWindow was closed"); PluginRegistry.GetInstance().CleanupPlugins(); OnLastWindowClosed(); } else { if (this.firstLogTabWindow == logWin) { // valid firstLogTabWindow is needed for the Invoke()-Calls in NewWindow() this.firstLogTabWindow = this.windowList[this.windowList.Count - 1]; } } }
public void NewWindow(string[] fileNames) { if (this.firstLogTabWindow.IsDisposed) { _logger.Warn("first GUI thread window is disposed. Setting a new one."); // may occur if a window is closed because of unhandled exception. // Determine a new 'firstWindow'. If no window is left, start a new one. RemoveWindow(this.firstLogTabWindow); if (this.windowList.Count == 0) { _logger.Info("No windows left. New created window will be the new 'first' GUI window"); LoadFiles(fileNames); } else { this.firstLogTabWindow = this.windowList[this.windowList.Count - 1]; NewWindow(fileNames); } } else { this.firstLogTabWindow.Invoke(new NewWindowFx(NewWindowWorker), new object[] { fileNames }); } }
public void NewWindow(string[] fileNames) { if (_firstLogTabWindow.IsDisposed) { Logger.logWarn("first GUI thread window is disposed. Setting a new one."); // may occur if a window is closed because of unhandled exception. // Determine a new 'firstWindow'. If no window is left, start a new one. RemoveWindow(_firstLogTabWindow); if (_windowList.Count == 0) { Logger.logInfo("No windows left. New created window will be the new 'first' GUI window"); LoadFiles(fileNames); } else { _firstLogTabWindow = _windowList[_windowList.Count - 1]; NewWindow(fileNames); } } else { _firstLogTabWindow.Invoke(new Action<string[]>(NewWindowWorker), new object[] { fileNames }); } }
public LogExpertApplicationContext(LogExpertProxy proxy, LogTabWindow firstLogWin) { this.proxy = proxy; this.proxy.LastWindowClosed += proxy_LastWindowClosed; firstLogWin.Show(); }
private void AddWindow(LogTabWindow window) { Logger.logInfo("Adding window to list"); _windowList.Add(window); }
public LogExpertProxy(LogTabWindow logTabWindow) { AddWindow(logTabWindow); logTabWindow.LogExpertProxy = this; firstLogTabWindow = logTabWindow; }
private void RemoveWindow(LogTabWindow window) { _logger.Info("Removing window from list"); this.windowList.Remove(window); }
private void AddWindow(LogTabWindow window) { _logger.Info("Adding window to list"); this.windowList.Add(window); }
private void RemoveWindow(LogTabWindow window) { Logger.logInfo("Removing window from list"); _windowList.Remove(window); }
public void WindowClosed(LogTabWindow logWin) { RemoveWindow(logWin); if (_windowList.Count == 0) { Logger.logInfo("Last LogTabWindow was closed"); PluginRegistry.GetInstance().CleanupPlugins(); OnLastWindowClosed(); } else { if (_firstLogTabWindow == logWin) { // valid firstLogTabWindow is needed for the Invoke()-Calls in NewWindow() _firstLogTabWindow = _windowList[_windowList.Count - 1]; } } }
private static void Sub_Main(string[] orgArgs) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Logger.logInfo("============================================================================"); Logger.logInfo("LogExpert " + Assembly.GetExecutingAssembly().GetName().Version.Major + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor + "/" + Assembly.GetExecutingAssembly().GetName().Version.Build.ToString() + " started."); Logger.logInfo("============================================================================"); List<string> argsList = new List<string>(); foreach (string fileArg in orgArgs) { try { FileInfo info = new FileInfo(fileArg); if (info.Exists) { argsList.Add(info.FullName); } else { argsList.Add(fileArg); } } catch (Exception) { MessageBox.Show("File name " + fileArg + " is not a valid file name!", "LogExpert Error"); } } string[] args = argsList.ToArray(); int pId = Process.GetCurrentProcess().SessionId; try { Settings settings = ConfigManager.Settings; bool isCreated = false; Mutex mutex = new System.Threading.Mutex(false, "Local\\LogExpertInstanceMutex" + pId, out isCreated); if (isCreated) { // first application instance Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LogTabWindow logWin = new LogTabWindow(args.Length > 0 ? args : null, 1, false); // first instance //WindowsIdentity wi = WindowsIdentity.GetCurrent(); IpcServerChannel ipcChannel = new IpcServerChannel("LogExpert" + pId); ChannelServices.RegisterChannel(ipcChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(LogExpertProxy), "LogExpertProxy", WellKnownObjectMode.Singleton); LogExpertProxy proxy = new LogExpertProxy(logWin); RemotingServices.Marshal(proxy, "LogExpertProxy"); LogExpertApplicationContext context = new LogExpertApplicationContext(proxy, logWin); Application.Run(context); ChannelServices.UnregisterChannel(ipcChannel); } else { int counter = 3; string errMsg = ""; IpcClientChannel ipcChannel = new IpcClientChannel("LogExpertClient#" + pId, null); ChannelServices.RegisterChannel(ipcChannel, false); while (counter > 0) { try { // another instance already exists //WindowsIdentity wi = WindowsIdentity.GetCurrent(); LogExpertProxy proxy = (LogExpertProxy)Activator.GetObject(typeof(LogExpertProxy), "ipc://LogExpert" + pId + "/LogExpertProxy"); if (settings.preferences.allowOnlyOneInstance) { proxy.LoadFiles(args); } else { proxy.NewWindowOrLockedWindow(args); } break; } catch (RemotingException e) { Logger.logError("IpcClientChannel error: " + e.Message); errMsg = e.Message; counter--; Thread.Sleep(500); } } if (counter == 0) { Logger.logError("IpcClientChannel error, giving up: " + errMsg); MessageBox.Show("Cannot open connection to first instance (" + errMsg + ")", "LogExpert"); } } mutex.Close(); } catch (Exception ex) { Logger.logError("Mutex error, giving up: " + ex.Message); MessageBox.Show("Cannot open connection to first instance (" + ex.Message + ")", "LogExpert"); } }
public LogWindow(LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading) { _logEventHandlerThread = new Thread(new ThreadStart(LogEventWorker)); _logEventHandlerThread.IsBackground = true; _logEventHandlerThread.Start(); BookmarkProvider = new BookmarkDataProvider(); BookmarkColor = Color.FromArgb(165, 200, 225); TempTitleName = ""; SuspendLayout(); InitializeComponent(); columnNamesLabel.Text = ""; // no filtering on columns by default _parentLogTabWin = parent; IsTempFile = isTempFile; ColumnizerCallbackObject = new ColumnizerCallback(this); FileName = fileName; ForcePersistenceLoading = forcePersistenceLoading; selectedDataGridView.DefaultCellStyle.WrapMode = DataGridViewTriState.True; selectedDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft; selectedDataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; selectedDataGridView.SelectionChanged += selectedDataGridView_SelectionChanged; dataGridView.CellValueNeeded += DataGridView_CellValueNeeded; dataGridView.CellPainting += DataGridView_CellPainting; dataGridView.SelectionChanged += DataGridView_NewSelectionChanged; dataGridView.DoubleClick += DataGridView_DoubleClick; filterGridView.CellValueNeeded += FilterGridView_CellValueNeeded; filterGridView.CellPainting += FilterGridView_CellPainting; Closing += LogWindow_Closing; Disposed += LogWindow_Disposed; _timeSpreadCalc = new TimeSpreadCalculator(this); timeSpreadingControl1.TimeSpreadCalc = _timeSpreadCalc; timeSpreadingControl1.LineSelected += TimeSpreadingControl1_LineSelected; tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute; tableLayoutPanel1.ColumnStyles[1].Width = 20; tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent; tableLayoutPanel1.ColumnStyles[0].Width = 100; _parentLogTabWin.HighlightSettingsChanged += Parent_HighlightSettingsChanged; SetColumnizer(PluginRegistry.GetInstance().RegisteredColumnizers[0]); _patternArgs.maxMisses = 5; _patternArgs.minWeight = 1; _patternArgs.maxDiffInBlock = 5; _patternArgs.fuzzy = 5; _filterParams = new FilterParams(); foreach (string item in ConfigManager.Settings.filterHistoryList) { filterComboBox.Items.Add(item); } filterRegexCheckBox.Checked = _filterParams.isRegex; filterCaseSensitiveCheckBox.Checked = _filterParams.isCaseSensitive; filterTailCheckBox.Checked = _filterParams.isFilterTail; splitContainer1.Panel2Collapsed = true; advancedFilterSplitContainer.SplitterDistance = FILTER_ADCANCED_SPLITTER_DISTANCE; _timeshiftSyncThread = new Thread(SyncTimestampDisplayWorker); _timeshiftSyncThread.IsBackground = true; _timeshiftSyncThread.Start(); _advancedButtonImage = advancedButton.Image; _searchButtonImage = filterSearchButton.Image; filterSearchButton.Image = null; dataGridView.EditModeMenuStrip = editModeContextMenuStrip; markEditModeToolStripMenuItem.Enabled = true; _panelOpenButtonImage = new Bitmap(GetType(), "Resources.PanelOpen.gif"); _panelCloseButtonImage = new Bitmap(GetType(), "Resources.PanelClose.gif"); Settings settings = ConfigManager.Settings; if (settings.appBounds != null && settings.appBounds.Right > 0) { Bounds = settings.appBounds; } _waitingForClose = false; dataGridView.Enabled = false; dataGridView.ColumnDividerDoubleClick += DataGridView_ColumnDividerDoubleClick; ShowAdvancedFilterPanel(false); filterKnobControl1.MinValue = 0; filterKnobControl1.MaxValue = SPREAD_MAX; filterKnobControl1.ValueChanged += FilterKnobControl1_CheckForFilterDirty; filterKnobControl2.MinValue = 0; filterKnobControl2.MaxValue = SPREAD_MAX; filterKnobControl2.ValueChanged += FilterKnobControl1_CheckForFilterDirty; fuzzyKnobControl.MinValue = 0; fuzzyKnobControl.MaxValue = 10; ToggleHighlightPanel(false); // hidden BookmarkProvider.BookmarkAdded += BookmarkProvider_BookmarkAdded; BookmarkProvider.BookmarkRemoved += BookmarkProvider_BookmarkRemoved; ResumeLayout(); _statusLineTrigger.Signal += StatusLineTrigger_Signal; _selectionChangedTrigger.Signal += SelectionChangedTrigger_Signal; PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); }
public LogExpertProxy(LogTabWindow logTabWindow) { AddWindow(logTabWindow); logTabWindow.LogExpertProxy = this; _firstLogTabWindow = logTabWindow; }
private static void Sub_Main(string[] orgArgs) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Logger.logInfo("============================================================================"); Logger.logInfo("LogExpert " + Assembly.GetExecutingAssembly().GetName().Version.Major + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor + "/" + Assembly.GetExecutingAssembly().GetName().Version.Build.ToString() + " started."); Logger.logInfo("============================================================================"); CmdLine cmdLine = new CmdLine(); CmdLineString configFile = new CmdLineString("config", false, "A configuration (settings) file"); cmdLine.RegisterParameter(configFile); string[] remainingArgs = cmdLine.Parse(orgArgs); List <string> argsList = new List <string>(); // This loop tries to convert relative file names into absolute file names (assuming that platform file names are given). // It tolerates errors, to give file system plugins (e.g. sftp) a change later. // TODO: possibly should be moved to LocalFileSystem plugin foreach (string fileArg in remainingArgs) { try { FileInfo info = new FileInfo(fileArg); if (info.Exists) { argsList.Add(info.FullName); } else { argsList.Add(fileArg); } } catch (Exception) { argsList.Add(fileArg); } } string[] args = argsList.ToArray(); if (configFile.Exists) { FileInfo cfgFileInfo = new FileInfo(configFile.Value); if (cfgFileInfo.Exists) { ConfigManager.Import(cfgFileInfo, ExportImportFlags.All); } else { MessageBox.Show("Config file not found", "LogExpert"); } } int pId = Process.GetCurrentProcess().SessionId; try { Settings settings = ConfigManager.Settings; bool isCreated = false; Mutex mutex = new System.Threading.Mutex(false, "Local\\LogExpertInstanceMutex" + pId, out isCreated); if (isCreated) { // first application instance Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LogTabWindow logWin = new LogTabWindow(args.Length > 0 ? args : null, 1, false); // first instance //WindowsIdentity wi = WindowsIdentity.GetCurrent(); IpcServerChannel ipcChannel = new IpcServerChannel("LogExpert" + pId); ChannelServices.RegisterChannel(ipcChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(LogExpertProxy), "LogExpertProxy", WellKnownObjectMode.Singleton); LogExpertProxy proxy = new LogExpertProxy(logWin); RemotingServices.Marshal(proxy, "LogExpertProxy"); LogExpertApplicationContext context = new LogExpertApplicationContext(proxy, logWin); Application.Run(context); ChannelServices.UnregisterChannel(ipcChannel); } else { int counter = 3; string errMsg = ""; IpcClientChannel ipcChannel = new IpcClientChannel("LogExpertClient#" + pId, null); ChannelServices.RegisterChannel(ipcChannel, false); while (counter > 0) { try { // another instance already exists //WindowsIdentity wi = WindowsIdentity.GetCurrent(); LogExpertProxy proxy = (LogExpertProxy)Activator.GetObject(typeof(LogExpertProxy), "ipc://LogExpert" + pId + "/LogExpertProxy"); if (settings.preferences.allowOnlyOneInstance) { proxy.LoadFiles(args); } else { proxy.NewWindowOrLockedWindow(args); } break; } catch (RemotingException e) { Logger.logError("IpcClientChannel error: " + e.Message); errMsg = e.Message; counter--; Thread.Sleep(500); } } if (counter == 0) { Logger.logError("IpcClientChannel error, giving up: " + errMsg); MessageBox.Show("Cannot open connection to first instance (" + errMsg + ")", "LogExpert"); } } mutex.Close(); } catch (Exception ex) { Logger.logError("Mutex error, giving up: " + ex.Message); MessageBox.Show("Cannot open connection to first instance (" + ex.Message + ")", "LogExpert"); } }
private static void Sub_Main(string[] orgArgs) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Logger.logInfo("============================================================================"); Logger.logInfo("LogExpert " + Assembly.GetExecutingAssembly().GetName().Version.Major + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor + "/" + Assembly.GetExecutingAssembly().GetName().Version.Build.ToString() + " started."); Logger.logInfo("============================================================================"); List <string> argsList = new List <string>(); foreach (string fileArg in orgArgs) { try { FileInfo info = new FileInfo(fileArg); if (info.Exists) { argsList.Add(info.FullName); } else { argsList.Add(fileArg); } } catch (Exception) { MessageBox.Show("File name " + fileArg + " is not a valid file name!", "LogExpert Error"); } } string[] args = argsList.ToArray(); int pId = Process.GetCurrentProcess().SessionId; try { Settings settings = ConfigManager.Settings; bool isCreated = false; Mutex mutex = new System.Threading.Mutex(false, "Local\\LogExpertInstanceMutex" + pId, out isCreated); if (isCreated) { // first application instance Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LogTabWindow logWin = new LogTabWindow(args.Length > 0 ? args : null, 1, false); // first instance //WindowsIdentity wi = WindowsIdentity.GetCurrent(); IpcServerChannel ipcChannel = new IpcServerChannel("LogExpert" + pId); ChannelServices.RegisterChannel(ipcChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(LogExpertProxy), "LogExpertProxy", WellKnownObjectMode.Singleton); LogExpertProxy proxy = new LogExpertProxy(logWin); RemotingServices.Marshal(proxy, "LogExpertProxy"); LogExpertApplicationContext context = new LogExpertApplicationContext(proxy, logWin); Application.Run(context); ChannelServices.UnregisterChannel(ipcChannel); } else { int counter = 3; string errMsg = ""; IpcClientChannel ipcChannel = new IpcClientChannel("LogExpertClient#" + pId, null); ChannelServices.RegisterChannel(ipcChannel, false); while (counter > 0) { try { // another instance already exists //WindowsIdentity wi = WindowsIdentity.GetCurrent(); LogExpertProxy proxy = (LogExpertProxy)Activator.GetObject(typeof(LogExpertProxy), "ipc://LogExpert" + pId + "/LogExpertProxy"); if (settings.preferences.allowOnlyOneInstance) { proxy.LoadFiles(args); } else { proxy.NewWindowOrLockedWindow(args); } break; } catch (RemotingException e) { Logger.logError("IpcClientChannel error: " + e.Message); errMsg = e.Message; counter--; Thread.Sleep(500); } } if (counter == 0) { Logger.logError("IpcClientChannel error, giving up: " + errMsg); MessageBox.Show("Cannot open connection to first instance (" + errMsg + ")", "LogExpert"); } } mutex.Close(); } catch (Exception ex) { Logger.logError("Mutex error, giving up: " + ex.Message); MessageBox.Show("Cannot open connection to first instance (" + ex.Message + ")", "LogExpert"); } }
public LogWindow(LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading) { SuspendLayout(); InitializeComponent(); columnNamesLabel.Text = ""; // no filtering on columns by default parentLogTabWin = parent; IsTempFile = isTempFile; //Thread.CurrentThread.Name = "LogWindowThread"; ColumnizerCallbackObject = new ColumnizerCallback(this); FileName = fileName; ForcePersistenceLoading = forcePersistenceLoading; dataGridView.CellValueNeeded += dataGridView_CellValueNeeded; dataGridView.CellPainting += dataGridView_CellPainting; filterGridView.CellValueNeeded += filterGridView_CellValueNeeded; filterGridView.CellPainting += filterGridView_CellPainting; Closing += LogWindow_Closing; Disposed += LogWindow_Disposed; timeSpreadCalc = new TimeSpreadCalculator(this); timeSpreadingControl1.TimeSpreadCalc = timeSpreadCalc; timeSpreadingControl1.LineSelected += timeSpreadingControl1_LineSelected; tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute; tableLayoutPanel1.ColumnStyles[1].Width = 20; tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent; tableLayoutPanel1.ColumnStyles[0].Width = 100; parentLogTabWin.HighlightSettingsChanged += parent_HighlightSettingsChanged; SetColumnizer(PluginRegistry.GetInstance().RegisteredColumnizers[0]); patternArgs.maxMisses = 5; patternArgs.minWeight = 1; patternArgs.maxDiffInBlock = 5; patternArgs.fuzzy = 5; //InitPatternWindow(); //this.toolwinTabControl.TabPages.Add(this.patternWindow); //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow); filterParams = new FilterParams(); foreach (string item in ConfigManager.Settings.filterHistoryList) { filterComboBox.Items.Add(item); } filterComboBox.DropDownHeight = filterComboBox.ItemHeight * ConfigManager.Settings.preferences.maximumFilterEntriesDisplayed; filterRegexCheckBox.Checked = filterParams.isRegex; filterCaseSensitiveCheckBox.Checked = filterParams.isCaseSensitive; filterTailCheckBox.Checked = filterParams.isFilterTail; splitContainer1.Panel2Collapsed = true; advancedFilterSplitContainer.SplitterDistance = FILTER_ADCANCED_SPLITTER_DISTANCE; timeshiftSyncThread = new Thread(SyncTimestampDisplayWorker); timeshiftSyncThread.IsBackground = true; timeshiftSyncThread.Start(); logEventHandlerThread = new Thread(LogEventWorker); logEventHandlerThread.IsBackground = true; logEventHandlerThread.Start(); //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker)); //this.filterUpdateThread.Start(); advancedButtonImage = advancedButton.Image; searchButtonImage = filterSearchButton.Image; filterSearchButton.Image = null; dataGridView.EditModeMenuStrip = editModeContextMenuStrip; markEditModeToolStripMenuItem.Enabled = true; panelOpenButtonImage = new Bitmap(GetType(), "Resources.PanelOpen.gif"); panelCloseButtonImage = new Bitmap(GetType(), "Resources.PanelClose.gif"); Settings settings = ConfigManager.Settings; if (settings.appBounds != null && settings.appBounds.Right > 0) { Bounds = settings.appBounds; } waitingForClose = false; dataGridView.Enabled = false; dataGridView.ColumnDividerDoubleClick += dataGridView_ColumnDividerDoubleClick; ShowAdvancedFilterPanel(false); filterKnobControl1.MinValue = 0; filterKnobControl1.MaxValue = SPREAD_MAX; filterKnobControl1.ValueChanged += filterKnobControl1_ValueChanged; filterKnobControl2.MinValue = 0; filterKnobControl2.MaxValue = SPREAD_MAX; filterKnobControl2.ValueChanged += filterKnobControl1_ValueChanged; fuzzyKnobControl.MinValue = 0; fuzzyKnobControl.MaxValue = 10; //PreferencesChanged(settings.preferences, true); AdjustHighlightSplitterWidth(); ToggleHighlightPanel(false); // hidden bookmarkProvider.BookmarkAdded += bookmarkProvider_BookmarkAdded; bookmarkProvider.BookmarkRemoved += bookmarkProvider_BookmarkRemoved; bookmarkProvider.AllBookmarksRemoved += bookmarkProvider_AllBookmarksRemoved; ResumeLayout(); statusLineTrigger.Signal += statusLineTrigger_Signal; selectionChangedTrigger.Signal += selectionChangedTrigger_Signal; PreferencesChanged(parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors); }
public void NewWindowWorker(string[] fileNames) { Logger.logInfo("Creating new LogTabWindow"); LogTabWindow logWin = new LogTabWindow(fileNames.Length > 0 ? fileNames : null, _logWindowIndex++, true); logWin.LogExpertProxy = this; AddWindow(logWin); logWin.Show(); logWin.Activate(); }