Exemple #1
0
        async void GetTreeForFolder(ExternalStorageFolder folder)
        {
            CurrentItems.Clear();

            var folderList = await folder.GetFoldersAsync();

            foreach (ExternalStorageFolder _folder in folderList)
            {
                CurrentItems.Add(new FileExplorerItem()
                {
                    IsFolder = true, Name = _folder.Name, Path = _folder.Path
                });
            }

            foreach (ExternalStorageFile _file in await folder.GetFilesAsync())
            {
                CurrentItems.Add(new FileExplorerItem()
                {
                    IsFolder = false, Name = _file.Name, Path = _file.Path
                });
            }

            if (!_folderTree.Contains(folder))
            {
                _folderTree.Push(folder);
            }

            CurrentPath = _folderTree.First().Path;
        }
Exemple #2
0
        void PopulateView()
        {
            CurrentItems.Clear();
            System.Drawing.Icon icon;
            icon = Etier.IconHelper.IconReader.GetFolderIcon(Etier.IconHelper.IconReader.IconSize.Small, Etier.IconHelper.IconReader.FolderType.Closed);

            try
            {
                foreach (string s in Directory.EnumerateDirectories(CurrentFolder))
                {
                    FSItemVM info = new FSItemVM()
                    {
                        FullPath    = s,
                        DisplayName = System.IO.Path.GetFileName(s),
                        type        = FSItemType.Folder,
                        DisplayIcon = Etier.IconHelper.IconReader.GetFolderIcon(s, Etier.IconHelper.IconReader.IconSize.Small, Etier.IconHelper.IconReader.FolderType.Closed).ToImageSource()
                    };
                    CurrentItems.Add(info);
                }
            } catch (Exception) {}

            try
            {
                foreach (string s in Directory.EnumerateFiles(CurrentFolder))
                {
                    FSItemVM info = new FSItemVM()
                    {
                        FullPath = s, DisplayName = System.IO.Path.GetFileName(s), type = FSItemType.File
                    };
                    try
                    {
                        icon             = Etier.IconHelper.IconReader.GetFileIcon(info.FullPath, Etier.IconHelper.IconReader.IconSize.Small, false);
                        info.DisplayIcon = icon.ToImageSource();
                    }
                    catch (Exception)
                    {
                        info.DisplayIcon = null;
                    }
                    CurrentItems.Add(info);
                }
            }
            catch (Exception) { }

            if (RecentFolders.Count == 0 || String.Compare(CurrentFolder, RecentFolders.Last()) != 0)
            {
                RecentFolders.Push(CurrentFolder);
            }
            if (ClearFuture)
            {
                FutureFolders.Clear();
            }
        }
Exemple #3
0
        public void LoadMessagesFromGivenFolder(string folder)
        {
            CurrentItems.Clear();
            var view = new FolderView(100)
            {
                PropertySet = new PropertySet(BasePropertySet.IdOnly)
                {
                    FolderSchema.DisplayName
                },
                Traversal = FolderTraversal.Deep
            };

            var findFolderResults = _service.FindFolders(WellKnownFolderName.Root, view);
            //find specific folder
            var targetFolder = findFolderResults.Where(x => x.DisplayName == folder);

            if (targetFolder.Count() > 0)
            {
                foreach (Folder f in targetFolder)
                {
                    var itemView    = new ItemView(30);
                    var targetItems = f.FindItems(itemView);
                    if (targetItems.Count() > 0)
                    {
                        foreach (var item in targetItems)
                        {
                            CurrentItems.Add(item.Id.ToString());
                        }
                    }

                    else
                    {
                        CurrentItems.Add("No Messages Found.");
                    }
                }
            }

            else
            {
                CurrentItems.Add("Folder does not exist.");
            }
        }
        public void RefreshList()
        {
            List <ComparisonItemViewModel> source;

            switch (ComparisonFilter)
            {
            case ComparisonFilter.OnBoth:
                source = _allSharedItems;
                break;

            case ComparisonFilter.OnMine:
                source = _allMyItems;
                break;

            case ComparisonFilter.OnOther:
                source = _allOtherItems;
                break;

            case ComparisonFilter.All:
                source = _allSharedItems.Concat(_allMyItems).Concat(_allOtherItems).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (StatusFilter != AnimeStatus.AllOrAiring)
            {
                switch (StatusFilterTarget)
                {
                case ComparisonStatusFilterTarget.My:
                    source = source.Where(model => model.MyEntry?.MyStatus == StatusFilter).ToList();
                    break;

                case ComparisonStatusFilterTarget.Other:
                    source = source.Where(model => model.OtherEntry?.MyStatus == StatusFilter).ToList();
                    break;

                case ComparisonStatusFilterTarget.Both:
                    source = source.Where(model => model.MyEntry?.MyStatus == StatusFilter && model.OtherEntry?.MyStatus == StatusFilter).ToList();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            switch (ComparisonSorting)
            {
            case ComparisonSorting.ScoreDifference:
                source = source.OrderByDescending(model => model.ScoreDifference).ToList();
                break;

            case ComparisonSorting.MyScore:
                source = source.OrderByDescending(model => model.MyEntry?.MyScore ?? 0).ToList();
                break;

            case ComparisonSorting.OtherScore:
                source = source.OrderByDescending(model => model.OtherEntry?.MyScore ?? 0).ToList();
                break;

            case ComparisonSorting.WatchedDifference:
                source = source.OrderByDescending(model => model.WatchedDifference).ToList();
                break;

            case ComparisonSorting.MyWatched:
                source = source.OrderByDescending(model => model.MyEntry?.MyEpisodes ?? 0).ToList();
                break;

            case ComparisonSorting.OtherWatched:
                source = source.OrderByDescending(model => model.OtherEntry?.MyEpisodes ?? 0).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (SortAscending)
            {
                source.Reverse();
            }

            CurrentItems.Clear();
            CurrentItems.AddRange(source);
            EmptyNoticeVisibility = !CurrentItems.Any();
        }
        async Task ExecuteLoadItemsCommand(Guid?parentId)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Items.Clear();
                CurrentItems.Clear();
                //BehindItems.Clear();
                //FutureItems.Clear();
                //CompletedItems.Clear();

                List <ProjectInsight.Models.Tasks.Task> items = await TasksService.GetByProject(parentId.Value);


                if (items != null)
                {
                    int total   = items.Count();
                    int brojace = 0;

                    foreach (var item in items)
                    {
                        brojace++;
                        TaskListItem newItem = new TaskListItem();
                        newItem.Id    = item.Id.Value;
                        newItem.Title = item.Name;


                        bool endDateIsPast = false;
                        //string displayDate = string.Empty;
                        string startDate = string.Empty;
                        string endDate   = string.Empty;

                        if (item.StartDateTimeUserLocal.HasValue && item.EndDateTimeUserLocal.HasValue)
                        {
                            if (item.StartDateTimeUserLocal.Value.Date == item.EndDateTimeUserLocal.Value.Date)
                            {
                                startDate = string.Empty;
                                endDate   = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy");
                            }
                            else
                            {
                                startDate = item.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - ";
                                endDate   = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy");
                            }
                            if (item.EndDateTimeUserLocal.Value.Date < DateTime.Now.Date)
                            {
                                endDateIsPast = true;
                            }
                        }
                        else
                        {
                            if (item.StartDateTimeUserLocal.HasValue)
                            {
                                //displayDate = task.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - ";
                                startDate = item.StartDateTimeUserLocal.Value.Date.ToString("M/d/yy") + " - ";
                            }
                            if (item.EndDateTimeUserLocal.HasValue)
                            {
                                //displayDate += task.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy");
                                endDate = item.EndDateTimeUserLocal.Value.Date.ToString("M/d/yy");

                                if (item.EndDateTimeUserLocal.Value.Date < DateTime.Now.Date)
                                {
                                    endDateIsPast = true;
                                }
                            }
                        }

                        //newItem.Line2a = displayDate;
                        newItem.Line2s = startDate;
                        newItem.Line2e = endDate;

                        newItem.Line2Color = endDateIsPast ? ConvertColorToHex((Color)Application.Current.Resources["RedTextColor"]) : ConvertColorToHex((Color)Application.Current.Resources["BlackTextColor"]);

                        string workStatus = item.WorkPercentCompleteType != null ? item.WorkPercentCompleteType.Name : string.Empty;
                        string TaskOwner  = string.Empty;

                        ///TODO to be removed this, TaskOwner should be used
                        if (item.TaskOwner != null)
                        {
                            TaskOwner = item.TaskOwner.FirstName + " " + item.TaskOwner.LastName;
                        }
                        //else
                        //{
                        //    if (item.TaskOwner_Id.HasValue)
                        //    {
                        //        User taskOwner = await UsersService.GetUser(item.TaskOwner_Id.Value);
                        //        if (taskOwner != null)
                        //            TaskOwner = taskOwner.FirstName + " " + taskOwner.LastName;
                        //    }
                        //}

                        newItem.Line3     = (workStatus != string.Empty ? workStatus + " - " : "") + TaskOwner;
                        newItem.Icon      = "item_task.png";
                        newItem.ProjectId = item.Project_Id != null ? item.Project_Id.Value : Guid.Empty;

                        int stat = 1;
                        if (brojace <= total / 4)
                        {
                            stat = 1;
                        }
                        else if (brojace <= total / 2)
                        {
                            stat = 2;
                        }
                        else if (brojace <= 3 * total / 4)
                        {
                            stat = 3;
                        }
                        else
                        {
                            stat = 4;
                        }
                        if (parentId == new Guid("d8ed1090-69b6-45b1-9c36-04fb26e64e7a"))
                        {
                            newItem.TaskScheduleCurrentState = stat;
                        }
                        else
                        {
                            newItem.TaskScheduleCurrentState = (item.TaskScheduleCurrentState ?? 1);
                        }

                        Items.Add(newItem);
                    }
                    GroupProjectsByStatus();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        async void GetTreeForExternalFolder(ExternalStorageFolder folder)
        {
            if (!_externalFolderTree.Contains(folder))
            {
                _externalFolderTree.Push(folder);
            }

            ProcessSelectedItems();

            CurrentItems.Clear();

            var folderList = await folder.GetFoldersAsync();

            foreach (ExternalStorageFolder _folder in folderList)
            {
                FileExplorerItem item = (from c in _selectedItems where c.Path == _folder.Path select c).FirstOrDefault();

                FileExplorerItem _addItem = new FileExplorerItem()
                {
                    IsFolder = true,
                    Name     = _folder.Name,
                    Path     = _folder.Path,
                    Selected = item != null ? true : false
                };

                CurrentItems.Add(_addItem);
            }

            var fileList = await folder.GetFilesAsync();

            if (fileList != null)
            {
                foreach (ExternalStorageFile _file in fileList)
                {
                    FileExplorerItem item = GetItemFromPath(_file.Path);

                    if (((ExtensionRestrictions & (Interop.ExtensionRestrictions.Custom | Interop.ExtensionRestrictions.InheritManifest)) != 0) && (Extensions.Count != 0))
                    {
                        string extension = Path.GetExtension(_file.Name);
                        if (Extensions.FindIndex(x => x.Equals(extension, StringComparison.OrdinalIgnoreCase)) != -1)
                        {
                            CurrentItems.Add(new FileExplorerItem()
                            {
                                IsFolder = false,
                                Name     = _file.Name,
                                Path     = _file.Path,
                                Selected = item != null ? true : false
                            });
                        }
                    }
                    else
                    {
                        CurrentItems.Add(new FileExplorerItem()
                        {
                            IsFolder = false,
                            Name     = _file.Name,
                            Path     = _file.Path,
                            Selected = item != null ? true : false
                        });
                    }
                }
            }

            CurrentPath = _externalFolderTree.First().Path;
        }
Exemple #7
0
        /// <summary>
        /// Fills the ListView, or rather CurrentItems
        /// </summary>
        public void PopulateView()
        {
            CurrentItems.Clear();
            if (!Directory.Exists(FV.CurrentFolder))
            {
                return;
            }

            try
            {
                DirectoryInfo cur   = new DirectoryInfo(FV.CurrentFolder);
                ImageSource   dummy = new BitmapImage();
                if (FV.ShowFolders)
                {
                    foreach (DirectoryInfo dir in cur.GetDirectories())
                    {
                        if (!FV.ShowHidden && dir.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }
                        FSItemVM info = new FSItemVM()
                        {
                            FullPath    = dir.FullName,
                            DisplayName = dir.Name,
                            type        = FSItemType.Folder
                        };
                        if (!FV.ShowIcons)
                        {
                            info.DisplayIcon = dummy;  // to prevent the icon from being loaded from file later
                        }
                        CurrentItems.Add(info);
                    }
                }

                string FilterString = "*";
                if (FV.FilterIndex >= 0 && FV.FilterIndex < FilterCount)
                {
                    FilterString = FilterList[FV.FilterIndex].ToString();
                }
                foreach (var CurFilterString in FilterString.Split(';'))
                {
                    foreach (FileInfo f in cur.EnumerateFiles(CurFilterString))
                    {
                        if (!FV.ShowHidden && f.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }

                        FSItemVM info = new FSItemVM()
                        {
                            FullPath    = f.FullName,
                            DisplayName = f.Name, //System.IO.Path.GetFileName(s),
                            type        = FSItemType.File
                        };
                        if (!FV.ShowIcons)
                        {
                            info.DisplayIcon = dummy; // to prevent the icon from being loaded from file later
                        }
                        CurrentItems.Add(info);
                    }
                }
            }
            catch (Exception) { }

            // reset column width manually (otherwise it is not updated)
            FV.TheGVColumn.Width = FV.TheGVColumn.ActualWidth;
            FV.TheGVColumn.Width = Double.NaN;

            if (RecentFolders.Count == 0 || String.Compare(FV.CurrentFolder, RecentFolders.Last()) != 0)
            {
                if (Directory.Exists(FV.CurrentFolder))
                {
                    RecentFolders.Push(FV.CurrentFolder);
                    if (ClearFuture)
                    {
                        FutureFolders.Clear();
                    }
                }
            }
        }
        /// <summary>
        ///     Will retrieve the full folder and file tree for a folder from the internal storage.
        /// </summary>
        /// <param name="folder">The instance of the folder for which the tree will be retrieved.</param>
        private async void GetTreeForFolder(IStorageFolderEx folder)
        {
            if (!FolderTree.Contains(folder))
            {
                FolderTree.Push(folder);
            }

            ProcessSelectedItems();

            CurrentItems.Clear();

            IEnumerable <IStorageFolderEx> folderList = await folder.GetFoldersAsync();

            foreach (IStorageFolderEx _folder in folderList)
            {
                FileExplorerItem item =
                    (from c in SelectedItems where c.Path == _folder.Path select c).FirstOrDefault();

                var _addItem = new FileExplorerItem
                {
                    IsFolder    = true,
                    Name        = _folder.Name,
                    DisplayName = _folder.DisplayName,
                    Path        = _folder.Path,
                    Selected    = false
                };

                CurrentItems.Add(_addItem);
            }

            IEnumerable <IStorageFileEx> fileList = await folder.GetFilesAsync();

            if (fileList != null)
            {
                foreach (IStorageFileEx _file in fileList)
                {
                    //FileExplorerItem item = GetItemFromPath(_file.Path);

                    if (((ExtensionRestrictions & (ExtensionRestrictions.Custom | ExtensionRestrictions.InheritManifest)) !=
                         0) && (Extensions.Count != 0))
                    {
                        string extension = Path.GetExtension(_file.Name);
                        if (Extensions.FindIndex(x => x.Equals(extension, StringComparison.OrdinalIgnoreCase)) != -1)
                        {
                            CurrentItems.Add(new FileExplorerItem
                            {
                                IsFolder    = false,
                                Name        = _file.Name,
                                DisplayName = _file.Name,
                                Path        = _file.Path,
                                Selected    = false
                            });
                        }
                    }
                    else
                    {
                        CurrentItems.Add(new FileExplorerItem
                        {
                            IsFolder    = false,
                            Name        = _file.Name,
                            Path        = _file.Path,
                            DisplayName = _file.Name,
                            Selected    = false
                        });
                    }
                }
            }

            CurrentPath = FolderTree.First()
                          .Path;
        }