Beispiel #1
0
 private void NameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         NumberTextBox.Focus(FocusState.Keyboard);
     }
 }
        /// <summary>
        /// Confirms whether the user input is valid. (Positive integers only).
        /// </summary>
        private void ConfirmInput()
        {
            //get number
            int copies;

            if (int.TryParse(NumberTextBox.Text, out copies) && copies > 0)  //if input is positive integer
            {
                //show confirm message box and only proceed if user clicks Yes
                if (MessageBox.Show("Confirm", "Confirm", MessageBoxButton.YesNo,
                                    MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    if (addOrRemove == AddOrRemove.Add)  //if window is in Add state
                    {
                        AddCopy(copies);
                    }
                    else if (addOrRemove == AddOrRemove.Remove)  //if window is in Remove state
                    {
                        RemoveCopy(copies);
                    }
                }
            }
            else  //input is not valid
            {
                ErrorLabel.Content = "Please enter a positive integer larger than 0";
                NumberTextBox.Focus();
                return;
            }
        }
Beispiel #3
0
        private void GoTo_OnLoaded(object sender, RoutedEventArgs e)
        {
            GoToLabel.Content     = String.Format(GoToLabel.Content.ToString(), Maximum);
            NumberTextBox.Maximum = Maximum;

            NumberTextBox.SelectAll();
        }
Beispiel #4
0
 // '.' Button Click Event.
 private void BtnPoint_Click(object sender, EventArgs e)
 {
     // Check If NumberTextBox Contains A Number That Is Already Decimal.
     if (NumberTextBox.Text.Contains(".") != true)
     {
         NumberTextBox.AppendText(".");
     }
 }
 private void ClearButton_Click(object sender, EventArgs e)
 {
     // Clear textbox  label and list box
     NumberTextBox.Clear();
     AnswerLabel.Text                = "";
     FromListBox.SelectedIndex       = -1;
     ToDistanceListBox.SelectedIndex = -1;
 }
        /// <summary>
        /// Saves the values in the EditViews controls and returns them as a Dictionary with key = attributename, value = the value from the control
        /// </summary>
        /// <param name="controls">The list of controls in the EditView</param>
        /// <returns>Key = attributename, value = the value from the control</returns>
        private Dictionary <string, object> ViewControlsToDictionary(Control.ControlCollection controls)
        {
            Dictionary <string, object> controlValues = new Dictionary <string, object>();

            foreach (Control c in controls)
            {
                if (c is NumberTextBox)
                {
                    NumberTextBox numTextBox = (NumberTextBox)c;
                    if (numTextBox.Text.Length > 0)
                    {
                        try
                        {
                            controlValues[c.Name] = Int32.Parse(numTextBox.Text);
                        }
                        catch (Exception e)
                        {
                            if (e is OverflowException || e is FormatException)
                            {
                                EditView.SetResponseLabel("Ett nummer är för stort, försök igen");
                            }
                            return(null);
                        }
                    }
                    else
                    {
                        controlValues[c.Name] = null;
                    }
                }
                else if (c is TextBox)
                {
                    TextBox txtBox = (TextBox)c;
                    controlValues[c.Name] = String.IsNullOrEmpty(txtBox.Text) ? null : txtBox.Text;
                }
                else if (c is DateTimePicker)
                {
                    controlValues[c.Name] = ((DateTimePicker)c).Value;
                }
                else if (c is ComboBox)
                {
                    IModel selectedIModel = (IModel)((ComboBox)c).SelectedItem;
                    if (selectedIModel != null)
                    {
                        controlValues[c.Name] = selectedIModel.GetIdentifyingAttributes().First().Value;
                    }
                    else
                    {
                        controlValues[c.Name] = null;
                    }
                }
                else if (c is CheckedListBox)
                {
                    // Skip, handled after the main-query is done
                }
            }
            return(controlValues);
        }
Beispiel #7
0
 private void NumBox_KeyUp(object sender, KeyEventArgs e)
 {
     if (Key.Enter == e.Key)
     {
         NumberTextBox numBox = (sender as NumberTextBox);
         PropertyInfo  prop   = numBox.Tag as PropertyInfo;
         int           number = numBox.Number;
         prop.SetValue(_selectedObject, number);
     }
 }
 protected virtual NumberTextBox CreateMinMaxTextBox(float value, int index)
 {
     NumberTextBox box = new NumberTextBox();
     box.Tag = index;
     box.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
     box.BorderStyle = BorderStyle.None;
     box.Text = value.ToString("f1", CultureInfo.InvariantCulture.NumberFormat);
     box.Margin = new Padding(0);
     box.TextChanged += new EventHandler(this.tb_minmax_TextChanged);
     return box;
 }
Beispiel #9
0
        private void comNumTb__KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Enter)
            {
                return;
            }
            NumberTextBox  tb = sender as NumberTextBox;
            ComponentField cf = tb.Tag as ComponentField;

            cf.SetValue(tb.Text);
        }
Beispiel #10
0
 public override void NumberTextBoxChanged(NumberTextBox box)
 {
     if (box == sizeX)
     {
         editor.SetBoundsSize(sizeX.Value, editor.BoundsHeight);
     }
     else if (box == sizeY)
     {
         editor.SetBoundsSize(editor.BoundsWidth, sizeY.Value);
     }
 }
        public NumberEditorView()
        {
            DataContextChanged += OnDataContextChanged;
            InitializeComponent();
            var textBinding = new Binding("DoubleValue")
            {
                Converter = CurrentConverter = new NumberTextConverter()
            };

            NumberTextBox.SetBinding(System.Windows.Controls.TextBox.TextProperty, textBinding);
        }
Beispiel #12
0
 void ApplyBtnClick(object sender, EventArgs e)
 {
     if (RemoveRadioButton.Checked)
     {
         m_ApplyData            = true;
         ControlPanel.Enabled   = false;
         SequencesPanel.Enabled = false;
         NumberPanel.Enabled    = false;
         ModePanel.Enabled      = false;
         if (!m_bw.IsBusy)
         {
             m_bw.RunWorkerAsync();
         }
     }
     else
     {
         if (string.IsNullOrWhiteSpace(SequencesTextBox.Text))
         {
             MessageBox.Show(
                 "Введите название Серии.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning
                 );
             SequencesTextBox.Focus();
         }
         else
         {
             if (!string.IsNullOrWhiteSpace(NumberTextBox.Text))
             {
                 int number = 0;
                 if (!int.TryParse(NumberTextBox.Text, out number))
                 {
                     MessageBox.Show(
                         "Номер Серии не может символы и/или пробелы! Введите число, или оставьте поле пустым, если у данной книги нет номера серии.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error
                         );
                     NumberTextBox.Focus();
                     return;
                 }
             }
             m_ApplyData            = true;
             ControlPanel.Enabled   = false;
             SequencesPanel.Enabled = false;
             NumberPanel.Enabled    = false;
             ModePanel.Enabled      = false;
             if (!m_bw.IsBusy)
             {
                 m_bw.RunWorkerAsync();
             }
         }
     }
 }
Beispiel #13
0
        private NumberTextBox createNumberTextBox()
        {
            var numBox = new NumberTextBox();

            numBox.Margin          = new Thickness(0, 2, 2, 0);
            numBox.BorderThickness = new Thickness(0);
            Grid.SetColumn(numBox, 1);
            Grid.SetRow(numBox, _panelParent.RowDefinitions.Count - 1);
            var template = (ControlTemplate)_View.Resources["validationErrorTemplate"];

            Validation.SetErrorTemplate(numBox, template);

            _panelParent.Children.Add(numBox);

            return(numBox);
        }
        public void TestNumbersOnly()
        {
            NumberTextBox numbers = null;

            AddStep("add number textbox", () =>
            {
                textBoxes.Add(numbers = new NumberTextBox
                {
                    PlaceholderText          = @"Only numbers",
                    Size                     = new Vector2(500, 30),
                    TabbableContentContainer = textBoxes
                });
            });

            AddStep(@"set number text", () => numbers.Text = @"1h2e3l4l5o6");
            AddAssert(@"number text only numbers", () => numbers.Text == @"123456");
        }
Beispiel #15
0
        public void TestNumbersOnly()
        {
            NumberTextBox numbers = null;

            AddStep("add number textbox", () =>
            {
                textBoxes.Add(numbers = new NumberTextBox
                {
                    PlaceholderText          = @"Only numbers",
                    Size                     = new Vector2(500, 30),
                    TabbableContentContainer = textBoxes
                });
            });

            // <c>U+FF11</c> is the Unicode FULLWIDTH DIGIT ONE character, treated as a number by char.IsNumber()
            AddStep(@"set number text", () => numbers.Text = "1h2e3l4l5o6\uFF11");
            AddAssert(@"number text only numbers", () => numbers.Text == @"123456");
        }
Beispiel #16
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            string name      = NameTextBox.Text;
            string writter   = WritterTextBox.Text;
            string time      = TimeTextBox.Text;
            string publisher = PublishTextBox.Text;
            string page      = PageTextBox.Text;
            string id        = NumberTextBox.Text;

            Thread thread = new Thread(threadStart);

            thread.Start();

            Book deletebook = new Book();

            for (int i = 0; i < remineder.Count; i++)
            {
                if (name == remineder[i].name && writter == remineder[i].writter && time == remineder[i].time &&
                    publisher == remineder[i].publisher && page == remineder[i].page && id == remineder[i].ID)
                {
                    IsRightForm isright = new IsRightForm();
                    if (isright.show())
                    {
                        deletebook.Delete(i);
                        BookDataGridView.Rows.Clear();
                        NumberTextBox.Clear();
                        NameTextBox.Clear();
                        WritterTextBox.Clear();
                        TimeTextBox.Clear();
                        PublishTextBox.Clear();
                        PageTextBox.Clear();
                        ShowAllBook();
                        break;
                    }
                }
                else if (i == remineder.Count - 1)
                {
                    MessageBox.Show("此书不存在");
                    break;
                }
            }
            //摧毁线程
            thread.Abort();
        }
        private void AddProviderbtn_Click(object sender, RoutedEventArgs e)
        {
            int i1 = 0, i2 = 0;

            foreach (UIElement elem in stacktextbox.Children)
            {
                TextBox textbox = new TextBox();
                if (elem is TextBox)
                {
                    textbox = elem as TextBox;
                    i1++;
                    if (textbox.Text != "" && !Validation.GetHasError(textbox))
                    {
                        i2++;
                    }
                }
            }

            if (i1 == i2 && CheckCompany(CompanyTextBox.Text))
            {
                Provider provider = new Provider();
                provider.CheckingAccount = AccountTextBox.Text;
                provider.PhoneNumber     = NumberTextBox.Text;
                provider.TypeOfProduct   = TypeTextBox.Text;
                provider.СompanyName     = CompanyTextBox.Text;
                db.Providers.Add(provider);
                db.SaveChanges();
                MessageBox.Show("Добавлено!");
                NameboxRefresh();
                AccountTextBox.Clear();
                NumberTextBox.Clear();
                TypeTextBox.Clear();
                CompanyTextBox.Clear();
            }
            else if (i1 != i2)
            {
                MessageBox.Show("Данные введены неккоректно!");
            }
            else
            {
                MessageBox.Show("Такая фирма уже существует!");
            }
        }
Beispiel #18
0
        public MapOptionsMenu(Scenes.Editor e)
            : base(e)
        {
            Vector2 zero = Vector2.Zero;

            sizeX     = new NumberTextBox(zero, zero, Game1.BlueColor, defIn, e.BoundsWidth, 10, 5000, this);
            sizeY     = new NumberTextBox(zero, zero, Game1.BlueColor, defIn, e.BoundsHeight, 10, 5000, this);
            sizeXText = new JustText(zero, zero, "Bounds.X:", 10);
            sizeYText = new JustText(zero, zero, "Bounds.Y:", 10);

            gridSize     = new Slider(zero, zero, Game1.BlueColor, Game1.RedColor, 10, 1, 100, editor.GridSize, true);
            gridSizeText = new JustText(zero, zero, "GridSize:", 10);
            gridPlus     = new Button(zero, zero, Game1.GreenColor, "Grid++", 10);
            gridMinus    = new Button(zero, zero, Game1.RedColor, "Grid--", 10);

            save = new Button(zero, zero, Game1.BlueColor, "Save as", defIn);
            exit = new Button(zero, zero, Game1.RedColor, "Exit to menu", defIn);

            backgroundType     = new Slider(zero, zero, Game1.BlueColor, Game1.RedColor, defIn, 1, 3, editor.BackgroundType, true);
            backgroundTypeText = new JustText(zero, zero, "Background:", defIn);
        }
        /// <summary>
        /// Sets the CopiesResult Property to copies value passed in argument and closes the window if copies is a valid amount.
        /// If copies exceeds the amount of copis available for checkout, then displays an error and focuses back on NumberTextBox
        /// </summary>
        /// <param name="copies">number of copies to remove</param>
        private void RemoveCopy(int copies)
        {
            //Check if can remove that amount of copies
            BookDetails bd = Owner as BookDetails;

            if (bd != null)
            {
                if (copies <= bd.Book.CopiesAvailable)  //if copies is a valid number
                {
                    CopiesResult = copies;
                    DialogResult = true;
                    this.Close();
                }
                else  //if copies is not a valid number
                {
                    ErrorLabel.Content = String.Format("Only {0} copies are available to remove", bd.Book.CopiesAvailable);
                    NumberTextBox.Focus();
                    return;
                }
            }
        }
Beispiel #20
0
 private void ClearData_Click(object sender, RoutedEventArgs e)
 {
     activeSkiRun.ClearCompData();             //Calls a method in the SkiRun class which empties the dictionary and the lists.
     IncomeTextBox.Clear();                    //Clears the income textbox.
     TotalScoresTextBox.Clear();               //Clears the total scores text box.
     EntriesTextBox.Clear();                   //Clears the ammount of entries the competiton had.
     TopThreeScoresTextBox.Clear();            //Clears the high scores text box so data doesn't overlap.
     AgeMinTextBox.Clear();                    //Clears the minimum age textbox.
     AgeMaxTextBox.Clear();                    //Clears the maximum age textbox.
     AgeAveTextBox.Clear();                    //Clears the average age textbox.
     AgeModeTextBox.Clear();                   //Clears the mode age textbox.
     activeSkiRun.CompetitorAges.Clear();      //Clears the ages list.
     CompetitorNumberTextBox.Text = "000000";  //Resets the competitor number text box.
     NumberTextBox.Clear();                    //Clears the number text box.
     NameTextBox.Clear();                      //Clears the name text box.
     AddressTextBox.Clear();                   //Clears the address text box.
     DetailsTextBox.Clear();                   //Clears the details text box.
     ScoreTextBox.Clear();                     //Clears the scores text box.
     SearchTextBox.Clear();                    //Clears the seach by name text box.
     TagTextBox.Clear();                       //Clears the tag text box.
     SearchByName.Items.Clear();               //Clears the search by name combo box.
 }
Beispiel #21
0
        public ResizeDialog()
        {
            widthEdit  = new NumberTextBox();
            heightEdit = new NumberTextBox();
            Button okButton     = new Button();
            Button cancelButton = new Button();

            AcceptButton = okButton;
            CancelButton = cancelButton;

            okButton.Text     = "Ok";
            cancelButton.Text = "Cancel";

            okButton.Click     += new EventHandler(OnOk);
            cancelButton.Click += new EventHandler(OnCancel);

            BoxSizer sizer = new VerticalBoxSizer()
                             .Add(
                new HorizontalBoxSizer()
                .Add("New width")
                .Add(widthEdit, SizerFlags.Expand)
                )
                             .Add(
                new HorizontalBoxSizer()
                .Add("New height")
                .Add(heightEdit, SizerFlags.Expand)
                )
                             .Add(
                new HorizontalBoxSizer()
                .Add(okButton)
                .Add(cancelButton)
                )
            ;

            Controls.Add(sizer);
            sizer.Dock = DockStyle.Fill;
        }
        private void InitControls()
        {
            int tableRow    = 0;
            int tableColumn = 0;

            /***
             * FontAlignmentTestWidget test = new FontAlignmentTestWidget ();
             * this.AddChild (test, tableRow++, tableColumn);
             ***/

            m_Label1 = new CaptionLabel("label1");
            //m_Label1.Styles.GetStyle (WidgetStates.Default).BackColorBrush.Color = SolarizedColors.Base2;
            m_Label1.Style.BackColorBrush.Color = Theme.Colors.Base2;
            m_Label1.Dock = Docking.Fill;
            m_Label1.Text = "Check Boxes".ToUpper();
            this.AddChild(m_Label1, tableRow++, tableColumn);

            m_CheckBox1 = new CheckBox("checkbox1", "CheckBox 1");
            this.AddChild(m_CheckBox1, tableRow++, tableColumn);

            m_CheckBox3         = new CheckBox("checkbox3", "CheckBox 3 (disabled)");
            m_CheckBox3.Enabled = false;
            this.AddChild(m_CheckBox3, tableRow++, tableColumn);

            m_ToggleCheckBox         = new ToggleCheckBox("togglecheckbox", "Option 1");
            m_ToggleCheckBox.Checked = true;
            this.AddChild(m_ToggleCheckBox, tableRow++, tableColumn);

            m_Label2 = new CaptionLabel("label2");
            m_Label2.Style.BackColorBrush.Color = Theme.Colors.Base2;
            m_Label2.Dock = Docking.Fill;
            m_Label2.Text = "Radio Buttons".ToUpper();
            this.AddChild(m_Label2, tableRow++, tableColumn);

            m_RadioButton1         = new RadioButton("radiobutton1", "RadioButton 1");
            m_RadioButton1.Checked = true;
            this.AddChild(m_RadioButton1, tableRow++, tableColumn);

            m_RadioButton2 = new RadioButton("radiobutton2", "RadioButton 2");
            this.AddChild(m_RadioButton2, tableRow++, tableColumn);

            m_RadioButton3 = new RadioButton("radiobutton3", "RadioButton 3");
            this.AddChild(m_RadioButton3, tableRow++, tableColumn);

            m_Label3 = new CaptionLabel("label3");
            m_Label3.Style.BackColorBrush.Color = Theme.Colors.Base2;
            m_Label3.Dock = Docking.Fill;
            m_Label3.Text = "Progress Bars".ToUpper();
            this.AddChild(m_Label3, tableRow++, tableColumn);

            m_ProgressBar         = new ProgressBar("ProgressBar1");
            m_ProgressBar.Value   = 0.625f;
            m_ProgressBar.Tooltip = "Click to animate..";
            m_ProgressBar.Click  += delegate {
                ParentWindow.Animator.AddAnimation(m_ProgressBar, "Value", 0, 1, 5);
            };
            m_ProgressBar.AnimationCompleted += delegate {
                m_ProgressBar.Value = 0.625f;
                (ParentWindow as ApplicationWindow).ShowNotification("Progressbar animation completed, state was reset to it's former value.", ColorContexts.Information);
            };
            this.AddChild(m_ProgressBar, tableRow++, tableColumn);


            /*** ***/
            // Circle Sliders in a Sub-Container
            m_CircleSliderSubContainer        = new TableLayoutContainer("m_CircleSliderSubContainer");
            m_CircleSliderSubContainer.Margin = new Padding(0, 0, 0, 16);

            m_CircleSlider1         = new CircleSlider("CircleSlider1", ColorContexts.Information);
            m_CircleSlider1.Value   = 0.75f;
            m_CircleSlider1.Tooltip = "Click to animate..";
            m_CircleSliderSubContainer.AddChild(m_CircleSlider1, 0, 0);
            m_CircleSlider1.Click += delegate {
                ParentWindow.Animator.AddAnimation(m_CircleSlider1, "Value", 0, 1, 5);
            };
            m_CircleSlider1.AnimationCompleted += delegate {
                m_CircleSlider1.Value = 0.75f;
                (ParentWindow as ApplicationWindow).ShowNotification("The animation was successfully completed.", ColorContexts.Success);
            };

            m_CircleSlider2             = new CircleSlider("CircleSlider1", ColorContexts.Information);
            m_CircleSlider2.Value       = 0.333f;
            m_CircleSlider2.CustomColor = Theme.Colors.Magenta;
            m_CircleSlider2.Tooltip     = "Drag up and down\nto change the value.";
            m_CircleSliderSubContainer.AddChild(m_CircleSlider2, 0, 1);

            this.AddChild(m_CircleSliderSubContainer, tableRow++, tableColumn);


            // >>> New Column >>>

            tableRow    = 0;
            tableColumn = 1;

            cmdDefaultButton        = new Button("cmdDefaultButton", "Default Button", ColorContexts.Default);
            cmdDefaultButton.Click += delegate {
                ParentWindow.ShowInfo("You pressed the default button. Great.");
            };
            this.AddChild(cmdDefaultButton, tableRow++, tableColumn);

            cmdShowInfo        = new Button("cmdShowInfo", "Info MessageBox", (char)FontAwesomeIcons.fa_info_circle, ColorContexts.Information);
            cmdShowInfo.Click += delegate {
                ParentWindow.ShowInfo("This is an info.");
            };
            this.AddChild(cmdShowInfo, tableRow++, tableColumn);

            cmdShowWarning        = new Button("cmdShowWarning", "Warning MessageBox", ColorContexts.Warning);
            cmdShowWarning.Click += delegate {
                ParentWindow.ShowWarning("This is a warning.");
            };
            this.AddChild(cmdShowWarning, tableRow++, tableColumn);

            cmdShowError        = new Button("cmdShowError", "Error MessageBox", ColorContexts.Danger);
            cmdShowError.Click += delegate {
                try {
                    throw new Exception("This is a sample error.");
                } catch (Exception ex) {
                    string errMsg = ex.Message + "\n" + Concurrency.GetStackTrace();
                    ParentWindow.ShowError(errMsg);
                }
            };
            this.AddChild(cmdShowError, tableRow++, tableColumn);

            cmdShowQuestion        = new Button("cmdShowQuestion", "Question MessageBox", ColorContexts.Question);
            cmdShowQuestion.Click += delegate {
                ParentWindow.ShowQuestion("This is a question. Are you sure ?");
            };
            this.AddChild(cmdShowQuestion, tableRow++, tableColumn);

            m_TextBox1      = new TextBox("TextBox1");
            m_TextBox1.Text = "Abcd Efg Hijk";
            this.AddChild(m_TextBox1, tableRow++, tableColumn);

            m_ShowPasswordChar                 = new CheckBox("ShowPasswordChar", "Password visible");
            m_ShowPasswordChar.Checked         = true;
            m_ShowPasswordChar.CheckedChanged += (object sender, EventArgs eCheckedChanged) =>
                                                 m_TextBox1.PasswordChar = m_ShowPasswordChar.Checked ? (char)0 : TextBox.DefaultPasswortChar;
            this.AddChild(m_ShowPasswordChar, tableRow++, tableColumn);

            m_NumberTextBox1       = new NumberTextBox("NumberTextBox1");
            m_NumberTextBox1.Value = 123.45m;
            this.AddChild(m_NumberTextBox1, tableRow++, tableColumn);

            m_ButtonTextBox1 = new ButtonTextBox("ButtonTextBox1", (char)FontAwesomeIcons.fa_send);
            m_ButtonTextBox1.Button.Click += delegate {
                (ParentWindow as ApplicationWindow).ShowNotification("Your email has been sent.", ColorContexts.Success);
            };
            this.AddChild(m_ButtonTextBox1, tableRow++, tableColumn);

            m_ComboListBox1 = new ComboListBox("ComboListBox1");
            m_ComboListBox1.Items.Add("Apple", 1);
            m_ComboListBox1.Items.Add("Orange", 2);
            m_ComboListBox1.Items.Add("Banana", 3);
            m_ComboListBox1.Items.Add("Cherry", 4);
            m_ComboListBox1.Items.Add("Pineapple", 5);
            m_ComboListBox1.SelectedIndex = 0;
            this.AddChild(m_ComboListBox1, tableRow++, tableColumn);

            m_ComboBox1 = new ComboBox("ComboBox1");
            m_ComboBox1.Items.Add("Apple", 1);
            m_ComboBox1.Items.Add("Orange", 2);
            m_ComboBox1.Items.Add("Banana", 3);
            m_ComboBox1.Items.Add("Cherry", 4);
            m_ComboBox1.Items.Add("Pineapple", 5);
            m_ComboBox1.SelectedIndex = 0;
            this.AddChild(m_ComboBox1, tableRow++, tableColumn);
        }
Beispiel #23
0
 public void Clean()
 {
     NumberTextBox.Text = string.Empty;
     NumberTextBox.Focus();
 }
Beispiel #24
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            DateTime currentDate;

            currentDate    = DateTime.Now;
            DateLabel.Text = currentDate.ToShortDateString();

            DateTime currentTime;

            currentTime    = DateTime.Now;
            TimeLabel.Text = currentTime.ToShortTimeString();

            OutputLabel.Text = string.Empty;

            if (FirstNameTextBox.Text == string.Empty)
            {
                OutputLabel.Text = "Must enter a first name";
                FirstNameTextBox.Focus();
                return;
            }

            if (LastNameTextBox.Text == string.Empty)
            {
                OutputLabel.Text = "Must enter a last name";
                LastNameTextBox.Focus();
                return;
            }

            if (AreaCodeTextBox.Text == string.Empty)
            {
                OutputLabel.Text = "Must enter an area code";
                AreaCodeTextBox.Focus();
                return;
            }

            if (AreaCodeTextBox.Text.Length < 3)
            {
                OutputLabel.Text     = "Area code must be 3 digits";
                AreaCodeTextBox.Text = string.Empty;
                AreaCodeTextBox.Focus();
                return;
            }

            Int32 AreaCodeEnterednumber;

            if (!Int32.TryParse(AreaCodeTextBox.Text, out AreaCodeEnterednumber))
            {
                OutputLabel.Text     = "Area code must be 3 digits";
                AreaCodeTextBox.Text = string.Empty;
                return;
            }

            if (ExchangeTextBox.Text == string.Empty)
            {
                OutputLabel.Text = "Must enter an exchange";
                ExchangeTextBox.Focus();
                return;
            }

            if (ExchangeTextBox.Text.Length < 3)
            {
                OutputLabel.Text     = "Exchange must be 3 digits";
                ExchangeTextBox.Text = string.Empty;
                ExchangeTextBox.Focus();
                return;
            }

            Int32 ExchangeEnterednumber;

            if (!Int32.TryParse(ExchangeTextBox.Text, out ExchangeEnterednumber))
            {
                OutputLabel.Text     = "Exchange must be 3 digits";
                ExchangeTextBox.Text = string.Empty;
                ExchangeTextBox.Focus();
                return;
            }

            if (NumberTextBox.Text == string.Empty)
            {
                OutputLabel.Text = "Must enter number";
                NumberTextBox.Focus();
                return;
            }

            if (NumberTextBox.Text.Length < 4)
            {
                OutputLabel.Text   = "Number must be 4 digits";
                NumberTextBox.Text = string.Empty;
                NumberTextBox.Focus();
                return;
            }

            Int32 NumberEnterednumber;

            if (!Int32.TryParse(NumberTextBox.Text, out NumberEnterednumber))
            {
                OutputLabel.Text   = "Number must be 4 digits";
                NumberTextBox.Text = string.Empty;
                NumberTextBox.Focus();
                return;
            }

            if (EmailTextBox.Text.Length < 5)
            {
                OutputLabel.Text = "Must be at least 5 characters";
                return;
            }

            if (!EmailTextBox.Text.Contains("@"))
            {
                OutputLabel.Text = "Must contain @";
                return;
            }

            if (EmailTextBox.Text.Substring(0, 1) == "@" || EmailTextBox.Text.Substring(EmailTextBox.Text.Length - 2, 1) == "@" || EmailTextBox.Text.Substring(EmailTextBox.Text.Length - 1, 1) == "@")
            {
                OutputLabel.Text = "@ Character may not be the 1st character nor one of the last 2";
                return;
            }

            if (EmailTextBox.Text.Substring(2, 1) == "." || EmailTextBox.Text.Substring(EmailTextBox.Text.Length - 1, 1) == ".")
            {
            }
        }
Beispiel #25
0
        private void FindCompetitor()                                                                  //Set up to find the competitors by their number.
        {
            DetailsTextBox.Clear();                                                                    //Clears the details textbox.
            Competitor editSkier;                                                                      //Makes aninstance of the Competitor class.

            if (SearchTextBox.Text.Trim() != "" && NumberTextBox.Text.Trim() != "")                    //You can only use on search method so if there is text in both it will be rejected.
            {
                MessageBox.Show("Please use only one search method!");                                 //The error message.
            }
            else if (SearchByName.Text.Trim() == "" && NumberTextBox.Text.Trim() == "")                //If there is no text in either search methods then the search will fail.
            {
                editSkier = null;                                                                      //There's no competitor.
                MessageBox.Show("There is no competitor with that number or name! Please try again."); //The error message.
                NameTextBox.Clear();                                                                   //Clears the name text box.
                AddressTextBox.Clear();                                                                //Clears the address text box.
                ScoreTextBox.Clear();                                                                  //Clears the score text box.
                NumberTextBox.Clear();                                                                 //Clears number text box.
                TagTextBox.Clear();                                                                    //Clears the tag text box.
            }

            //***NOTE*** - This is a very inefficient way to seach. I have the same code twice for each search method because I didn't know how to differentiate between the two.

            else if (SearchByName.Text.Trim() != "")                          //If search by name has some text in it then it will make a competitor.
            {
                editSkier = SkiRun.FindSkierByName(SearchByName.Text.Trim()); //Calls the find competitor by name in the SkiRun class.
                try
                {
                    NameTextBox.Text    = editSkier.GetName().Trim();                                                                                                                                                                                                                                    //Sets the competitor name.
                    AddressTextBox.Text = editSkier.GetAddress().Trim();                                                                                                                                                                                                                                 //Sets the competitor address.
                    ScoreTextBox.Text   = editSkier.GetScore().Trim();                                                                                                                                                                                                                                   //Sets the competitor score.

                    if (editSkier.GetSponsor() == null && editSkier.GetBlood() == null && editSkier.GetNoK() == null)                                                                                                                                                                                    //If there's no sponsor, no blood type and no next of kin then it must be an amateur.
                    {
                        DetailsTextBox.Text = "Class: Amatuer" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £100";                                                                                                                                   //Information show in details text box.
                        TagTextBox.Text     = "Amateur";                                                                                                                                                                                                                                                 //Displays the tag in the tag text box.
                    }
                    else if (editSkier.GetSponsor() != null)                                                                                                                                                                                                                                             //If the sponsor does no equal null then it must be a professional.
                    {
                        DetailsTextBox.Text = "Class: Professional" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £200" + Environment.NewLine + "Sponsor: " + editSkier.GetSponsor();                                                                 //Information show in details text box.
                        TagTextBox.Text     = "Professional";                                                                                                                                                                                                                                            //Displays the tag in the tag text box.
                    }
                    else if (editSkier.GetBlood() != null)                                                                                                                                                                                                                                               //If blood type does not equal null then is must be a celebrity.
                    {
                        DetailsTextBox.Text = "Class: Celebrity" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You do not have to pay." + Environment.NewLine + "Blood Type: " + editSkier.GetBlood() + Environment.NewLine + "Next of Kin: " + editSkier.GetNoK(); //Information show in details text box.
                        TagTextBox.Text     = "Celebrity";                                                                                                                                                                                                                                               //Displays the tag in the tag text box.
                    }
                }
                catch
                {
                    MessageBox.Show("Could not find competitor!");  //If the user types a name it cannot find then it will display this.
                }
            }
            else if (NumberTextBox.Text.Trim() != "")                    //If the number text box has something in it then it will use this method.
            {
                editSkier = SkiRun.FindSkier(NumberTextBox.Text.Trim()); //Calls the find competitor in the SkiRun class.
                try
                {
                    NameTextBox.Text    = editSkier.GetName();                                                                                                                                                                                                                                           //Sets the competitor name.
                    AddressTextBox.Text = editSkier.GetAddress();                                                                                                                                                                                                                                        //Sets the competitor address.
                    ScoreTextBox.Text   = editSkier.GetScore();                                                                                                                                                                                                                                          //Sets the competitor score.

                    if (editSkier.GetSponsor() == null && editSkier.GetBlood() == null && editSkier.GetNoK() == null)                                                                                                                                                                                    //If there's no sponsor, no blood type and no next of kin then it must be an amateur.
                    {
                        DetailsTextBox.Text = "Class: Amatuer" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £100";                                                                                                                                   //Information show in details text box.
                        TagTextBox.Text     = "Amateur";                                                                                                                                                                                                                                                 //Displays the tag in the tag text box.
                    }
                    else if (editSkier.GetSponsor() != null)                                                                                                                                                                                                                                             //If the sponsor does no equal null then it must be a professional.
                    {
                        DetailsTextBox.Text = "Class: Professional" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You have paid £200" + Environment.NewLine + "Sponsor: " + editSkier.GetSponsor();                                                                 //Information show in details text box.
                        TagTextBox.Text     = "Professional";                                                                                                                                                                                                                                            //Displays the tag in the tag text box.
                    }
                    else if (editSkier.GetBlood() != null)                                                                                                                                                                                                                                               //If blood type does not equal null then is must be a celebrity.
                    {
                        DetailsTextBox.Text = "Class: Celebrity" + Environment.NewLine + "Your age: " + editSkier.GetAge() + Environment.NewLine + "You do not have to pay." + Environment.NewLine + "Blood Type: " + editSkier.GetBlood() + Environment.NewLine + "Next of Kin: " + editSkier.GetNoK(); //Information show in details text box.
                        TagTextBox.Text     = "Celebrity";                                                                                                                                                                                                                                               //Displays the tag in the tag text box.
                    }
                }
                catch
                {
                    MessageBox.Show("Could not find competitor!");  //If the user types a name it cannot find then it will display this.
                }
            }
            //NumberTextBox.Clear();
            //SearchByName.Items.Clear();
            //SearchTextBox.Clear();
        }
Beispiel #26
0
        private void load()
        {
            Children = new Drawable[]
            {
                drawableSkeleton = new DrawableSkeleton(Link.Skeleton)
                {
                    RelativeSizeAxes = Axes.Y,
                    Width            = skeleton_width,
                    BoneClicked      = bone =>
                    {
                        currentBone   = bone;
                        boneText.Text = bone.Name;

                        sensorIdInput.Text     = Link.Get(bone.Name, true)?.SensorId.ToString() ?? string.Empty;
                        sensorIdInput.ReadOnly = false;
                    }
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = skeleton_width
                    },
                    Children = new Drawable[]
                    {
                        new FillFlowContainer
                        {
                            AutoSizeAxes = Axes.Both,
                            Anchor       = Anchor.TopLeft,
                            Origin       = Anchor.TopLeft,
                            Direction    = FillDirection.Vertical,
                            Children     = new Drawable[]
                            {
                                portInput = new BasicTextBox
                                {
                                    PlaceholderText   = "Serial Port",
                                    Size              = new Vector2(250, 20),
                                    CommitOnFocusLost = true
                                },
                                receiverIdInput = new NumberTextBox
                                {
                                    PlaceholderText   = "Receiver ID",
                                    Size              = new Vector2(250, 20),
                                    CommitOnFocusLost = true
                                },
                                boneText = new SpriteText
                                {
                                    Text = "Select a bone",
                                    Font = new FontUsage(size: 24, weight: "Bold")
                                },
                                sensorIdInput = new NumberTextBox
                                {
                                    PlaceholderText   = "Sensor ID",
                                    Size              = new Vector2(250, 20),
                                    CommitOnFocusLost = true,
                                    ReadOnly          = true
                                },
                                new TextButton
                                {
                                    Text   = "Calibrate All",
                                    Size   = new Vector2(250, 20),
                                    Action = () =>
                                    {
                                        Link.CalibrateAll();
                                    }
                                }
                            }
                        }
                    }
                }
            };

            portInput.OnCommit += (sender, newText) =>
            {
                Link.Port = sender.Text;
            };

            receiverIdInput.OnCommit += (sender, newText) =>
            {
                if (sender.Text == string.Empty)
                {
                    return;
                }

                Link.ReceiverId = int.Parse(sender.Text);
            };

            sensorIdInput.OnCommit += (sender, newText) =>
            {
                if (sender.Text == string.Empty)
                {
                    return;
                }

                var id = int.Parse(sender.Text);
                if (currentBone == null)
                {
                    return;
                }

                var existing = Link.Get(currentBone.Name, true) ?? Link.Get(id, true);

                if (existing == null)
                {
                    Link.Register(currentBone.Name, id);
                }
                else
                {
                    Link.UpdateLink(currentBone.Name, id);
                }
            };
        }
Beispiel #27
0
        public IDMigrationPanel(EditorScreen e)
        {
            editorScreen = e;

            Size         = new Vector2(700, 650);
            Anchor       = Anchor.Centre;
            Origin       = Anchor.Centre;
            CornerRadius = 10;
            Masking      = true;

            for (var i = 0; i < 4; i++)
            {
                stepLists[i] = GetNewStepList(Editor, (IDMigrationMode)i);
            }

            AddInternal(new Container
            {
                RelativeSizeAxes = Axes.Both,
                CornerRadius     = 10,
                Masking          = true,
                Children         = new Drawable[]
                {
                    TabControl = new IDMigrationTabControl(),
                    new Container
                    {
                        Size         = new Vector2(700, 650 - IDMigrationTabControl.DefaultHeight),
                        Y            = IDMigrationTabControl.DefaultHeight,
                        CornerRadius = 10,
                        Masking      = true,
                        Children     = new Drawable[]
                        {
                            new Box
                            {
                                RelativeSizeAxes = Axes.Both,
                                Colour           = FromHex("1a1a1a")
                            },
                            new IDMigrationActionContainer
                            {
                                RelativeSizeAxes = Axes.Both,
                                Children         = new Drawable[]
                                {
                                    stepListContainer = new Container
                                    {
                                        RelativeSizeAxes = Axes.Y,
                                        Width            = 520,
                                        CornerRadius     = 10,
                                        Masking          = true,
                                        Children         = new Drawable[]
                                        {
                                            new Box
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                                Colour           = FromHex("111111")
                                            },
                                            currentStepList = stepLists[0]
                                        }
                                    },
                                    new FillFlowContainer
                                    {
                                        Anchor  = Anchor.TopRight,
                                        Origin  = Anchor.TopRight,
                                        Spacing = new Vector2(5),
                                        Margin  = new MarginPadding
                                        {
                                            Top        = 5,
                                            Horizontal = 10
                                        },
                                        RelativeSizeAxes = Axes.Y,
                                        Width            = 160,
                                        Children         = new Drawable[]
                                        {
                                            GetNewSpriteText("Source From"),
                                            sourceFrom = GetNewNumberTextBox(),
                                            GetNewSpriteText("Source To"),
                                            sourceTo = GetNewNumberTextBox(),
                                            GetNewSpriteText("Target From"),
                                            targetFrom = GetNewNumberTextBox(),
                                            GetNewSpriteText("Target To"),
                                            targetTo = GetNewNumberTextBox()
                                        }
                                    },
                                    new FillFlowContainer
                                    {
                                        Anchor           = Anchor.BottomRight,
                                        Origin           = Anchor.BottomRight,
                                        Direction        = FillDirection.Vertical,
                                        Spacing          = new Vector2(10),
                                        Margin           = new MarginPadding(10),
                                        RelativeSizeAxes = Axes.Y,
                                        Width            = 160,
                                        Children         = new Drawable[]
                                        {
                                            performMigration = GetNewFadeButton(8, "Perform Migration",
                                                                                greenEnabledColor, PerformMigration),
                                            removeSteps = GetNewFadeButton(0, "Remove Steps", redEnabledColor,
                                                                           RemoveSelectedSteps),
                                            cloneSteps = GetNewFadeButton(0, "Clone Steps", grayEnabledColor,
                                                                          CloneSelectedSteps),
                                            deselectAll = GetNewFadeButton(0, "Deselect All", grayEnabledColor,
                                                                           DeselectAll),
                                            selectAll   = GetNewFadeButton(0, "Select All", grayEnabledColor, SelectAll),
                                            loadSteps   = GetNewFadeButton(0, "Load Steps", grayEnabledColor, LoadSteps),
                                            saveStepsAs = GetNewFadeButton(0, "Save Steps As", grayEnabledColor,
                                                                           SaveStepsAs),
                                            saveSteps  = GetNewFadeButton(0, "Save Steps", grayEnabledColor, SaveSteps),
                                            createStep = GetNewFadeButton(0, "Create Step", greenEnabledColor,
                                                                          CreateNewStep)
                                        }
                                    }
                                }
                            }
                        }
                    },
                    notification = new ToastNotification
                    {
                        Anchor = Anchor.BottomCentre,
                        Origin = Anchor.BottomCentre,
                        Size   = new Vector2(200, 30),
                        Margin = new MarginPadding {
                            Bottom = 15
                        },
                        Text = "Finished Operation"
                    }
                }
            });

            TabControl.TabSelected += TabChanged;

            sourceFrom.NumberChanged += HandleSourceFromChanged;
            sourceTo.NumberChanged   += HandleSourceToChanged;
            targetFrom.NumberChanged += HandleTargetFromChanged;
            targetTo.NumberChanged   += HandleTargetToChanged;

            CommonIDMigrationStep.ValueChanged += CommonIDMigrationStepChanged;

            Editor.IDMigrationOperationCompleted += HandleIDMigrationOperationCompleted;

            // After everything's loaded, initialize the property for things to work properly
            UpdateFileDialogBindables(CurrentStepList = currentStepList);

            UpdateFadeButtonEnabledStates();
        }
Beispiel #28
0
 // '9' Button Click Event.
 private void Btn9_Click(object sender, EventArgs e)
 {
     NumberTextBox.AppendText("9");
 }
        private void addFilme(object sender, RoutedEventArgs e)
        {
            OpenConnectionDB();

            string insertFilme = "gestordefilmes.sp_AddFilme";

            Filme f = new Filme();


            if (textBox4.Text.Length == 0)
            {
                MessageBox.Show("Campo 'Titulo' é obrigatorio!");
                return;
            }
            else
            {
                f.titulo = textBox4.Text;
            }


            if (textBox7.Text.Length == 0)
            {
                MessageBox.Show("Campo 'Descrição' é obrigatorio!");
                return;
            }
            else
            {
                f.descricao = textBox7.Text;
            }



            if (comboBox1.SelectedItem == null)
            {
                MessageBox.Show("Campo 'Categoria' é obrigatorio!");
                return;
            }
            else
            {
                f.categoria = comboBox1.SelectedValue.ToString();
            }



            if (rb1.IsChecked == false && rb2.IsChecked == false && rb3.IsChecked == false && rb4.IsChecked == false && rb5.IsChecked == false)
            {
                MessageBox.Show("Campo 'Classificação' é obrigatorio!");
                return;
            }
            else if (rb1.IsChecked == true)
            {
                f.classificacao = 1;
            }
            else if (rb2.IsChecked == true)
            {
                f.classificacao = 2;
            }
            else if (rb3.IsChecked == true)
            {
                f.classificacao = 3;
            }
            else if (rb4.IsChecked == true)
            {
                f.classificacao = 4;
            }
            else if (rb5.IsChecked == true)
            {
                f.classificacao = 5;
            }


            if (NumberTextBox.Text == "")
            {
                MessageBox.Show("Campo 'Duração' é obrigatorio!");
                return;
            }
            else
            {
                f.duracao = Convert.ToInt32(NumberTextBox.Text);
            }


            if (comboBox.SelectedItem == null)
            {
                MessageBox.Show("Campo 'Companhia' é obrigatorio!");
                return;
            }
            f.companhia_id = Convert.ToInt32(comboBox.Text.Split('[', ']')[1]);


            if (comboBox2.SelectedItem == null)
            {
                MessageBox.Show("Campo 'Diretor' é obrigatorio!");
                return;
            }
            f.diretor_id = Convert.ToInt32(comboBox2.Text.Split('[', ']')[1]);


            if (comboBox5.SelectedItem == null)
            {
                MessageBox.Show("Campo 'Realizador' é obrigatorio!");
                return;
            }
            f.realizador_id = Convert.ToInt32(comboBox5.Text.Split('[', ']')[1]);



            SqlCommand insertQuery = new SqlCommand(insertFilme, cnn);

            insertQuery.CommandType = CommandType.StoredProcedure;

            DataTable actors = new DataTable();

            actors.Clear();
            actors.Columns.Add("id");
            foreach (CheckBox s in listBox.Items)
            {
                if (s.IsChecked.HasValue && s.IsChecked.Value)
                {
                    DataRow row = actors.NewRow();
                    row["id"] = s.Content.ToString().Split('[', ']')[1];
                    actors.Rows.Add(row);
                }
            }


            DataTable escritores = new DataTable();

            escritores.Clear();
            escritores.Columns.Add("id");
            foreach (CheckBox s in listBox1.Items)
            {
                if (s.IsChecked.HasValue && s.IsChecked.Value)
                {
                    DataRow row = escritores.NewRow();
                    row["id"] = s.Content.ToString().Split('[', ']')[1];
                    escritores.Rows.Add(row);
                }
            }


            //
            DataTable bandaSonora = new DataTable();

            bandaSonora.Clear();
            bandaSonora.Columns.Add("id");
            foreach (CheckBox s in listBox2.Items)
            {
                if (s.IsChecked.HasValue && s.IsChecked.Value)
                {
                    DataRow row = bandaSonora.NewRow();
                    row["id"] = s.Content.ToString().Split('[', ']')[1];
                    bandaSonora.Rows.Add(row);
                }
            }


            insertQuery.Parameters.AddWithValue("@titulo", f.titulo);
            insertQuery.Parameters.AddWithValue("@descricao", f.descricao);
            insertQuery.Parameters.AddWithValue("@categoria", f.categoria);
            insertQuery.Parameters.AddWithValue("@classificacao", f.classificacao);
            insertQuery.Parameters.AddWithValue("@duracao", f.duracao);
            insertQuery.Parameters.AddWithValue("@idcompanhia", f.companhia_id);
            insertQuery.Parameters.AddWithValue("@iddiretor", f.diretor_id);
            insertQuery.Parameters.AddWithValue("@idrealizador", f.realizador_id);


            SqlParameter param_genre = insertQuery.Parameters.AddWithValue("@Escritor", escritores);

            param_genre.SqlDbType = SqlDbType.Structured;
            param_genre.TypeName  = "gestordefilmes.listaEscritor";

            SqlParameter param_actors = insertQuery.Parameters.AddWithValue("@Elenco", actors);

            param_actors.SqlDbType = SqlDbType.Structured;
            param_actors.TypeName  = "gestordefilmes.listaElenco";

            SqlParameter param_writers = insertQuery.Parameters.AddWithValue("@Banda", bandaSonora);

            param_writers.SqlDbType = SqlDbType.Structured;
            param_writers.TypeName  = "gestordefilmes.listaBanda";


            try
            {
                insertQuery.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERRO ao inserir Filme na Base de Dados", "Gestor de Filmes", MessageBoxButton.OK, MessageBoxImage.Error);
                Console.WriteLine(ex.Message);
                return;
            }

            MessageBox.Show("Filme '" + f.titulo + "' adicionado com sucesso!", "Gestor de Filmes", MessageBoxButton.OK, MessageBoxImage.Information);

            textBox8.Clear();
            textBox4.Clear();
            textBox7.Clear();
            NumberTextBox.Clear();

            comboBox1.SelectedValue = false;
            comboBox.SelectedValue  = false;
            comboBox2.SelectedValue = false;
            comboBox5.SelectedValue = false;

            listBox.Items.Clear();
            listBox1.Items.Clear();
            listBox2.Items.Clear();

            completeCheckedListBox("SELECT id, nome FROM gestordefilmes.udf_Atores()", listBox);

            completeCheckedListBox("SELECT id, titulo FROM gestordefilmes.udf_Musicas()", listBox2);

            completeCheckedListBox("SELECT id, nome FROM gestordefilmes.udf_Escritores()", listBox1);

            rb1.IsChecked = false;
            rb2.IsChecked = false;
            rb3.IsChecked = false;
            rb4.IsChecked = false;
            rb5.IsChecked = false;

            cnn.Close();
        }
        public TestSceneTextBox()
        {
            FillFlowContainer textBoxes = new FillFlowContainer
            {
                Direction = FillDirection.Vertical,
                Spacing   = new Vector2(0, 50),
                Padding   = new MarginPadding
                {
                    Top = 50,
                },
                Anchor           = Anchor.TopCentre,
                Origin           = Anchor.TopCentre,
                RelativeSizeAxes = Axes.Both,
                Size             = new Vector2(0.9f, 1)
            };

            Add(textBoxes);

            textBoxes.Add(new BasicTextBox
            {
                Size = new Vector2(100, 16),
                TabbableContentContainer = textBoxes
            });

            textBoxes.Add(new BasicTextBox
            {
                Text        = @"Limited length",
                Size        = new Vector2(200, 20),
                LengthLimit = 20,
                TabbableContentContainer = textBoxes
            });

            textBoxes.Add(new BasicTextBox
            {
                Text = @"Box with some more text",
                Size = new Vector2(500, 30),
                TabbableContentContainer = textBoxes
            });

            textBoxes.Add(new BasicTextBox
            {
                PlaceholderText          = @"Placeholder text",
                Size                     = new Vector2(500, 30),
                TabbableContentContainer = textBoxes
            });

            textBoxes.Add(new BasicTextBox
            {
                Text                     = @"prefilled placeholder",
                PlaceholderText          = @"Placeholder text",
                Size                     = new Vector2(500, 30),
                TabbableContentContainer = textBoxes
            });

            NumberTextBox numbers;

            textBoxes.Add(numbers = new NumberTextBox
            {
                PlaceholderText          = @"Only numbers",
                Size                     = new Vector2(500, 30),
                TabbableContentContainer = textBoxes
            });

            textBoxes.Add(new BasicTextBox
            {
                Text     = "Readonly textbox",
                Size     = new Vector2(500, 30),
                ReadOnly = true,
                TabbableContentContainer = textBoxes
            });

            FillFlowContainer otherTextBoxes = new FillFlowContainer
            {
                Direction = FillDirection.Vertical,
                Spacing   = new Vector2(0, 50),
                Padding   = new MarginPadding
                {
                    Top  = 50,
                    Left = 500
                },
                Anchor           = Anchor.TopCentre,
                Origin           = Anchor.TopCentre,
                RelativeSizeAxes = Axes.Both,
                Size             = new Vector2(0.8f, 1)
            };

            otherTextBoxes.Add(new BasicTextBox
            {
                PlaceholderText          = @"Textbox in separate container",
                Size                     = new Vector2(500, 30),
                TabbableContentContainer = otherTextBoxes
            });

            otherTextBoxes.Add(new PasswordTextBox
            {
                PlaceholderText          = @"Password textbox",
                Text                     = "Secret ;)",
                Size                     = new Vector2(500, 30),
                TabbableContentContainer = otherTextBoxes
            });

            FillFlowContainer nestedTextBoxes = new FillFlowContainer
            {
                Direction = FillDirection.Vertical,
                Spacing   = new Vector2(0, 50),
                Margin    = new MarginPadding {
                    Left = 50
                },
                RelativeSizeAxes = Axes.Both,
                Size             = new Vector2(0.8f, 1)
            };

            nestedTextBoxes.Add(new BasicTextBox
            {
                PlaceholderText          = @"Nested textbox 1",
                Size                     = new Vector2(457, 30),
                TabbableContentContainer = otherTextBoxes
            });

            nestedTextBoxes.Add(new BasicTextBox
            {
                PlaceholderText          = @"Nested textbox 2",
                Size                     = new Vector2(457, 30),
                TabbableContentContainer = otherTextBoxes
            });

            nestedTextBoxes.Add(new BasicTextBox
            {
                PlaceholderText          = @"Nested textbox 3",
                Size                     = new Vector2(457, 30),
                TabbableContentContainer = otherTextBoxes
            });

            otherTextBoxes.Add(nestedTextBoxes);

            Add(otherTextBoxes);

            //textBoxes.Add(tb = new PasswordTextBox(@"", 14, Vector2.Zero, 300));
            AddStep(@"set number text", () => numbers.Text = @"1h2e3l4l5o6");
            AddAssert(@"number text only numbers", () => numbers.Text == @"123456");
        }
Beispiel #31
0
        private void Load()
        {
            controls = new Dictionary <Controls.Control, PropertyInfo>();
            Type type = SettingInstance.GetType();


            PropertyInfo[] properties  = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            Grid           currentGrid = null;

            foreach (var prop in properties)
            {
                if (Attribute.IsDefined(prop, typeof(InvisibleSettingAttribute)))
                {
                    continue;
                }

                var group = prop.GetCustomAttribute <SettingGroupAttribute>();
                if (group == null || string.IsNullOrWhiteSpace(group.GroupName))
                {
                    currentGrid = GetGrid("");
                }
                else
                {
                    currentGrid = GetGrid(group.GroupName);
                }

                string name     = GetName(prop);
                int    rowCount = currentGrid.RowDefinitions.Count;

                currentGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                currentGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(8)
                });



                object           value        = prop.GetValue(SettingInstance);
                Controls.Control valueControl = null;
                if (value is string || value is int || value is double || value is SolidColorBrush || value is Color)
                {
                    TextBlock tbk = null;
                    if (value is string)
                    {
                        tbk = new TextBlock()
                        {
                            Text = name
                        };
                        valueControl = new FzLib.UI.FlatStyle.TextBox()
                        {
                            Text = value as string
                        };
                    }
                    else if (value is int)
                    {
                        tbk = new TextBlock()
                        {
                            Text = name
                        };
                        valueControl = new NumberTextBox()
                        {
                            MatchMode = NumberTextBox.Mode.IntegerNumber
                        };
                        (valueControl as TextBox).Text = ((int)value).ToString();
                    }
                    else if (value is double)
                    {
                        tbk = new TextBlock()
                        {
                            Text = name
                        };
                        valueControl = new NumberTextBox()
                        {
                            MatchMode = NumberTextBox.Mode.All
                        };
                        (valueControl as TextBox).Text = ((double)value).ToString();
                    }
                    else if (value is SolidColorBrush)
                    {
                        tbk = new TextBlock()
                        {
                            Text = name
                        };
                        valueControl = new FzLib.UI.Picker.ColorPickerTextBox()
                        {
                            ColorBrush = value as SolidColorBrush
                        };
                    }
                    else if (value is Color)
                    {
                        tbk = new TextBlock()
                        {
                            Text = name
                        };
                        valueControl = new FzLib.UI.Picker.ColorPickerTextBox()
                        {
                            ColorBrush = new SolidColorBrush((Color)value)
                        };
                    }
                    currentGrid.Children.Add(tbk);
                    Grid.SetRow(tbk, rowCount);
                    currentGrid.Children.Add(valueControl);
                    Grid.SetRow(valueControl, rowCount);
                    Grid.SetColumn(valueControl, 2);
                }
                else if (value is bool)
                {
                    valueControl = new FzLib.UI.FlatStyle.CheckBox()
                    {
                        Content = name, IsChecked = (bool)value
                    };

                    currentGrid.Children.Add(valueControl);
                    Grid.SetRow(valueControl, rowCount);
                    Grid.SetColumnSpan(valueControl, 3);
                }
                controls.Add(valueControl, prop);
            }
            if (mainPanel.Children.Count > 2 && groups.ContainsKey(""))
            {
                Grid grid = groups[""] as Grid;
                grid.Margin = new Thickness(10, 0, 0, 0);
            }
        }