예제 #1
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);
        }
예제 #2
0
 public ImageProxyService(ImageProxySettings settings)
 {
     Endpoint    = settings.Endpoint;
     FunctionKey = settings.FunctionKey;
 }