Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Apr 11, 2020
1 parent 2418f16 commit bb48bcc
Show file tree
Hide file tree
Showing 13 changed files with 536 additions and 223 deletions.
244 changes: 86 additions & 158 deletions Analogy.LogViewer.WindowsEventLogs/EventLogsSettings.Designer.cs

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

52 changes: 32 additions & 20 deletions Analogy.LogViewer.WindowsEventLogs/EventLogsSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Analogy.LogViewer.WindowsEventLogs.Managers;

Expand All @@ -12,36 +15,45 @@ public EventLogsSettings()
InitializeComponent();
}

private void GitRepositoriesSettings_Load(object sender, EventArgs e)
{

}


private void btnAdd_Click(object sender, EventArgs e)
{

List<string> selected = lstAvailable.SelectedItems.Cast<string>().ToList();
lstSelected.Items.AddRange(selected.ToArray());
foreach (var log in selected)
{
lstAvailable.Items.Remove(log);
}
UpdateUserSettingList();
}

private void btnBrowser_Click(object sender, EventArgs e)
private void btnRemove_Click(object sender, EventArgs e)
{
using (FolderBrowserDialog folderDlg = new FolderBrowserDialog
{
ShowNewFolderButton = false
})
List<string> selected = lstSelected.SelectedItems.Cast<string>().ToList();
lstAvailable.Items.AddRange(selected.ToArray());
foreach (var log in selected)
{
// Show the FolderBrowserDialog.
DialogResult result = folderDlg.ShowDialog();
if (result == DialogResult.OK)
{
txtRepository.Text = folderDlg.SelectedPath;
}
lstSelected.Items.Remove(log);
}
UpdateUserSettingList();
}
private void UpdateUserSettingList()
{
UserSettingsManager.UserSettings.Logs = lstSelected.Items.OfType<string>().ToList();
}

private void BtnDelete_Click(object sender, EventArgs e)
private void EventLogsSettings_Load(object sender, EventArgs e)
{

lstSelected.Items.AddRange(UserSettingsManager.UserSettings.Logs.ToArray());
try
{
var all = System.Diagnostics.Eventing.Reader.EventLogSession.GlobalSession.GetLogNames().Where(EventLog.Exists).ToList().Except(UserSettingsManager.UserSettings.Logs).ToArray();
lstAvailable.Items.AddRange(all);
}
catch (Exception exception)
{
MessageBox.Show("Error loading all logs. Make sure you are running as administrator. Error:" + exception.Message, "Error",
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}
}
}
}
Loading

0 comments on commit bb48bcc

Please sign in to comment.