コード例 #1
0
        public void AddRecentFile(string filename)
        {
            if (string.IsNullOrEmpty(filename) || filename.ToLower() == "untitled")
            {
                return;
            }

            if (RecentDocuments.Contains(filename))
            {
                RecentDocuments.Remove(filename);
            }

            RecentDocuments.Insert(0, filename);
            OnPropertyChanged(nameof(RecentDocuments));

            if (RecentDocuments.Count > RecentDocumentsLength)
            {
                // the hard way to force collection to properly refresh so bindings work properly
                var recents = RecentDocuments.Take(RecentDocumentsLength);
                RecentDocuments.Clear();
                foreach (var recent in recents)
                {
                    RecentDocuments.Add(recent);
                }
            }
        }
コード例 #2
0
        public void AddRecentFile(string filename)
        {
            if (string.IsNullOrEmpty(filename) || filename.ToLower() == "untitled")
            {
                return;
            }

            if (RecentDocuments.Contains(filename))
            {
                RecentDocuments.Remove(filename);
            }

            RecentDocuments.Insert(0, filename);
            OnPropertyChanged(nameof(RecentDocuments));

            if (RecentDocuments.Count > RecentDocumentsLength)
            {
                RecentDocuments.Clear();
                foreach (var recent in RecentDocuments.Take(RecentDocumentsLength))
                {
                    RecentDocuments.Add(recent);
                }
            }
        }