public ItemDetailViewModel(Xamarin.Forms.INavigation navigation, ToDoItemModel item = null) { _navigation = navigation; PomodoroChart = new BarChart() { Entries = new List <Entry>() }; Title = item?.Title; SelectedItem = item; PopulateChart(); Xamarin.Forms.MessagingCenter.Subscribe <PomodoroViewModel, PomodoroItemModel>(this, Consts.AddNewToDoItemStr, (obj, newPomodoroItem) => { Pomodoros.Add(newPomodoroItem); NumberOfPomodoros++; }); DoneButtonTouched = new Xamarin.Forms.Command(async() => { var newItem = await DataStore.SetDoneTodo(SelectedItem.Id); Xamarin.Forms.MessagingCenter.Send(this, Consts.DoneTodoItemStr, newItem); await _navigation.PopAsync(); }); }
public ContractorUserControlViewModel(object owner) { var parentViewModel = (HomeViewModel)owner; if (parentViewModel != null) { this.UserProfile = parentViewModel.UserProfile; } UpdateDescriptionLabel(UserProfile?.IsContractor == true); //provide initial description while loading job jobService = new JobService(); RefreshJobList = new Xamarin.Forms.Command(async(e) => { await RefreshListAsync(); }, (param) => { if (IsBusy) { return(false); } return(true); }); GoToJobView = new Xamarin.Forms.Command(async(e) => { this.selectedJob = (Job)e; await Navigator.Instance.NavigateTo(PageType.JOB_ACCEPTANCE_VIEW, this); }, (param) => { return(true); }); }
public BarcodeTypesViewModel() { SearchCommand = new Xamarin.Forms.Command(async() => await Search()); SaveCommand = new Xamarin.Forms.Command(async() => await Save()); Search(); }
public MainPageViewModel(Action <Exception, string> errorLog, Action <string, IDictionary <string, string> > logger) { _logger = logger; _tello = new Tello(false, false, errorLog); IncreaseAltitudeCommand = new Xamarin.Forms.Command(_ => IncreateMaxAltitude(), _ => CanIncreaseMaxAltitude); DecreaseAltitudeCommand = new Xamarin.Forms.Command(_ => DecreateMaxAltitude(), _ => CanDecreaseMaxAltitude); }
public LivrosViewModel() { CarregarCommand = new Xamarin.Forms.Command(async() => { var livros = await ApiLivros.Api.GetAsync(); Livros = new ObservableCollection <Model.Livro>(livros); }); }
public CountryViewModel() { Countrys = new ObservableCollection <Model.Country>(); InitializeCommand = new Xamarin.Forms.Command(async() => { var countrys2 = await API.Api.getAsync(); Countrys = new ObservableCollection <Model.Country>(countrys2); }); }
public HistoryUserControlViewModel(object owner) { var parentViewModel = (HomeViewModel)owner; if (parentViewModel != null) { this.UserProfile = parentViewModel.UserProfile; } UpdateDescriptionLabel(); jobService = new JobService(); RefreshJobList = new Xamarin.Forms.Command(async(e) => { await RefreshListAsync(); }, (param) => { if (IsBusy) { return(false); } return(true); }); EditJobRequestHistoryCmd = new Xamarin.Forms.Command(e => { //TODO if required }, param => { return(true); }); DeleteJobRequestHistoryCmd = new Xamarin.Forms.Command(e => { //TODO if required }, param => { return(true); }); SortJobByDate = new Xamarin.Forms.Command(e => { }, param => { return(true); }); GoToJobView = new Xamarin.Forms.Command(async e => { this.selectedJob = (Job)e; await Navigator.Instance.NavigateTo(PageType.HISTORY_JOB_VIEW, this); }, param => { return(true); }); }
public CastDetailsViewModel() { BarChart = new BarChart(); CircleChart = new DonutChart() { LabelTextSize = 14 }; GoToProfileCommand = new Xamarin.Forms.Command(async() => await GoToImdbProfile()); GoHomePageCommand = new Xamarin.Forms.Command(async() => await GoToMainPage()); }
public TicketDetailViewModel(MerchandisingTicket ticket = null) { Title = "Ticket Details"; Ticket = ticket; TimerText = string.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds); Comment = Ticket.comment; SubmitCommand = new Xamarin.Forms.Command(OnSubmit); TimerStart = new Xamarin.Forms.Command(TimeStart); TimerStop = new Xamarin.Forms.Command(TimeStop); TimerComplete = new Xamarin.Forms.Command(TimeComplete); }
public MoviesViewModel() { // Bind the results to ListView. Results = new ObservableCollection <Models.Result>(); LoadMoviesCommand = new Xamarin.Forms.Command(async() => { var r = await TMDBAPI.API.GetUpcomingMoviesAsync(this._page); foreach (var item in r.Results) { String PosterImage; // Check if a poster image path is available, otherwise shows placeholder. if (null != item.Poster_Path) { PosterImage = "https://image.tmdb.org/t/p/w300/" + item.Poster_Path; } else { PosterImage = "no_poster_placeholder.png"; } // Wraps texto to fit listview space. String OverviewWrap; int max_chars = 150; max_chars -= item.Title.Length; if (item.Overview.Length > max_chars) { OverviewWrap = item.Overview.Substring(0, max_chars) + "..."; } else { OverviewWrap = item.Overview; } Results.Add(new Models.Result { Id = item.Id, Title = item.Title, Backdrop_Path = item.Backdrop_Path, Genre_Ids = item.Genre_Ids, Overview = OverviewWrap, Poster_Path = PosterImage, Release_Date = "Release: " + item.Release_Date }); } }); // Automatically loads upcoming movies from API. LoadMoviesCommand.Execute(this); }
public MoviesSearchViewModel() { // Bind the results to ListView. Results = new ObservableCollection <Models.Result>(); SearchMoviesCommand = new Xamarin.Forms.Command(async() => { // Clear listing. Results.Clear(); var r = await TMDBAPI.API.SearchMoviesAsync(SearchedText); foreach (var item in r.Results) { // Check if a poster image path is available, otherwise shows placeholder. String PosterImage; if (null != item.Poster_Path) { PosterImage = "https://image.tmdb.org/t/p/w500/" + item.Poster_Path; } else { PosterImage = "no_poster_placeholder.png"; } // Wraps texto to fit listview space. String OverviewWrap; int max_chars = 150; max_chars -= item.Title.Length; if (item.Overview.Length > max_chars) { OverviewWrap = item.Overview.Substring(0, max_chars) + "..."; } else { OverviewWrap = item.Overview; } Results.Add(new Models.Result { Id = item.Id, Title = item.Title, Backdrop_Path = item.Backdrop_Path, Genre_Ids = item.Genre_Ids, Overview = OverviewWrap, Poster_Path = PosterImage, Release_Date = "Release: " + item.Release_Date }); } }); }
public ProfessorViewModel() { var teste = ProfessorRepository.GetProfessoresSqlAzureAsync(); OnAdicionarProfessorCMD = new OnAdicionarProfessorCMD(this); OnEditarProfessorCMD = new OnEditarProfessorCMD(this); OnDeleteProfessorCMD = new OnDeleteProfessorCMD(this); OnSairCMD = new Xamarin.Forms.Command(OnSair); OnNovoCMD = new Xamarin.Forms.Command(OnNovo); CopiaListaProfessores = new List <Professor>(); Carregar(); }
public OrderInfoViewModel(Tables table = null) { this.Table = table; // Order = table.Orders.FirstOrDefault(); Sekces = new ObservableCollection <Sekce>(); Orders = new ObservableCollection <Orders>(); Items = new TabItemCollection(); Polozkas = new ObservableCollection <Items>(); OrderDetails = new ObservableCollection <OrderDetail>(); LoadItemsCommand = new Xamarin.Forms.Command(async() => await GetOrderDetail()); //Přiřadíme příkazu metodu a určíme jeho aynchronní provedení }
public EditRequestorProfileViewModel(object owner) { var parentViewModel = (UserProfileUserControlViewModel)owner; this.parentViewModel = parentViewModel; if (parentViewModel != null) { var tempUserProfile = parentViewModel.UserProfile; if (tempUserProfile != null) { Name = tempUserProfile.Name; Mobile = tempUserProfile.Mobile; Email = tempUserProfile.Email; SelectedCity = tempUserProfile.City; SelectedCountry = tempUserProfile.Country; ImagePath = tempUserProfile.PathToProfileImage; SelectedCategory = tempUserProfile.Category; Company = tempUserProfile.CompanyName; CompanyAddress = tempUserProfile.CompanyRegisteredAddress; userSystemUUID = tempUserProfile.SystemUUID; } } locationService = new LocationService(); userService = new UserService(); userProfileRepository = new UserProfileRepository(); userIdentityRepository = new UserIdentityRepository(); SubmitProfileChangeCmd = new SubmitProfileChangeRequestorCommand(this); ChangeProfileImageCmd = new Xamarin.Forms.Command((e) => { ChangeProfileImageAsync(); }, (param) => { if (param == null) { return(false); } var isBusy = (bool)param; return(!isBusy); }); LoadContractorOptions(); this.SubscribeMeToThis(parentViewModel); PopulateLocations(); LoadImageUploaderOptions(); }
/// <summary> /// Constructor for VM /// </summary> /// <param name="currentFolders">Current folders.</param> public FolderIconPickerViewModel(System.Collections.Generic.IEnumerable <Icon> currentFolders) { CurrentFolderStrings = new System.Collections.Generic.List <string>(); if (currentFolders.Any()) { foreach (var folder in currentFolders) { CurrentFolderStrings.Add(folder.Text); } } IconSelectedFromList = new Xamarin.Forms.Command(ItemSelected); CommandSaveClicked = new Xamarin.Forms.Command(SaveClicked); }
public ModifyIconViewModel(Icon _currentIcon, FieldControl _controller) { currentIcon = _currentIcon; controller = _controller; ButtonResetSize = new Xamarin.Forms.Command(ResetSizeOfButton); ButtonIncreaseSize = new Xamarin.Forms.Command(IncreaseSizeOfIcon); ButtonIncreaseSize2 = new Xamarin.Forms.Command(IncreaseSizeOfIconLarge); ButtonDecreaseSize = new Xamarin.Forms.Command(DecreaseSizeOfIcon); ButtonDecreaseSize2 = new Xamarin.Forms.Command(DecreaseSizeOfIconLarge); ButtonEditText = new Xamarin.Forms.Command(EditIconText); ButtonPinning = new Xamarin.Forms.Command(PinIcon); ButtonDelete = new Xamarin.Forms.Command(DeleteIcon); }
public JobAcceptanceViewViewModel(object owner) { parentViewModel = (BaseViewModel)owner; if (parentViewModel is ContractorUserControlViewModel) { var contractorUserControlViewModel = (ContractorUserControlViewModel)parentViewModel; this.Job = contractorUserControlViewModel.GetSelectedJob(); UserProfile = contractorUserControlViewModel.UserProfile; } jobviewCommonUserControlViewModel = new JobViewCommonUserControlViewModel(this); jobService = new JobService(); AcceptJobCmd = new Xamarin.Forms.Command(async e => { if (selectedJob != null) { var result = await jobService.AcceptJob(new Model.Requests.AcceptJobRequestRequest { ContractorUUID = UserProfile?.SystemUUID, JobSystemUUID = selectedJob.SystemUUID }); if (result == true) { Navigator.Instance.OkAlert("Job Accepted", "You have accepted the job, please call the requestor for more details.", "OK"); await Navigator.Instance.ReturnPrevious(UIPageType.PAGE); if (parentViewModel is ContractorUserControlViewModel) { var contractorUserControlViewModel = (ContractorUserControlViewModel)parentViewModel; await contractorUserControlViewModel.RefreshListAsync(); } } else { Navigator.Instance.OkAlert("Error", "There is a problem with the server. Please try again later.", "OK"); } } }, param => { return(true); }); }
public LivrosViewModel() { Livros = new ObservableCollection <Model.Livro>(); Livros.Add(new Model.Livro { Id = 1, Nome = "Primeiro Livro" }); CarregarCommand = new Xamarin.Forms.Command( async() => { //Livros.Add(new Model.Livro { Id = 1, Titulo = $"Livro {Livros.Count}" }); var livros = await ApiLivros.Api.GetAsync(); Livros = new ObservableCollection <Model.Livro>(livros); } ); }
public AppViewModel() { LoadRegions(); LoadRegionsCommand = new Xamarin.Forms.Command(LoadRegions); CitiesSearchCommand = new Xamarin.Forms.Command <string>( execute: (string inputText) => { Cities = Search(_citiesSearchQueryTemplate, Region.Id, inputText); }); CentersSearchCommand = new Xamarin.Forms.Command <string>( execute: (string inputText) => { Centers = Search(_centersSearchQueryTemplate, City.Id, inputText); }); }
/// <summary> /// Set up VM /// </summary> /// <param name="_controller">Controller.</param> public SettingsPageViewModel(FieldControl _controller) { controller = _controller; CommandSaveBoard = new Xamarin.Forms.Command(ResumeOperation); CommandDeselecting = new Xamarin.Forms.Command(DeselectOperation); CommandOperatingMode = new Xamarin.Forms.Command(ChangeMode); CommandAddIconLocal = new Xamarin.Forms.Command(AddIconLocal); CommandAddIconPhoto = new Xamarin.Forms.Command(AddIconPhoto); CommandAddIconStored = new Xamarin.Forms.Command(AddIconStored); CommandAddFolder = new Xamarin.Forms.Command(AddFolder); CommandHelp = new Xamarin.Forms.Command(ShowHelpPopup); CommandAbout = new Xamarin.Forms.Command(ShowAboutPopup); CommandClose = new Xamarin.Forms.Command(Close); RefreshSettingsStatus(); }
public JobViewViewModel(object owner) { parentViewModel = (BaseViewModel)owner; if (parentViewModel is DashboardUserControlViewModel) { var dashboardViewModel = (DashboardUserControlViewModel)parentViewModel; this.selectedJob = dashboardViewModel.GetSelectedJob(); UserProfile = dashboardViewModel.UserProfile; SubscribeMeToThis(dashboardViewModel); } jobviewCommonUserControlViewModel = new JobViewCommonUserControlViewModel(this); jobService = new JobService(); EditCmd = new Xamarin.Forms.Command(async e => { await Navigator.Instance.NavigateTo(PageType.EDIT_JOB_VIEW, this); }, param => { return(true); }); DeleteCmd = new Xamarin.Forms.Command(e => { Navigator.Instance.ConfirmationAlert("Confirmation", "Are you sure you want to delete this job (cannot be undone)?", "Yes", "No", async() => { //For android await DoDeleteJob(selectedJob); }, async() => { //For ios await DoDeleteJob(selectedJob); }); }, param => { return(true); }); }
public ServerViewModel(ICoreServices services) : base(services) { this.BleAdapter .WhenStatusChanged() .Subscribe(x => this.Status = x); var cmd = new Command(async _ => { if (this.BleAdapter.Status != AdapterStatus.PoweredOn) { this.Dialogs.Alert("Could not start GATT Server. Adapter Status: " + this.BleAdapter.Status); return; } try { this.BuildServer(); if (this.server.IsRunning) { this.server.Stop(); } else { await this.server.Start(new AdvertisementData { LocalName = "TestServer" }); } } catch (Exception ex) { this.Dialogs.Alert(ex.ToString(), "ERROR"); } }); this.ToggleServer = cmd; this.Clear = new Command(() => this.Output = String.Empty); }
/// <summary> /// 通过反射从教务系统服务中读取所有的设置属性和方法。 /// </summary> private SettingViewModel() { Title = "设置中心"; var type = Core.App.Service.GetType(); var props = type.GetProperties(); var voids = type.GetMethods(); Items = ( from prop in props where prop.GetCustomAttribute(typeof(SettingsAttribute)) != null select new SettingWrapper(prop) ).Union( from @void in voids where @void.GetCustomAttribute(typeof(SettingsAttribute)) != null select new SettingWrapper(@void) ).ToList(); SaveConfigures = new Command(async() => { Core.App.Service.SaveSettings(); await ShowMessage("设置中心", "保存成功!"); }); }
public SensorVM() { StartCommand = new Xamarin.Forms.Command(StartSubmit); }
public Language() { CloseButtonTapped = new Xamarin.Forms.Command(TapCloseButton); }
public Page1ViewModel() { SaveCommand = new Xamarin.Forms.Command(HandleAction); }
public TodolistViewModel() { _todolists = new ObservableCollection <Todolist>(); _switchTodolist = new Xamarin.Forms.Command(async(id) => { // Set the header IDictionary <string, string> headers = new Dictionary <string, string>(); // Fetch the user token headers.Add("Authorization", "Bearer " + App.UserSession.Token); // define the body string body = " { \"todolistId\": \"" + id + "\" } "; CurrentItems = await App.WsHost.ExecuteGet <ObservableCollection <Item> >("todos", "get", headers, body); }); _tickItem = new Xamarin.Forms.Command(async(id) => { // Get the selected item Item item = CurrentItems.Where <Item>(item => item.Id == id.ToString()).FirstOrDefault(); // Set the header IDictionary <string, string> headers = new Dictionary <string, string>(); // Fetch the user token headers.Add("Authorization", "Bearer " + App.UserSession.Token); // Set paraeters string[] parameters = { id.ToString() }; // Check it in the data base await App.WsHost.ExecutePut("todos", "check", headers, null, parameters); // Switch the boolean attribute of Done item.Done = !item.Done; CurrentItems[CurrentItems.IndexOf(item)] = item; }); _addItem = new Xamarin.Forms.Command(async() => { // Set the header IDictionary <string, string> headers = new Dictionary <string, string>(); // Fetch the user token headers.Add("Authorization", "Bearer " + App.UserSession.Token); // define the body string body = " { \"name\": \"" + FormTitle + "\",\"todolistId\": \"" + CurrentTodolist.Id + "\" } "; // Check it in the data base var item = await App.WsHost.ExecutePost <Item>("todos", "add", headers, body); // Add to the current item CurrentItems.Add(new Item { ItemTitle = item.ItemTitle, Id = item.Id }); // Empty the form FormTitle = string.Empty; }); _signout = new Xamarin.Forms.Command(() => { try { // Remove the stored token SecureStorage.Remove("oauth_token"); // Move to the sign in page App.Current.MainPage = new SignInPage(); } catch (Exception ex) { throw new Exception("Signout process: " + ex.Message); } }); _deleteItem = new Xamarin.Forms.Command(async(id) => { try { //Item item = new Item(); // Get the selected item // item = (from itm in CurrentItems // where itm.Id == id.ToString() // select itm) //.FirstOrDefault<Item>();//CurrentItems.Where<Item>(item => item.Id == id.ToString()).FirstOrDefault(); // int itemIndex = CurrentItems.IndexOf(item); // Set the header IDictionary <string, string> headers = new Dictionary <string, string>(); // Fetch the user token headers.Add("Authorization", "Bearer " + App.UserSession.Token); // Set paraeters string[] parameters = { id.ToString() }; // Check it in the data base await App.WsHost.ExecuteDelete("todos", null, headers, null, parameters); // ToDo: I'm reloading everery data but it's not a good things performance wise. // I can't remove the item directely form the list because SwipeView is boken // // define the body string body = " { \"todolistId\": \"" + CurrentTodolist.Id + "\" } "; // Reload data CurrentItems = await App.WsHost.ExecuteGet <ObservableCollection <Item> >("todos", "get", headers, body); // Remove the item from the list //CurrentItems.Remove(item); } catch (Exception ex) { throw new Exception(ex.Message); } }); _addTodolist = new Xamarin.Forms.Command(async() => { try { // Set the header IDictionary <string, string> headers = new Dictionary <string, string>(); // Fetch the user token headers.Add("Authorization", "Bearer " + App.UserSession.Token); // define the body string body = " { \"title\": \"" + FormTitle + "\" } "; // Check it in the data base var todolist = await App.WsHost.ExecutePost <Todolist>("todolists", "create", headers, body); // Add to the current item Todolists.Add(new Todolist { Title = todolist.Title, Id = todolist.Id }); // Empty the form FormTitle = string.Empty; UpdateCurrentTodolist(Todolists.Last()); } catch (Exception ex) { throw new Exception(ex.Message); } }); // Fetch all the todolists FetchTodolist(); }
public DashboardUserControlViewModel(object owner) { var parentViewModel = (HomeViewModel)owner; if (parentViewModel != null) { this.UserProfile = parentViewModel.UserProfile; SubscribeMeToThis(parentViewModel); } UpdateDescriptionLabel(); jobService = new JobService(); RefreshJobList = new Xamarin.Forms.Command(async(e) => { await RefreshListAsync(); }, (param) => { if (IsBusy) { return(false); } return(true); }); EditJobRequestCmd = new Xamarin.Forms.Command(async e => { this.selectedJob = (Job)e; await Navigator.Instance.NavigateTo(PageType.EDIT_JOB_VIEW, this); }, param => { return(true); }); DeleteJobRequestCmd = new Xamarin.Forms.Command(async e => { var job = (Job)e; Navigator.Instance.ConfirmationAlert("Confirmation", "Are you sure you want to delete this job (cannot be undone)?", "Yes", "No", async() => { //For android await DoDeleteJob(job); await RefreshListAsync(); }, async() => { //For ios await DoDeleteJob(job); await RefreshListAsync(); }); }, param => { return(true); }); GoToJobView = new Xamarin.Forms.Command(async e => { this.selectedJob = (Job)e; await Navigator.Instance.NavigateTo(PageType.JOB_VIEW, this); }, param => { return(true); }); }
public JobHistoryViewViewModel(object owner) { parentViewModel = (BaseViewModel)owner; if (parentViewModel is HistoryUserControlViewModel) { var historyViewModel = (HistoryUserControlViewModel)parentViewModel; this.Job = historyViewModel.GetSelectedJob(); GoToProfilePageCmd = new Xamarin.Forms.Command(async e => { await Navigator.Instance.NavigateTo(PageType.PROFILE_VIEW, this); }, param => { if (param == null) { return(false); } return(!(bool)param); }); string userSystemUUID = ""; userService = new UserService(); jobService = new JobService(); var user = historyViewModel?.UserProfile; if (user != null && this.Job != null) { //if the current user is a contractor, and this job is the job that this contractor accepted, the profile displayed would be the job requestor's if (user.IsContractor && this.Job.ContractorSystemUUID == user.SystemUUID) { userSystemUUID = this.Job.RequestorSystemUUID; HasProfile = true; ProfileType = Constants.REQUESTOR; } else if (this.Job.RequestorSystemUUID == user.SystemUUID && !string.IsNullOrEmpty(this.Job.ContractorSystemUUID)) { //if the job has contractor user uuid assigned (that means the job is accepted by a contractor), then the profile displayed would be contractor's userSystemUUID = this.Job.ContractorSystemUUID; HasProfile = true; ProfileType = Constants.CONTRACTOR; if (this.Job.Status != Constants.SUSPENDED && this.Job.Status != Constants.COMPLETED) { ShowFooterButtons = true; } } } if (!string.IsNullOrEmpty(userSystemUUID)) { GetProfileData(userSystemUUID); } } jobviewCommonUserControlViewModel = new JobViewCommonUserControlViewModel(this); SuspendCmd = new Xamarin.Forms.Command(async e => { Navigator.Instance.ConfirmationAlert("Confirmation", "Are you sure you want to suspend this job?", "Yes", "No", async() => { //For android await DoSuspendJob(); }, async() => { //For ios await DoSuspendJob(); }); }, param => { if (param == null) { return(false); } return(!(bool)param); }); JobCompletedCmd = new Xamarin.Forms.Command(async e => { Navigator.Instance.ConfirmationAlert("Confirmation", "Are you sure you want to complete this job?", "Yes", "No", async() => { //For android await DoCompleteJob(); }, async() => { //For ios await DoCompleteJob(); }); }, param => { if (param == null) { return(false); } return(!(bool)param); }); }
public FloorPlanViewModel() { Devices = new ObservableCollection <DeviceModel>(GetDevices()); OpenFloorDevicesCommand = new Xamarin.Forms.Command(OpenFloorDevices); }