public CreateFolderViewModel()
 {
     if (IsInDesignMode)
     {
         _metadata = new MetaData { Path = "/photos" };
     }
 }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (RemoveBackEntry)
            {
                NavigationService.RemoveBackEntry();
            }

            Messenger.Default.Register<MetaDataViewModel>(this, MessengerToken.GetLink, GetLinkPage);

            var data = new MetaData
                           {
                               Path = GetPath(),
                               Icon = GetIcon()
                           };

            PageTitle.Text = data.Name.ToLower();
            _viewModel.RegisterMessengers.Execute(null);
            _viewModel.LoadItems.Execute(data);

            SetPinIcon(data);

            if (RemoveBackEntry)
            {
                App.NeedDataRefresh = true;
            }

            base.OnNavigatedTo(e);
        }
Beispiel #3
0
        public static bool IsPinned(MetaData metaData)
        {
            string path = string.Format("/FolderPage.xaml?path={0}&icon={1}", metaData.Path, metaData.Icon);
            var tile = LiveTileHelper.GetTile(new Uri(path, UriKind.Relative));

            return tile != null;
        }
Beispiel #4
0
 public static DropBoxItem FromMetaData(MetaData metaData)
 {
     if(metaData.Is_Dir)
     {
         return new DropBoxFolder(metaData.Path, metaData.Name);
     }
     return new DropBoxFile(metaData.Path, metaData.Name);
 }
 private async void GetMetaData()
 {
     _metaData = _client.GetMetaData(path: "/Photos/Camera/2014/2014-05-11");
     _position = 0;
     LoadImageIntoControl(await GetImage(_position));
     if (_position < _metaData.Contents.Count - 1)
         await GetImage(_position + 1); // cache the next image
 }
Beispiel #6
0
 protected virtual void ParseImageMetadata(MetaData data)
 {
     Client.GetMediaAsync(data.Path, response =>
                                         {
                                             var media = MediaFactory.CreateFromUrl(Settings.Id, response.Url);
                                             NewMedia(media);
                                             ((List<Media>)Media).Add(media);
                                         }, exception => Debug.WriteLine(exception));
 }
Beispiel #7
0
        public static void RemoveTile(MetaData metaData)
        {
            string path = string.Format("/FolderPage.xaml?path={0}&icon={1}", metaData.Path, metaData.Icon);
            var tile = LiveTileHelper.GetTile(new Uri(path, UriKind.Relative));

            if (tile != null)
            {
                tile.Delete();
            }
        }
 public static IEnumerable<MetaData> GetMetadataRecursive(MetaData metaData)
 {
     var result = new List<MetaData>() {metaData};
     if (metaData.Contents != null) {
         foreach (var data in metaData.Contents) {
             result.AddRange(GetMetadataRecursive(data));
         }
     }
     return result;
 }
Beispiel #9
0
 public FileEntry(MetaData md, ImageSource thumb)
 {
     Modified = md.ModifiedDate;
     Title = md.Name;
     Image = thumb;
     IdString = md.Path;
     IsFolder = md.Is_Dir;
     IsGDrive = false;
     IsViewable = !md.Is_Dir && IsExtViewable(md.Extension.Replace(".", ""));
 }
Beispiel #10
0
 public static DropboxFileMeta Create(MetaData m)
 {
   return new DropboxFileMeta
   {
     IsDir = m.Is_Dir,
     IsDeleted = m.Is_Deleted,
     Extension = m.Extension,
     Name = m.Name,
     LastModifiedUtc = m.UTCDateModified,
     Path = m.Path
   };
 }
        /// <summary>
        /// Converting DropBox Model to FileObject
        /// </summary>
        /// <param name="meta">DropBox Model</param>
        /// <returns>POJO FileObject</returns>
        public static FileObject ConvertToFileObject(MetaData meta)
        {
            string Name = meta.Name;
            string UpdateAt = meta.ModifiedDate.ToString(); //14/02/2014 15:48:13
            string Id = meta.Path; // Full path
            string ParentId = meta.Path;
            double Size = meta.Bytes * 1.0;
            FileObject.FileObjectType Type = (meta.Is_Dir ? FileObject.FileObjectType.FOLDER : FileObject.FileObjectType.FILE);
            string Extension = (meta.Extension == null || "".Equals(meta.Extension)) ? "" : meta.Extension.Substring(1, meta.Extension.Length -1); // .png

            return new FileObject(Id,Name,Size,Type,Extension,UpdateAt);
        }
Beispiel #12
0
        private static string GetRelativeTime(MetaData data)
        {
            DateTime date;
            var parsed = DateTime.TryParseExact(
                data.Modified,
                "ddd, dd MMM yyyy HH:mm:ss +ffff",
                CultureInfo.InvariantCulture,
                DateTimeStyles.None, out date);

            return parsed
                ? date.ToRelative()
                : string.Empty;
        }
Beispiel #13
0
        public MetaListItemInfo(MetaData data)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            Title = data.Name;
            _path = data.Path;
            _idDir = data.Is_Dir;
            _modified = data.Modified;

            Icon = ThemeData.GetImage(
                data.Is_Dir ? "folder" : "entry");
        }
Beispiel #14
0
        private static bool UnpublishedMarkdownFiles(MetaData arg)
        {
            if (arg.Name == null)
                return false;
            var withoutExtension = Path.GetFileNameWithoutExtension(arg.Name);
            var extension = Path.GetExtension(arg.Name);
            return
                withoutExtension != null &&
                extension != null &&
                withoutExtension.IndexOf(PublishedMarker, StringComparison.Ordinal) == -1 &&
                withoutExtension.IndexOf(WorkInProgressMarker, StringComparison.Ordinal) == -1 &&
                extension == ".md";

        }
Beispiel #15
0
        public static void CreateTile(MetaData metaData)
        {
            ImageSource imageSource = new BitmapImage(new Uri(string.Format("/TileIcon/{0}.png", metaData.Icon), UriKind.Relative));
            var visual = new LiveTileVisual();
            visual.SetProperties(metaData.Name, imageSource);
            var data = new RadExtendedTileData
                           {
                               VisualElement = visual
                           };

            string path = string.Format("/FolderPage.xaml?path={0}&icon={1}", metaData.Path, metaData.Icon);

            LiveTileHelper.CreateTile(data, new Uri(path, UriKind.Relative));
        }
        public void DisplayContents(string path)
        {
            Console.WriteLine("Displaying the contents of : {0}",path);

            AppDelegate.Dropbox.GetMetaDataAsync(path, response => {

                _dropboxData = response.Data;
                InvokeOnMainThread(()=>{
                    this.TableView.DataSource = new TableDataSource(this);
                    this.TableView.Delegate = new TableDelegate(this);
                    this.TableView.ReloadData();
                });
            });
        }
Beispiel #17
0
        protected override void AdditionalSetup()
        {
            _randomFile1 = Path.GetRandomFileName() + ".md";
            var client = GetAuthorizedClient();
            client.UploadFile("/", _randomFile1, GetFileContent());

            _f = GetDropboxFacade();
            var files = _f.GetAllUnpublished();
            _file = files[0];
            _f.UpdatePublishState(files);

            var c = GetAuthorizedClient();
            _meta = c.GetMetaData();
        }
Beispiel #18
0
        public MetaListItemInfo(MetaData data)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            _path = data.Path;
            _size = data.Bytes;
            _isDir = data.Is_Dir;
            _modified = data.Modified;

            Title = data.Name;
            Notes = GetRelativeTime(data);
            Icon = ThemeData.GetImage(
                data.Is_Dir ? "folder" : "entry");
        }
        protected override void ParseImageMetadata(MetaData data)
        {
            var localPath = LocalPathFromRemotePath(data.Path);
            if (File.Exists(localPath)) return;
            Client.GetFileAsync(data.Path,
                     delegate(IRestResponse response)
                     {

                         using (var fs = new FileStream(localPath, FileMode.CreateNew, FileAccess.Write))
                         {
                             fs.Write(response.RawBytes, 0, response.RawBytes.Length);
                         }
                         var media = new LocalMedia(localPath, Settings.Id);
                         NewMedia(media);
                         ((List<Media>)Media).Add(media);
                     },
                     exception => Debug.WriteLine(exception));
        }
        public DropboxRepository(string appKey, string appSecret, string userToken, string userSecret, string folderPath)
        {
            if (!string.IsNullOrEmpty(appKey) && !string.IsNullOrEmpty(appSecret) && !string.IsNullOrEmpty(userToken) && !string.IsNullOrEmpty(userSecret) && !string.IsNullOrEmpty(folderPath))
            {
                _client = new DropNetClient(apiKey: appKey, appSecret: appSecret, userToken: userToken, userSecret: userSecret);

                _cacheKey = string.Format(_cacheKey, appKey);
                var cachedMetaData = LoadFromCache<MetaData>(cacheKey: _cacheKey);
                if (cachedMetaData != null)
                {
                    _dropboxImageFolderMetaData = cachedMetaData;
                }
                else
                {
                    _dropboxImageFolderMetaData = _client.GetMetaData(path: folderPath);
                    AddToCache(item: _dropboxImageFolderMetaData, cacheKey: _cacheKey, absoluteExpiration: DateTime.Now.AddHours(1));
                }
            }
        }
        void OnUploadSuccess(MetaData metaData)
        {
            Utilities.ShowProgressIndicator(false);
            Uploading = false;

            App.NeedDataRefresh = true;
            MessageBox.Show(string.Format("'{0}' uploaded successfully", metaData.Name), Labels.SuccessTitle,
                            MessageBoxButton.OK);

            if (_navigationService != null)
            {
                try
                {
                    _navigationService.GoBack();
                }

                catch
                {
                    _navigationService.Navigate(new Uri("/MainPage.xaml?refresh=true", UriKind.Relative));
                }
            }
        }
Beispiel #22
0
 protected void ParseMetadata(MetaData data)
 {
     if (data.Is_Dir)
     {
         if (data.Contents == null && Settings.Recursive)
         {
             ReadFolder(data.Path);
         }
         else if (data.Contents != null)
         {
             foreach (var d in data.Contents)
             {
                 ParseMetadata(d);
             }
         }
     }
     else
     {
         if (!MediaFactory.IsPathMedia(data.Path)) return;
         ParseImageMetadata(data);
     }
 }
Beispiel #23
0
 private static bool FolderExists(DropNet.Models.MetaData backupFolder)
 {
     return(backupFolder != null && !backupFolder.Is_Deleted && backupFolder.Is_Dir);
 }
Beispiel #24
0
 /// <summary>
 /// Gets the thumbnail of an image given its MetaData
 /// </summary>
 /// <param name="file"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public byte[] GetThumbnail(MetaData file, ThumbnailSize size)
 {
     return GetThumbnail(file.Path, size);
 }
Beispiel #25
0
 /// <summary>
 /// Gets the thumbnail of an image given its MetaData
 /// </summary>
 /// <param name="file"></param>
 /// <returns></returns>
 public byte[] GetThumbnail(MetaData file)
 {
     return GetThumbnail(file.Path, ThumbnailSize.Small);
 }
Beispiel #26
0
        private void OnMetaDataCompleted(MetaData metaData)
        {
            if (metaData != null)
            {
                this.HandleHistory();

                this.Root = this.targetFolder == null ? NewDownload.RootDirectoryLabel : this.targetFolder.Title;
                this.Data = new ObservableCollection<BaseFile>();
                foreach (var item in metaData.Contents)
                {
                    if (item != null)
                    {
                        var mediaType = this.MediaSupportService.GetMediaType(item.Name);
                        switch (mediaType)
                        {
                            case MediaType.Unknown:
                                if (item.Is_Dir)
                                {
                                    this.Data.Add(new Folder()
                                    {
                                        Title = item.Name,
                                        URL = item.Path,
                                    });
                                }
                                break;
                            case MediaType.Video:
                                this.Data.Add(new VideoFile()
                                {
                                    Title = item.Name,
                                    URL = item.Path,
                                    Size = FileSizeConverter.Convert(item.Bytes)
                                });
                                break;
                            case MediaType.Audio:
                                this.Data.Add(new AudioFile()
                                {
                                    Title = item.Name,
                                    URL = item.Path,
                                    Size = FileSizeConverter.Convert(item.Bytes)
                                });
                                break;
                            default:
                                break;
                        }
                    }
                }
                this.Data = new ObservableCollection<BaseFile>(this.Data.OrderBy(d => d, new FileTypeComparer()).ThenBy(d => d.Title));
                this.EmptyFolder = !this.Data.Any();
            }
            base.MessengerInstance.Send<ScreenLock, URLSelectorDropboxPage>(ScreenLock.Release());
        }
Beispiel #27
0
 public Task<IRestResponse> GetThumbnailTask(MetaData file)
 {
     return GetThumbnailTask(file.Path, ThumbnailSize.Small);
 }
Beispiel #28
0
 public Task<IRestResponse> GetThumbnailTask(MetaData file, ThumbnailSize size)
 {
     return GetThumbnailTask(file.Path, size);
 }
        private void RefreshCache(MetaData md)
        {
            if (md.Contents == null)
            {
                var oldMd = default(MetaData);
                if (MetaDataCache.TryGetValue(md.Path, out oldMd))
                {
                    md.Contents = oldMd.Contents;
                }
            }
            else
            {
                foreach (var content in md.Contents)
                {
                    RefreshCache(content);
                }
            }

            MetaDataCache[md.Path] = md;
        }
        internal Stream CreateFile(MetaData dirMetaData, string fileName)
        {
            var virtualPath = dirMetaData.Path;
            var file = GetFile(CombineVirtualPath(virtualPath, fileName));
            if (file != null)
            {
                throw new ArgumentException("A file with the same name already exists");
            }

            return new InMemoryStream((contents) =>
            {
                var newFileMetaData = this.CreateFile(virtualPath, fileName, contents);
                if (dirMetaData.Contents != null)
                {
                    dirMetaData.Contents.Add(newFileMetaData);
                }
            });
        }
Beispiel #31
0
 /// <summary>
 /// Gets the thumbnail of an image given its MetaData
 /// </summary>
 /// <param name="file">The metadat file</param>
 /// <param name="size">Thumbnail size</param>
 /// <param name="success">success callback</param>
 /// <param name="failure">Failure callback</param>
 public void GetThumbnailAsync(MetaData file, ThumbnailSize size, Action<byte[]> success, Action<DropboxException> failure)
 {
     GetThumbnailAsync(file.Path, size, success, failure);
 }