Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trdwll committed Jul 31, 2018
1 parent c45fc02 commit 3065835
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 105 deletions.
5 changes: 0 additions & 5 deletions UE4LogParser/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ namespace UE4LogParser
{
public static class Utils
{
public static bool Contains(string source, string toCheck, StringComparison comp)
{
return source.IndexOf(toCheck, comp) >= 0;
}

public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
{
if (val.CompareTo(min) < 0) return min;
Expand Down
88 changes: 27 additions & 61 deletions UE4LogParser/frmMain.Designer.cs

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

77 changes: 41 additions & 36 deletions UE4LogParser/frmMain.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.IO;

namespace UE4LogParser
Expand All @@ -17,8 +12,6 @@ public partial class frmMain : Form
public frmMain()
{
InitializeComponent();

toolStripStatusLabel.Text = "";
}

private string[] keywords = { "ERROR", "WARNING", "INFO" };
Expand Down Expand Up @@ -83,58 +76,70 @@ private void menuSettings_Click(object sender, EventArgs e)

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
using (FileStream fs = File.Open(opened_log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
try
{
using (BufferedStream bs = new BufferedStream(fs))
using (FileStream fs = File.Open(opened_log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (StreamReader sr = new StreamReader(bs))
using (BufferedStream bs = new BufferedStream(fs))
{
string line;
while ((line = sr.ReadLine()) != null)
using (StreamReader sr = new StreamReader(bs))
{
foreach (string keyword in keywords)
string line;
while ((line = sr.ReadLine()) != null)
{
if (Utils.Contains(line, keyword, StringComparison.OrdinalIgnoreCase))
foreach (string keyword in keywords)
{
logView.Invoke(new Action(() =>
if (line.ToUpper().Contains(keyword.ToUpper()))
{
logView.Rows.Add(new string[] {
logView.Rows.Count.ToString(), keyword, line
});
}));
export_log.Add(line);
logView.Invoke(new Action(() =>
{
logView.Rows.Add(new string[] {
logView.Rows.Count.ToString(), keyword, line
});
}));

export_log.Add(line);
}
}
}
}
}
}

// int percent = (int)(((double)fs.Length) * 100.0) + 1;
// backgroundWorker1.ReportProgress(percent);
if (export_log.Count >= 1)
{
menuExport.Enabled = true;
}
}

if (export_log.Count >= 1)
catch (System.Exception ex)
{
menuExport.Enabled = true;
logView.Invoke(new Action(() => { logView.Enabled = true; }));
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
private void menuAbout_Click(object sender, EventArgs e)
{
toolStripProgressBar.Value = e.ProgressPercentage;
toolStripStatusLabel.Text = $"{e.ProgressPercentage.ToString()}% Loaded";
MessageBox.Show("UE4LogParser \r\nDeveloped by Russ 'trdwll' Treadwell\r\nwww.trdwll.com", "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

if (e.ProgressPercentage == 100)
{
backgroundWorker1.CancelAsync();
toolStripStatusLabel.Text = "Loaded Log";
}
private void logView_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}

private void menuAbout_Click(object sender, EventArgs e)
private void logView_DragDrop(object sender, DragEventArgs e)
{
MessageBox.Show("UE4LogParser \r\nDeveloped by Russ 'trdwll' Treadwell\r\nwww.trdwll.com", "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
logView.Rows.Clear();
export_log.Clear();
opened_log = "";

string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);

if (files.Length >= 1)
{
opened_log = files[0]; // Such a terrible way to handle this, but it's fine. lol
backgroundWorker1.RunWorkerAsync();
}
}
}
}
3 changes: 0 additions & 3 deletions UE4LogParser/frmMain.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>134, 17</value>
</metadata>
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>250, 17</value>
</metadata>
Expand Down

0 comments on commit 3065835

Please sign in to comment.