Esempio n. 1
0
 private void NomCategorie(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     categorieSelectionne.Nom        = args.Text;
     enseignantSelectionne.Categorie = categorieSelectionne;
     categorie.update(categorieSelectionne.Id, categorieSelectionne);
     enseignant.update(enseignantSelectionne.Id, enseignantSelectionne);
 }
Esempio n. 2
0
 private void ProfileSelector_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     if (!string.IsNullOrWhiteSpace(args.Text) && TerminalList.All((Profile) => Profile.Name != args.Text))
     {
         TerminalList.Add(new TerminalProfile(args.Text, string.Empty, string.Empty, default));
     }
 }
Esempio n. 3
0
        private void EncodingCombo_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
        {
            try
            {
                if (Encodings.FirstOrDefault((Enco) => Enco.EncodingName == args.Text) is Encoding ExistCoding)
                {
                    if (UserSelectedEncoding.CodePage != ExistCoding.CodePage)
                    {
                        UserSelectedEncoding = ExistCoding;
                    }
                }
                else
                {
                    if (int.TryParse(args.Text, out int CodePage))
                    {
                        UserSelectedEncoding = Encoding.GetEncoding(CodePage);
                    }
                    else
                    {
                        UserSelectedEncoding = Encoding.GetEncoding(args.Text);
                    }
                }

                args.Handled = false;
            }
            catch
            {
                args.Handled      = true;
                InvalidTip.IsOpen = true;
            }
        }
        private void EncodingOption_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
        {
            try
            {
                if (AvailableEncoding.FirstOrDefault((Enco) => Enco.EncodingName == args.Text) is Encoding ExistCoding)
                {
                    CurrentEncoding = ExistCoding;
                }
                else
                {
                    if (int.TryParse(args.Text, out int CodePage))
                    {
                        CurrentEncoding = Encoding.GetEncoding(CodePage);
                    }
                    else
                    {
                        CurrentEncoding = Encoding.GetEncoding(args.Text);
                    }
                }

                args.Handled = false;
            }
            catch
            {
                CurrentEncoding   = null;
                InvalidTip.IsOpen = true;
                args.Handled      = true;
            }
        }
Esempio n. 5
0
        private void Combo3_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
        {
            bool isDouble = double.TryParse(sender.Text, out double newValue);

            // Set the selected item if:
            // - The value successfully parsed to double AND
            // - The value is in the list of sizes OR is a custom value between 8 and 100
            if (isDouble && (FontSizes.Contains(newValue) || (newValue < 100 && newValue > 8)))
            {
                // Update the SelectedItem to the new value.
                sender.SelectedItem = newValue;
            }
            else
            {
                // If the item is invalid, reject it and revert the text.
                sender.Text = sender.SelectedValue.ToString();

                var dialog = new ContentDialog();
                dialog.Content         = "The font size must be a number between 8 and 100.";
                dialog.CloseButtonText = "Close";
                dialog.DefaultButton   = ContentDialogButton.Close;
                var task = dialog.ShowAsync();
            }

            // Mark the event as handled so the framework doesn’t update the selected item automatically.
            args.Handled = true;
        }
 private async void ComboBoxResolution_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     await RunOnUIThreadAndWaitAsync(CoreDispatcherPriority.High, () =>
     {
         if (int.TryParse(args.Text, out int intValue))
         {
             // entered pure number, try to apply it
             ScanResolution resolution = ViewModel.ScannerResolutions.FirstOrDefault((x) => x.Resolution.DpiX == intValue);
             if (resolution != null)
             {
                 // found corresponding resolution
                 ViewModel.SelectedResolution = resolution;
             }
             else
             {
                 // no resolution for number, find the closest available one
                 resolution = ViewModel.ScannerResolutions.Aggregate((x, y) => Math.Abs(x.Resolution.DpiX - intValue) < Math.Abs(y.Resolution.DpiX - intValue) ? x : y);
                 ViewModel.SelectedResolution = resolution;
             }
         }
         else
         {
             sender.SelectedItem = ViewModel.SelectedResolution;
             args.Handled        = true;
         }
     });
 }
        private void EncodingProfile_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
        {
            try
            {
                if (Encoding.GetEncodings().FirstOrDefault((Enco) => Enco.DisplayName == args.Text) is EncodingInfo ExistEnco)
                {
                    if (CurrentEncoding != ExistEnco.GetEncoding())
                    {
                        CurrentEncoding = ExistEnco.GetEncoding();
                        _ = LoadTextWithEncoding(CurrentEncoding);
                    }
                }
                else
                {
                    if (int.TryParse(args.Text, out int CodePage))
                    {
                        CurrentEncoding = Encoding.GetEncoding(CodePage);
                        _ = LoadTextWithEncoding(CurrentEncoding);
                    }
                    else
                    {
                        CurrentEncoding = Encoding.GetEncoding(args.Text);
                        _ = LoadTextWithEncoding(CurrentEncoding);
                    }
                }

                args.Handled = false;
            }
            catch
            {
                args.Handled      = true;
                InvalidTip.IsOpen = true;
            }
        }
Esempio n. 8
0
 private void ParamCB_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     if (!(filterParam is PersonData) || args.Text != (filterParam as PersonData).Name)
     {
         sender.ItemsSource    = MoviesController.GetInstance().GetPersons(args.Text);
         sender.IsDropDownOpen = true;
     }
 }
Esempio n. 9
0
 private static void RepeatsComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     if (args.Text == "∞")
     {
         return;
     }
     if (!int.TryParse(args.Text, out int value) || value <= 0)
     {
         RepeatsComboBox.Text = "1";
     }
 }
Esempio n. 10
0
 private void Extension_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     if (sender.Items.All((Item) => Item.ToString() != args.Text))
     {
         if (args.Text.Length <= 1 || !args.Text.StartsWith(".") || args.Text.LastIndexOf(".") != 0)
         {
             InvalidInputTip.IsOpen = true;
             args.Handled           = true;
         }
     }
 }
Esempio n. 11
0
 private void TagSelector_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     if (!string.IsNullOrEmpty(args.Text))
     {
         AvailableTags.Add(args.Text);
         CurrentTag = args.Text;
     }
     else
     {
         args.Handled = true;
     }
 }
        private void CanvasComboBoxFontSizeTextBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
        {
            if (float.TryParse(args.Text, out var size))
            {
                SetFontSize(size);

                if (SelectedTextDrawable != null)
                {
                    _drawingSurfaceRenderer.ExecuteUpdateTextBoxFontSize(size);
                    ReDrawCanvas();
                }
            }
        }
Esempio n. 13
0
 private void ComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     try
     {
         var size = int.Parse(sender.Text);
         if (!sender.Items.Contains(size))
         {
             sender.Items[0] = sender.Text;
         }
         Storage.DanmuSize = size;
     }
     catch (Exception) { }
 }
Esempio n. 14
0
    private void MyComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
    {
        var items = ItemsSource as ObservableCollection <UserRole>;

        if (items.Count > 0)
        {
            if (items.Any <UserRole>(s => s.name == args.Text))
            {
                return;
            }
            else
            {
                var newItem = new UserRole()
                {
                    id = (items.Count + 1).ToString(), name = args.Text
                };
                items.Add(newItem);
            }
        }
    }
        private void TimePickerComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
        {
            // https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/combo-box#text-submitted
            // This is only invoked for unknown (unmatched) values

            // However there seems to be a bug where it submits even if user selects from list, after they then leave the text control
            if (_timeEntries.Any(i => i.DisplayText == args.Text))
            {
                // Don't do anything, framework should correctly update (keep) the selected item
                return;
            }

            if (ParseText(args.Text, out TimeSpan time))
            {
                var matching = _timeEntries.FirstOrDefault(i => i.Time == time);
                if (matching != null)
                {
                    // Select the item
                    args.Handled = true;
                    TimePickerComboBox.SelectedItem = matching;
                }
                else
                {
                    // Add the item and select it
                    args.Handled = true;
                    TimePickerComboBox.SelectedItem = AddTime(time);
                }
            }

            else
            {
                // Mark the event as handled so the framework doesn't update the selected item.
                args.Handled = true;

                var correctString  = "EditingClassScheduleItemView_Invalid" + (this is TextBasedEndTimePicker ? "End" : "Start") + "Time";
                var correctTitle   = PowerPlannerResources.GetString(correctString + ".Title");
                var correctContent = PowerPlannerResources.GetString(correctString + ".Content");
                new PortableMessageDialog(correctContent, correctTitle).Show();
            }
        }
        private void Combo3_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
        {
            if (double.TryParse(sender.Text, out double newValue) && newValue < 100 && newValue > 8)
            {
                // Update the SelectedItem to the new value.
                sender.SelectedItem = newValue;
            }
            else
            {
                // If the item is invalid, reject it and revert the text.
                sender.Text = sender.SelectedValue.ToString();

                var dialog = new ContentDialog();
                dialog.Content         = "The font size must be a number between 8 and 100.";
                dialog.CloseButtonText = "Close";
                dialog.DefaultButton   = ContentDialogButton.Close;
                var task = dialog.ShowAsync();
            }

            // Mark the event as handled so the framework doesn’t update the selected item automatically.
            args.Handled = true;
        }
Esempio n. 17
0
        private async void FontSizeSelectingComboBoxTextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
        {
            double inputFontSize = 0;

            if (double.TryParse(this.FontSizeSelectingComboBox.Text, out inputFontSize))
            {
                //if input too small or too big
                if (inputFontSize < 5 || inputFontSize > 300)
                {
                    ContentDialog invalidDialog = new ContentDialog
                    {
                        Content         = "字号只能为 5 到 300 之间的数字",
                        CloseButtonText = "确定",
                    };
                    await invalidDialog.ShowAsync();

                    return;
                }

                mainPage.localSettings.Values["FontSize"] = inputFontSize;
                mainPage.ApplySettings(this, null);
                return;
            }

            //if input illegal
            else
            {
                ContentDialog invalidDialog = new ContentDialog
                {
                    Content         = "字号只能为 5 到 300 之间的数字",
                    CloseButtonText = "确定",
                };
                await invalidDialog.ShowAsync();

                return;
            }
        }
Esempio n. 18
0
 private void DayComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
 }
 void IComboBoxTextSubmittedEventArgsResolver.Handled(ComboBoxTextSubmittedEventArgs e, bool handled) => e.Handled = handled;
 bool IComboBoxTextSubmittedEventArgsResolver.Handled(ComboBoxTextSubmittedEventArgs e) => e.Handled;
 string IComboBoxTextSubmittedEventArgsResolver.Text(ComboBoxTextSubmittedEventArgs e) => e.Text;
 /// <summary>
 /// Sets whether the TextSubmitted event was handled or not.
 /// If <c>true</c>, the framework will not automatically update the selected item of the ComboBox to the new value.
 /// </summary>
 /// <param name="e">The requested <see cref="ComboBoxTextSubmittedEventArgs"/>.</param>
 /// <param name="handled"><c>true</c> to mark the event as handled; otherwise, <c>false</c>.</param>
 public static void Handled(this ComboBoxTextSubmittedEventArgs e, bool handled) => Resolver.Handled(e, handled);
 /// <summary>
 /// Gets whether the TextSubmitted event was handled or not.
 /// If <c>true</c>, the framework will not automatically update the selected item of the ComboBox to the new value.
 /// </summary>
 /// <param name="e">The requested <see cref="ComboBoxTextSubmittedEventArgs"/>.</param>
 /// <returns><c>true</c> to mark the event as handled; otherwise, <c>false</c>.</returns>
 public static bool Handled(this ComboBoxTextSubmittedEventArgs e) => Resolver.Handled(e);
 /// <summary>
 /// Gets the custom text value entered by the user.
 /// </summary>
 /// <param name="e">The requested <see cref="ComboBoxTextSubmittedEventArgs"/>.</param>
 /// <returns>The custom text value entered by the user.</returns>
 public static string Text(this ComboBoxTextSubmittedEventArgs e) => Resolver.Text(e);
Esempio n. 25
0
 private void TextSubmitted(Windows.UI.Xaml.Controls.ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
 }
Esempio n. 26
0
 private void ComboBoxTypeCours_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     infosAssignationSelect.TypeCours.Nom = args.Text;
     TypeCours.update(infosAssignationSelect.TypeCours.Id, infosAssignationSelect.TypeCours);
 }
Esempio n. 27
0
 private void ProfileNameComboBox_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     ValidateInput();
 }
Esempio n. 28
0
 private void NomTypeCours(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     equivalentTDSelectionne.TypeCours.Nom = args.Text;
     typeCours.update(equivalentTDSelectionne.TypeCours.Id, equivalentTDSelectionne.TypeCours);
 }
 private void ComboBoxFromLocation_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArgs args)
 {
     //subject.Text = _subjectText + args.Text;
     comboBoxFromLocationTextBox.Text = args.Text;
 }