Пример #1
0
        public void init()
        {
            UserControl stage = (UserControl)Application.Current.RootVisual;

            stage.AllowDrop = true;

            stage.Drop += new DragEventHandler(delegate(object sender, DragEventArgs eventArgs)
            {
                _files.Clear();

                BlobBuilder bb;
                File blob;

                FileInfo[] fileInfos = eventArgs.Data.GetData(DataFormats.FileDrop) as FileInfo[];

                foreach (FileInfo fileInfo in fileInfos)
                {
                    bb = new BlobBuilder();
                    bb.append(fileInfo);
                    blob = bb.getFile();
                    _files.Add(blob);
                }

                Drop(this, null);
            });

            stage.DragEnter += new DragEventHandler(delegate(object sender, DragEventArgs eventArgs)
            {
                DragEnter(this, null);
            });

            stage.DragLeave += new DragEventHandler(delegate(object sender, DragEventArgs eventArgs)
            {
                DragLeave(this, null);
            });
        }
Пример #2
0
        public Dictionary<string, object> getResponseAsBlob()
        {
            if (_response == null) {
                return null;
            }

            BlobBuilder bb = new BlobBuilder();
            bb.append(_response);
            File blob = bb.getFile("", _url.LocalPath);
            Moxie.blobPile.Add(blob.id, blob);
            return blob.ToObject();
        }
Пример #3
0
        private void _openDialog()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            _files.Clear();

            try
            {
                dialog.Multiselect = this._multiple;
                dialog.Filter = this._accept;

                if ((bool)dialog.ShowDialog())
                {
                    BlobBuilder bb;
                    File blob;
                    FileReader fileReader = new FileReader();

                    foreach (FileInfo fileInfo in dialog.Files)
                    {
                        bb = new BlobBuilder();
                        bb.append(fileInfo);
                        blob = bb.getFile();
                        _files.Add(blob);
                    }
                    Change(this, null);
                }
                else
                {
                    Cancel(this, null);
                }
            }
            catch (Exception ex)
            {
                // throw error
            }
        }
Пример #4
0
 private Dictionary<string, object> _getAsBlob(string type = "image/jpeg", int quality = 90)
 {
     MemoryStream stream = new MemoryStream();
     getAsEncodedStream(stream, type, quality);
     BlobBuilder bb = new BlobBuilder();
     bb.append(stream);
     Blob blob = bb.getFile(type, this.name);
     Moxie.blobPile.Add(blob.id, blob);
     return blob.ToObject();
 }