This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* hide "empty" projects in tool window * Refresh-Button as Icon * a bit more theming
- Loading branch information
Showing
10 changed files
with
205 additions
and
111 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 |
---|---|---|
|
@@ -51,3 +51,5 @@ docs/input/tasks/* | |
|
||
# Wyam related | ||
config.wyam.* | ||
.vshistory/ | ||
.history/ |
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,84 +1,21 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
using MediatRvs.Models; | ||
using Microsoft.VisualStudio.PlatformUI; | ||
using Microsoft.VisualStudio.Shell; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace MediatRvs | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MediatrToolWindowControl. | ||
/// </summary> | ||
public partial class MediatrToolWindowControl : UserControl, INotifyPropertyChanged | ||
public partial class MediatrToolWindowControl : UserControl | ||
{ | ||
private MediatrProject[] _projects; | ||
private ICommand _refreshCommand; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MediatrToolWindowControl"/> class. | ||
/// </summary> | ||
public MediatrToolWindowControl() | ||
{ | ||
InitializeComponent(); | ||
DataContext = this; | ||
RefreshCommand = new DelegateCommand(LoadProjects); | ||
ThreadHelper.JoinableTaskFactory.Run(async () => await InitLoadProjectsAsync()); | ||
} | ||
|
||
public MediatrProject[] Projects | ||
{ | ||
get => _projects; | ||
set | ||
{ | ||
_projects = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public ICommand RefreshCommand | ||
{ | ||
get => _refreshCommand; | ||
set | ||
{ | ||
_refreshCommand = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
private async Task InitLoadProjectsAsync() | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
LoadProjects(); | ||
} | ||
|
||
private void LoadProjects() | ||
{ | ||
ThreadHelper.JoinableTaskFactory.Run(async () => | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
var adapter = new ProjectContentAdapter(); | ||
try | ||
{ | ||
var projects = adapter.GetMessages().ToArray(); | ||
Projects = projects; | ||
} | ||
catch (Exception e) | ||
{ | ||
Logger.Log(e); | ||
} | ||
}); | ||
DataContext = new MediatrToolWindowViewModel(); | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
private void OnPropertyChanged([CallerMemberName] string property = null) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Windows.Input; | ||
using MediatRvs.Models; | ||
using Microsoft.VisualStudio.PlatformUI; | ||
using Microsoft.VisualStudio.Shell; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace MediatRvs | ||
{ | ||
public class MediatrToolWindowViewModel: INotifyPropertyChanged | ||
{ | ||
private MediatrProject[] _projects; | ||
private ICommand _refreshCommand; | ||
|
||
public MediatrToolWindowViewModel() | ||
{ | ||
RefreshCommand = new DelegateCommand(LoadProjects); | ||
ThreadHelper.JoinableTaskFactory.Run(async () => await InitLoadProjectsAsync()); | ||
|
||
} | ||
|
||
public MediatrProject[] Projects | ||
{ | ||
get => _projects; | ||
set | ||
{ | ||
_projects = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public ICommand RefreshCommand | ||
{ | ||
get => _refreshCommand; | ||
set | ||
{ | ||
_refreshCommand = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
private async Task InitLoadProjectsAsync() | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
LoadProjects(); | ||
} | ||
|
||
private void LoadProjects() | ||
{ | ||
ThreadHelper.JoinableTaskFactory.Run(async () => | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
var adapter = new ProjectContentAdapter(); | ||
try | ||
{ | ||
var elements = adapter.GetMediatRContent(); | ||
Projects = elements.ToArray(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Logger.Log(e); | ||
} | ||
}); | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
private void OnPropertyChanged([CallerMemberName] string property = null) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); | ||
} | ||
|
||
} | ||
} |
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,12 +1,13 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Generic; | ||
|
||
namespace MediatRvs.Models | ||
{ | ||
public class MediatrProject | ||
{ | ||
public string Name { get; set; } | ||
|
||
public IEnumerable<MediatrElement> Elements { get; set; } | ||
public string Path { get; set; } | ||
|
||
public IEnumerable<MediatrElement> Elements { get; set; } | ||
} | ||
} | ||
} |
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.