Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
426 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace RoslynPad.UI | ||
{ | ||
public interface IDialog | ||
{ | ||
void Show(); | ||
Task ShowAsync(); | ||
void Close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
namespace RoslynPad.UI | ||
using System.Threading.Tasks; | ||
|
||
namespace RoslynPad.UI | ||
{ | ||
public interface ISaveFileDialog | ||
{ | ||
bool OverwritePrompt { get; set; } | ||
bool AddExtension { get; set; } | ||
string Filter { get; set; } | ||
FileDialogFilter Filter { set; } | ||
string DefaultExt { get; set; } | ||
string FileName { get; set; } | ||
|
||
bool? Show(); | ||
Task<string> ShowAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,74 @@ | ||
using Avalonia.Controls; | ||
using System; | ||
using System.Linq; | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Markup.Xaml; | ||
using RoslynPad.UI; | ||
|
||
namespace RoslynPad | ||
{ | ||
class DocumentTreeView : UserControl | ||
{ | ||
private MainViewModel _viewModel; | ||
|
||
public DocumentTreeView() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
var treeView = this.Find<TreeView>("Tree"); | ||
treeView.ItemContainerGenerator.Materialized += ItemContainerGenerator_Materialized; | ||
treeView.ItemContainerGenerator.Dematerialized += ItemContainerGenerator_Dematerialized; | ||
} | ||
|
||
private void ItemContainerGenerator_Materialized(object sender, Avalonia.Controls.Generators.ItemContainerEventArgs e) | ||
{ | ||
foreach (var item in e.Containers) | ||
{ | ||
if (item.ContainerControl is TreeViewItem treeViewItem) | ||
{ | ||
treeViewItem.PointerPressed += OnDocumentClick; | ||
treeViewItem.KeyDown += OnDocumentKeyDown; | ||
} | ||
} | ||
} | ||
|
||
private void ItemContainerGenerator_Dematerialized(object sender, Avalonia.Controls.Generators.ItemContainerEventArgs e) | ||
{ | ||
foreach (var item in e.Containers) | ||
{ | ||
if (item.ContainerControl is TreeViewItem treeViewItem) | ||
{ | ||
treeViewItem.PointerPressed -= OnDocumentClick; | ||
treeViewItem.KeyDown -= OnDocumentKeyDown; | ||
} | ||
} | ||
} | ||
|
||
protected override void OnDataContextChanged(EventArgs e) | ||
{ | ||
_viewModel = DataContext as MainViewModel; | ||
} | ||
|
||
|
||
private void OnDocumentClick(object sender, PointerPressedEventArgs e) | ||
{ | ||
if (e.MouseButton == MouseButton.Left && e.ClickCount >= 2) | ||
{ | ||
OpenDocument(e.Source); | ||
} | ||
} | ||
|
||
private void OnDocumentKeyDown(object sender, KeyEventArgs e) | ||
{ | ||
if (e.Key == Key.Enter) | ||
{ | ||
OpenDocument(e.Source); | ||
} | ||
} | ||
|
||
private void OpenDocument(object source) | ||
{ | ||
var documentViewModel = (DocumentViewModel)((Control)source).DataContext; | ||
_viewModel.OpenDocument(documentViewModel); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.