/// <summary>
 /// Populates the page with content passed during navigation.  Any saved state is also
 /// provided when recreating a page from a prior session.
 /// </summary>
 /// <param name="navigationParameter">The parameter value passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
 /// </param>
 /// <param name="pageState">A dictionary of state preserved by this page during an earlier
 /// session.  This will be null the first time a page is visited.</param>
 protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
 {
     VM = (ParticipateLiveVM)navigationParameter;
     _notificationChannel = await Win8Notification.GetNotificationChannel();
     _notificationChannel.PushNotificationReceived += notificationChannel_PushNotificationReceived; 
     await VM.RegisterForNotification(_notificationChannel.Uri, "Win8", VM.CurrentSurvey.ChannelName);
 }
Exemplo n.º 2
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			btnLive.TouchUpInside += (s,a) => {
				var vm= new ParticipateLiveVM();
				var selectSurvey = (SelectSurveyController)this.Storyboard.InstantiateViewController("SelectSurvey");
				selectSurvey.VM=vm;
				this.PresentViewController(selectSurvey,true,null);
			};
			btnStatic.TouchUpInside += (s,a) => {
				var vm= new ParticipateStaticVM();
				var selectSurvey = (SelectSurveyController)this.Storyboard.InstantiateViewController("SelectSurvey");
				selectSurvey.VM=vm;
				this.PresentViewController(selectSurvey,true,null);
			};
		}
Exemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.LiveSurvey);
            this.SetOrientationBackground(Resource.Id.LiveSurvey);
            VM = (ParticipateLiveVM)AppModel.VM;
            layout = FindViewById<LinearLayout>(Resource.Id.liveOptionLayout);

            PushClient.CheckDevice(this);
            PushClient.CheckManifest(this);
            if (AppModel.GCMNote != null)
            {
                CleanGCMNote();
            }
            ShowLoading();
            AppModel.GCMNote = new GCMNotifier();
            AppModel.GCMNote.RegistrationUpdated += GCMNote_RegistrationUpdated;
            PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);

            VM.PropertyChanged += (e, a) =>
            {
                RunOnUiThread(() =>
                {
                    if (a.PropertyName == "NotificationMessage")
                    {
                        Toast.MakeText(this, VM.NotificationMessage, ToastLength.Long).Show();
                    }
                    if (a.PropertyName == "CurrentQuestion")
                    {

                        ClearComponents();
                        InitComponents();

                    }
                    if (a.PropertyName == "IsClosed")
                    {
                        this.Finish();
                        StartActivity(typeof(Home));
                    }
                });
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SelectSurvey);
            this.SetOrientationBackground(Resource.Id.SelectFrame);

            var btnStart = FindViewById<Button>(Resource.Id.btnStart);
            var txtFirstName = FindViewById<TextView>(Resource.Id.txtFirstName);
            var txtlastName = FindViewById<TextView>(Resource.Id.txtLastName);
            var txtSurveyCode = FindViewById<TextView>(Resource.Id.txtSurveyCode);

            btnStart.Click += async(e, a) =>
            {

                try
                {
                    switch (Intent.GetStringExtra("VM"))
                    {
                        case "ParticipateLiveVM":
                            ShowLoading();
                            var lvm = new ParticipateLiveVM();
                            lvm.User.FirstName = txtFirstName.Text;
                            lvm.User.LastName = txtlastName.Text;
                            lvm.ChannelName = txtSurveyCode.Text;
                            var lr = await lvm.FindSurveyCurrentChannel();
                            progress.Dismiss();
                            if (lr == 1)
                            {
                                AppModel.VM = lvm;
                                StartActivity(typeof(LiveSurveyActivity));
                            }
                            else
                            {
                                var builder1 = new AlertDialog.Builder(new ContextThemeWrapper(this, Resource.Style.AlertDialogCustom));
                                builder1.SetTitle("Oops, somethings wrong");
                                builder1.SetMessage(lvm.ErrorMessage);
                                builder1.SetPositiveButton("OK", delegate { });
                                var alert1 = builder1.Show();
                                ChangeDialogColor(alert1);

                            }
                            break;
                        case "ParticipateStaticVM":
                            ShowLoading();
                            var svm = new ParticipateStaticVM();
                            svm.User.FirstName = txtFirstName.Text;
                            svm.User.LastName = txtlastName.Text;
                            svm.ChannelName = txtSurveyCode.Text;
                            var sr = await svm.FindSurveyCurrentChannel();
                            progress.Dismiss();
                            if (sr == 1)
                            {
                                AppModel.VM = svm;
                                StartActivity(typeof(StaticSurveyActivity));
                            }
                            else
                            {
                                var builder2 = new AlertDialog.Builder(new ContextThemeWrapper(this, Resource.Style.AlertDialogCustom));
                                builder2.SetTitle("Oops, somethings wrong");
                                builder2.SetMessage(svm.ErrorMessage);
                                builder2.SetPositiveButton("OK", delegate { });
                                var alert2 = builder2.Show();
                                ChangeDialogColor(alert2);
                            }
                            break;
                    }
                }
                catch (Exception ex)
                {
                    var builder1 = new AlertDialog.Builder(new ContextThemeWrapper(this, Resource.Style.AlertDialogCustom));
                    builder1.SetTitle("Error...");
                    builder1.SetMessage(ex.Message);
                    builder1.SetPositiveButton("Ok", delegate
                    {

                    });
                    var alert1 = builder1.Show();
                    ChangeDialogColor(alert1);
                }

            };
        }