Skip to content

Commit

Permalink
Readded various control methods + general tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
woanware committed Jul 1, 2019
1 parent 3f88fab commit 498f518
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 57 deletions.
1 change: 0 additions & 1 deletion Source/FormMain.Designer.cs

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

75 changes: 23 additions & 52 deletions Source/FormMain.cs
Expand Up @@ -25,7 +25,6 @@ public partial class FormMain : Form
private Color contextColour = Color.LightGray;
private Configuration config;
private Dictionary<string, LogFile> logs;
private int currentTabIndex = -1;
#endregion

#region Constructor
Expand Down Expand Up @@ -152,8 +151,7 @@ private void LoadFile(string filePath, bool newTab)
this.cancellationTokenSource = new CancellationTokenSource();
menuToolsMultiStringSearch.Enabled = true;

// Clear any existing filters/reset values
//
// Clear any existing filters/reset values
this.searches = new Searches();

if (newTab == true)
Expand Down Expand Up @@ -193,8 +191,6 @@ private void LoadFile(string filePath, bool newTab)
lf.Dispose();
lf.Load(filePath, synchronizationContext, cancellationTokenSource.Token);
}

// this.Text = "LogViewer - " + filePath;
}

/// <summary>
Expand Down Expand Up @@ -237,16 +233,18 @@ private void Export(string filePath)
this.hourGlass = new HourGlass(this);
SetProcessingState(false);
statusProgress.Visible = true;
// this.cancellationTokenSource = new CancellationTokenSource();
this.cancellationTokenSource = new CancellationTokenSource();

//if (listLines.ModelFilter == null)
//{
// lf.Export(filePath, cancellationTokenSource.Token);
//}
//else
//{
// lf.Export(listLines.FilteredObjects, filePath, cancellationTokenSource.Token);
//}
LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];

if (lf.List.ModelFilter == null)
{
lf.Export(filePath, cancellationTokenSource.Token);
}
else
{
lf.Export(lf.List.FilteredObjects, filePath, cancellationTokenSource.Token);
}
}

/// <summary>
Expand All @@ -259,9 +257,10 @@ private void ExportSelected(string filePath)
this.hourGlass = new HourGlass(this);
SetProcessingState(false);
statusProgress.Visible = true;
// this.cancellationTokenSource = new CancellationTokenSource();
this.cancellationTokenSource = new CancellationTokenSource();

//lf.Export(listLines.SelectedObjects, filePath, cancellationTokenSource.Token);
LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];
lf.Export(lf.List.SelectedObjects, filePath, cancellationTokenSource.Token);
}
#endregion

Expand Down Expand Up @@ -581,8 +580,7 @@ private void contextMenuSearchColourMatch_Click(object sender, EventArgs e)

this.highlightColour = cd.Color;

LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];
lf.List.Refresh();
logs[tabControl.SelectedTab.Tag.ToString()].List.Refresh();
}

/// <summary>
Expand All @@ -601,8 +599,7 @@ private void contextMenuSearchColourContext_Click(object sender, EventArgs e)

this.contextColour = cd.Color;

LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];
lf.List.Refresh();
logs[tabControl.SelectedTab.Tag.ToString()].List.Refresh();
}

/// <summary>
Expand Down Expand Up @@ -833,16 +830,6 @@ private void menuFileOpenNewTab_Click(object sender, EventArgs e)
LoadFile(openFileDialog.FileName, true);
}

/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuFileOpenNewTab_Click(object sender, EventArgs e)
{

}

/// <summary>
/// Close the resources used for opening and processing the log file
/// </summary>
Expand Down Expand Up @@ -870,12 +857,6 @@ private void menuFileClose_Click(object sender, EventArgs e)

tabControl.TabPages.Remove(tabControl.SelectedTab);

//// Clear any existing filters/reset values
//this.listLines0.ModelFilter = null;
//this.viewMode = Global.ViewMode.Standard;
//this.searches = new Searches();
//this.filterIds.Clear();

if (logs.Count == 0)
{
menuFileOpen.Enabled = false;
Expand Down Expand Up @@ -977,6 +958,7 @@ private void SetProcessingState(bool enabled)
MethodInvoker methodInvoker = delegate
{
menuFileOpen.Enabled = enabled;
menuFileOpenNewTab.Enabled = enabled;
menuFileExit.Enabled = enabled;
toolButtonCumulative.Enabled = enabled;
toolButtonSearch.Enabled = enabled;
Expand All @@ -998,10 +980,10 @@ private void SetProcessingState(bool enabled)
/// <param name="enabled"></param>
private void UpdateStatusLabel(string text, ToolStripStatusLabel control)
{
//synchronizationContext.Post(new SendOrPostCallback(o =>
//{
// control.Text = (string)o;
//}), text);
synchronizationContext.Post(new SendOrPostCallback(o =>
{
control.Text = (string)o;
}), text);
}
#endregion

Expand All @@ -1013,19 +995,8 @@ private void UpdateStatusLabel(string text, ToolStripStatusLabel control)
/// <param name="e"></param>
private void statusProgress_Click(object sender, EventArgs e)
{
//this.cancellationTokenSource.Cancel();
this.cancellationTokenSource.Cancel();
}
#endregion

/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
{
currentTabIndex = tabControl.SelectedIndex;
}

}
}
6 changes: 2 additions & 4 deletions Source/LogFile.cs
Expand Up @@ -45,7 +45,6 @@ internal class LogFile
public int LineCount { get; private set; } = 0;
private FileStream fileStream;
private Mutex readMutex = new Mutex();
private string filePath;
public string FileName { get; private set; }
public List<ushort> FilterIds { get; private set; } = new List<ushort>();
public FastObjectListView List { get; set; }
Expand All @@ -68,7 +67,6 @@ public LogFile()
/// <param name="ct"></param>
public void Load(string filePath, SynchronizationContext st, CancellationToken ct)
{
this.filePath = filePath;
this.FileName = Path.GetFileName(filePath);

Task.Run(() => {
Expand Down Expand Up @@ -208,8 +206,8 @@ public void Dispose()
{
this.Lines.Clear();
this.LongestLine = new LogLine();
this.LineCount = 0;
this.filePath = string.Empty;
this.LineCount = 0;
this.FileName = String.Empty;
this.FilterIds = new List<ushort>();
this.List.ModelFilter = null;
this.FilterIds.Clear();
Expand Down

0 comments on commit 498f518

Please sign in to comment.