Ejemplo n.º 1
0
        public void Handle(DocumentDeleted message)
        {
            RecentDocuments
            .Where(x => x.Id == message.DocumentId)
            .ToList()
            .Apply(x => RecentDocuments.Remove(x));

            //TODO: update collections
            //Collections
            //    .Where(x => x.Name == message.Document.CollectionType)
            //    .Apply(x => x.Count--);
        }
Ejemplo n.º 2
0
        // add a document to the MRU list
        public void AddDocument(string fileName)
        {
            // look for the file in the current list
            RecentDocumentItem doc = RecentDocuments.FirstOrDefault(x => x.FileName == fileName);

            if (doc != null)
            {
                // update date
                doc.Date = DateTime.Now;
            }
            else if (!string.IsNullOrEmpty(fileName))
            {
                // not a member, add
                doc = new RecentDocumentItem
                {
                    Text    = Path.GetFileName(fileName),
                    SubText = Path.GetDirectoryName(fileName),
                    Date    = DateTime.Now
                };
                RecentDocuments.Add(doc);
            }

            // trim list
            while (RecentDocuments.Count > MAX_ITEMS)
            {
                // first - check not pinned docs
                var notPinned = RecentDocuments.Where(x => !x.Pinned).OrderBy(x => x.Date);
                if (notPinned.Count() > 0)
                {
                    RecentDocuments.Remove(notPinned.Last());
                }
                else
                {
                    // remove last pinned doc
                    RecentDocuments.Remove(RecentDocuments.OrderBy(x => x.Date).Last());
                }
            }
        }