/// <summary> /// ローテートログの追加 /// </summary> void _NewLogFile() { var lineDesign = new TextDesign( null ) { Typeface = m_logTypeface, FontSize = m_logFontSize, Foreground = m_logForeground, }; var text = "-------------------- ログファイルが再生成されました。以前のファイルの取得漏れの可能性があります。--------------------"; lineDesign.Update( text ); #if false var item = new LineListBoxItem2( lineLayout ) { LineNum = 0, FontFamily = m_logFontFamily, FontStyle = m_logFontStyle, FontWeight = m_logFontWeight, FontStretch = m_logFontStretch, FontSize = m_logFontSize, Foreground = m_logForeground, }; #else var item = new LineListBoxItem( lineDesign ) { LineNum = 0, FontFamily = m_logFontFamily, FontSize = m_logFontSize, }; #endif m_data.Add( item ); }
/// <summary> /// ログファイルの更新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _logWatcher_LogFileChanged( object sender, EventArgs e ) { // ログの読み込み var readData = m_logReader.ReadDiff(); if( readData == null ) { return; } var startIndex = 0; var lineNum = readData.StartLineNum; { var maxLine = Tailer.MaxLine; if( m_first ) { // 一度に大量のログを追加すると固まってしまうので、初回は数行のみ maxLine = m_firstMaxLine; } if( readData.Lines.Count > maxLine ) { startIndex = readData.Lines.Count - maxLine; lineNum += startIndex; } } // 非同期スレッドで作れるところまでは作る(GUI に関係ない部分の作成) var lineDesigns = new List<TextDesign>(); for( int index=startIndex; index<readData.Lines.Count; index++ ) { var line = readData.Lines[ index ]; var lineDesign = new TextDesign( Tailer.Conditions ) { Typeface = m_logTypeface, FontSize = m_logFontSize, Foreground = m_logForeground, }; lineDesign.Update( line ); lineDesigns.Add( lineDesign ); } // GUI の作成 Dispatcher.BeginInvoke( new Action<ReadData,List<TextDesign>>( _AddLineListBoxItem ), readData, lineDesigns ); }