コード例 #1
0
        public override void Initialize(IViewModelHost host)
        {
 	        base.Initialize(host);

            // set RegisterCommand to defer to the DoRegistration method...
            this.RegisterCommand = new DelegateCommand((args) => DoRegistration(args as CommandExecutionContext));
        }
コード例 #2
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            ViewMonthlyServiceCommand = new DelegateCommand((e) =>
            {
                //set servicetypeid
                MFundiRuntime.ServiceTypeID = 2;

                Host.ShowView(typeof(IChargePageViewModel));
            });
            ViewDayServiceCommand = new DelegateCommand((e) =>
            {
                MFundiRuntime.ServiceTypeID = 1;
                Host.ShowView(typeof(IChargePageViewModel));
            });
            LogoutCommand = new DelegateCommand(async(e) =>
            { // sign out
                await LogOut();
            });

            TaskDoneCommand = new DelegateCommand((e) =>
            { // mark task as complete
                Host.ShowView(typeof(IPendingTicketsPageViewModel));
            });
        }
コード例 #3
0
        internal static Task ShowAlertAsync(this IViewModelHost page, string message)
        {
            // show...
            MessageDialog dialog = new MessageDialog(message != null ? message : string.Empty);

            return(dialog.ShowAsync().AsTask());
        }
コード例 #4
0
ファイル: StoryPageViewModel.cs プロジェクト: mbrit/Kanblog
        public StoryPageViewModel(IViewModelHost host)
            : base(host)
        {
            this.Streams = new ObservableCollection <StreamItem>();

            // commands...
            this.CancelCommand = new DelegateCommand((args) =>
            {
                //if(this.IsDirty && await this.Host.ConfirmAsync())
                //    this.Host.GoBack();
                //else
                this.Host.GoBack();
            });

            this.SaveCommand = new DelegateCommand(async(args) => await HandleSaveAsync());

            this.DeleteCommand = new DelegateCommand(async(args) =>
            {
                if (await this.Host.ConfirmAsync())
                {
                    await this.Item.SoftDeleteAsync();
                    this.Host.GoBack();
                }
            });
        }
コード例 #5
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            // set RegisterCommand to defer to the DoRegistration method...
            this.RegisterCommand = new DelegateCommand((args) => DoRegistration(args as CommandExecutionContext));
        }
コード例 #6
0
        internal static IAsyncOperation <IUICommand> ShowAlertAsync(this IViewModelHost page, string message)
        {
            // show...
            MessageDialog dialog = new MessageDialog(message != null ? message : string.Empty);

            return(dialog.ShowAsync());
        }
コード例 #7
0
 public LogonPageViewModel(IViewModelHost host)
     : base(host)
 {
     // set RegisterCommand to defer to the DoRegistration method...
     this.LogonCommand = new DelegateCommand((args) => DoLogon(args as CommandExecutionContext));
     this.RegisterCommand = new NavigateCommand<IRegisterPageViewModel>(host);
 }
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            // set...
            this.RegisterCommand = new NavigateCommand <IRegisterPageViewModel>(host);
        }
コード例 #9
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            SubmitCommand = new DelegateCommand((args) => Submit(args as CommandExecutionContext));
            //if (localSettings.Values.ContainsKey("VerifyPhone"))
            //    PhoneNumber = localSettings.Values["VerifyPhone"].ToString();
        }
コード例 #10
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);
            Locations = new List <string>();
            locations = new List <string>();

            SubmitCommand     = new DelegateCommand((args) => Submit(args as CommandExecutionContext));
            UpdateListCommand = new DelegateCommand((args) => Suggest(args as CommandExecutionContext));
        }
コード例 #11
0
        public ReportsPageViewModel(IViewModelHost host)
            : base(host)
        {
            // setup...
            this.Items = new ObservableCollection<ReportItem>();

            // commands...
            this.RefreshCommand = new DelegateCommand(async (e) => await this.DoRefresh(true));
        }
        public ShareTargetPageViewModel(IViewModelHost host)
            : base(host)
        {
            this.ShowImage = false;
            this.Sharing = false;
            this.SupportsComment = true;

            this.ShareCommand = new DelegateCommand(async (args) => await HandleShareCommandAsync());
        }
コード例 #13
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            HireCommand         = new DelegateCommand((args) => Hire(args as CommandExecutionContext));
            CancelCommand       = new NavigateCommand <IHomePageViewModel>(host);
            CallCommand         = new DelegateCommand((args) => Call(args as CommandExecutionContext));
            RequestOtherCommand = new DelegateCommand((args) => Other(args as CommandExecutionContext));
        }
コード例 #14
0
ファイル: StreamsPageViewModel.cs プロジェクト: mbrit/Kanblog
        public StreamsPageViewModel(IViewModelHost host)
            : base(host)
        {
            this.Streams = new ObservableCollection <StreamViewItem>();

            this.NewCommand = new DelegateCommand(async(args) =>
            {
                this.Host.ShowView <StoryPageViewModel>(await StoryItem.CreateForNewAsync());
            });
        }
コード例 #15
0
        internal static void InitializeViewModel(this IViewModelHost page)
        {
            // create the model - ultimately we'll replace this with an IoC container...
            var model = new RegisterPageViewModel();

            model.Initialize(page);

            // set the data context...
            ((Page)page).DataContext = model;
        }
コード例 #16
0
ファイル: StreamsPageViewModel.cs プロジェクト: mbrit/Kanblog
        public StreamsPageViewModel(IViewModelHost host)
            : base(host)
        {
            this.Streams = new ObservableCollection<StreamViewItem>();

            this.NewCommand = new DelegateCommand(async (args) =>
            {
                this.Host.ShowView<StoryPageViewModel>(await StoryItem.CreateForNewAsync());
            });
        }
        public SearchResultsPageViewModel(IViewModelHost host)
            : base(host)
        {
            this.MasterItems = new List<ReportViewItem>();
            this.Results = new ObservableCollection<ReportViewItem>();
            this.Filters = new ObservableCollection<SearchFilter>();

            // command...
            this.SelectionCommand = new NavigateCommand<IReportPageViewModel>(this.Host);
        }
コード例 #18
0
        public ReportsPageViewModel(IViewModelHost host)
            : base(host)
        {
            // setup...
            this.Items = new ObservableCollection<ReportViewItem>();
            this.SelectedItems = new List<ReportViewItem>();

            // commands...
            this.RefreshCommand = new DelegateCommand(async (e) =>
            {
                this.Host.HideAppBar();
                await this.DoRefresh(true);

                // toast...
                string message = "I found 1 report.";
                if (this.Items.Count != 1)
                    message = string.Format("I found {0} reports.", this.Items.Count);
                var toast = new ToastNotificationBuilder(new string[] { "Reports refreshed.", message });
                toast.ImageUri = "ms-appx:///Assets/Toast.jpg";
                toast.Update();
            });

            // update any selection that we were given...
            this.SelectionCommand = new DelegateCommand((args) =>
            {
                // update the selection...
                this.SelectedItems.Clear();
                foreach (ReportViewItem item in (IEnumerable<object>)args)
                    this.SelectedItems.Add(item);

                // raise...
                this.OnPropertyChanged("SelectedItems");
                this.OnPropertyChanged("HasSelectedItems");
            });

            // dump the state...
            this.DumpSelectionCommand = new DelegateCommand(async (e) =>
            {
                if (this.SelectedItems.Count > 0)
                {
                    var builder = new StringBuilder();
                    foreach (var item in this.SelectedItems)
                    {
                        if (builder.Length > 0)
                            builder.Append("\r\n");
                        builder.Append(item.Title);
                    }

                    // show...
                    await this.Host.ShowAlertAsync(builder.ToString());
                }
                else
                    await this.Host.ShowAlertAsync("(No selection)");
            });
        }
コード例 #19
0
        public SearchResultsPageViewModel(IViewModelHost host)
            : base(host)
        {
            this.MasterItems = new List<ReportViewItem>();
            this.Results = new ObservableCollection<ReportViewItem>();
            this.Filters = new ObservableCollection<SearchFilter>();

            // command...
            this.SelectionCommand = new DelegateCommand(async (args) =>
            {
                await this.Host.ShowAlertAsync("Selected: " + ((ReportViewItem)args).Title);
            });
        }
コード例 #20
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            Locations         = new List <string>();
            locations         = new List <string>();
            SignUpCommand     = new DelegateCommand((args) => DoRegister(args as CommandExecutionContext));
            SignInCommand     = new DelegateCommand((args) => DoLogin(args as CommandExecutionContext));
            VerifyCommand     = new DelegateCommand((args) => Verify(args as CommandExecutionContext));
            ForgotCommand     = new DelegateCommand((args) => ForgotPassword(args as CommandExecutionContext));
            UpdateListCommand = new DelegateCommand((args) => Suggest(args as CommandExecutionContext));
            IsSelected        = true;
        }
コード例 #21
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            if (MFundiRuntime.ServiceTypeID == 1)
            {
                SummaryText = res.GetString("StandardFee");
            }
            else
            {
                SummaryText = res.GetString("FinderFee");
            }

            //prompt to pay and proceed to view maid
            ProceedCommand = new DelegateCommand((args) => Proceed(args as CommandExecutionContext));
        }
コード例 #22
0
        public ReportsPageViewModel(IViewModelHost host)
            : base(host)
        {
            // setup...
            this.Items = new ObservableCollection<ReportViewItem>();
            this.SelectedItems = new List<ReportViewItem>();

            // commands...
            this.RefreshCommand = new DelegateCommand(async (e) =>
            {
                this.Host.HideAppBar();
                await this.DoRefresh(true);
            });

            // update any selection that we were given...
            this.SelectionCommand = new DelegateCommand((args) =>
            {
                // update the selection...
                this.SelectedItems.Clear();
                foreach (ReportViewItem item in (IEnumerable<object>)args)
                    this.SelectedItems.Add(item);

                // raise...
                this.OnPropertyChanged("SelectedItems");
                this.OnPropertyChanged("HasSelectedItems");
            });

            // dump the state...
            this.DumpSelectionCommand = new DelegateCommand(async (e) =>
            {
                if (this.SelectedItems.Count > 0)
                {
                    var builder = new StringBuilder();
                    foreach (var item in this.SelectedItems)
                    {
                        if (builder.Length > 0)
                            builder.Append("\r\n");
                        builder.Append(item.Title);
                    }

                    // show...
                    await this.Host.ShowAlertAsync(builder.ToString());
                }
                else
                    await this.Host.ShowAlertAsync("(No selection)");
            });
        }
コード例 #23
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            HireCommand         = new DelegateCommand((args) => Hire(args as CommandExecutionContext));
            CancelCommand       = new NavigateCommand <IHomePageViewModel>(host);
            CallCommand         = new DelegateCommand((args) => Call(args as CommandExecutionContext));
            RequestOtherCommand = new DelegateCommand((args) => Other(args as CommandExecutionContext));
            if (MFundiRuntime.ServiceTypeID == 2)
            {
                IsMonthly = true;
            }
            else
            {
                IsMonthly = false;
            }
        }
コード例 #24
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);
            ErrorBucket errors = new ErrorBucket();

            Items          = new ObservableCollection <TicketItem>();
            SelectedTicket = new TicketItem();
            SubmitCommand  = new DelegateCommand(async(e) =>
            {
                TicketID = (int)e;

                MFundiRuntime.TicketID = TicketID.ToString();

                var proxy = TinyIoCContainer.Current.Resolve <ITaskCompleteServiceProxy>();

                using (EnterBusy())
                {
                    var result = await proxy.TaskCompleteAsync(TicketID);

                    if (!(result.HasErrors))
                    {
                        if (result.Status != "success")
                        {
                            errors.CopyFrom(result);
                        }
                        else
                        {
                            var toast = new ToastNotificationBuilder(new string[] { result.Message });
                            toast.Update();
                            Host.ShowView(typeof(IEvaluationPageViewModel));
                        }
                    }
                    else
                    {
                        errors.CopyFrom(result);
                    }

                    if (errors.HasErrors)
                    {
                        await Host.ShowAlertAsync(errors.GetErrorsAsString());
                    }
                }
            });
        }
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            // commands...
            this.RefreshCommand = new DelegateCommand(async(e) =>
            {
                this.Host.HideAppBar();
                await this.DoRefresh(true);

                // toast...
                string message = StringHelper.Format("Reports_Toast_IFound1Report");
                if (this.Items.Count != 1)
                {
                    message = StringHelper.Format("Reports_Toast_IFoundNReports", this.Items.Count);
                }
                var toast      = new ToastNotificationBuilder(new string[] { StringHelper.Format("Reports_Toast_ReportsRefreshed"), message });
                toast.ImageUri = "ms-appx:///Assets/Toast.jpg";
                toast.Update();
            });

            // open the singleton report view...
            this.SelectionCommand = new NavigateCommand <IReportPageViewModel>(this.Host);

            // show the location...
            this.ShowLocationCommand = new DelegateCommand(async(e) =>
            {
                // get the location...
                var result = await LocationHelper.GetCurrentLocationAsync();
                if (result.Code == LocationResultCode.Ok)
                {
                    await this.Host.ShowAlertAsync(string.Format("Lat: {0}, Long: {1}, Accuracy: {2}",
                                                                 result.Location.Coordinate.Latitude, result.Location.Coordinate.Longitude,
                                                                 result.Location.Coordinate.Accuracy));
                }
                else
                {
                    await this.Host.ShowAlertAsync("Failed to get location: " + result.Code.ToString());
                }
            });

            // add...
            this.NewCommand = new DelegateCommand((e) => this.Host.ShowView(typeof(IEditReportPageViewModel), new ReportViewItem(new ReportItem())));
        }
コード例 #26
0
        internal static void InitializeViewModel(this IViewModelHost host, IViewModel model = null)
        {
            // if we don't get given a model?
            if (model == null)
            {
                var attr = (ViewModelAttribute)host.GetType().GetTypeInfo().GetCustomAttribute <ViewModelAttribute>();
                if (attr != null)
                {
                    model = (IViewModel)TinyIoCContainer.Current.Resolve(attr.ViewModelInterfaceType);
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Page '{0}' is not decorated with ViewModelAttribute."));
                }
            }

            // setup...
            model.Initialize((IViewModelHost)host);
            ((Page)host).DataContext = model;
        }
コード例 #27
0
 public virtual void Initialize(IViewModelHost host)
 {
     this.Host = host;
 }
コード例 #28
0
 public HelpPaneViewModel(IViewModelHost host)
     : base(host)
 {
     WebHelpCommand = new DelegateCommand(async (args) => await SettingsInteractionHelper.ShowWebHelpAsync());
 }
コード例 #29
0
 public ViewModel(IViewModelHost host)
     : base(host)
 {
 }
コード例 #30
0
 public virtual void Initialize(IViewModelHost host)
 {
     this.Host = host;
 }
コード例 #31
0
 public static void ShowView <T>(this IViewModelHost host, object parameter = null)
     where T : IViewModel
 {
     host.ShowView(typeof(T), parameter);
 }
コード例 #32
0
 protected ViewModel(IViewModelHost host)
 {
     this.Host = host;
 }
コード例 #33
0
 public MySettingsPaneViewModel(IViewModelHost host)
     : base(host)
 {
 }
コード例 #34
0
        public override void Initialize(IViewModelHost host)
        {
            base.Initialize(host);

            ForgotCommand = new DelegateCommand((args) => ForgotPassword(args as CommandExecutionContext));
        }
コード例 #35
0
 internal static IViewModel GetModel(this IViewModelHost page)
 {
     return(((Control)page).DataContext as IViewModel);
 }
コード例 #36
0
 public NavigateCommand(IViewModelHost host)
 {
     this.Host = host;
 }
コード例 #37
0
 internal static IAsyncOperation <IUICommand> ShowAlertAsync(this IViewModelHost page, ErrorBucket errors)
 {
     return(ShowAlertAsync(page, errors.GetErrorsAsString()));
 }
コード例 #38
0
ファイル: ViewModel.cs プロジェクト: mbrit/Kanblog
 protected ViewModel(IViewModelHost host)
 {
     this.Host = host;
 }
コード例 #39
0
 public RegisterPageViewModel(IViewModelHost host)
     : base(host)
 {
     // set RegisterCommand to 
     this.RegisterCommand = new DelegateCommand((args) => DoRegistration());
 }
コード例 #40
0
 public override void Initialize(IViewModelHost host)
 {
     base.Initialize(host);
     SubmitCommand = new DelegateCommand((args) => Evaluate(args as CommandExecutionContext));
 }
コード例 #41
0
 public override void Initialize(IViewModelHost host)
 {
     base.Initialize(host);
     this.RegisterCommand = new NavigateCommand<IRegisterPageViewModel>(host);
 }
コード例 #42
0
        //// event for the change...
        //public event PropertyChangedEventHandler PropertyChanged;

        public ViewModel(IViewModelHost host)
        {
            this.Host = host;
            //this.Values = new Dictionary<string, object>();
        }
コード例 #43
0
 // specialised GetHandler implementation...
 public U GetHandler <U>(IViewModelHost host)
     where U : IViewModel
 {
     return(GetHandlerInternal <U>(host));
 }
コード例 #44
0
 public ViewModel(IViewModelHost host)
 {
     this.Host = host;
 }
コード例 #45
0
 internal static Task ShowAlertAsync(this IViewModelHost page, ErrorBucket errors)
 {
     return(ShowAlertAsync(page, errors.GetErrorsAsString()));
 }