当前位置: 首页>>代码示例>>C#>>正文


C# IMvxMessenger.Publish方法代码示例

本文整理汇总了C#中IMvxMessenger.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# IMvxMessenger.Publish方法的具体用法?C# IMvxMessenger.Publish怎么用?C# IMvxMessenger.Publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMvxMessenger的用法示例。


在下文中一共展示了IMvxMessenger.Publish方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JabbrService

		public JabbrService()
		{
			Connections = new ObservableCollection<JabbrConnection> ();

			Settings = Mvx.Resolve<ISettingsService> ();
			Messenger = Mvx.Resolve<IMvxMessenger> ();

			Settings.Accounts.CollectionChanged += (sender, e) => {

				if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
				{
					foreach (Account a in e.OldItems)
					{
						var cons = Connections.Where(c => c.Account.Id == a.Id);

						if (cons != null)
							foreach (var con in cons)
								con.Client.Disconnect();
					}
				}
				else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
				{
					foreach (Account a in e.NewItems)
					{
						if (Connections.Where(con => con.Account.Id == a.Id).Count() <= 0)
							AddClient(a);
					}
				}

				Messenger.Publish<AccountsChangedMessage>(new AccountsChangedMessage(this));
			};
		}
开发者ID:slodge,项目名称:JabbRIsMobile,代码行数:32,代码来源:JabbrService.cs

示例2: TestViewModel

        public TestViewModel(IMvxMessenger messenger)
        {
            _messenger = messenger;

            _receivedTokenDisposable = _messenger.Subscribe<TokenChangedMessage>(msg =>
            {
                if(msg == null) return;
                var token = msg.NewToken;
                if(token == null) return;

                Issuer = token.Issuer;
                Audience = token.Audience;
                IdentityProvider = token.IdentityProvider;
                ExpiresOn = token.ExpiresOn;
                RawToken = token.RawToken;
            });

            _loggedInTokenDisposable =
                _messenger.Subscribe<LoggedInMessage>(async msg =>
                    {
                        //Validate token here, i.e. call your Web Service
                        await Task.Delay(2000);
                        //Calling this immediately, can result in nothing happening
                        //MvxAndroidTask might still be "showing".
                        _messenger.Publish(new CloseSelfMessage(this) {Close = true});
                    });
        }
开发者ID:remcok,项目名称:Cheesebaron.MvxPlugins,代码行数:27,代码来源:TestViewModel.cs

示例3: 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;
        }
开发者ID:obiwan007,项目名称:bettrdiet,代码行数:43,代码来源:MainViewModel.cs

示例4: DialogsViewModel

        public DialogsViewModel(IUserDialogService dialogService, IMvxMessenger messenger) {
			this.dialogs = dialogService;
            this.backgroundToken = messenger.Subscribe<BackgroundAlert>(msg => 
                dialogService.Toast(msg.Message)
            );

            this.SendBackgroundAlert = new MvxCommand(() => 
                messenger.Publish(new BackgroundAlert(this, "Test"))
            );

            this.ActionSheet = new MvxCommand(() => 
                dialogService.ActionSheet(new ActionSheetConfig()
                    .SetTitle("Test Title")
                    .Add("Option 1", () => this.Result = "Option 1 Selected")
                    .Add("Option 2", () => this.Result = "Option 2 Selected")
                    .Add("Option 3", () => this.Result = "Option 3 Selected")
                    .Add("Option 4", () => this.Result = "Option 4 Selected")
                    .Add("Option 5", () => this.Result = "Option 5 Selected")
                    .Add("Option 6", () => this.Result = "Option 6 Selected")
                )
            );

            this.Alert = new MvxCommand(async () => {
                await dialogService.AlertAsync("Test alert", "Alert Title", "CHANGE ME!");
                this.Result = "Returned from alert!";
            });

            this.Confirm = new MvxCommand(async () => {
                var r = await dialogService.ConfirmAsync("Pick a choice", "Pick Title", "Yes", "No");
                var text = (r ? "Yes" : "No");
                this.Result = "Confirmation Choice: " + text;
            });

            this.Login = new MvxCommand(async () => {
                var r = await dialogService.LoginAsync(message: "Enter your user name & password below");
                this.Result = String.Format(
                    "Login {0} - User Name: {1} - Password: {2}",
                    r.Ok ? "Success" : "Cancelled",
                    r.LoginText,
                    r.Password
                );
            });

            this.Prompt = new MvxCommand(async () => {
                var r = await dialogService.PromptAsync("Enter a value");
                this.Result = r.Ok
                    ? "OK " + r.Text
                    : "Prompt Cancelled";
            });

            this.PromptSecure = new MvxCommand(async () => {
                var r = await dialogService.PromptAsync("Enter a value", inputType: InputType.Password);
                this.Result = r.Ok
                    ? "OK " + r.Text
                    : "Secure Prompt Cancelled";
            });

            this.Toast = new MvxCommand(() => {
                this.Result = "Toast Shown";
                dialogService.Toast("Test Toast", onClick: () => this.Result = "Toast Pressed");
            });

            this.Progress = new MvxCommand(async () => {
                var cancelled = false;

                using (var dlg = dialogService.Progress("Test Progress")) {
                    dlg.SetCancel(() => cancelled = true);
                    while (!cancelled && dlg.PercentComplete < 100) {
                        await Task.Delay(TimeSpan.FromMilliseconds(500));
                        dlg.PercentComplete += 2;
                    }
                }
                this.Result = (cancelled ? "Progress Cancelled" : "Progress Complete");
            });

            this.ProgressNoCancel = new MvxCommand(async () => {
                using (var dlg = dialogService.Progress("Progress (No Cancel)")) {
                    while (dlg.PercentComplete < 100) {
                        await Task.Delay(TimeSpan.FromSeconds(1));
                        dlg.PercentComplete += 20;
                    }
                }
            });

            this.Loading = new MvxCommand(async () => {
                var cancelSrc = new CancellationTokenSource();

                using (var dlg = dialogService.Loading("Test Progress")) {
                    dlg.SetCancel(cancelSrc.Cancel);

                    try { 
                        await Task.Delay(TimeSpan.FromSeconds(5), cancelSrc.Token);
                    }
                    catch { }
                }
                this.Result = (cancelSrc.IsCancellationRequested ? "Loading Cancelled" : "Loading Complete");
            });

            this.LoadingNoCancel = new MvxCommand(async () => {
                using (dialogService.Loading("Loading (No Cancel)")) 
//.........这里部分代码省略.........
开发者ID:Mvvmcross-Cn,项目名称:acrmvvmcross,代码行数:101,代码来源:DialogsViewModel.cs


注:本文中的IMvxMessenger.Publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。