forked from flq/MemBus
-
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.
Some refactoring to tame the ShellView in future
- Loading branch information
Showing
12 changed files
with
178 additions
and
126 deletions.
There are no files selected for viewing
25 changes: 4 additions & 21 deletions
25
Membus.WpfTwitterClient/Frame/Config/ClientPublishingConventions.cs
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,34 +1,17 @@ | ||
using MemBus.Publishing; | ||
using MemBus.Setup; | ||
using MemBus.Subscribing; | ||
using MemBus.Support; | ||
using Membus.WpfTwitterClient.Startup; | ||
|
||
namespace Membus.WpfTwitterClient.Frame | ||
namespace Membus.WpfTwitterClient.Frame.Config | ||
{ | ||
public class ClientPublishingConventions : ISetup<IConfigurableBus> | ||
{ | ||
public void Accept(IConfigurableBus setup) | ||
{ | ||
setup.ConfigurePublishing( | ||
p => | ||
{ | ||
p.MessageMatch( | ||
m => m.IsType<TransportMessage>() || m.IsType<RequestToStartup>(), | ||
l => l.PublishPipeline(new SequentialPublisher()) | ||
); | ||
p.MessageMatch( | ||
m => m.Name.EndsWith("Request"), | ||
l => l.PublishPipeline(Publish.This(new TransportMessage { On = true }), new ParallelNonBlockingPublisher()) | ||
); | ||
p.MessageMatch( | ||
m => m.Name.EndsWith("Response"), | ||
l => l.PublishPipeline(new ParallelBlockingPublisher(), Publish.This(new TransportMessage { On = false })) | ||
); | ||
}); | ||
setup.ConfigureSubscribing(s => s.MessageMatch( | ||
m => m.Name.EndsWith("Response") || m.IsType<TransportMessage>(), | ||
c => c.ShapeOutwards(new ShapeToUiDispatch(), new ShapeToDispose()))); | ||
p => p.MessageMatch( | ||
m => m.IsType<RequestToStartup>(), | ||
l => l.PublishPipeline(new SequentialPublisher()))); | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,17 @@ | ||
namespace Membus.WpfTwitterClient.Frame.UI | ||
{ | ||
public class RequestForAttention | ||
{ | ||
private readonly object viewModel; | ||
|
||
public RequestForAttention(object viewModel) | ||
{ | ||
this.viewModel = viewModel; | ||
} | ||
|
||
public object ViewModel | ||
{ | ||
get { return viewModel; } | ||
} | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
Membus.WpfTwitterClient/GatherAccessToken/VerifyPinViewModel.cs
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,30 @@ | ||
using Caliburn.Micro; | ||
|
||
namespace Membus.WpfTwitterClient.GatherAccessToken | ||
{ | ||
public class VerifyPinViewModel : PropertyChangedBase | ||
{ | ||
private readonly string possibleVerifier; | ||
|
||
public VerifyPinViewModel(string possibleVerifier) | ||
{ | ||
this.possibleVerifier = possibleVerifier; | ||
} | ||
|
||
public string PossibleVerifier | ||
{ | ||
get { return possibleVerifier; } | ||
} | ||
|
||
private string verifierOverride; | ||
public string VerifierOverride | ||
{ | ||
get { return verifierOverride; } | ||
set | ||
{ | ||
verifierOverride = value; | ||
NotifyOfPropertyChange(()=>VerifierOverride); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Linq; | ||
using Caliburn.Micro; | ||
using MemBus.Support; | ||
using Membus.WpfTwitterClient.Frame.UI; | ||
|
||
namespace Membus.WpfTwitterClient.ShellOfApp | ||
{ | ||
public class ActivityViewModel : PropertyChangedBase, IDisposable | ||
{ | ||
private readonly DisposeContainer disposer = new DisposeContainer(); | ||
|
||
public ActivityViewModel(IObservable<ApplicationActivityMessage> activityMessages) | ||
{ | ||
var busyStream1 = activityMessages | ||
.Where(msg => msg.GettingBusy) | ||
.SubscribeOnDispatcher().Subscribe(onGettingBusy); | ||
var busyStream2 = activityMessages | ||
.Where(msg => msg.GettingCalm) | ||
.SubscribeOnDispatcher().Subscribe(onGettingCalm); | ||
disposer.Add(busyStream1, busyStream2); | ||
} | ||
|
||
private bool isBusy; | ||
public bool IsBusy | ||
{ | ||
get { return isBusy; } | ||
set | ||
{ | ||
if (value.Equals(isBusy)) | ||
return; | ||
isBusy = value; | ||
NotifyOfPropertyChange(() => IsBusy); | ||
} | ||
} | ||
|
||
private string busyMessage; | ||
public string BusyMessage | ||
{ | ||
get { return busyMessage; } | ||
set | ||
{ | ||
if (value == null || value.Equals(busyMessage)) | ||
return; | ||
busyMessage = value; | ||
NotifyOfPropertyChange(() => BusyMessage); | ||
} | ||
} | ||
|
||
private void onGettingBusy(ApplicationActivityMessage msg) | ||
{ | ||
BusyMessage = string.Empty; | ||
IsBusy = true; | ||
BusyMessage = msg.BusyText; | ||
} | ||
|
||
private void onGettingCalm(ApplicationActivityMessage msg) | ||
{ | ||
IsBusy = false; | ||
} | ||
|
||
|
||
void IDisposable.Dispose() | ||
{ | ||
disposer.Dispose(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Linq; | ||
using Caliburn.Micro; | ||
using MemBus.Support; | ||
using Membus.WpfTwitterClient.Frame.UI; | ||
|
||
namespace Membus.WpfTwitterClient.ShellOfApp | ||
{ | ||
[Single] | ||
public class ShellViewModel : Conductor<Screen> | ||
{ | ||
public ActivityViewModel ActivityViewModel { get; private set; } | ||
private readonly DisposeContainer disposeContainer = new DisposeContainer(); | ||
|
||
public ShellViewModel(IObservable<RequestToActivateMainScreen> activationStream, ActivityViewModel activityVm) | ||
{ | ||
ActivityViewModel = activityVm; | ||
var screenStreamDispose = activationStream | ||
.Where(msg => msg.ScreenAvailable) | ||
.SubscribeOnDispatcher().Subscribe(onNextScreenRequest); | ||
|
||
disposeContainer.Add(screenStreamDispose, activityVm); | ||
|
||
DisplayName = "MemBus OnTweet!"; | ||
} | ||
|
||
private void onNextScreenRequest(RequestToActivateMainScreen request) | ||
{ | ||
DisplayName = request.Screen.DisplayName; | ||
ActivateItem(request.Screen); | ||
} | ||
|
||
protected override void OnDeactivate(bool close) | ||
{ | ||
disposeContainer.Dispose(); | ||
base.OnDeactivate(close); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.