public StartUsage2() { this.InitializeComponent(); PagesUtilities.AddBackButtonHandler(); Timer.Tick += Timer_Tick; Timer.Interval = new TimeSpan(0, 1, 0); //so time would be updated }
private void BindButtonWidget() { if (!string.IsNullOrEmpty(this.Text)) { this.ButtonTextLtl.Text = this.Text; } if (this.LandingPageId != null && this.LandingPageId != Guid.Empty) { var pageNodeUrl = PagesUtilities.GetPageUrlById(this.LandingPageId); this.ButtonLink.NavigateUrl = pageNodeUrl; } else if (!string.IsNullOrEmpty(this.ExternalLink)) { this.ButtonLink.NavigateUrl = this.ExternalLink; } if (this.Alignment == "Right") { this.ButtonLink.CssClass += " align-right"; } else if (this.Alignment == "Center") { this.ButtonLink.CssClass += " align-center"; } else { this.ButtonLink.CssClass += " align-left"; } }
private void BackToPositive(object sender, TappedRoutedEventArgs e) { PagesUtilities.GetAllCheckBoxesTags(EditNegativeEffectsGrid, out List <int> intList); GlobalContext.RegisterContext.IntNegativePreferences = intList; Frame.Navigate(typeof(EditPositivePage)); }
private void AutoSuggestBox_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { if (isStrainListFull == false) { return; } if (StrainChosen != null) { if (StrainChosen.ToLower().Equals(StrainList.Text.ToLower())) { if (e.Key == Windows.System.VirtualKey.Enter) { StrainList.IsSuggestionListOpen = false; PagesUtilities.SleepSeconds(0.2); SubmitString(null, null); } } else { UsageContext.ChosenStrain = null; } } }
public ActiveSession() { InitializeComponent(); PagesUtilities.AddBackButtonHandler((object sender, Windows.UI.Core.BackRequestedEventArgs e) => { EndSessionAsync(null, null); }); }
public EditNegativePage() { this.InitializeComponent(); PagesUtilities.AddBackButtonHandler((object sender, Windows.UI.Core.BackRequestedEventArgs e) => { BackToPositive(null, null); }); }
public UsageDisplay() { InitializeComponent(); PagesUtilities.AddBackButtonHandler((object sender, Windows.UI.Core.BackRequestedEventArgs e) => { GoBack(null, null); }); }
private async void SearchStrain(object sender, RoutedEventArgs e) { // Get checked effects PagesUtilities.GetAllCheckBoxesTags(MedicalSearchGrid, out List <int> MedicalList); PagesUtilities.GetAllCheckBoxesTags(PositiveSearchGrid, out List <int> PositiveList); // Produce bitmap of effects int MedicalBitMap = StrainToInt.FromIntListToBitmap(MedicalList); int PositiveBitMap = StrainToInt.FromIntListToBitmap(PositiveList); var url = ""; if ((MedicalList.Count == 0) && (PositiveList.Count == 0) && ((StrainName.Text == "") || (StrainName.Text == "e.g. 'Alaska'"))) { // Nothing chosen Status.Text = "Invaild Search! Please enter search parameter"; } else { Status.Text = ""; if ((StrainName.Text != "") && (StrainName.Text != "e.g. 'Alaska'")) { // Search by strain name url = Constants.MakeUrl("strain/name/" + StrainName.Text); GlobalContext.searchType = 1; } else { // Search by effect url = Constants.MakeUrl($"strain/effects?medical={MedicalBitMap}&positive={PositiveBitMap}"); GlobalContext.searchType = 2; } try { // Build request for information var res = HttpManager.Manager.Get(url); if (res == null) { return; } var str = await res.Result.Content.ReadAsStringAsync(); AppDebug.Line(str); if (GlobalContext.searchType == 1) { Frame.Navigate(typeof(StrainSearchResults), str); // Search by name } else if (GlobalContext.searchType == 2) { // Search by effect GlobalContext.searchResult = str; Frame.Navigate(typeof(EffectsSearchResults)); } } catch (Exception ex) { AppDebug.Exception(ex, "SearchStrain"); await new MessageDialog("Failed get: \n" + url, "Exception in Search Strain").ShowAsync(); } } }
public StrainSearchResults() { this.InitializeComponent(); this.FixPageSize(); PagesUtilities.AddBackButtonHandler((object sender, Windows.UI.Core.BackRequestedEventArgs e) => { BackToSearchPage(null, null); }); }
private void PopulateWhoWeAreLinksRepeater() { if (this.WhoWeArePageIds != null && this.WhoWeArePageIds.Length > 0) { var pages = PagesUtilities.GetPageNodesByIds(this.WhoWeArePageIds).OrderBy(p => p.Title); this.whoWeArePagesList.DataSource = pages; this.whoWeArePagesList.DataBind(); } }
private void ProductsList_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e) { if (e.Item is RadListViewDataItem) { HtmlControl heading3 = e.Item.FindControl("ProductTitle") as HtmlControl; DynamicContent productItem = ((RadListViewDataItem)e.Item).DataItem as DynamicContent; string productTitle = String.Empty; if (productItem != null) { productTitle = productItem.GetString("Title"); } if (heading3 != null) { if (productTitle.StartsWith("EU")) { HtmlGenericControl span = new HtmlGenericControl("span"); span.Attributes.Add("class", productNameSpanClass); string firstPart = productTitle.Substring(0, 2); string secondPart = productTitle.Substring(2); Literal literalEU = new Literal(); literalEU.Text = firstPart; heading3.Controls.Add(literalEU); span.InnerText = secondPart; heading3.Controls.Add(span); } else { Literal productTitleLtl = new Literal(); productTitleLtl.Text = productTitle; heading3.Controls.Add(productTitleLtl); } } //Add NavigateUrl to Policy Coverage link HyperLink policyCoverageLink = e.Item.FindControl("PolicyCoverageLink") as HyperLink; PageNode policyCoveragePageNode = productItem.GetValue("PolicyCoverageLandingPage") as PageNode; if (policyCoverageLink != null && policyCoveragePageNode != null) { policyCoverageLink.NavigateUrl = PagesUtilities.GetPageUrlByPageNode(policyCoveragePageNode); } //Add NavigateUrl to Read More link HyperLink readMoreLink = e.Item.FindControl("ReadMoreLink") as HyperLink; PageNode readMorePageNode = productItem.GetValue("ReadMoreLandingPage") as PageNode; if (readMoreLink != null && readMorePageNode != null) { readMoreLink.NavigateUrl = PagesUtilities.GetPageUrlByPageNode(readMorePageNode); } } }
private void PopulateNavigation() { IQueryable <PageNode> topLevelPages = PagesUtilities.GetTopLevelPages(true); if (topLevelPages != null) { this.menuItemsList.ItemDataBound += MenuItemsList_ItemDataBound; this.menuItemsList.DataSource = topLevelPages; this.menuItemsList.DataBind(); } }
private async void SubmitFeedback(object sender, TappedRoutedEventArgs e) // Send feedback to server { HttpResponseMessage res = null; UsageUpdateRequest req; double[] ranks = new double[4]; ranks = GetRanks(questionDictionary); try { // Build request for server progressRing.IsActive = true; GlobalContext.CurrentUser.UsageSessions.LastOrDefault().usageFeedback = questionDictionary; UsageData use = GlobalContext.CurrentUser.UsageSessions.LastOrDefault(); string userId = GlobalContext.CurrentUser.Data.UserID; req = new UsageUpdateRequest(use.UsageStrain.Name, use.UsageStrain.ID, userId, ((DateTimeOffset)use.StartTime).ToUnixTimeMilliseconds(), ((DateTimeOffset)use.EndTime).ToUnixTimeMilliseconds(), ranks[0], ranks[1], ranks[2], use.HeartRateMax, use.HeartRateMin, (int)use.HeartRateAverage, ranks[3], questionDictionary); res = await HttpManager.Manager.Post(Constants.MakeUrl("usage"), req); // Send request if (res != null) { // Request sent successfully if (res.IsSuccessStatusCode) { Status.Text = "Usage update Successful!"; var index = GlobalContext.CurrentUser.UsageSessions.Count - 1; GlobalContext.CurrentUser.UsageSessions[index].UsageId = res.GetContent()["body"]; PagesUtilities.SleepSeconds(0.5); Frame.Navigate(typeof(DashboardPage)); } else { Status.Text = "Usage update failed! Status = " + res.StatusCode; } } else { Status.Text = "Usage update failed!\nPost operation failed"; } Frame.Navigate(typeof(DashboardPage)); } catch (Exception x) { AppDebug.Exception(x, "UsageUpdate"); } }
private void JobOpeningsList_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e) { if (e.Item is RadListViewDataItem) { HyperLink applyNowLink = e.Item.FindControl("ApplyNowLink") as HyperLink; if (applyNowLink != null) { applyNowLink.NavigateUrl = PagesUtilities.GetPageUrlById(this.ApplyNowLandingPage); } } }
private void SetButtonUrl(HyperLink hyperLink, Guid buttonLandingPage, string buttonExternalLink) { if (buttonLandingPage != null && buttonLandingPage != Guid.Empty) { var pageNodeUrl = PagesUtilities.GetPageUrlById(buttonLandingPage); hyperLink.NavigateUrl = pageNodeUrl; } else if (!string.IsNullOrEmpty(buttonExternalLink)) { hyperLink.NavigateUrl = buttonExternalLink; } }
private void PopilateProductsList() { PageNode productsPage = PagesUtilities.GetPageNodeByTitle("products"); var childNodes = productsPage.Nodes; if (productsPage != null && childNodes.Count > 0) { this.productsList.ItemDataBound += ProductsList_ItemDataBound; this.productsList.DataSource = childNodes; this.productsList.DataBind(); } }
public void OnPageLoaded(object sender, RoutedEventArgs e) { PagesUtilities.DontFocusOnAnythingOnLoaded(sender, e); GetSuggestedRadio.IsChecked = true; StrainList.AddHandler(KeyDownEvent, new KeyEventHandler(AutoSuggestBox_KeyDown), true); if (UsageContext.ChosenStrain != null) //went back to this page { StrainChosen = StrainList.Text = UsageContext.ChosenStrain.Name; } }
public void OnPageLoaded(object sender, RoutedEventArgs e) { PagesUtilities.DontFocusOnAnythingOnLoaded(sender, e); try { EnumDescriptions positive = new EnumDescriptions("Would you use this strain again?", "Rate the quality of the treatment:"); PostQuestions.Items.Add(positive); questionDictionary[positive.q1] = "Don't know"; } catch (Exception x) { AppDebug.Exception(x, "PostTreatment2 => OnPageLoaded"); } }
private async void SendEmailAsync(object sender, RoutedEventArgs e) { HttpResponseMessage res = null; SendEmailRequest req; if (EmailAddressBox.Text.IsValidEmail()) // Check email validity { try { progressRing.IsActive = true; // Send email request req = new SendEmailRequest(EmailAddressBox.Text, FreeMessageBox.Text); // Export usages res = await HttpManager.Manager.Post(Constants.MakeUrl($"usage/export/{GlobalContext.CurrentUser.Data.UserID}"), req); progressRing.IsActive = false; if (res != null) { if (res.IsSuccessStatusCode) { // Email sent successfully await new MessageDialog($"An email was sent to {EmailAddressBox.Text} successfully", "Success").ShowAsync(); } else { await new MessageDialog($"There was an error while sending the mail (status: {res.StatusCode}, message: \"{res.GetContent()["message"]}\"", "Error").ShowAsync(); } } else { await new MessageDialog($"There was an error with the server, response is empty.", "Error").ShowAsync(); } PagesUtilities.SleepSeconds(1); Frame.Navigate(typeof(DashboardPage)); } catch (Exception x) { AppDebug.Exception(x, "UsageUpdate"); } } else { // Email address not valid await new MessageDialog("Invalid email address. Please try again").ShowAsync(); } }
public void OnPageLoaded(object sender, RoutedEventArgs e) { PagesUtilities.DontFocusOnAnythingOnLoaded(sender, e); try { // Load questions for user needs foreach (var medicalNeed in GlobalContext.CurrentUser.Data.MedicalNeeds) { var info = medicalNeed.GetAttribute <EnumDescriptions>(); PostQuestions.Items.Add(info); // Add to display questionDictionary[info.q1] = "Don't know"; } } catch (Exception x) { AppDebug.Exception(x, "PostTreatment => OnPageLoaded"); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var req = GlobalContext.CurrentUser.Data.NegativePreferences; if (req != null) { try { PagesUtilities.SetAllCheckBoxesTags(EditNegativeEffectsGrid, NegativePreferencesEnumMethods.FromEnumToIntList(req)); } catch (Exception exc) { AppDebug.Exception(exc, "EditPositiveEffectsPage.OnNavigatedTo"); } } }
private async void EditRegister(object sender, RoutedEventArgs e) { HttpResponseMessage res = null; var user_id = GlobalContext.CurrentUser.Data.UserID; try { progressRing.IsActive = true; PagesUtilities.GetAllCheckBoxesTags(EditNegativeEffectsGrid, out List <int> intList); GlobalContext.RegisterContext.IntNegativePreferences = intList; res = await HttpManager.Manager.Post(Constants.MakeUrl($"edit/{user_id}"), GlobalContext.RegisterContext); if (res != null) { if (res.IsSuccessStatusCode) { Status.Text = "Edit profile Successful!"; PagesUtilities.SleepSeconds(0.5); Frame.Navigate(typeof(DashboardPage), res); } else { Status.Text = "Register failed! Status = " + res.StatusCode; } } else { Status.Text = "Register failed!\nPost operation failed"; } } catch (Exception exc) { AppDebug.Exception(exc, "Register"); } finally { progressRing.IsActive = false; } }
private async void StartSession(object sender, RoutedEventArgs e) { StartAction(); bool useBand = UseBand.IsChecked.Value && isPaired && GlobalContext.Band.IsConnected(); // Enter usage details UsageContext.Usage = new UsageData(UsageContext.ChosenStrain, DateTime.Now, useBand); if (!useBand) { Frame.Navigate(typeof(ActiveSession)); } else // Use band, start acquiring heart rate { Acquiring.Visibility = Visibility.Visible; bool res = false; try { // Get heart rate res = await Task.Run(() => GlobalContext.Band.StartHeartRate(UsageContext.Usage.HeartRateChangedAsync)); } catch (Exception x) { AppDebug.Exception(x, "StartSession => StartHeartRate"); } Acquiring.Visibility = Visibility.Collapsed; EndAction(); if (res) { // Continue to active session with correct parameters ContinueButton.Content = "Success!"; PagesUtilities.SleepSeconds(1); Frame.Navigate(typeof(ActiveSession)); } else { await new MessageDialog("Try reconnecting the band, re-pairing and wear the band", "Failed!").ShowAsync(); return; } } }
private async void EndSessionAsync(object sender, RoutedEventArgs e) { try { var yesCommand = new UICommand("End Session", cmd => { AppDebug.Line("ending session..."); progressRing.IsActive = true; try { if (UsageContext.Usage.UseBandData) { // Stop band usage GlobalContext.Band.StopHeartRate(); PagesUtilities.SleepSeconds(0.5); } UsageContext.Usage.EndUsage(); } catch (Exception x) { AppDebug.Exception(x, "EndSession"); } progressRing.IsActive = false; Frame.Navigate(typeof(PostTreatment)); }); var noCommand = new UICommand("Continue Session", cmd => { AppDebug.Line("Cancel end session"); }); var dialog = new MessageDialog("Are you sure you want to end the session", "End Session") { Options = MessageDialogOptions.None }; dialog.Commands.Add(yesCommand); dialog.Commands.Add(noCommand); await dialog.ShowAsync(); } catch (Exception x) { AppDebug.Exception(x, "Remove_Click"); } }
private void GoToEditPositive(object sender, TappedRoutedEventArgs e) { if (GlobalContext.RegisterContext == null) { GlobalContext.RegisterContext = new RegisterRequest(); } GlobalContext.RegisterContext.Username = GlobalContext.CurrentUser.Data.Username; GlobalContext.RegisterContext.Password = "******"; GlobalContext.RegisterContext.DOB = GlobalContext.CurrentUser.Data.DOB; GlobalContext.RegisterContext.Gender = GlobalContext.CurrentUser.Data.Gender; GlobalContext.RegisterContext.Country = GlobalContext.CurrentUser.Data.Country; GlobalContext.RegisterContext.City = GlobalContext.CurrentUser.Data.City; PagesUtilities.GetAllCheckBoxesTags(EditMedicalGrid, out List <int> intList); GlobalContext.RegisterContext.IntListMedicalNeeds = intList; Frame.Navigate(typeof(EditPositivePage), GlobalContext.RegisterContext); }
private void AddButton(Control parent, string btnText, Guid landingPageId, string btnExternalLink) { HyperLink btnLink = new HyperLink(); btnLink.CssClass = "b"; Literal btnTextLtl = new Literal(); btnTextLtl.Text = btnText; btnLink.Controls.Add(btnTextLtl); if (landingPageId != null && landingPageId != Guid.Empty) { var pageNodeUrl = PagesUtilities.GetPageUrlById(landingPageId); btnLink.NavigateUrl = pageNodeUrl; } else if (!string.IsNullOrEmpty(btnExternalLink)) { btnLink.NavigateUrl = btnExternalLink; } parent.Controls.Add(btnLink); }
/// <summary> /// Method for adding custom button. /// </summary> /// <param name="btnText">The button text.</param> /// <param name="btnLandingPage">The button landing page.</param> /// <param name="btnBackground">The button background color.</param> private HyperLink AddButton(string btnText, Guid btnLandingPage, string externalLink, string btnBackground) { HyperLink button = new HyperLink(); if (!string.IsNullOrEmpty(btnText)) { button.Text = btnText; } if (btnLandingPage != null && btnLandingPage != Guid.Empty) { var pageNodeUrl = PagesUtilities.GetPageUrlById(btnLandingPage); button.NavigateUrl = pageNodeUrl; } else if (!string.IsNullOrEmpty(externalLink)) { button.NavigateUrl = externalLink; } if (!string.IsNullOrEmpty(btnBackground)) { if (btnBackground == "White") { button.CssClass = whiteBtnCssClass; } else if (btnBackground == "Blue") { button.CssClass = blueBtnCssClass; } else { button.CssClass = ""; } } return(button); }
public PostTreatment() { this.InitializeComponent(); this.FixPageSize(); PagesUtilities.AddBackButtonHandler((object sender, BackRequestedEventArgs e) => { }); }
public void OnPageLoaded(object sender, RoutedEventArgs e) { PagesUtilities.DontFocusOnAnythingOnLoaded(sender, e); }
public EffectsSearchResults() { this.InitializeComponent(); this.FixPageSize(); PagesUtilities.AddBackButtonHandler(); }