mirror of https://github.com/AMT-Cheif/Stylet.git
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Stylet.Samples.RedditBrowser.Events;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Stylet.Samples.RedditBrowser.Pages
|
|
{
|
|
public class ShellViewModel : Conductor<IScreen>.Collections.OneActive, IHandle<OpenSubredditEvent>
|
|
{
|
|
private ISubredditViewModelFactory subredditViewModelFactory;
|
|
|
|
public TaskbarViewModel Taskbar { get; private set; }
|
|
|
|
public ShellViewModel(IEventAggregator events, TaskbarViewModel taskbarViewModel, ISubredditViewModelFactory subredditViewModelFactory)
|
|
{
|
|
this.DisplayName = "Reddit Browser";
|
|
|
|
this.Taskbar = taskbarViewModel;
|
|
this.subredditViewModelFactory = subredditViewModelFactory;
|
|
|
|
events.Subscribe(this);
|
|
}
|
|
|
|
public void Handle(OpenSubredditEvent message)
|
|
{
|
|
var item = this.subredditViewModelFactory.CreateSubredditViewModel();
|
|
item.Subreddit = message.Subreddit;
|
|
item.SortMode = message.SortMode;
|
|
this.ActivateItem(item);
|
|
}
|
|
}
|
|
|
|
public interface ISubredditViewModelFactory
|
|
{
|
|
SubredditViewModel CreateSubredditViewModel();
|
|
}
|
|
}
|