本文整理汇总了C#中IMvxMessenger.SubscribeOnMainThread方法的典型用法代码示例。如果您正苦于以下问题:C# IMvxMessenger.SubscribeOnMainThread方法的具体用法?C# IMvxMessenger.SubscribeOnMainThread怎么用?C# IMvxMessenger.SubscribeOnMainThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMvxMessenger
的用法示例。
在下文中一共展示了IMvxMessenger.SubscribeOnMainThread方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HomeViewModel
public HomeViewModel(IDescriptionService descriptionService, IMvxMessenger messenger)
{
_token = messenger.SubscribeOnMainThread<TickMessage>(OnTick);
Descriptions = descriptionService.Descriptions
.Select(x => new DescriptionViewModel(x))
.ToList();
}
示例2: AddViewModel
public AddViewModel(ICollectionService collectionService, ILocationService locationService, IMvxMessenger messenger)
{
_collectionService = collectionService;
_locationService = locationService;
_token = messenger.SubscribeOnMainThread<LocationMessage>(OnLocation);
GetInitialLocation();
}
示例3: GenerateViewModel
public GenerateViewModel(IMvxMessenger messenger, IDisplayDimensionsService displayDimensionsService,
IMandelbrotTaskGenerator mandelbrotTaskGenerator)
{
_displayDimensionsService = displayDimensionsService;
_mandelbrotTaskGenerator = mandelbrotTaskGenerator;
_mvxSubscriptionToken = messenger.SubscribeOnMainThread<TickMessage>(OnTick);
_autoPlay = true;
}
示例4: RootViewModel
public RootViewModel(IAuthenticationService authService, IMvxMessenger messenger)
{
_authService = authService;
_sessionChangedToken = messenger.SubscribeOnMainThread<SessionStateChangedMessage>((m) =>
{
reloadFavorites();
});
this.UserStoreViewModel = MvxToolbox.LoadViewModel<BaseUserStoreViewModel>();
}
示例5: AddViewModel
public AddViewModel(
ICollectionService collectionService,
ILocationService locationService,
IMvxMessenger messenger,
IMvxPictureChooserTask pictureChooserTask, IMvxFileStore fileStore)
{
_collectionService = collectionService;
_locationService = locationService;
_pictureChooserTask = pictureChooserTask;
_fileStore = fileStore;
_token = messenger.SubscribeOnMainThread<LocationMessage>(OnLocation);
GetInitialLocation();
}
示例6: BaseUserStoreViewModel
public BaseUserStoreViewModel(IAuthenticationService authService, IMvxMessenger messenger )
:base(authService, messenger)
{
this.ShouldSubscribeToSessionChange = true;
_storeChangeToken = messenger.SubscribeOnMainThread<StoreChangedMessage>((message) =>
{
//If the changed store is related to current user then refetch the user store to reflect the change
if(message.Store != null && this.CurrentUser != null &&
message.Store.OwnerID == this.CurrentUser.ID)
{
reloadUserStore();
}
});
PropertyChanged += propertyChanged;
}
示例7: MainViewModel
public MainViewModel()
{
_ds = BettrFitDataSource.Instance;
_messenger = Mvx.Resolve<IMvxMessenger>();
_mapNav = new Dictionary<string, Type>();
_mapNav.Add(menuNutritionPlan, typeof(NutritionPlanOverviewViewModel));
_mapNav.Add(menuNutritiondiary, typeof(NutritionPlanMainViewModel));
_mapNav.Add(menuGoals, typeof(GoalOverviewViewModel));
_mapNav.Add(menuNutrition, typeof(NutritionPlanMainViewModel));
_mapNav.Add(menuWeight, typeof(DailyDataOverviewViewModel));
_mapNav.Add("Login", typeof(LoginViewModel));
_mapNav.Add("Login mit Facebook", typeof(FirstViewModel));
_mapNav.Add(CultureHelper.GetLocalString("Register|Registrieren"), typeof(RegisterViewModel));
NavCommands = new ObservableCollection<NavEntry>();
NavCommand = new MvxCommand<string>(OnNavCommand);
LogoffCommand = new MvxCommand(OnLogoffCommand);
RefreshCommand = new MvxCommand(OnRefreshCommand);
ShowInfoCommand = new MvxCommand(OnShowInfo);
FeedbackCommand = new MvxCommand(OnFeedbackCommand);
ShakeCommand = new MvxCommand(()=>_messenger.Publish(new ShakeEvent(this)));
ShowAGBCommand = new MvxCommand(OnShowAGB);
_logintoken = _messenger.Subscribe<LoggedInEvent>(a => LoginChanged(a.LoggedIn));
_synctoken = _messenger.Subscribe<SyncEvent>(a => RaisePropertyChanged("Sync"));
_nonetworktoken = _messenger.SubscribeOnMainThread<NetworkEvent>(m =>
{
IsNetworkAvailable = m.IsAvailable;
});
LoginChanged(_ds.IsLoggedIn());
//var client = WebService.Instance.WS;
RaisePropertyChanged("Sync");
IsNotRefreshing = true;
}
示例8: ScanAsMessageViewModel
public ScanAsMessageViewModel(IMvxMessenger messenger, IWatcher watcher)
{
_watcher = watcher;
_messageToken = messenger.SubscribeOnMainThread<MessageReceived>(MessageRecieved);
}
示例9: OnViewModelSet
//.........这里部分代码省略.........
TouchModeAbove = TouchMode.Fullscreen,
BehindOffset = 80,
ShadowWidth = 20,
ShadowDrawableRes = Resource.Drawable.SlidingMenuShadow,
SecondaryShadowDrawableRes = Resource.Drawable.SlidingMenuShadowRight
};
slidingMenu.AttachToActivity (this, SlideStyle.Content);
slidingMenu.SetMenu (Resource.Layout.Menu_Frame);
//slidingMenu.ShadowDrawableRes = Resource.Drawable.SlidingMenuShadow;
menuFragment = new MenuFragment ();
menuFragment.ViewModel = ViewModel;
SupportFragmentManager.BeginTransaction ()
.Replace (Resource.Id.menu_frame, menuFragment).Commit ();
slidingMenu.SetSecondaryMenu (Resource.Layout.UserList_Frame);
//slidingMenu.SecondaryShadowDrawableRes = Resource.Drawable.SlidingMenuShadowRight;
emptyFragment = new EmptyFragment ();
emptyFragment.ViewModel = this.ViewModel;
SupportFragmentManager.BeginTransaction ()
.Replace (Resource.Id.content_frame, emptyFragment).Commit ();
//TODO: Put some kind of default view in the chat fragment space
homeViewModel.PropertyChanged += (sender, e) => {
Console.WriteLine("PropertyChanged: "+ e.PropertyName);
if (e.PropertyName == "CurrentRoom")
{
if (homeViewModel.CurrentRoom == null)
{
if (emptyFragment == null)
emptyFragment = new EmptyFragment();
chatFragment = null;
SupportFragmentManager.BeginTransaction ()
.Replace (Resource.Id.content_frame, emptyFragment).Commit ();
LegacyBar.Title = "JabbR";
showActions = false;
ToggleActions();
userListFragment.ViewModel = null;
SupportFragmentManager.BeginTransaction ()
.Replace (Resource.Id.userlist_frame, userListFragment).Commit ();
return;
}
showActions = true;
if (chatFragment == null)
{
chatFragment = new ChatFragment();
chatFragment.ViewModel = homeViewModel.CurrentRoom;
SupportFragmentManager.BeginTransaction()
.Replace(Resource.Id.content_frame, chatFragment).Commit();
}
else
{
chatFragment.ViewModel = homeViewModel.CurrentRoom;
}
if (userListFragment == null)
{
userListFragment = new UserListFragment();
userListFragment.ViewModel = homeViewModel.CurrentRoom;
SupportFragmentManager.BeginTransaction ()
.Replace (Resource.Id.userlist_frame, userListFragment).Commit ();
}
else
{
userListFragment.ViewModel = homeViewModel.CurrentRoom;
}
ToggleActions();
slidingMenu.Toggle();
this.RunOnUiThread(() => LegacyBar.Title = homeViewModel.CurrentRoom.Room.Name);
}
};
messenger = Mvx.Resolve<IMvxMessenger> ();
_mvxMsgTokUserSelected = messenger.SubscribeOnMainThread<UserSelectedMessage> (msg => {
chatFragment.AppendText("@" + msg.User.Name);
slidingMenu.ShowContent(true);
});
}