public LogViewer( EmuDebugger debugger ) : this() { this.Debugger = debugger; string[] names = Enum.GetNames( typeof( Feature ) ); _features = new FeatureInfo[ names.Length ]; foreach( string name in names ) { FeatureInfo feature = new FeatureInfo( name ); int value = ( int )Enum.Parse( typeof( Feature ), name ); _features[ value ] = feature; } Log.Instance = this; _addLine = new AddLineDelegate( this.AddLine ); listView_Resize( this, EventArgs.Empty ); criticalToolStripMenuItem.ForeColor = Color.DarkRed; verboseToolStripMenuItem.ForeColor = Color.DarkGreen; everythingToolStripMenuItem.ForeColor = Color.Blue; _lines = new List<ListViewItem>( 10000 ); if( ( System.Diagnostics.Debugger.IsAttached == true ) && ( System.Diagnostics.Debugger.IsLogging() == true ) ) { _debugEnabled = true; } else { _debugEnabled = false; } debugWriteToolStripButton.Visible = _debugEnabled; toolStripSeparator3.Visible = _debugEnabled; Bitmap image = Properties.Resources.OutputIcon as Bitmap; this.Icon = Icon.FromHandle( image.GetHicon() ); this.LoadSettings(); this.Refilter(); }
private void AddLine( Verbosity verbosity, FeatureInfo feature, ListViewItem item ) { try { if( ( int )verbosity > ( int )_globalVerbosity ) return; bool autoScroll = true; if( listView.Items.Count > 0 ) autoScroll = listView.Items[ listView.Items.Count - 1 ].Focused; listView.BeginUpdate(); listView.Items.Add( item ); if( autoScroll == true ) { item.EnsureVisible(); item.Focused = true; } listView.EndUpdate(); } catch { //Debugger.Break(); } }