Skip to content

Commit

Permalink
Finished final UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
woanware committed Jul 3, 2019
1 parent f0c04f6 commit c0cf30a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 149 deletions.
21 changes: 2 additions & 19 deletions Source/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions Source/FormMain.cs
Expand Up @@ -155,7 +155,7 @@ private void LoadFile(string filePath, bool newTab)
LogFile lf = new LogFile();
logs.Add(lf.Guid, lf);

tabControl.TabPages.Add(lf.Initialise());
tabControl.TabPages.Add(lf.Initialise(filePath));
lf.SetContextMenu(contextMenu);
lf.ViewMode = Global.ViewMode.Standard;
lf.ProgressUpdate += LogFile_LoadProgress;
Expand Down Expand Up @@ -184,6 +184,7 @@ private void LoadFile(string filePath, bool newTab)

// Get the current selected log file and open the file using that object
LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];
tabControl.SelectedTab.ToolTipText = filePath;
lf.Dispose();
lf.Load(filePath, synchronizationContext, cancellationTokenSource.Token);
}
Expand Down Expand Up @@ -265,13 +266,12 @@ private void ExportSelected(string filePath)
///
/// </summary>
/// <param name="message"></param>
private void LogFile_LoadError(string message)
private void LogFile_LoadError(string fileName, string message)
{
UserInterface.DisplayErrorMessageBox(this, message);
UserInterface.DisplayErrorMessageBox(this, message + " (" + fileName + ")");

synchronizationContext.Post(new SendOrPostCallback(o =>
{
this.Text = "LogViewer";
statusProgress.Visible = false;
this.hourGlass.Dispose();
SetProcessingState(true);
Expand Down Expand Up @@ -299,7 +299,7 @@ private void LogFile_LoadProgress(int percent)
/// <summary>
///
/// </summary>
private void LogFile_SearchComplete(LogFile lf, TimeSpan duration, long matches, int numTerms, bool cancelled)
private void LogFile_SearchComplete(LogFile lf, string fileName, TimeSpan duration, long matches, int numTerms, bool cancelled)
{
synchronizationContext.Post(new SendOrPostCallback(o =>
{
Expand All @@ -308,7 +308,8 @@ private void LogFile_SearchComplete(LogFile lf, TimeSpan duration, long matches,
this.hourGlass.Dispose();
SetProcessingState(true);
this.cancellationTokenSource.Dispose();
UpdateStatusLabel("Matched " + matches + " lines (Search Terms: " + numTerms + ") # Duration: " + duration, statusLabelSearch);
UpdateStatusLabel("Matched " + matches + " lines (Search Terms: " + numTerms + ") # Duration: " + duration + " (" + fileName + ")", statusLabelMain);
this.processing = false;
}), null);
Expand All @@ -318,23 +319,23 @@ private void LogFile_SearchComplete(LogFile lf, TimeSpan duration, long matches,
///
/// </summary>
/// <param name="val"></param>
private void LogFile_ExportComplete(LogFile lf, TimeSpan duration, bool val)
private void LogFile_ExportComplete(LogFile lf, string fileName, TimeSpan duration, bool val)
{
synchronizationContext.Post(new SendOrPostCallback(o =>
{
statusProgress.Visible = false;
this.hourGlass.Dispose();
SetProcessingState(true);
this.cancellationTokenSource.Dispose();
UpdateStatusLabel("Export complete # Duration: " + duration, statusLabelSearch);
UpdateStatusLabel("Export complete # Duration: " + duration + " (" + fileName + ")", statusLabelMain);
this.processing = false;
}), null);
}

/// <summary>
///
/// </summary>
private void LogFile_LoadComplete(LogFile lf, TimeSpan duration, bool cancelled)
private void LogFile_LoadComplete(LogFile lf, string fileName, TimeSpan duration, bool cancelled)
{
synchronizationContext.Post(new SendOrPostCallback(o =>
{
Expand All @@ -358,8 +359,7 @@ private void LogFile_LoadComplete(LogFile lf, TimeSpan duration, bool cancelled)
SetProcessingState(true);
this.cancellationTokenSource.Dispose();
UpdateStatusLabel(lf.Lines.Count + " Lines # Duration: " + duration, statusLabelMain);
UpdateStatusLabel("", statusLabelSearch);
UpdateStatusLabel(lf.Lines.Count + " Lines # Duration: " + duration + " (" + fileName + ")", statusLabelMain);
menuFileClose.Enabled = true;
menuFileOpen.Enabled = true; // Enable the standard file open, since we can now open in an existing tab, since at least one tab exists
int index = tabControl.TabPages.IndexOfKey("tabPage" + lf.Guid);
Expand Down Expand Up @@ -860,7 +860,6 @@ private void menuFileClose_Click(object sender, EventArgs e)
}

UpdateStatusLabel("", statusLabelMain);
UpdateStatusLabel("", statusLabelSearch);
}

/// <summary>
Expand Down
69 changes: 12 additions & 57 deletions Source/LogFile.cs
Expand Up @@ -19,11 +19,10 @@ namespace LogViewer
internal class LogFile
{
#region Delegates
public delegate void SearchCompleteEvent(LogFile lf, TimeSpan duration, long matches, int numSearchTerms, bool cancelled);
public delegate void CompleteEvent(LogFile lf, TimeSpan duration, bool cancelled);
public delegate void BoolEvent(bool val);
public delegate void DefaultEvent();
public delegate void MessageEvent(string message);
public delegate void SearchCompleteEvent(LogFile lf, string fileName, TimeSpan duration, long matches, int numSearchTerms, bool cancelled);
public delegate void CompleteEvent(LogFile lf, string fileName, TimeSpan duration, bool cancelled);
public delegate void BoolEvent(string fileName, bool val);
public delegate void MessageEvent(string fileName, string message);
public delegate void ProgressUpdateEvent(int percent);
#endregion

Expand Down Expand Up @@ -452,7 +451,7 @@ public void Export(IEnumerable lines, string filePath, CancellationToken ct)
}
#endregion

public TabPage Initialise()
public TabPage Initialise(string filePath)
{
OLVColumn colLineNumber = ((OLVColumn)(new OLVColumn()));
OLVColumn colText = ((OLVColumn)(new OLVColumn()));
Expand Down Expand Up @@ -531,7 +530,8 @@ public TabPage Initialise()
tp.TabIndex = 0;
tp.Text = "Loading...";
tp.UseVisualStyleBackColor = true;
tp.Tag = this.Guid;
tp.Tag = this.Guid;
tp.ToolTipText = filePath;

return tp;
}
Expand Down Expand Up @@ -715,90 +715,45 @@ public string GetLine(int lineNumber)
return Regex.Replace(Encoding.ASCII.GetString(buffer), "[\0-\b\n\v\f\x000E-\x001F\x007F-ÿ]", "", RegexOptions.Compiled);
}

/// <summary>
///
/// </summary>
/// <param name="lineNumber"></param>
/// <returns></returns>
//public byte[] GetLineBytes(int lineNumber)
//{
// if (lineNumber >= this.Lines.Count)
// {
// return new byte[]{};
// }

// byte[] buffer = new byte[this.Lines[lineNumber].CharCount + 1];
// try
// {
// this.readMutex.WaitOne();
// this.fileStream.Seek(this.Lines[lineNumber].Offset, SeekOrigin.Begin);
// this.fileStream.Read(buffer, 0, this.Lines[lineNumber].CharCount);
// this.readMutex.ReleaseMutex();
// }
// catch (Exception) { }

// return buffer;
//}

#region Event Methods
/// <summary>
///
/// </summary>
private void OnLoadError(string message)
{
var handler = LoadError;
if (handler != null)
{
handler(message);
}
LoadError?.Invoke(this.FileName, message);
}

/// <summary>
///
/// </summary>
private void OnProgressUpdate(int progress)
{
var handler = ProgressUpdate;
if (handler != null)
{
handler(progress);
}
ProgressUpdate?.Invoke(progress);
}

/// <summary>
///
/// </summary>
private void OnLoadComplete(TimeSpan duration, bool cancelled)
{
var handler = LoadComplete;
if (handler != null)
{
handler(this, duration, cancelled);
}
LoadComplete?.Invoke(this, this.FileName, duration, cancelled);
}

/// <summary>
///
/// </summary>
private void OnExportComplete(TimeSpan duration, bool cancelled)
{
var handler = ExportComplete;
if (handler != null)
{
handler(this, duration, cancelled);
}
ExportComplete?.Invoke(this, this.FileName, duration, cancelled);
}

/// <summary>
///
/// </summary>
private void OnSearchComplete(TimeSpan duration, long matches, int numTerms, bool cancelled)
{
var handler = SearchComplete;
if (handler != null)
{
handler(this, duration, matches, numTerms, cancelled);
}
SearchComplete?.Invoke(this, this.FileName, duration, matches, numTerms, cancelled);
}
#endregion
}
Expand Down
61 changes: 0 additions & 61 deletions history.md

This file was deleted.

Binary file removed history.pdf
Binary file not shown.

0 comments on commit c0cf30a

Please sign in to comment.