Ejemplo n.º 1
0
        public SearchBox(string initialText = "", string placeholder = "Search", ContextMenu contextMenu = null)
        {
            _textBox = new TextBox(initialText);

            if (!string.IsNullOrEmpty(placeholder))
            {
                _textBox.HtmlElement.SetAttribute("placeholder", placeholder);
            }

            _textBox.TextInput += (sender, args) =>
            {
                TextInput?.Invoke(sender, args);
            };

            this.SetClass("search-box");

            this.VisualTree.Add(_textBox);

            this.VisualTree.Add(new Icon(Icons.Magnify));

            if (contextMenu != null)
            {
                VisualTree.Add(contextMenu);
            }
        }
Ejemplo n.º 2
0
        public ImageProxyBox(ImageProxySettings settings, string initialValue = null, string initialCatalog = null, string width = "-webkit-fill-available",
                             Action <LINQPad.Controls.TextBox> onTextInput    = null)
        {
            _settings      = settings;
            initialCatalog = initialCatalog ?? System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            this.SetClass("file-box image-proxy-box");

            _textBox = new LINQPad.Controls.TextBox(initialValue, width, onTextInput);

            _textBox.TextInput += (sender, args) =>
            {
                TextInput?.Invoke(sender, args);
                UpdateImageContainer(_textBox.Text);
            };

            this.VisualTree.Add(_textBox);

            var btnSelectFile = new IconButton(Icons.FolderOpen, async(_) =>
            {
                var path = ShowOpenFileDialog(initialCatalog);

                if (!string.IsNullOrEmpty(path))
                {
                    _imageContainer.Content = "Uploading...";
                    IsUploading             = true;
                    _textBox.Text           = await UploadFile(path);
                    IsUploading             = false;
                    TextInput?.Invoke(_textBox, null !);
                    UpdateImageContainer(_textBox.Text);
                }
            });

            _imageContainer = new LINQPad.DumpContainer();

            this.VisualTree.Add(btnSelectFile);
            this.VisualTree.Add(_imageContainer);
        }
Ejemplo n.º 3
0
        public FileBox(string initialValue = null, string initialCatalog = null, string width = "-webkit-fill-available",
                       Action <LINQPad.Controls.TextBox> onTextInput = null)
        {
            this.SetClass("file-box");
            initialCatalog = initialCatalog ?? System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            _textBox = new LINQPad.Controls.TextBox(initialValue, width, onTextInput);

            _textBox.TextInput += (sender, args) =>
            {
                TextInput?.Invoke(sender, args);
            };

            this.VisualTree.Add(_textBox);

            var btnSelectFile = new IconButton(Icons.FolderOpen, (_) =>
            {
                var path      = ShowOpenFileDialog(initialCatalog);
                _textBox.Text = path ?? _textBox.Text;
                TextInput?.Invoke(_textBox, null !);
            });

            this.VisualTree.Add(btnSelectFile);
        }