Inheritance: Control, ITextBox
 /// <summary>
 /// Применить к текстовому полю.
 /// </summary>
 /// <param name="box">Текстовое поле.</param>
 public void ApplyToTextBox(TextBox box)
 {
     if (box != null)
     {
         box.Text = provider.SetMarkup(box.Text, tag, box.SelectionStart, box.SelectionLength);
     }
 }
 private void addImage_Tapped(object sender, TappedRoutedEventArgs e)
 {
     numIngredients++;
     TextBox newTxtBox = new TextBox();
     newTxtBox.Name = "Ingredient"+ numIngredients;
     newTxtBox.Margin = new Thickness(10, 0, 0, 0);
     if (!flagColumn)
     {
         newTxtBox.SetValue(Grid.RowProperty, addImage.GetValue(Grid.RowProperty));
         newTxtBox.SetValue(Grid.ColumnProperty, 0);
         IngredientsGrid.RowDefinitions.Add(new RowDefinition());
         addImage.SetValue(Grid.RowProperty, ((int)addImage.GetValue(Grid.RowProperty) + 1));
     }
     else
     {
         newTxtBox.SetValue(Grid.RowProperty, lastRow);
         newTxtBox.SetValue(Grid.ColumnProperty, 1);
         lastRow++;
     }
     IngredientsGrid.Children.Remove(addImage);
     IngredientsGrid.UpdateLayout();
     IngredientsGrid.Children.Add(newTxtBox);
     IngredientsGrid.UpdateLayout();
     IngredientsGrid.Children.Add(addImage);
     IngredientsGrid.UpdateLayout();
     IngredientsPanel.UpdateLayout();
     numberTxtBox++;
     if(numberTxtBox % 4 == 0)
     {
         flagColumn = !flagColumn;
     }
    // IngredientsPanel.Children.Add(addImage);
 }
示例#3
0
		public static void SetBindableText(TextBox element, string value)
		{
			if (element != null)
			{
				element.SetValue(BindableTextProperty, value);
			}
		}
示例#4
0
        public static bool GetAlwaysScrollToEnd(TextBox textBox)
        {
            if (textBox == null)
                throw new ArgumentNullException(nameof(textBox));

            return (bool)textBox.GetValue(AlwaysScrollToEndProperty);
        }
示例#5
0
        public static void SetAlwaysScrollToEnd(TextBox textBox, bool alwaysScrollToEnd)
        {
            if (textBox == null)
                throw new ArgumentNullException(nameof(textBox));

            textBox.SetValue(AlwaysScrollToEndProperty, alwaysScrollToEnd);
        }
        public static async Task Search(object sender, RoutedEventArgs e, GridView SearchResults, TextBox SearchTermText, TextBlock StatusResult, IPlatformParameters parent)
        {
            if (string.IsNullOrEmpty(SearchTermText.Text))
            {
                MessageDialog dialog = new MessageDialog("Please enter a valid search term.");
                await dialog.ShowAsync();
                return;
            }

            List<User> results = await DirectorySearcherLib.DirectorySearcher.SearchByAlias(SearchTermText.Text, parent);
            if (results.Count == 0)
            {
                StatusResult.Text = "User Not Found. Try Another Term.";
                StatusResult.Foreground = new SolidColorBrush(Windows.UI.Colors.White);
                results.Add(new User());
            }
            else if (results[0].error != null)
            {
                StatusResult.Text = "Error! " + results[0].error;
                StatusResult.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
            }
            else
            {
                StatusResult.Text = "Success";
                StatusResult.Foreground = new SolidColorBrush(Windows.UI.Colors.Green);
            }

            SearchResults.ItemsSource = results;
        }
示例#7
0
        public void CreateField(DetailFormHelper helper, FieldData fieldData)
        {
            var text = fieldData as TextFieldData;
            int row;
            var textBlock  = helper.AddRow(text, out row);

            var textBox = new TextBox
            {
                TextWrapping = TextWrapping.Wrap,
                Text = DetailFormHelper.GetValueAsString(helper.DataElement, text.name, fieldData.defaultValue),
                Margin = new Thickness(5),
            };

            var lineHeight = Math.Max(1, text.lineHeight);
            textBox.Height = 20 * lineHeight;
            if (lineHeight > 1)
            {
                textBlock.VerticalAlignment = VerticalAlignment.Top;
                textBox.AcceptsReturn = true;
            }

            Grid.SetColumn(textBox, 1);
            Grid.SetRow(textBox, row);

            helper.GridFields.Children.Add(textBox);

            helper.BindingActions.Add(
                () => helper.DataElement.set(text.name, textBox.Text));
        }
示例#8
0
 protected override void OnApplyTemplate()
 { 
     textBox = GetTemplateChild(PART_TEXT_NAME) as TextBox;
     button = GetTemplateChild(PART_BUTTON_NAME) as Button;
     InitEvents();
     
 }
        // returns a rect for selected text
        // if no text is selected, returns caret location
        // textbox should not be empty
        private Rect GetTextboxSelectionRect(TextBox textbox)
        {
            Rect rectFirst, rectLast;
            if (textbox.SelectionStart == textbox.Text.Length)
            {
                rectFirst = textbox.GetRectFromCharacterIndex(textbox.SelectionStart - 1, true);
            }
            else
            {
                rectFirst = textbox.GetRectFromCharacterIndex(textbox.SelectionStart, false);
            }

            int lastIndex = textbox.SelectionStart + textbox.SelectionLength;
            if (lastIndex == textbox.Text.Length)
            {
                rectLast = textbox.GetRectFromCharacterIndex(lastIndex - 1, true);
            }
            else
            {
                rectLast = textbox.GetRectFromCharacterIndex(lastIndex, false);
            }

            rectFirst.Union(rectLast);

            GeneralTransform transform = textbox.TransformToVisual(null);
            return transform.TransformBounds(rectFirst);
        }
        public void InitializeComponent()
        {
            if (_contentLoaded)
                return;

            _contentLoaded = true;
            Application.LoadComponent(this, new System.Uri("ms-appx:///CommentPage.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application);
 
            pageRoot = (TheBellyofAuthority.Common.LayoutAwarePage)this.FindName("pageRoot");
            commentBar = (Windows.UI.Xaml.Controls.AppBar)this.FindName("commentBar");
            DeleteButton = (Windows.UI.Xaml.Controls.Button)this.FindName("DeleteButton");
            EditButton = (Windows.UI.Xaml.Controls.Button)this.FindName("EditButton");
            commentThread = (Windows.UI.Xaml.Controls.ListView)this.FindName("commentThread");
            commentLabel = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("commentLabel");
            commentBox = (Windows.UI.Xaml.Controls.TextBox)this.FindName("commentBox");
            postButton = (Windows.UI.Xaml.Controls.Button)this.FindName("postButton");
            backButton = (Windows.UI.Xaml.Controls.Button)this.FindName("backButton");
            pageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageTitle");
            UserPanel = (Windows.UI.Xaml.Controls.StackPanel)this.FindName("UserPanel");
            progBar = (Windows.UI.Xaml.Controls.ProgressBar)this.FindName("progBar");
            LabelBox = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("LabelBox");
            UserBox = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("UserBox");
            ApplicationViewStates = (Windows.UI.Xaml.VisualStateGroup)this.FindName("ApplicationViewStates");
            FullScreenLandscape = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenLandscape");
            Filled = (Windows.UI.Xaml.VisualState)this.FindName("Filled");
            FullScreenPortrait = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait");
            Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped");
        }
示例#11
0
        private void TextBox_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
        {
            var textBox = sender as TextBox;
            NewToDoItemNameTextBox = textBox;

            if (!string.IsNullOrEmpty(textBox.Text)
                && textBox.Text.Length > 3)
            {
                if (AddNewItemConfirmButton != null)
                    AddNewItemConfirmButton.IsEnabled = true;

                if (e.Key == Windows.System.VirtualKey.Enter)
                {
                    // Handle 'Enter' key for keyboard users
                    if (e.Key == Windows.System.VirtualKey.Enter)
                    {
                        e.Handled = true;
                        CreateNewToDoItem(textBox);
                    }
                }
            }
            else
            {
                if (AddNewItemConfirmButton != null)
                    AddNewItemConfirmButton.IsEnabled = false;
            }
        }
        /// <summary>
        /// Sets up the player dialog labels and text boxes for names.
        /// </summary>
        public LocalGameDialog()
        {
            this.InitializeComponent();
            PlayerNames = new List<TextBox>();

            for (var i = 0; i < 6; i++)
            {

                var block = new TextBlock()
                {
                    Text = "Player " + (i + 1),
                    Foreground = ((PlayerNumber) (i + 1)).Color(),
                    VerticalAlignment = VerticalAlignment.Center

                };

                var box = new TextBox
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    Height = 32,
                    MaxLength = 8

                };

                PlayerGrid.Children.Add(block);
                Grid.SetColumn(block, 0);
                Grid.SetRow(block, i);

                PlayerGrid.Children.Add(box);
                Grid.SetColumn(box, 1);
                Grid.SetRow(box,i);

                PlayerNames.Add(box);
            }
        }
示例#13
0
文件: Common.cs 项目: mbin/Win81App
        static public bool HandleException(Exception exception, TextBox outputField, MainPage rootPage)
        {
            SyndicationErrorStatus status = SyndicationError.GetStatus(exception.HResult);
            if (status != SyndicationErrorStatus.Unknown)
            {
                outputField.Text += "The response content is not valid. " +
                    "Please make sure to use a URI that points to an Atom feed.\r\n";
            }
            else
            {
                WebErrorStatus webError = WebError.GetStatus(exception.HResult);

                if (webError == WebErrorStatus.Unauthorized)
                {
                    outputField.Text += "Incorrect username or password.\r\n";
                }
                else if (webError == WebErrorStatus.Unknown)
                {
                    // Neither a syndication nor a web error.
                    return false;
                }
            }

            rootPage.NotifyUser(exception.Message, NotifyType.ErrorMessage);

            return true;
        }
        public Contact CreateContactFromUserInput(TextBox EmailAddress, TextBox PhoneNumber)
        {
            if (EmailAddress.Text.Length == 0 && PhoneNumber.Text.Length == 0)
            {
                NotifyUser("You must enter an email address and/or phone number.", NotifyType.ErrorMessage);
                return null;
            }

            Contact contact = new Contact();

            // Maximum length for email address is 321, enforced by XAML markup.
            if (EmailAddress.Text.Length > 0)
            {
                ContactEmail email = new ContactEmail() { Address = EmailAddress.Text };
                contact.Emails.Add(email);
            }

            // Maximum length for phone number is 50, enforced by XAML markup.
            if (PhoneNumber.Text.Length > 0)
            {
                ContactPhone phone = new ContactPhone() { Number = PhoneNumber.Text };
                contact.Phones.Add(phone);
            }

            return contact;
        }
示例#15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppbarContent"/> class.
        /// </summary>
        public AppbarContent()
        {
            this.InitializeComponent();

            searchTextBlock = searchBox;
            this.advanceSearchButton = AdvanceSearchButton;
        }
        /// <summary>
        /// Called when [element changed].
        /// </summary>
        /// <param name="e">The e.</param>
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
            if(Element == null )
            {
                return;
            }
            var view = (ExtendedEntry)Element;

            //Because Xamarin EntryRenderer switches the type of control we need to find the right one
            if (view.IsPassword)
            {
                _thisPasswordBox = (PasswordBox) (Control.Content as Windows.UI.Xaml.Controls.Grid).Children.FirstOrDefault(c => c is PasswordBox);
            }
            else
            {
                _thisPhoneTextBox = (TextBox) (Control.Content as Windows.UI.Xaml.Controls.Grid).Children.FirstOrDefault(c => c is TextBox); 
            }

            SetFont(view);
            SetTextAlignment(view);
            SetBorder(view);
            SetPlaceholderTextColor(view);
            SetMaxLength(view);
            SetIsPasswordRevealButtonEnabled(view);

        }
        public TextSearchFilter(ICollectionView filteredView, TextBox textBox)
        {
            string filterText = "";

           /* filteredView.Filter = delegate(object obj)
            {

                if (string.IsNullOrEmpty(filterText))
                    return true;

                string str = obj as string;

                if (string.IsNullOrEmpty(str))
                    return false;

                int index = str.IndexOf(filterText, 0, StringComparison.CurrentCultureIgnoreCase);

                return index > -1;

            };
            textBox.TextChanged += delegate
            {
                filterText = textBox.Text;
                filteredView.Refresh();
            };**/
        }
示例#18
0
        public void InitializeComponent()
        {
            if (_contentLoaded)
                return;

            _contentLoaded = true;
            Application.LoadComponent(this, new System.Uri("ms-appx:///HomePage.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application);
 
            pageRoot = (_8Tracks.Common.LayoutAwarePage)this.FindName("pageRoot");
            groupedItemsViewSource = (Windows.UI.Xaml.Data.CollectionViewSource)this.FindName("groupedItemsViewSource");
            passwordPrompt = (Windows.UI.Xaml.Controls.Grid)this.FindName("passwordPrompt");
            itemGridView = (Windows.UI.Xaml.Controls.GridView)this.FindName("itemGridView");
            itemListView = (Windows.UI.Xaml.Controls.ListView)this.FindName("itemListView");
            backButton = (Windows.UI.Xaml.Controls.Button)this.FindName("backButton");
            pageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageTitle");
            loginText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("loginText");
            loginBox = (Windows.UI.Xaml.Controls.TextBox)this.FindName("loginBox");
            passwordText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("passwordText");
            passwordBox = (Windows.UI.Xaml.Controls.PasswordBox)this.FindName("passwordBox");
            doneButton = (Windows.UI.Xaml.Controls.Button)this.FindName("doneButton");
            ApplicationViewStates = (Windows.UI.Xaml.VisualStateGroup)this.FindName("ApplicationViewStates");
            FullScreenLandscape = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenLandscape");
            Filled = (Windows.UI.Xaml.VisualState)this.FindName("Filled");
            FullScreenPortrait = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait");
            Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped");
        }
 /// <summary>
 /// Constructor for the WP8 chat app.
 /// </summary>
 public ChatAppWinRT(TextBox currentMessageInputBox, TextBlock chatHistory, ScrollViewer chatHistoryScroller)
     : base("WinRT", ConnectionType.TCP)
 {
     this.CurrentMessageInputBox = currentMessageInputBox;
     this.ChatHistory = chatHistory;
     this.ChatHistoryScroller = chatHistoryScroller;
 }
        private async void TeamTwoName()
        {
            
                TextBox txtName = new TextBox();
                Grid contentGrid = new Grid();
                contentGrid.Children.Add(txtName);
                ContentDialog nameDialog = new ContentDialog()
                {
                    Title = "Enter Team Two Name",
                    Content = contentGrid,
                    PrimaryButtonText = "Submit"
                };

                await nameDialog.ShowAsync();

                if (txtName.Text != "")
                {
                    team2Name = txtName.Text;
                }
                else
                {
                    team2Name = "Team Two";
                }

                teamTwoName.Text = team2Name;       
        }
示例#21
0
文件: Tweet.g.i.cs 项目: sagar-sm/Mu
        public void InitializeComponent()
        {
            if (_contentLoaded)
                return;

            _contentLoaded = true;
            Application.LoadComponent(this, new System.Uri("ms-appx:///Tweet.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application);
 
            pageRoot = (Mu_genotype1.Common.LayoutAwarePage)this.FindName("pageRoot");
            primaryColumn = (Windows.UI.Xaml.Controls.ColumnDefinition)this.FindName("primaryColumn");
            titlePanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("titlePanel");
            itemListScrollViewer = (Windows.UI.Xaml.Controls.ScrollViewer)this.FindName("itemListScrollViewer");
            itemListScrollViewer2 = (Windows.UI.Xaml.Controls.ScrollViewer)this.FindName("itemListScrollViewer2");
            PeerTweets = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("PeerTweets");
            itemListView2 = (Windows.UI.Xaml.Controls.ListView)this.FindName("itemListView2");
            TweetBox = (Windows.UI.Xaml.Controls.TextBox)this.FindName("TweetBox");
            TweetIt = (Windows.UI.Xaml.Controls.Button)this.FindName("TweetIt");
            PinPanel = (Windows.UI.Xaml.Controls.StackPanel)this.FindName("PinPanel");
            itemListView = (Windows.UI.Xaml.Controls.ListView)this.FindName("itemListView");
            PinTb = (Windows.UI.Xaml.Controls.TextBox)this.FindName("PinTb");
            VerifyPinButton = (Windows.UI.Xaml.Controls.Button)this.FindName("VerifyPinButton");
            backButton = (Windows.UI.Xaml.Controls.Button)this.FindName("backButton");
            pageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageTitle");
            pageSubtitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageSubtitle");
            FullScreenLandscape = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenLandscape");
            Filled = (Windows.UI.Xaml.VisualState)this.FindName("Filled");
            FullScreenPortrait = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait");
            FullScreenPortrait_Detail = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait_Detail");
            Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped");
            Snapped_Detail = (Windows.UI.Xaml.VisualState)this.FindName("Snapped_Detail");
            TwitterConnectBtn = (Windows.UI.Xaml.Controls.Button)this.FindName("TwitterConnectBtn");
            RefreshButton = (Windows.UI.Xaml.Controls.Button)this.FindName("RefreshButton");
        }
示例#22
0
 public TextBoxHelper(TextBox textBox)
 {
     textBox.TextChanged += (o, a) =>
         {
             textBox.SetValue(BindableTextProperty, textBox.Text);
         };
 }
示例#23
0
        public MyUserControl1(int width, int height, CardObj CardData)
        {
            this.InitializeComponent();
            this.width = width;
            this.height = height;

            if (CardData != null)
            {
                this.LoadDataOfCard(CardData);
            }
            else
            {
                addRow();
                for (int i = 0; i < 10; ++i)
                {
                    TextBox tx = new TextBox();
                    tx.BorderThickness = new Thickness(0);
                    tx.FontSize = 16;
                    tx.FontFamily = new FontFamily("Segoe UI");
                    tx.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                    tx.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                    tx.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
                    if (i == 0)
                    {
                        tx.Foreground = new SolidColorBrush(Color.FromArgb(255, 128, 128, 128));
                        tx.Text = "Enter Instructions";
                        tx.GotFocus += OnEnter;
                    }
                    else
                    {
                        tx.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
                        tx.Text = "";
                    }

                    tx.Width = width;
                    tx.AllowDrop = true;
                    tx.Drop += DragEventHandler;
                    tx.DragEnter += Highlight;
                    tx.DragLeave += Unhighlight;
                    tx.KeyDown += EnterNextLine;
                    this.reversePanel.Children.Add(tx);
                }
                Button SaveButt = new Button();
                //SaveButt.BorderThickness = new Thickness(0);
                SaveButt.FontSize = 16;
                
                
                SaveButt.Visibility = Visibility.Visible;
                //SaveButt.Opacity = 5000;
                SaveButt.Foreground = new SolidColorBrush(Color.FromArgb(255, 128, 128, 128));
                SaveButt.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                SaveButt.Width = 500;
                //SaveButt.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
                SaveButt.Content = "Save";
                SaveButt.Click += SaveButt_Click;
                this.reversePanel.Children.Add(SaveButt);
            }

        }
示例#24
0
 private void TextBox_TextChanging(TextBox sender, TextBoxTextChangingEventArgs args)
 {
     double dtemp;
     if (!double.TryParse(sender.Text, out dtemp) && sender.Text != "")
     {
         sender.Text = sender.Text.Remove(--sender.SelectionStart, 1);
     }
 }
 static void AddToBoundPropertyDictionary(TextBox txtBox, PropertyInfo boundProperty)
 {
     PropertyInfo propInfo;
     if (!_boundProperties.TryGetValue(txtBox, out propInfo))
     {
         _boundProperties.Add(txtBox, boundProperty);
     }
 }
示例#26
0
 public SearchBar(TextBox searchControl, ListBox resultSearchControl, SongTextControl songTextControl, ListBox listArtistsControl)
 {
     this.searchControl = searchControl;
     this.resultSearchControl = resultSearchControl;
     this.songTextControl = songTextControl;
     this.listArtistsControl = listArtistsControl;
     searchControl.TextChanged += searchControl_TextChanged;
     resultSearchControl.SelectionChanged += ResultSearchControl_SelectionChanged;
 }
示例#27
0
		public static string GetBindableText(TextBox element)
		{
			if (element != null)
			{
				return (string)element.GetValue(BindableTextProperty);
			}

			return null;
		}
示例#28
0
 internal static void ScenarioStarted(Button startButton, Button cancelButton, TextBox outputField)
 {
     startButton.IsEnabled = false;
     cancelButton.IsEnabled = true;
     if (outputField != null)
     {
         outputField.Text = String.Empty;
     }
 }
示例#29
0
        private void CreateNewToDoItem(TextBox textBox)
        {
            var list = textBox.DataContext as ViewModels.TodoListViewModel;
            list.AddCommand.Execute(textBox.Text);
            textBox.Text = string.Empty;
            textBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);

            if (AddNewItemConfirmButton != null)
                AddNewItemConfirmButton.IsEnabled = false;
        }
示例#30
0
        private void SetTextBoxToNumerics(TextBox textBox)
        {
            var scope = new InputScope();
            var name = new InputScopeName();

            name.NameValue = InputScopeNameValue.Number;
            scope.Names.Add(name);

            textBox.InputScope = scope;
        }
示例#31
0
        private async void PrintButton_Click(object sender, RoutedEventArgs e)
        {
#if !HAS_UNO
            SampleController.Current.DisplayWaitRing = true;

            var printBlock = new RichTextBlock
            {
                FontFamily     = _codeView.FontFamily,
                RequestedTheme = ElementTheme.Light
            };
            var printFormatter = new RichTextBlockFormatter(ElementTheme.Light);
            printFormatter.FormatRichTextBlock(_displayedText, _language, printBlock);

            _printHelper = new PrintHelper(_container);
            _printHelper.AddFrameworkElementToPrint(printBlock);

            _printHelper.OnPrintFailed    += PrintHelper_OnPrintFailed;
            _printHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;
            _printHelper.OnPrintCanceled  += PrintHelper_OnPrintCanceled;

            await _printHelper.ShowPrintUIAsync("Windows Community Toolkit Sample App");
#endif
        }
示例#32
0
        public void InitializeComponent()
        {
            if (_contentLoaded)
            {
                return;
            }

            _contentLoaded = true;
            Application.LoadComponent(this, new System.Uri("ms-resource://spotifyapp/Files/View/GroupedCollectionPage.xaml"));

            GroupedCollectionViewSource = (Windows.UI.Xaml.Data.CollectionViewSource) this.FindName("GroupedCollectionViewSource");
            LayoutRoot        = (Windows.UI.Xaml.Controls.Grid) this.FindName("LayoutRoot");
            OrientationStates = (Windows.UI.Xaml.VisualStateGroup) this.FindName("OrientationStates");
            Full          = (Windows.UI.Xaml.VisualState) this.FindName("Full");
            Fill          = (Windows.UI.Xaml.VisualState) this.FindName("Fill");
            Portrait      = (Windows.UI.Xaml.VisualState) this.FindName("Portrait");
            Snapped       = (Windows.UI.Xaml.VisualState) this.FindName("Snapped");
            AppBar        = (Windows.UI.Xaml.Controls.ApplicationBar) this.FindName("AppBar");
            ItemListView  = (Windows.UI.Xaml.Controls.ListView) this.FindName("ItemListView");
            ItemGridView  = (Windows.UI.Xaml.Controls.GridView) this.FindName("ItemGridView");
            BackButton    = (Windows.UI.Xaml.Controls.Button) this.FindName("BackButton");
            PageTitle     = (Windows.UI.Xaml.Controls.TextBlock) this.FindName("PageTitle");
            SearchTextBox = (Windows.UI.Xaml.Controls.TextBox) this.FindName("SearchTextBox");
        }
示例#33
0
        /// <summary>
        /// Trim text for text box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void TrimText(object sender, RoutedEventArgs e)
        {
            TextBox TB = (TextBox)sender;

            TB.Text = TB.Text.Trim();
        }
示例#34
0
        private UWPControls.StackPanel CreateResultStackPanel()
        {
            var resultStackPanel = new UWPControls.StackPanel();

            //Dùng cho hiển thị Token

            UWPControls.TextBox fbTokenTextBox = new UWPControls.TextBox();
            fbTokenTextBox.Width           = 300;
            fbTokenTextBox.Margin          = new UWPXaml.Thickness(10);
            fbTokenTextBox.BorderThickness = new UWPXaml.Thickness(0);
            fbTokenTextBox.Background      = new UWPXaml.Media.SolidColorBrush(Windows.UI.Colors.Transparent);
            fbTokenTextBox.IsReadOnly      = true;
            fbTokenTextBox.TextWrapping    = UWPXaml.TextWrapping.Wrap;
            fbTokenTextBox.SetBinding(UWPControls.TextBox.TextProperty, new UWPXaml.Data.Binding()
            {
                Source = _viewModel,
                Path   = new UWPXaml.PropertyPath("FBToken"),
                Mode   = UWPXaml.Data.BindingMode.OneWay
            });

            UWPControls.Button copyTokenButton = new UWPControls.Button();
            copyTokenButton.Width   = 150;
            copyTokenButton.Margin  = new UWPXaml.Thickness(0, 0, 5, 0);
            copyTokenButton.Content = "Sao chép Token";
            copyTokenButton.Click  += (o, args) => { Clipboard.SetText(_viewModel.FBToken ?? string.Empty); };

            UWPControls.Button saveTokenButton = new UWPControls.Button {
                Width = 120, Content = "Lưu Token"
            };
            saveTokenButton.SetBinding(UWPControls.Button.CommandProperty, new UWPXaml.Data.Binding()
            {
                Source = _viewModel,
                Path   = new UWPXaml.PropertyPath("SaveTokenCommand")
            });

            UWPControls.StackPanel successCommandButtonsStackPanel = new UWPControls.StackPanel();
            successCommandButtonsStackPanel.Orientation         = UWPControls.Orientation.Horizontal;
            successCommandButtonsStackPanel.Margin              = new UWPXaml.Thickness(10);
            successCommandButtonsStackPanel.HorizontalAlignment = UWPXaml.HorizontalAlignment.Center;
            successCommandButtonsStackPanel.Children.Add(copyTokenButton);
            successCommandButtonsStackPanel.Children.Add(saveTokenButton);


            UWPControls.StackPanel successStackPanel = new UWPControls.StackPanel();

            successStackPanel.Children.Add(fbTokenTextBox);
            successStackPanel.Children.Add(successCommandButtonsStackPanel);

            successStackPanel.SetBinding(UWPXaml.UIElement.VisibilityProperty,
                                         new UWPXaml.Data.Binding()
            {
                Source    = _viewModel,
                Path      = new UWPXaml.PropertyPath("FBToken"),
                Converter = new NullTovisibilityConverter()
            });

            //Dùng cho hiển thị lỗi
            UWPControls.StackPanel errorStackPanel = new UWPControls.StackPanel();

            UWPControls.TextBlock errorMsgTextBlock = new UWPControls.TextBlock();
            errorMsgTextBlock.Width        = 300;
            errorMsgTextBlock.TextWrapping = UWPXaml.TextWrapping.WrapWholeWords;
            errorMsgTextBlock.Foreground   = new UWPXaml.Media.SolidColorBrush(Windows.UI.Colors.Red);
            errorMsgTextBlock.SetBinding(UWPControls.TextBlock.TextProperty, new UWPXaml.Data.Binding()
            {
                Source = _viewModel,
                Path   = new UWPXaml.PropertyPath("ErrorMsg")
            });

            errorStackPanel.Children.Add(errorMsgTextBlock);

            //Thêm cả 2 panel success và error vào panel chính
            resultStackPanel.Children.Add(errorStackPanel);
            resultStackPanel.Children.Add(successStackPanel);

            return(resultStackPanel);
        }
示例#35
0
 /// <summary>
 /// Only allow digit in text box
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void OnlyDigitBeforeTextChanging(TextBox sender, TextBoxBeforeTextChangingEventArgs e)
 {
     e.Cancel = e.NewText.Any(c => !char.IsDigit(c));
 }
示例#36
0
        public double?NumericText(Windows.UI.Xaml.Controls.TextBox sender)
        { //logics
            if (org == null)
            {
                org = new cTxtBoxProperty(sender);
            }

            //System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CurrentUICulture;
            System.Globalization.CultureInfo ci = new CultureInfo("zh-CN");
            cTxtBoxProperty edi  = new cTxtBoxProperty(sender);
            string          sPtn = MyPattern;
            string          sAdd = string.Empty;
            string          sSub = string.Empty;
            int             iChg = edi.iLen - org.iBeg - org.sRig.Length;

            if (iChg >= 0)
            {
                sAdd = edi.sTxt.Substring(org.iBeg, iChg);
                sSub = org.sSel;
            }
            else
            { //backspace?
                if (org.iLen >= edi.iLen)
                {
                    if (org.iBeg - (org.iLen - edi.iLen) >= 0)
                    {
                        sSub = org.sTxt.Substring(org.iBeg - (org.iLen - edi.iLen), (org.iLen - edi.iLen));
                    }
                }
            }

            int    iBgx = edi.iBeg;
            int    iSlx = 0;
            string sFnl = org.sTxt;

            int iNeg = sFnl.IndexOf(ci.NumberFormat.NegativeSign);
            int iDot = sFnl.IndexOf(ci.NumberFormat.NumberDecimalSeparator);

            if (sAdd == ci.NumberFormat.NegativeSign)
            {
                if (iNeg == -1)
                {     //add
                    if (CanNegNum)
                    { //accepts negative numbers
                     //if (ci.TextInfo.IsRightToLeft)
                     //{
                     //    sFnl = ci.NumberFormat.NegativeSign + sFnl; //sFnl = sFnl + ci.NumberFormat.NegativeSign;
                     //    iBgx = edi.iBeg - ci.NumberFormat.NegativeSign.Length;
                     //}
                     //else
                     //{
                        sFnl = ci.NumberFormat.NegativeSign + sFnl;
                        iBgx = edi.iBeg;
                        //}
                    }
                    else
                    {//does not accepts negative numbers
                        //if (ci.TextInfo.IsRightToLeft)
                        //{
                        iBgx = edi.iBeg - ci.NumberFormat.NegativeSign.Length;
                        //}
                        //else
                        //{
                        //    iBgx = edi.iBeg;
                        //}
                    }
                }
                else
                {//remove
                    sFnl = sFnl.Remove(iNeg, ci.NumberFormat.NegativeSign.Length);
                    if (iNeg >= iBgx)
                    {
                        iBgx = edi.iBeg - ci.NumberFormat.NegativeSign.Length;
                    }
                    else
                    {
                        //if (ci.TextInfo.IsRightToLeft)
                        //{
                        //    iBgx = edi.iBeg - ci.NumberFormat.NegativeSign.Length;
                        //}
                        //else
                        //{
                        iBgx = edi.iBeg - ci.NumberFormat.NegativeSign.Length - ci.NumberFormat.NegativeSign.Length;
                        //}
                    }
                }
            } //end NegativeSign
            else if (sAdd == ci.NumberFormat.NumberDecimalSeparator)
            { //NumberDecimalSeparator
                if (iDot == -1)
                { //add
                    sFnl = edi.sTxt;
                }
                else
                { //go to point
                    sFnl = org.sTxt;
                    iBgx = iDot + ci.NumberFormat.NumberDecimalSeparator.Length;
                }
            }
            else if (sAdd == ".")
            { //dotAsDecimalSeparator
                if (IsDotSepa)
                {
                    if (iDot == -1)
                    { //add
                        sFnl = edi.sTxt;
                    }
                    else
                    { //go to point
                        sFnl = org.sTxt;
                        iBgx = iDot + ci.NumberFormat.NumberDecimalSeparator.Length;
                    }
                }
                else
                {
                    sFnl = edi.sTxt; //override
                }
            }
            else if (sSub == ci.NumberFormat.NumberGroupSeparator & org.iSel == 0)
            { //backspace and GroupSeparator
                if (edi.iBeg == 0)
                {
                    sFnl = edi.sTxt;
                }
                else
                {
                    sFnl = edi.sLef.Replace(ci.NumberFormat.NumberGroupSeparator, string.Empty);
                    int iRem = edi.sLef.Length - sFnl.Length;
                    sFnl = sFnl.Substring(0, edi.sLef.Length - iRem - 1) + edi.sRig;
                    iBgx = iBgx - iRem - 1;
                }
            }//end backspace and GroupSeparator
            else
            {
                sFnl = edi.sTxt;
            }

            if (iBgx > sFnl.Length)
            {
                iBgx = sFnl.Length;
            }
            string sLfx = sFnl.Substring(0, iBgx);
            string sRgx = sFnl.Substring(iBgx);

            sRgx = sRgx.Replace(ci.NumberFormat.NumberGroupSeparator, string.Empty);
            sFnl = sFnl.Replace(ci.NumberFormat.NumberGroupSeparator, string.Empty);

            if (LstRemStr != null)
            {
                foreach (string sRem in LstRemStr)
                {
                    sRgx = sRgx.Replace(sRem, string.Empty); //automatically trimmed
                    sFnl = sFnl.Replace(sRem, string.Empty); //automatically trimmed
                }
            }

            //s += "Rgx: " + sRgx.ToString() + Environment.NewLine;
            //s += "Fnl: " + sFnl.ToString() + Environment.NewLine;

            if (!CanNegNum)
            {//remove negative sign
                sRgx = sRgx.Replace(ci.NumberFormat.NegativeSign, string.Empty);
                sFnl = sFnl.Replace(ci.NumberFormat.NegativeSign, string.Empty);
            }
            //Debug.WriteLine("ClsNumTextTagIn--------------" + sFnl);
            decimal dFnl = decimal.Zero;
            decimal dRgx = decimal.Zero;

            if (decimal.TryParse(sFnl, out dFnl))
            {
                if (AllowNullValue && sFnl.StartsWith(".") && dFnl == decimal.Zero)
                {
                    sender.Text            = "";
                    sender.SelectionStart  = 0;
                    sender.SelectionLength = 0;
                    return(null);
                }

                int iDtx = sFnl.IndexOf(ci.NumberFormat.NumberDecimalSeparator);
                int iDif = sFnl.Length - dFnl.ToString().Length;

                if (iDtx == -1)
                {//DecimalSeparator does not exist
                    sFnl = dFnl.ToString(sPtn);
                    int iTmp = sFnl.IndexOf(ci.NumberFormat.NumberDecimalSeparator);
                    if (iTmp == -1)
                    {//DecimalSeparator not found after apply pattern
                        if (sRgx == string.Empty)
                        {
                            iBgx = sFnl.Length;
                        }
                        else
                        {
                            if (sRgx.StartsWith(decimal.Zero.ToString()))
                            {
                                sRgx = decimal.One.ToString() + sRgx;
                                if (decimal.TryParse(sRgx, out dRgx))
                                {
                                    sRgx = dRgx.ToString(sPtn);
                                    if (sRgx.StartsWith(decimal.One.ToString() + ci.NumberFormat.NumberDecimalSeparator))
                                    {
                                        iBgx = sFnl.Length - sRgx.Length + (decimal.One.ToString() + ci.NumberFormat.NumberDecimalSeparator).Length;
                                    }
                                    else
                                    {
                                        iBgx = sFnl.Length - sRgx.Length + decimal.One.ToString().Length;
                                    }
                                }
                            }
                            else
                            {
                                if (decimal.TryParse(sRgx, out dRgx))
                                {
                                    sRgx = dRgx.ToString(sPtn);
                                    iBgx = sFnl.Length - sRgx.Length;
                                }
                            }
                        }
                    }
                    else
                    {//DecimalSeparator found after apply pattern
                        if (sRgx == string.Empty)
                        {
                            iBgx = iTmp;
                        }
                        else
                        {
                            if (sRgx.StartsWith(decimal.Zero.ToString()))
                            {
                                sRgx = decimal.One.ToString() + sRgx;
                                if (decimal.TryParse(sRgx, out dRgx))
                                {
                                    sRgx = dRgx.ToString(sPtn);
                                    if (sRgx.StartsWith(decimal.One.ToString() + ci.NumberFormat.NumberDecimalSeparator))
                                    {
                                        iBgx = sFnl.Length - sRgx.Length + (decimal.One.ToString() + ci.NumberFormat.NumberDecimalSeparator).Length;
                                    }
                                    else
                                    {
                                        iBgx = sFnl.Length - sRgx.Length + decimal.One.ToString().Length;
                                    }
                                }
                            }
                            else
                            {
                                if (decimal.TryParse(sRgx, out dRgx))
                                {
                                    sRgx = dRgx.ToString(sPtn);
                                    iBgx = sFnl.Length - sRgx.Length;
                                }
                            }
                        }
                    }

                    if (iBgx < 0)
                    {
                        iBgx = 0;
                    }
                }
                else
                {     //DecimalSeparator does exist
                    if (sFnl.Length - sRgx.Length <= iDtx)
                    { //before DecimalSeparator
                        sFnl = dFnl.ToString(sPtn);
                        if (sRgx.StartsWith(decimal.Zero.ToString()))
                        {
                            sRgx = decimal.One.ToString() + sRgx;
                            if (decimal.TryParse(sRgx, out dRgx))
                            {
                                sRgx = dRgx.ToString(sPtn);
                                if (sRgx.StartsWith(decimal.One.ToString() + ci.NumberFormat.NumberDecimalSeparator))
                                {
                                    iBgx = sFnl.Length - sRgx.Length + (decimal.One.ToString() + ci.NumberFormat.NumberDecimalSeparator).Length;
                                }
                                else
                                {
                                    iBgx = sFnl.Length - sRgx.Length + decimal.One.ToString().Length;
                                }
                            }
                        }
                        else if (sRgx.StartsWith(ci.NumberFormat.NumberDecimalSeparator))
                        {
                            if (decimal.TryParse(sRgx, out dRgx))
                            {
                                sRgx = dRgx.ToString(sPtn);
                                iBgx = sFnl.Length - sRgx.Length + ci.NumberFormat.NumberDecimalSeparator.Length;
                            }
                        }
                        else
                        {
                            if (decimal.TryParse(sRgx, out dRgx))
                            {
                                sRgx = dRgx.ToString(sPtn);
                                iBgx = sFnl.Length - sRgx.Length;
                            }
                        }

                        if (iBgx < 0)
                        {
                            iBgx = 0;
                        }
                    }
                    else
                    {//after DecimalSeparator
                        sFnl = dFnl.ToString(sPtn);

                        var newValue = decimal.Parse(sFnl);
                        //四舍五入了,如要去掉
                        if (newValue > dFnl)
                        {
                            var de       = (newValue - dFnl);
                            int i        = 1;
                            var deString = de.ToString();
                            if (int.TryParse(deString.LastOrDefault().ToString(), out i))
                            {
                                dFnl = dFnl - (de / i * 5);
                                sFnl = dFnl.ToString(sPtn);
                            }
                            ;
                        }
                        dFnl = decimal.Parse(sFnl);

                        int iTmp = sFnl.IndexOf(ci.NumberFormat.NumberDecimalSeparator); //override
                        if (iTmp == -1)
                        {                                                                // pattern does not accept DecimalSeparator
                            iBgx = sFnl.Length;
                        }
                        else
                        {
                            if (sSub != string.Empty & sAdd == string.Empty)
                            {// if backspace (after decimal separator)
                                if (iTmp + 1 < iBgx)
                                {
                                    iBgx = iBgx - 1;
                                }
                                else
                                {
                                    iBgx = iTmp;
                                }
                            }

                            if (sFnl.Length > iBgx)
                            {
                                if (iBgx > iTmp)
                                {
                                    iSlx = 1;
                                }
                            }
                        }
                    }
                }
                sender.Text            = sFnl;
                sender.SelectionStart  = iBgx;
                sender.SelectionLength = iSlx;
            }//end of if decimal
            else
            {//not decimal
                if (IsNumOnly)
                { //IsNumOnly =true
                    decimal dOrg = decimal.Zero;

                    if (sFnl != string.Empty && decimal.TryParse(org.sTxt, out dOrg))
                    {
                        sender.Text            = org.sTxt;
                        sender.SelectionStart  = org.iBeg;
                        sender.SelectionLength = org.iSel;
                        return((double)dOrg);
                    }
                    else
                    {
                        if (AllowNullValue && sFnl == string.Empty)
                        {
                            sender.Text            = "";
                            sender.SelectionStart  = 0;
                            sender.SelectionLength = 0;
                            return(null);
                        }
                        else
                        {
                            decimal dAdd = decimal.Zero;
                            decimal.TryParse(sAdd, out dAdd);
                            sFnl = dAdd.ToString(sPtn);
                            int iTmp = sFnl.IndexOf(ci.NumberFormat.NumberDecimalSeparator);

                            if (iTmp == -1)
                            {
                                iBgx = sFnl.Length;
                            }
                            else
                            {
                                iBgx = iTmp;
                            }
                            sender.Text            = sFnl;
                            sender.SelectionStart  = iBgx;
                            sender.SelectionLength = 0;
                        }
                    }
                }
                else
                { //numbersOnly false
                    sender.Text            = edi.sTxt;
                    sender.SelectionStart  = edi.iBeg;
                    sender.SelectionLength = edi.iSel;
                }
            }

            return((double)dFnl);
        }
示例#37
0
 public void Refresh(Windows.UI.Xaml.Controls.TextBox sender)
 {
     org = new cTxtBoxProperty(sender);
 }