Skip to content

Commit

Permalink
Add Open menu
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara committed Aug 10, 2023
1 parent e7f3f74 commit 8767241
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/OneHub.Tools.HeapView/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
x:Class="OneHub.Tools.HeapView.MainWindow"
Title="Heap View"
DragDrop.AllowDrop="True">
<heapView:HeapView Name="heapView">
</heapView:HeapView>

<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="File">
<NativeMenu>
<NativeMenuItem Header="Open" Click="OnOpenClicked" Gesture="Ctrl+O"/>
</NativeMenu>
</NativeMenuItem>
</NativeMenu>
</NativeMenu.Menu>

<Grid RowDefinitions="Auto, *">
<NativeMenuBar Grid.Row="0" />
<heapView:HeapView Grid.Row="1" Name="heapView">
</heapView:HeapView>
</Grid>

</Window>
14 changes: 14 additions & 0 deletions src/OneHub.Tools.HeapView/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,18 @@ private void Drop(object? sender, DragEventArgs e)
}
}
}

public async void OnOpenClicked(object? sender, EventArgs args)
{
var options = new FilePickerOpenOptions
{
AllowMultiple = false,
FileTypeFilter = new[] { new FilePickerFileType("GC dump") { Patterns = new[] { "*.gcdump" } } }
};
var result = await StorageProvider.OpenFilePickerAsync(options);
if (result != null && result.Count == 1 && result[0].TryGetLocalPath() is string path)
{
Open(path);
}
}
}

0 comments on commit 8767241

Please sign in to comment.