Esempio n. 1
0
 public TextBoxView(TextBox parent)
 {
     this.caretTimer = new DispatcherTimer();
     this.caretTimer.Interval = PlatformInterface.Instance.CaretBlinkTime;
     this.caretTimer.Tick += this.CaretTimerTick;
     this.parent = parent;
 }
Esempio n. 2
0
        public void Setter_With_TwoWay_Binding_And_Activator_Should_Update_Source()
        {
            using (UnitTestApplication.Start(TestServices.MockThreadingInterface))
            {
                var data = new Data
                {
                    Foo = "foo",
                };

                var control = new TextBox
                {
                    DataContext = data,
                };

                var setter = new Setter
                {
                    Property = TextBox.TextProperty,
                    Value = new Binding
                    {
                        Path = "Foo",
                        Mode = BindingMode.TwoWay
                    }
                };

                var activator = Observable.Never<bool>().StartWith(true);

                setter.Apply(null, control, activator);
                Assert.Equal("foo", control.Text);

                control.Text = "bar";
                Assert.Equal("bar", data.Foo);
            }
        }
Esempio n. 3
0
        public ApplyStyling()
        {
            _app = UnitTestApplication.Start(TestServices.StyledWindow);

            TextBox textBox;

            _window = new Window
            {
                Content = textBox = new TextBox(),
            };

            _window.ApplyTemplate();
            textBox.ApplyTemplate();

            var border = (Border)textBox.GetVisualChildren().Single();

            if (border.BorderThickness != 2)
            {
                throw new Exception("Styles not applied.");
            }

            _window.Content = null;

            // Add a bunch of styles with lots of class selectors to complicate matters.
            for (int i = 0; i < 100; ++i)
            {
                _window.Styles.Add(new Style(x => x.OfType<TextBox>().Class("foo").Class("bar").Class("baz"))
                {
                    Setters = new[]
                    {
                        new Setter(TextBox.TextProperty, "foo"),
                    }
                });
            }
        }
        /// <summary>
        /// Initializes the new instance of <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            this.InitializeComponent();
            App.AttachDevTools(this);

            btnGetWavHeader = this.FindControl<Button>("btnGetWavHeader");
            progress = this.FindControl<ProgressBar>("progress");
            btnCancel = this.FindControl<Button>("btnCancel");
            btnSplitWavFiles = this.FindControl<Button>("btnSplitWavFiles");
            textOutputPath = this.FindControl<TextBox>("textOutputPath");
            btnBrowseOutputPath = this.FindControl<Button>("btnBrowseOutputPath");
            textOutput = this.FindControl<TextBox>("textOutput");

            var v = Assembly.GetExecutingAssembly().GetName().Version;
            Title = string.Format("SimpleWavSplitter v{0}.{1}.{2}", v.Major, v.Minor, v.Build);

            btnBrowseOutputPath.Click += async (sender, e) => await GetOutputPath();
            btnGetWavHeader.Click += async (sender, e) => await GetWavHeader();
            btnSplitWavFiles.Click += async (sender, e) => await SplitWavFiles();
            btnCancel.Click += async (sender, e) => await CancelSplitWavFiles();
        }
        public OpenPlaydotsGame()
        {
            this.InitializeComponent();
            App.AttachDevTools(this);
            DataContext = this;

            _textBox = this.Find<TextBox>("InputTextBox");
            var okButton = this.Find<Button>("OkButton");
            var cancelButton = this.Find<Button>("CancelButton");

            _clipboardTimer = new Timer(ClipboardUpdateEvent, null, 0, Timeout.Infinite);

            okButton.Click += (sender, e) =>
            {
                _clipboardTimer.Dispose();
                Close(_textBox.Text);
            };
            cancelButton.Click += (sender, e) =>
            {
                _clipboardTimer.Dispose();
                Close(null);
            };
        }
Esempio n. 6
0
        public void TextBox_Class_Listeners_Are_Freed()
        {
            using (UnitTestApplication.Start(TestServices.StyledWindow))
            {
                TextBox textBox;

                var window = new Window
                {
                    Content = textBox = new TextBox()
                };

                // Do a layout and make sure that TextBox gets added to visual tree and its 
                // template applied.
                LayoutManager.Instance.ExecuteInitialLayoutPass(window);
                Assert.Same(textBox, window.Presenter.Child);

                // Get the border from the TextBox template.
                var border = textBox.GetTemplateChildren().FirstOrDefault(x => x.Name == "border");

                // The TextBox should have subscriptions to its Classes collection from the
                // default theme.
                Assert.NotEmpty(((INotifyCollectionChangedDebug)textBox.Classes).GetCollectionChangedSubscribers());

                // Clear the content and ensure the TextBox is removed.
                window.Content = null;
                LayoutManager.Instance.ExecuteLayoutPass();
                Assert.Null(window.Presenter.Child);

                // Check that the TextBox has no subscriptions to its Classes collection.
                Assert.Null(((INotifyCollectionChangedDebug)textBox.Classes).GetCollectionChangedSubscribers());
            }
        }
Esempio n. 7
0
 private void InitializeComponent()
 {
     Application.LoadComponent(this, new Uri("/Test;component/MainWindow.xaml", UriKind.Relative));
     this.textBox = (TextBox)this.FindName("textBox");
     this.popup = (Popup)this.FindName("popup");
 }
Esempio n. 8
0
 public void Add_And_Style_TextBox()
 {
     var textBox = new TextBox();
     _window.Content = textBox;
     textBox.ApplyTemplate();
 }