Inheritance: System.Windows.Markup.IAddChild
Beispiel #1
0
		public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object source)
		{
			InputScopeName isn = new InputScopeName ();
			if (source == null)
				return isn;

			Type type = source.GetType ();
			if (!CanConvertFrom (type))
				return isn;

			if (type == typeof (string)) {
				string value = (source as string);
				if (value.Length == 0)
					return isn;

				if (value.IndexOf (',') == -1) {
					isn.NameValue = Parse (value);
				} else {
					string[] values = value.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries);
					foreach (string v in values)
						Parse (v);
					isn.NameValue = InputScopeNameValue.PhraseList;
				}
				return isn;
			}

			throw new NotImplementedException ();
		}
Beispiel #2
0
        ///<summary>
        /// Converts the given value to InputScope type
        ///</summary>
        /// <param name="context">
        /// The conversion context.
        /// </param>
        /// <param name="culture">
        /// The current culture that applies to the conversion.
        /// </param>
        /// <param name="source">
        /// The source object to convert from.
        /// </param>
        /// <returns>
        /// InputScope object with a specified scope name, otherwise InputScope with Default scope.
        /// </returns>

        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object source)
        {
            string stringSource           = source as string;
            InputScopeNameValue nameValue = InputScopeNameValue.Default;
            InputScopeName      inputScopeName;

            if (null != stringSource)
            {
                stringSource = stringSource.Trim();

                if (-1 != stringSource.LastIndexOf('.'))
                {
                    stringSource = stringSource.Substring(stringSource.LastIndexOf('.') + 1);
                }

                if (!stringSource.Equals(String.Empty))
                {
                    nameValue = (InputScopeNameValue)Enum.Parse(typeof(InputScopeNameValue), stringSource);
                }
            }

            inputScopeName           = new InputScopeName();
            inputScopeName.NameValue = nameValue;
            return(inputScopeName);
        }
        public MainPage()
        {
            InitializeComponent();

            var numericScope = new InputScope();
            var numericScopeName = new InputScopeName();
            totalbillblock.Visibility = Visibility.Collapsed;
            totaltipblock.Visibility = Visibility.Collapsed;
            totalperpersonblock.Visibility = Visibility.Collapsed;
            tipperperson.Visibility = Visibility.Collapsed;
            //taxpercentlbl.Visibility = Visibility.Collapsed;
            //taxtextbox.Visibility = Visibility.Collapsed;
            taxtextbox.IsEnabled = false;
            numericScopeName.NameValue = InputScopeNameValue.Number;
            numericScope.Names.Add(numericScopeName);
            billbox.InputScope = numericScope;
            billbox.Text = DEFAULTBILL.ToString("#.##");
            tippercentdsp.Text = DEFAULTTIPPERC.ToString();
            taxtextbox.InputScope = numericScope;
            tipvaluebox.InputScope = numericScope;
            peoplebox.InputScope = numericScope;
            taxtextbox.InputScope = numericScope;
            tippercentdsp.InputScope = numericScope;
            TipPercentBoxChange();

            initialized = true;
            tipreviewdsp.Visibility = REVIEW ? Visibility.Visible : Visibility.Collapsed;
            funphrases = new List<List<String>>();
            PopulateTierLists();
            RecalculateEverything();
        }
        private void Use_Zip_Code(object sender, System.Windows.RoutedEventArgs e)
        {
            TextBox textBox = new TextBox();
            // restrict input to digits:
            InputScope inputScope = new InputScope();
            InputScopeName inputScopeName = new InputScopeName();
            inputScopeName.NameValue = InputScopeNameValue.Digits;
            inputScope.Names.Add(inputScopeName);
            textBox.InputScope = inputScope;

            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Message = "Enter your US zip code:",
                LeftButtonContent = "okay",
                RightButtonContent = "cancel",
                Content = textBox
            };
            messageBox.Loaded += (a, b) =>
            {
                textBox.Focus();
            };
            messageBox.Show();
            messageBox.Dismissed += (s, args) =>
            {
                if (args.Result == CustomMessageBoxResult.LeftButton)
                {
                    if (textBox.Text.Length >= 5)
                    {
                        geocodeUsingString(textBox.Text);
                    }
                }
            };
        }
 public static InputScope ToInputScope(this InputScopeNameValue inputScopeNameValue)
 {
     var inputScope = new InputScope();
     var inputScopeName = new InputScopeName { NameValue = inputScopeNameValue };
     inputScope.Names.Add(inputScopeName);
     return inputScope;
 }
 private void textBox_email_Tap(object sender, EventArgs e)
 {
     InputScope Keyboard = new InputScope();
     InputScopeName ScopeName = new InputScopeName();
     ScopeName.NameValue = InputScopeNameValue.EmailSmtpAddress;
     Keyboard.Names.Add(ScopeName);
     textBox_email.InputScope = Keyboard;
 }
Beispiel #7
0
 private InputScope GetSearchInputScope()
 {
     InputScope scope = new InputScope();
     InputScopeName name = new InputScopeName();
     name.NameValue = InputScopeNameValue.Search;
     scope.Names.Add(name);
     return scope;
 }
 void MainPageLoaded(object sender, RoutedEventArgs e)
 {
     var numericScope = new InputScope();
     var numericScopeName = new InputScopeName();
     numericScopeName.NameValue = InputScopeNameValue.Number;
     numericScope.Names.Add(numericScopeName);
     numberTextBox.InputScope = numericScope;
 }
 //set the keyboard to number input mode for the servings text box
 private void setInputScope()
 {
     InputScope inputScope = new InputScope();
     InputScopeName inputScopeName = new InputScopeName();
     inputScopeName.NameValue = InputScopeNameValue.Number;
     inputScope.Names.Add(inputScopeName);
     txtServings.InputScope = inputScope;
 }
Beispiel #10
0
 private void textBox_phone_Tap(object sender, EventArgs e)
 {
     InputScope Keyboard = new InputScope();
     InputScopeName ScopeName = new InputScopeName();
     ScopeName.NameValue = InputScopeNameValue.Digits;
     Keyboard.Names.Add(ScopeName);
     textBox_phone.InputScope = Keyboard;
 }
 static MoneyInputTextBox()
 {
     InputScopeName name = new InputScopeName
     {
         NameValue = InputScopeNameValue.TelephoneNumber
     };
     NumberInputScope = new InputScope();
     NumberInputScope.Names.Add(name);
 }
Beispiel #12
0
 public MainPage()
 {
     InitializeComponent();
     var numericScope = new InputScope();
     var numericScopeName = new InputScopeName();
     numericScopeName.NameValue = InputScopeNameValue.Number;
     numericScope.Names.Add(numericScopeName);
     bxGuess.InputScope = numericScope;
 }
Beispiel #13
0
 public Fee()
 {
     InitializeComponent();
     var numericScope = new InputScope();
     var numericScopeName = new InputScopeName();
     numericScopeName.NameValue = InputScopeNameValue.Number;
     numericScope.Names.Add(numericScopeName);
     feeBox.InputScope = numericScope;
 }
Beispiel #14
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            InputScopeName isn = (value as InputScopeName);

            if ((isn == null) || (destinationType != typeof(string)))
            {
                throw new NotImplementedException();
            }

            return(isn.NameValue.ToString());
        }
        public MyIntTextBox()
        {
            Value = 0;
            InputScope scope = new InputScope();
            InputScopeName name = new InputScopeName();

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

            InputScope = scope;
        }
Beispiel #16
0
        public FuelConsumption()
        {
            InitializeComponent();

            var numericScope = new InputScope();
            var numericScopeName = new InputScopeName();
            numericScopeName.NameValue = InputScopeNameValue.Number;
            numericScope.Names.Add(numericScopeName);
            cityBox.InputScope = numericScope;
            mixedBox.InputScope = numericScope;
            hwBox.InputScope = numericScope;
        }
Beispiel #17
0
        private async void Donate_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var InSc = new System.Windows.Input.InputScope();
            InputScopeName name = new InputScopeName();

            name.NameValue = InputScopeNameValue.Number;
            InSc.Names.Add(name);
            var initialValue = (2.0f).ToString("N2");

            const string DonationItem = "Donazione libera";

            PayPal.Checkout.BuyNow purchase = new PayPal.Checkout.BuyNow("*****@*****.**") { UseSandbox = false, DisplayShipping = 1, ConfirmedShippingOnly = false, Currency = "EUR" };
            var item = new PayPal.Checkout.ItemBuilder(DonationItem)
                .Name(DonationItem)
                .Description(DonationItem)
                .ID("DON")
                .Price(float.Parse(initialValue).ToString(new NumberFormatInfo { CurrencyDecimalDigits = 2, NumberDecimalDigits = 2, CurrencyDecimalSeparator = ".", NumberDecimalSeparator = ".", NumberGroupSeparator = ",", CurrencyGroupSeparator = "," }))
                .Tax("0.00")
                //.AddMetadata("type", "Digital") //It must be included. Modify paypal account to allow this
                .Quantity(1);

            purchase.AddItem(item);


            purchase.Error += new EventHandler<PayPal.Checkout.Event.ErrorEventArgs>((source, eventArg) =>
            {
                new MessagePrompt { IsCancelVisible = false, Title = "SimInfo", Message = string.Format(AppResources.DonateError, eventArg.Message) }.Show();
                SystemTray.SetProgressIndicator(this, new ProgressIndicator() { Text = "", IsIndeterminate = true, IsVisible = false });
            });
            purchase.Complete += new EventHandler<PayPal.Checkout.Event.CompleteEventArgs>((source, eventArg) =>
            {
                new MessagePrompt { IsCancelVisible = false, Title = "SimInfo", Message = AppResources.DonateSuccess }.Show();
                SystemTray.SetProgressIndicator(this, new ProgressIndicator() { Text = "", IsIndeterminate = true, IsVisible = false });
            });
            purchase.Cancel += new EventHandler<PayPal.Checkout.Event.CancelEventArgs>((source, eventArg) =>
            {
                new MessagePrompt { IsCancelVisible = false, Title = "SimInfo", Message = AppResources.DonateCancel }.Show();
                SystemTray.SetProgressIndicator(this, new ProgressIndicator() { Text = "", IsIndeterminate = true, IsVisible = false });
            });
            purchase.Start += new EventHandler<PayPal.Checkout.Event.StartEventArgs>((source, eventArg) =>
            {
                SystemTray.SetProgressIndicator(this, new ProgressIndicator() { Text = AppResources.PaypalLoading, IsIndeterminate = true, IsVisible = true });

            });
            purchase.Auth += new EventHandler<PayPal.Checkout.Event.AuthEventArgs>((source, eventArg) =>
            {
                SystemTray.SetProgressIndicator(this, new ProgressIndicator() { Text = string.Format(AppResources.PayPalAuth, eventArg.Token), IsIndeterminate = true, IsVisible = false });
            });

            bool res = await purchase.Execute();

        }
Beispiel #18
0
        ///<summary>
        /// Converts the given value as InputScope object to the specified type.
        /// This converter only supports string type as a type to convert to.
        ///</summary>
        /// <param name="context">
        /// The conversion context.
        /// </param>
        /// <param name="culture">
        /// The current culture that applies to the conversion.
        /// </param>
        /// <param name="value">
        /// The value to convert.
        /// </param>
        /// <param name="destinationType">
        /// The type to convert to.
        /// </param>
        /// <returns>
        /// A new object of the specified type (string) converted from the given InputScope object.
        /// </returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            InputScopeName inputScopeName = value as InputScopeName;

            if (null != destinationType && null != inputScopeName)
            {
                if (destinationType == typeof(string))
                {
                    return(Enum.GetName(typeof(InputScopeNameValue), inputScopeName.NameValue));
                }
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                var control = (PhoneTextBox) Control.Children[0];
                InputScope inputScope = new InputScope();
                InputScopeName inputScopeName = new InputScopeName();

                inputScopeName.NameValue = InputScopeNameValue.TelephoneNumber;
                inputScope.Names.Add(inputScopeName);
                control.InputScope = inputScope;
            }
        }
Beispiel #20
0
 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/TS;component/Add.xaml", System.UriKind.Relative));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.ContentPanel = ((System.Windows.Controls.ListBox)(this.FindName("ContentPanel")));
     this.Name = ((System.Windows.Controls.TextBox)(this.FindName("Name")));
     this.nm = ((System.Windows.Input.InputScopeName)(this.FindName("nm")));
     this.nd = ((System.Windows.Controls.TextBlock)(this.FindName("nd")));
     this.Story = ((System.Windows.Controls.TextBox)(this.FindName("Story")));
     this.str = ((System.Windows.Input.InputScopeName)(this.FindName("str")));
     this.NameAuthor = ((System.Windows.Controls.TextBox)(this.FindName("NameAuthor")));
     this.nmthr = ((System.Windows.Input.InputScopeName)(this.FindName("nmthr")));
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string newText;
           
            if (NavigationContext.QueryString.TryGetValue("cantidadPersonas", out newText))
            {
                cantPersonas = Convert.ToInt32(newText);
            }
            if (NavigationContext.QueryString.TryGetValue("valorTotal", out newText))
            {
                valorTotal = Convert.ToInt32(newText);   
            }
            if (NavigationContext.QueryString.TryGetValue("valorVuelto", out newText))
            {
                valorVuelto = Convert.ToInt32(newText);
            }


            for (int i = 1; i != cantPersonas + 1; i++)
            {
                InputScope scope = new InputScope();
                InputScopeName name = new InputScopeName();

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

                TextBlock texto = new TextBlock();
                texto.Text = "Ingrese lo que Pago la Persona " + i;
                TextBox txtCampo = new TextBox();
                txtCampo.Name = "Persona" + i;
                txtCampo.Text = 0+"";
                txtCampo.InputScope = scope;
                txtCampo.GotFocus += txtCampo_GotFocus;
                txtCampo.LostFocus += txtCampo_LostFocus;
                txtCampo.TextChanged += txtCampo_TextChanged;
               
                panelControl.Children.Add(texto);
                panelControl.Children.Add(txtCampo);
            }

            Button btnCalcular = new Button();
            btnCalcular.Content="Calcular";
            btnCalcular.Click+=btnCalcular_Click;
            panelControl.Children.Add(btnCalcular);
            panelControl.Children.Add(stackPanel);
            base.OnNavigatedTo(e);
        }
Beispiel #22
0
		public void InDesign ()
		{
			InputScopeName isn = null;

			DesignerProperties.SetIsInDesignMode (Application.Current.RootVisual, true);
			try {
				// creation time limitation only
				isn = new InputScopeName (InputScopeNameValue.AddressCity);
			}
			finally {
				DesignerProperties.SetIsInDesignMode (Application.Current.RootVisual, false);
			}

			Assert.AreEqual (InputScopeNameValue.AddressCity, isn.NameValue, "NameValue");
			isn.NameValue = (InputScopeNameValue) Int32.MaxValue;
			Assert.AreEqual ((InputScopeNameValue) Int32.MaxValue, isn.NameValue, "bad-value");
		}
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string newText = string.Empty;
            
            if (NavigationContext.QueryString.TryGetValue("cantidadPersonas", out newText))
            {     
                    cantPersonas = Convert.ToInt32(newText);
                    
            }
            if (NavigationContext.QueryString.TryGetValue("pagoPersonas", out newText))
            {
                valorDividido = newText;
                valorDivididoPermanente = newText;
            }
            TextBlock textoDiferencia = new TextBlock();
            textoDiferencia.Name = "diferencia";
            
            panelControl.Children.Add(textoDiferencia);
           
            for (int i = 1; i != cantPersonas+1; i++)
            {
                InputScope scope = new InputScope();
                InputScopeName name = new InputScopeName();

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

                TextBlock texto = new TextBlock();
                texto.Text = "Persona " + i;
                TextBox txtCampo = new TextBox();
                txtCampo.Name = "Persona" + i;
                txtCampo.Text = valorDividido;
                txtCampo.InputScope = scope;
                txtCampo.LostFocus += txtCampo_LostFocus;
                txtCampo.TextChanged += txtCampo_TextChanged;


                panelControl.Children.Add(texto);
                panelControl.Children.Add(txtCampo);
            }

            base.OnNavigatedTo(e);
        }
Beispiel #24
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object source)
        {
            InputScopeName isn = new InputScopeName();

            if (source == null)
            {
                return(isn);
            }

            Type type = source.GetType();

            if (!CanConvertFrom(type))
            {
                return(isn);
            }

            if (type == typeof(string))
            {
                string value = (source as string);
                if (value.Length == 0)
                {
                    return(isn);
                }

                if (value.IndexOf(',') == -1)
                {
                    isn.NameValue = Parse(value);
                }
                else
                {
                    string[] values = value.Split(new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string v in values)
                    {
                        Parse(v);
                    }
                    isn.NameValue = InputScopeNameValue.PhraseList;
                }
                return(isn);
            }

            throw new NotImplementedException();
        }
Beispiel #25
0
 private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
 {
     //loading logic here
     //either custom regex or:
     InputScope scope = new InputScope();
     InputScopeName name = new InputScopeName();
     name.NameValue = InputScopeNameValue.Url;
     scope.Names.Add(name);
     txtServerAddress.InputScope = scope;
     //or in XAML for MVC:
     /*
      * <TextBox Name="txtPhoneNumber" Height="71" Width="460" >
             <TextBox.InputScope>
                 <InputScope>
                     <InputScopeName NameValue="Number" />
                 </InputScope>
         </TextBox.InputScope>
     </TextBox>
      */
 }
Beispiel #26
0
 public MainPage()
 {
     InitializeComponent();
      var numericScope = new InputScope();
      var numericScopeName = new InputScopeName();
      totalbillblock.Visibility = Visibility.Collapsed;
      totaltipblock.Visibility = Visibility.Collapsed;
      totalperpersonblock.Visibility = Visibility.Collapsed;
      tipperperson.Visibility = Visibility.Collapsed;
      //taxpercentlbl.Visibility = Visibility.Collapsed;
      //taxtextbox.Visibility = Visibility.Collapsed;
      taxtextbox.IsEnabled = false;
      numericScopeName.NameValue = InputScopeNameValue.Number;
      numericScope.Names.Add(numericScopeName);
      billbox.InputScope = numericScope;
      billbox.Text = DEFAULTBILL.ToString("#.##");
      taxbox.InputScope = numericScope;
      tipBox.InputScope = numericScope;
      peoplebox.InputScope = numericScope;
      taxtextbox.InputScope = numericScope;
      initialized = true;
      RecalculateEverything();
 }
Beispiel #27
0
		public void InDesign ()
		{
			InputScope i = null;
			InputScopeName isn = null;

			DesignerProperties.SetIsInDesignMode (Application.Current.RootVisual, true);
			try {
				// creation time limitation only
				i = new InputScope ();
				isn = new InputScopeName (InputScopeNameValue.AddressCity);
			}
			finally {
				DesignerProperties.SetIsInDesignMode (Application.Current.RootVisual, false);
			}

			Assert.AreEqual (0, i.Names.Count, "Count");
			Assert.IsFalse (i.Names.IsFixedSize, "IsFixedSize");
			Assert.IsFalse (i.Names.IsReadOnly, "IsReadOnly");
			Assert.IsInstanceOfType<List<InputScopeName>> (i.Names, "type");

			i.Names.Add (isn);
			Assert.AreEqual (1, i.Names.Count, "1");
		}
Beispiel #28
0
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            NavigationService.RemoveBackEntry();

            InputScope scope = new InputScope();
            InputScopeName scopeName = new InputScopeName();
            scopeName.NameValue = InputScopeNameValue.Chat;
            scope.Names.Add(scopeName);
            tbText.InputScope = scope;

            if (!Session.hasUsernameAndPassword())
            {
                var settings = IsolatedStorageSettings.ApplicationSettings;
                try
                {
                    String u = settings[Constants.KEY_USERNAME].ToString();
                    String p = settings[Constants.KEY_PASSWORD].ToString();
                    Session.username = u;
                    Session.password = p;
                    if (u == string.Empty || p == string.Empty)
                    {
                        navigateToLoginPage();
                    }
                }
                catch (KeyNotFoundException)
                {
                    navigateToLoginPage();
                }
            }
        }
Beispiel #29
0
        private void addInputType(InputType inputType)
        {
            if (inputType.Type == InputType.INPUT_TYPE_PASSWORD)
            {
                PasswordBox passwordBox = new PasswordBox();
                passwordBox.Password = inputType.Value;
                ContentPanel.Children.Add(passwordBox);
                passwordBox.Focus();
                passwordBox.LostFocus += new RoutedEventHandler(TextChanged_Clicked);
                passwordBox.KeyDown += OnKeyDownHandler;
            } else if (inputType.Type == InputType.INPUT_TYPE_DATE)
            {
                DatePicker datePicker = new DatePicker();
                datePicker.Header = inputType.Name;
                datePicker.Value = toDateTime(inputType.Value);
                ContentPanel.Children.Add(datePicker);
                datePicker.Focus();
                datePicker.ValueChanged += Date_Changed;

            } else
            {
                TextBox textBox = new TextBox();
                textBox.Text = inputType.Value;
                InputScope Keyboard = new InputScope();
                InputScopeName ScopeName = new InputScopeName();
                switch (inputType.Type)
                {
                    case InputType.INPUT_TYPE_DATE:
                        ScopeName.NameValue = InputScopeNameValue.Date;
                        break;
                    case InputType.INPUT_TYPE_AMOUNT:
                        ScopeName.NameValue = InputScopeNameValue.CurrencyAmount;
                        break;
                    case InputType.INPUT_TYPE_EMAIL:
                        ScopeName.NameValue = InputScopeNameValue.EmailUserName;
                        break;
                    case InputType.INPUT_TYPE_NUMBER:
                        ScopeName.NameValue = InputScopeNameValue.Number;
                        break;
                    case InputType.INPUT_TYPE_PASSWORD:
                        ScopeName.NameValue = InputScopeNameValue.Password;
                        break;
                    case InputType.INPUT_TYPE_PHONE:
                        ScopeName.NameValue = InputScopeNameValue.TelephoneNumber;
                        break;
                    case InputType.INPUT_TYPE_URL:
                        ScopeName.NameValue = InputScopeNameValue.Url;
                        break;
                    case InputType.INPUT_TYPE_STRING:
                        ScopeName.NameValue = InputScopeNameValue.Text;
                        break;
                }
                Keyboard.Names.Add(ScopeName);
                textBox.InputScope = Keyboard;
                ContentPanel.Children.Add(textBox);
                textBox.Focus();
                textBox.LostFocus += new RoutedEventHandler(TextChanged_Clicked);
                textBox.KeyDown += OnKeyDownHandler;
            }
        }
        // ReSharper restore InconsistentNaming
        private void SendBoxDoubleTap(object sender, GestureEventArgs e)
        {
            if (pop != null && pop.IsOpen) {
                pop.IsOpen = false;
                LayoutRoot.Children.Remove(pop);
                return;
            }

            if (!IsolatedStorageSettings.ApplicationSettings.Contains("ux.allowaltcodes")) {
                return;
            }

            var grid = new Grid {
                Width = 250,
                Height = 75
            };

            var inputScope = new InputScope();
            var name = new InputScopeName { NameValue = InputScopeNameValue.Number };
            inputScope.Names.Add(name);

            var tb = new TextBox {
                Margin = new Thickness(5, 0, 85, 0),
                Padding = new Thickness(0),
                InputScope = inputScope,
                FontSize = 30,
                MaxLength = 5
            };
            grid.Children.Add(tb);

            var btn = new Button {
                Width = 85,
                Margin = new Thickness(5),
                Content = "INS",
                HorizontalAlignment = HorizontalAlignment.Right,
                Padding = new Thickness(0),
            };
            btn.Click += (o, args) => {
                ushort value;
                if (!ushort.TryParse(tb.Text, out value)) {
                    MessageBox.Show("Value must be between 0 and 65535");
                    tb.Focus();
                    return;
                }
                SendBox.Text += (char)value;
                tb.Text = "";
                if (IsolatedStorageSettings.ApplicationSettings.Contains("ux.recursivealtcodeentry")) {
                    tb.Focus();
                } else {
                    pop.IsOpen = false;
                    LayoutRoot.Children.Remove(pop);
                    SendBox.Focus();
                    SendBox.Select(SendBox.Text.Length, 0);
                }
            };
            grid.Children.Add(btn);

            var border = new Border {
                Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x1A, 0x91, 0xDB)),
                Child = grid
            };

            pop = new Popup {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(0, 0, 0, 75),
                Width = 250,
                Height = 75,
                Child = border
            };
            LayoutRoot.Children.Add(pop);

            pop.IsOpen = true;

            tb.Focus();
        }
 private InputScope GetTextInputScope()
 {
     InputScope scope = new InputScope();
     InputScopeName name = new InputScopeName();
     name.NameValue = InputScopeNameValue.Text;
     scope.Names.Add(name);
     return scope;
 }
Beispiel #32
0
        protected virtual InputScope GetInputScope(InputType inputType)
        {
            var name = new InputScopeName();
            var scope = new InputScope();

            switch (inputType) {
                case InputType.Email:
                    name.NameValue = InputScopeNameValue.EmailNameOrAddress;
                    break;

                case InputType.Name:
                    name.NameValue = InputScopeNameValue.PersonalFullName;
                    break;

                case InputType.Number:
                    name.NameValue = InputScopeNameValue.Number;
                    break;

                case InputType.Phone:
                    name.NameValue = InputScopeNameValue.NameOrPhoneNumber;
                    break;

                case InputType.Url:
                    name.NameValue = InputScopeNameValue.Url;
                    break;

                default:
                    name.NameValue = InputScopeNameValue.Default;
                    break;
            }
            scope.Names.Add(name);
            return scope;
        }
Beispiel #33
0
        private void SetInputScope(TextBox curBox, int inputMode)
        {
            // TextBox.SetInputScope
            InputScope inputScope = new InputScope();
            InputScopeName name = new InputScopeName();

            switch (inputMode)
            {
                case 0:// kEditBoxInputModeAny
                    name.NameValue = InputScopeNameValue.Default;
                    break;
                case 1:// kEditBoxInputModeEmailAddr
                    name.NameValue = InputScopeNameValue.EmailNameOrAddress;
                    break;
                case 2:// kEditBoxInputModeNumeric
                    name.NameValue = InputScopeNameValue.Number;
                    break;
                case 3:// kEditBoxInputModePhoneNumber
                    name.NameValue = InputScopeNameValue.TelephoneNumber;
                    break;
                case 4:// kEditBoxInputModeUrl
                    name.NameValue = InputScopeNameValue.Url;
                    break;
                case 5:// kEditBoxInputModeDecimal
                    name.NameValue = InputScopeNameValue.Digits;
                    break;
                case 6:// kEditBoxInputModeSingleLine
                    name.NameValue = InputScopeNameValue.Default;
                    break;
                default:
                    name.NameValue = InputScopeNameValue.Default;
                    break;
            }

            inputScope.Names.Add(name);
            curBox.InputScope = inputScope;
        }
        ///<summary>
        /// Converts the given value to InputScope type
        ///</summary>
        /// <param name="context">
        /// The conversion context.
        /// </param>
        /// <param name="culture">
        /// The current culture that applies to the conversion.
        /// </param>
        /// <param name="source">
        /// The source object to convert from.
        /// </param>
        /// <returns>
        /// InputScope object with a specified scope name, otherwise InputScope with Default scope.
        /// </returns>

        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object source)
        {
            string stringSource = source as string;
            InputScopeNameValue nameValue = InputScopeNameValue.Default;
            InputScopeName inputScopeName;

            if (null != stringSource)
            {
                stringSource = stringSource.Trim();

                if (-1 != stringSource.LastIndexOf('.'))
                    stringSource = stringSource.Substring(stringSource.LastIndexOf('.')+1);
                    
                if (!stringSource.Equals(String.Empty))
                {
                
                    nameValue = (InputScopeNameValue)Enum.Parse(typeof(InputScopeNameValue), stringSource);
                }
            }
            
            inputScopeName = new InputScopeName();
            inputScopeName.NameValue = nameValue;
            return inputScopeName;    
        }