private void RefreshRemoteFiles() { using (var client = new FilerServerProxyService.FileServerClient()) { RemoteFiles.Clear(); try { string[] availableFiles = client.GetAvailableFiles(); foreach (string file in availableFiles) { RemoteFiles.Add(file); } } // Display error and continue catch (Exception ex) { Trace.TraceError(ex.Message); MessageBox.Show(ex.Message, "Error"); } } }
public async void NavigateRemote(string path) { RemotePath = path; RemoteFiles.Clear(); var json = await SendCommand("list:" + path); JArray array; try { array = JArray.Parse(json); } catch { return; } var temp = new List <FileItem>(); foreach (var obj in array) { var rpath = obj.Value <string>("path"); var folder = obj.Value <bool>("folder"); if (!folder && mss.currentItem != null && mss.currentItem.Path.Equals(rpath)) { temp.Add(mss.currentItem); continue; } var name = obj.Value <string>("name"); long size = 0; if (!folder) { size = obj.Value <long>("size"); } var ext = Path.GetExtension(name).ToUpper(); if (ext.Length > 0) { ext = ext.Substring(1); } var date = new DateTime(1970, 1, 1, 0, 0, 0); date = date.AddMilliseconds(obj.Value <long>("date")); FileItem item; if (MusicFileItem.IsMusicFile(rpath)) { item = new MusicFileItem(); } else if (PictureFileItem.IsPictureFile(rpath)) { item = new PictureFileItem(); } else { item = new FileItem(); } item.Model = this; item.Path = rpath; item.Name = name; item.Size = size; item.Extension = folder ? "FOLDER" : ext; item.Date = date.ToString(); item.IsFolder = folder; item.IsRemote = true; temp.Add(item); } temp.Sort(new Comparison <FileItem>((t1, t2) => { if (t1.IsFolder && !t2.IsFolder) { return(-1); } else if (!t1.IsFolder && t2.IsFolder) { return(1); } return(string.Compare(t1.Name, t2.Name, true)); })); RemoteFiles = new ObservableCollection <FileItem>(temp); }