Skip to content

Commit

Permalink
Renamed a few things, moved extensions to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
robin.rexstedt committed Apr 12, 2017
1 parent 55efa2a commit 55c8cdf
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 13 deletions.
7 changes: 7 additions & 0 deletions Logdiver.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logdiver", "Logdiver\Logdiver.csproj", "{A492DBAB-392C-4388-9E5A-0F0C60399F37}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1A21BA34-BD46-4508-A054-D2519D31375E}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion Logdiver/FilterSettingsDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Logdiver"
mc:Ignorable="d"
Title="Create new listener" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" SizeToContent="WidthAndHeight" ContentRendered="Window_ContentRendered">
Title="Create new target" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" SizeToContent="WidthAndHeight" ContentRendered="Window_ContentRendered">
<Grid Margin="15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down
43 changes: 42 additions & 1 deletion Logdiver/Logdiver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -37,6 +53,18 @@
<PropertyGroup>
<StartupObject>Logdiver.App</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>E017968E413EA30EE3C813158C9D972663117483</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>Logdiver_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand All @@ -63,7 +91,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Util\DispatcherWinFormsCompatAdapter.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Util\Extensions.cs" />
<Compile Include="FilteredTextBox.cs" />
<Compile Include="Util\LogFileMonitor.cs" />
<Compile Include="SpaceStation13ClientLog.cs" />
Expand Down Expand Up @@ -105,6 +133,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Logdiver_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand All @@ -115,6 +144,18 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion Logdiver/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:Logdiver"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
Title="Logdiver" Height="350" Width="525">
<Window.CommandBindings>
<CommandBinding Command="New" CanExecute="NewCommand_CanExecute" Executed="NewCommand_Executed"/>
<CommandBinding Command="Open" CanExecute="OpenCommand_CanExecute" Executed="OpenCommand_Executed"/>
Expand Down
4 changes: 2 additions & 2 deletions Logdiver/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyFileVersion("0.2.0.0")]
34 changes: 27 additions & 7 deletions Logdiver/SpaceStation13ClientLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ namespace Logdiver
{
public class SpaceStation13ClientLog : IDisposable
{
private bool hasBeenRead;
private bool _hasBeenRead;

public static string DELIMITER = "\n";
public static TimeSpan BlockDuplicateTimeSpan = new TimeSpan(0,0,0,1);

public string FileName { get; private set; }

Expand All @@ -26,6 +27,9 @@ public class SpaceStation13ClientLog : IDisposable

private LogFileMonitor monitor;

private string _lastLine;
private DateTime _lastLineTime;

private Dictionary<string, string> _replacementDictionary = new Dictionary<string, string>
{
{"<span class='game say'>", "GAMESAY: " },
Expand All @@ -52,6 +56,7 @@ public class SpaceStation13ClientLog : IDisposable
{"[F]","" },
{"[B]","" },
{"[R]","" },
{"(?) (PP) (VV) (SM) (JMP) (CA) (TAKE)","" },
{"\r", "" }
};

Expand All @@ -78,18 +83,33 @@ private void MonitorLine(object sender, LineEventArgs lineEventArgs)
{
var line = ProcessString(lineEventArgs.Line);

line = $"[{DateTime.Now:HH:mm:ss}]" + line;
line = $"[{DateTime.Now:HH:mm:ss}] " + line;

Content += Environment.NewLine + line;
OnLine?.Invoke(this, new LineEventArgs(line.Trim()));
SendLine(line);
}
}
}

private void SendLine(string line)
{
if (_lastLine != null)
{
if (_lastLine.Equals(line) && (DateTime.Now - _lastLineTime) > BlockDuplicateTimeSpan)
{
return;
}
}

_lastLine = line;
_lastLineTime = DateTime.Now;
OnLine?.Invoke(this, new LineEventArgs(line.Trim()));
}

public void InitialRead()
{
if (hasBeenRead) return;
if (_hasBeenRead) return;

hasBeenRead = true;
_hasBeenRead = true;

string read;

Expand All @@ -103,7 +123,7 @@ public void InitialRead()

foreach (var line in Content.Split(new[] { DELIMITER }, StringSplitOptions.RemoveEmptyEntries))
{
OnLine?.Invoke(this, new LineEventArgs(line.Trim()));
SendLine(line);
}

monitor = new LogFileMonitor(FileName, synchronize, DELIMITER);
Expand Down
2 changes: 1 addition & 1 deletion Logdiver/Extensions.cs → Logdiver/Util/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Logdiver
namespace Logdiver.Util
{
internal static class Extensions
{
Expand Down

0 comments on commit 55c8cdf

Please sign in to comment.