Example #1
0
        public override async void PerformAction()
        {
            ReminderActionTypes desiredAction = this.GetActionFromCommand();

            switch (desiredAction)
            {
            case ReminderActionTypes.CREATE:
                var reminder = await this.NewReminderAsync();

                // if the reminder is null, don't do anything
                if (reminder != null)
                {
                    this.ClearArea();
                    if (this.DynamicArea != null)
                    {
                        RelativePanel panel = this.CreateReminderCard(reminder);
                        this.DynamicArea.Children.Add(panel);
                        RelativePanel.SetAlignHorizontalCenterWithPanel(panel, true);
                        RelativePanel.SetAlignVerticalCenterWithPanel(panel, true);
                    }
                }
                break;

            case ReminderActionTypes.EDIT:
                this.EditReminder();
                break;

            case ReminderActionTypes.DELETE:
                this.DeleteReminder();
                break;
            }
        }
Example #2
0
 private void SetUpUI()
 {
     this.StartRecordingButton  = VoiceMemoUIHelper.BuildStartRecordingButton(this.StartRecording);
     this.StopRecordingButton   = VoiceMemoUIHelper.BuildStopRecordingButton(this.StopRecording);
     this.SaveRecordingButton   = VoiceMemoUIHelper.BuildSaveRecordingButton(this.SaveRecording);
     this.DeleteRecordingButton = VoiceMemoUIHelper.BuildDeleteRecordingButton(this.DeleteRecording);
     this.RecordingNameBox      = VoiceMemoUIHelper.BuildDisplayNameTextBox();
     // relatively place all the components
     RelativePanel.SetAlignVerticalCenterWithPanel(StartRecordingButton, true);
     RelativePanel.SetAlignHorizontalCenterWithPanel(StartRecordingButton, true);
     RelativePanel.SetAlignVerticalCenterWithPanel(StopRecordingButton, true);
     RelativePanel.SetAlignHorizontalCenterWithPanel(StopRecordingButton, true);
     RelativePanel.SetAlignVerticalCenterWithPanel(SaveRecordingButton, true);
     RelativePanel.SetAlignHorizontalCenterWithPanel(SaveRecordingButton, true);
     RelativePanel.SetAlignVerticalCenterWithPanel(DeleteRecordingButton, true);
     RelativePanel.SetAlignHorizontalCenterWithPanel(DeleteRecordingButton, true);
     // place the save and delete buttons next to each other
     RelativePanel.SetLeftOf(DeleteRecordingButton, SaveRecordingButton);
     // place the text box below the save button
     RelativePanel.SetBelow(RecordingNameBox, SaveRecordingButton);
     RelativePanel.SetAlignLeftWith(RecordingNameBox, SaveRecordingButton);
     RelativePanel.SetAlignRightWith(RecordingNameBox, SaveRecordingButton);
     // hide all our buttons except the start recording one
     this.ResetUIComponents();
     // now add everything to the dynamic area
     this.DynamicArea.Children.Add(StartRecordingButton);
     this.DynamicArea.Children.Add(StopRecordingButton);
     this.DynamicArea.Children.Add(SaveRecordingButton);
     this.DynamicArea.Children.Add(DeleteRecordingButton);
     this.DynamicArea.Children.Add(RecordingNameBox);
 }
Example #3
0
        public override async void PerformAction()
        {
            AlarmActionTypes desiredAction = this.GetActionFromCommand();

            switch (desiredAction)
            {
            case AlarmActionTypes.CREATE:
                var alarm = await this.NewAlarm();

                this.ClearArea();
                if (this.DynamicArea != null)
                {
                    RelativePanel panel = CreateAlarmCard(alarm);
                    this.DynamicArea.Children.Add(panel);
                    RelativePanel.SetAlignHorizontalCenterWithPanel(panel, true);
                    RelativePanel.SetAlignVerticalCenterWithPanel(panel, true);
                }
                break;

            case AlarmActionTypes.EDIT:
                this.EditAlarm();
                break;

            case AlarmActionTypes.DELETE:
                this.DeleteAlarm();
                break;
            }
        }
Example #4
0
 /// <summary>
 /// Shows a loading ring on our <see cref="DynamicArea"/>, clearing the area before displaying the ring
 /// </summary>
 protected void ShowLoading()
 {
     if (this.DynamicArea != null)
     {
         this.DynamicArea.Children.Clear();
         // show a spinning progress ring in the middle of the area
         ProgressRing theRing = new ProgressRing();
         theRing.Width  = 100;
         theRing.Height = theRing.Width;
         RelativePanel.SetAlignHorizontalCenterWithPanel(theRing, true);
         RelativePanel.SetAlignVerticalCenterWithPanel(theRing, true);
         this.DynamicArea.Children.Add(theRing);
         theRing.IsActive = true;
     }
 }
Example #5
0
        public static void ShowMessageOnRelativePanel(RelativePanel panel, string messageToShow)
        {
            panel.Children.Clear();
            TextBlock textBlock = new TextBlock
            {
                FontSize     = 48,
                Text         = messageToShow,
                TextWrapping = TextWrapping.Wrap
            };
            ScrollViewer scrollPanel = new ScrollViewer();

            panel.Children.Add(scrollPanel);
            RelativePanel.SetAlignVerticalCenterWithPanel(scrollPanel, true);
            RelativePanel.SetAlignHorizontalCenterWithPanel(scrollPanel, true);
            scrollPanel.Content = textBlock;
        }
Example #6
0
        private async void ProvideDirectionsSuccessMessage(string destination)
        {
            // show a link to the search
            this.ClearArea();
            var linkElement = new HyperlinkButton();

            linkElement.Content = $"Directions to {destination.ToLower()}";
            string directionsLink = await GetDirectionsLink(destination);

            if (directionsLink != null)
            {
                linkElement.NavigateUri = new Uri(directionsLink);
                linkElement.FontSize    = 24;
                RelativePanel.SetAlignHorizontalCenterWithPanel(linkElement, true);
                RelativePanel.SetAlignVerticalCenterWithPanel(linkElement, true);
                this.DynamicArea.Children.Add(linkElement);
                TextToSpeechEngine.SpeakText(this.MediaElement, $"Alright, getting {linkElement.Content.ToString().ToLower()}");
            }
        }
Example #7
0
        public override void PerformAction()
        {
            //get list of searchable websites from database
            List <SearchableWebsite> allSearchableWebsites = StoredProcedures.QueryAllSearchableWebsites();
            //need to check if user provided a website to search
            bool isUserProvidedWebsiteSearch = false;

            //go through list of searchable websites. return true if user included the searchable website in search
            //this will also set the website if there is a match
            isUserProvidedWebsiteSearch = GetActionFromCommand(allSearchableWebsites);
            string searchParameters;
            string searchQuery;

            if (isUserProvidedWebsiteSearch)
            {
                //find what is wanted to be searched and concatenate with + for end of url
                searchParameters = GetSearchParameters(isUserProvidedWebsiteSearch);
                searchQuery      = BuildSearchQuery(desiredSearchableWebsite, searchParameters);
                //launch browser. this will be done with the default browser
                LaunchSearch(searchQuery);
            }
            else
            {
                //sets desiredSearchEngine, which is the default selected in settings
                GetDefaultSearchEngine();
                searchParameters = GetSearchParameters(isUserProvidedWebsiteSearch);
                searchQuery      = BuildSearchQuery(desiredSearchEngine, searchParameters);
                //launch browser. this will be done with the default browser
                LaunchSearch(searchQuery);
            }
            // show a link to the search
            this.ClearArea();
            var linkElement = new HyperlinkButton();

            linkElement.Content     = $"{searchParameters} on {(desiredSearchableWebsite != null ? desiredSearchableWebsite.Name : desiredSearchEngine?.Name)}";
            linkElement.NavigateUri = new Uri(searchQuery);
            linkElement.FontSize    = 24;
            RelativePanel.SetAlignHorizontalCenterWithPanel(linkElement, true);
            RelativePanel.SetAlignVerticalCenterWithPanel(linkElement, true);
            this.DynamicArea.Children.Add(linkElement);
            // announce to the user that we're searching for something
            TextToSpeechEngine.SpeakText(this.MediaElement, $"Sure, searching for {linkElement.Content}");
        }
Example #8
0
 private void SaveRecording()
 {
     // make sure to run this in the main thread so that we can access our recording name box
     Utils.RunOnMainThread(async() =>
     {
         if (StringUtils.IsNotBlank(this.RecordingNameBox.Text))
         {
             try
             {
                 string DisplayName    = RecordingNameBox.Text;
                 string FileName       = await this.AudioRecorder.SaveAudioToFile();
                 string FullFilePath   = $"{Windows.ApplicationModel.Package.Current.InstalledLocation.Path}\\VoiceNotes";
                 int RecordingDuration = await this.AudioRecorder.GetAudioDuration(FileName);
                 DateTime DateRecorded = this.AudioRecorder.GetDateRecorded();
                 DateTime timeRecorded = this.AudioRecorder.GetTimeRecorded();
                 // insert the voice memo into the database
                 StoredProcedures.CreateVoiceNote(FileName, DisplayName, RecordingDuration, FullFilePath, DateRecorded, DateRecorded);
                 // clear our dynamic area and show the ui for the newly-recorded voice memo
                 this.ClearArea();
                 RelativePanel voiceMemoPanel = VoiceMemoUIHelper.BuildVoiceMemoPanel(StoredProcedures.QueryLatestVoiceMemo(), this.AudioRecorder, () => Utils.RunOnMainThread(() => this.ClearArea()));
                 // position the panel in the center of the panel
                 RelativePanel.SetAlignHorizontalCenterWithPanel(voiceMemoPanel, true);
                 RelativePanel.SetAlignVerticalCenterWithPanel(voiceMemoPanel, true);
                 this.DynamicArea.Children.Add(voiceMemoPanel);
             }
             catch (Exception)
             {
                 // TODO display an error message
             }
         }
         else
         {
             UIUtils.HighlightUIElement(this.RecordingNameBox);
         }
     });
 }