Skip to content

Commit

Permalink
Merge pull request #11 from SirMossi/master
Browse files Browse the repository at this point in the history
Start live log viewer with a filename as start argument
  • Loading branch information
alexwiese committed Jan 25, 2021
2 parents 9a0ba6e + 30ae5d3 commit c61b2d1
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 14 deletions.
3 changes: 2 additions & 1 deletion HallOfFame.md
Expand Up @@ -3,4 +3,5 @@
A list of all the people who contributed code to the project.
Don't forget to add your name with your pull request.

* Alex Wiese
* Alex Wiese
* Robert Hofmann
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -12,6 +12,11 @@ Live Log Viewer will monitor files for changes, renaming, deletion and creation.

![Demo](https://windows-cdn.softpedia.com/screenshots/Live-Log-Viewer_1.png)

### Usage

At startup, you are automatically prompted to open a log file that you want to open.
It is also possible to specify a file as a startup parameter, which will then be automatically displayed when the program is started.

### Encoding

Live Log Viewer supports different Encoding per file, based on the Encodings available on the machine.
Expand Down
2 changes: 1 addition & 1 deletion src/Live Log Viewer/App.cs
Expand Up @@ -13,7 +13,7 @@ public App()
}

[STAThread]
public static void Main()
public static void Main(string[] args)
{
var app = new App
{
Expand Down
1 change: 1 addition & 0 deletions src/Live Log Viewer/Live Log Viewer.csproj
Expand Up @@ -6,6 +6,7 @@
<RootNamespace>LiveLogViewer</RootNamespace>
<UseWPF>true</UseWPF>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<ApplicationIcon>Content\icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions src/Live Log Viewer/Properties/launchSettings.json
@@ -0,0 +1,7 @@
{
"profiles": {
"Live Log Viewer": {
"commandName": "Project"
}
}
}
5 changes: 5 additions & 0 deletions src/Live Log Viewer/ViewModels/MainViewModel.cs
Expand Up @@ -66,6 +66,11 @@ public MainViewModel()
FreezeFileCommand = new RelayCommand(FreezeFile, CanFreezeFile);

Settings.Default.PropertyChanged += OnSettingsChanged;

if (Environment.GetCommandLineArgs().Length > 1)
{
AddFileMonitor(Environment.GetCommandLineArgs()[1]);
}
}

private void OnSettingsChanged(object s, PropertyChangedEventArgs e)
Expand Down
27 changes: 15 additions & 12 deletions src/Live Log Viewer/Views/MainWindow.xaml.cs
Expand Up @@ -22,8 +22,8 @@ namespace LiveLogViewer.Views
/// </summary>
public partial class MainWindow : Window
{
private readonly MainViewModel _mainViewModel = new MainViewModel();
private readonly MainViewModel _mainViewModel = new MainViewModel();

public MainWindow()
{
InitializeComponent();
Expand All @@ -35,9 +35,12 @@ public MainWindow()

private void OnContentRendered(object s, EventArgs e)
{
PromptForFile();
}

if (Environment.GetCommandLineArgs().Length <= 1)
{
PromptForFile();
}
}

private void AddButton_OnClick(object sender, RoutedEventArgs e)
{
PromptForFile();
Expand All @@ -61,17 +64,17 @@ private void PromptForFile()
{
MessageBox.Show($"Error: {exception.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}

private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
var textBox = (TextBox)sender;
var fileMonitorViewModel = (FileMonitorViewModel)textBox.DataContext;
if (fileMonitorViewModel?.IsFrozen == false)
var fileMonitorViewModel = (FileMonitorViewModel)textBox.DataContext;

if (fileMonitorViewModel?.IsFrozen == false)
textBox.ScrollToEnd();
}
}

private void ConfigButton_OnClick(object sender, RoutedEventArgs e)
{
new ConfigurationWindow { Owner = this }.ShowDialog();
Expand Down

0 comments on commit c61b2d1

Please sign in to comment.