Skip to content

Commit

Permalink
Add support to drag/drop a log file to the main window to load and mo…
Browse files Browse the repository at this point in the history
…nitor it
  • Loading branch information
belkiss committed Jul 4, 2024
1 parent dfc2d2a commit c4ac425
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:my="clr-namespace:FASTBuildMonitor"
AllowDrop="True" Drop="UserControl_Drop"
mc:Ignorable="d"
d:DesignHeight="440" d:DesignWidth="800"
Name="MyToolWindow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2239,15 +2239,30 @@ public static class CommandArgumentIndex

private int _lastProcessedPosition = 0;

private string _path = null;
private void ChangePath(string path)
{
_path = path;
_fileStream = null;
}

private void ProcessInputFileStream()
{
if (_fileStream == null)
{
string path = System.IO.Path.GetTempPath() + @"\FastBuild\FastBuildLog.log";
string path;
if (_path == null)
{
path = System.IO.Path.GetTempPath() + @"\FastBuild\FastBuildLog.log";

if (!Directory.Exists(System.IO.Path.GetDirectoryName(path)))
if (!Directory.Exists(System.IO.Path.GetDirectoryName(path)))
{
Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
}
}
else
{
Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
path = _path;
}

if (!File.Exists(path))
Expand Down Expand Up @@ -2799,5 +2814,18 @@ private void HandleTick(object sender, EventArgs e)
ResetState();
}
}

private void UserControl_Drop(object sender, DragEventArgs e)
{
// If the DataObject contains string data, extract it.
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] fileDrops = e.Data.GetData(DataFormats.FileDrop) as string[];
if (fileDrops.Length == 1)
{
ChangePath(fileDrops[0]);
}
}
}
}
}

0 comments on commit c4ac425

Please sign in to comment.