Esempio n. 1
0
 /// <summary>
 /// Adds the stored list of historically spoken phrases to the GUI as Buttons
 /// </summary>
 private void AddPhrases()
 {
     this.Dispatcher.Invoke(() =>
     {
         foreach (Tuple <DateTime, string> pair in util.getSpokenPhrases())
         {
             var phraseButton = new Button
             {
                 Text   = pair.Item2,
                 Height = 140
             };
             phraseButton.Click += SelectText;
             _ = phraseStack.Children.Add(phraseButton);
         }
     });
 }
Esempio n. 2
0
        /// <summary>
        /// When one of the items in the scroll pane are selected, the selectedText instance/member variable will assume
        /// the value of the string contained in the TextBlock that is the child of the 'sender' Button.
        /// If the currently selected button is clicked again it clears the selectedText variable
        /// </summary>
        private void SelectText(object sender, RoutedEventArgs args)
        {
            var button = (Button)sender;

            if (button.IsSelected == false)
            {
                if (selectedButton != null)
                {
                    selectedButton.IsSelected = false;
                }
                button.IsSelected = true;
                selectedButton    = button;
                scan.NewListToScanThough <Button>(sidePanel);
                //scan.IgnoreSelectPressOnce=true;
            }
            else
            {
                button.IsSelected = false;
                selectedButton    = null;
            }
        }
Esempio n. 3
0
        private async Task Launcher_OnClickAsync(object sender, RoutedEventArgs e)
        {
            var apps = await RokuHttp.GetAllChannels();

            ScrollingSelectionWindow ssw = new ScrollingSelectionWindow();

            foreach (var app in apps.OrderBy(a => a.Name))
            {
                await ssw.Dispatcher.BeginInvoke(new Action(() =>
                {
                    Button btn = new Button()
                    {
                        Text = app.Name,
                        Tag = app.Id
                    };
                    ssw.addElement(btn);
                    //Autoscan2.Instance.GoBackPress += (s,_) => { ssw.Close(); };
                    btn.Click += (s, _) =>
                    {
                        ssw.result = (string)btn.Tag;
                        ssw.Close();
                    };
                }));

                Console.WriteLine("{0}.\t {1}", app.Id, app.Name);
            }
            string result = (string)ssw.prompt();

            if (result is null)
            {
                return;
            }
            Console.WriteLine("selected result");
            Console.WriteLine(result);
            _ = RokuHttp.LaunchChannel(result);
        }
Esempio n. 4
0
        /*
         * Generate n buttons that will be used as suggestions
         */
        private List <Button> getNSuggestions(int n)
        {
            List <Button> retVal = new List <Button>();
            List <KeyValuePair <string, int> > suggestions = parseTree.getSuggestions();

            int i = 0;

            while (i < n && i < suggestions.Count)
            {
                Button         b  = new Button();
                BrushConverter bc = new BrushConverter();
                b.Foreground = (Brush)bc.ConvertFrom("#FF00D5EA");
                TextBlock textBlock = new TextBlock
                {
                    Text = suggestions[i].Key
                };
                b.Text    = suggestions[i].Key;
                b.Content = textBlock;
                retVal.Add(b);
                i++;
            }

            return(retVal);
        }