Beispiel #1
0
        /// <summary>
        /// Exchange the spots of pinned items <paramref name="item1"/>
        /// and <paramref name="item2"/> via exchange of IsPinned values
        /// and direct add/remove in viewmodel collection.
        /// </summary>
        /// <param name="item1"></param>
        /// <param name="item2"></param>
        /// <returns></returns>
        private bool ExchangePinnedSpots(IMRUEntryViewModel item1
                                         , IMRUEntryViewModel item2)
        {
            if (item1 != null && item2 != null)
            {
                if (item1.IsPinned == 0 || item2.IsPinned == 0)
                {
                    return(false);
                }

                this.Entries.Remove(item2.PathFileName);
                this.Entries.Remove(item1.PathFileName);

                var isPinnedBack = item1.IsPinned;
                item1.SetIsPinned(item2.IsPinned);
                item2.SetIsPinned(isPinnedBack);

                this.Entries.Add(item2.PathFileName, item2);
                this.Entries.Add(item1.PathFileName, item1);

                return(true);
            }

            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Negates the pin entry state for a given mru list entry.
        /// </summary>
        /// <param name="val"></param>
        private void PinUnpinEntry(IMRUEntryViewModel val)
        {
            var newIsPinnedValue = (val.IsPinned == 0 ? _NextIsPinnedValue : 0);

            var oldIsPinnedValue = val.IsPinned;

            val.SetIsPinned(newIsPinnedValue);

            if (newIsPinnedValue != 0)     // Increment next IsPinned order entry
            {
                _NextIsPinnedValue += 1;   // If this entry is a newly pinned enty

                // Update all entries if this entry is the first entry to be pinned
                if (_NextIsPinnedValue == 2 && Entries.Count > 0)
                {
                    List <IMRUEntryViewModel> values = new List <IMRUEntryViewModel>();

                    foreach (var item in Entries.Values)
                    {
                        values.Add(item);
                    }

                    foreach (var item in values)
                    {
                        UpdateEntry(item);
                    }
                }
            }
            else
            {
                DecrementPinnedValues(oldIsPinnedValue);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Pin or unpines an entry depending on the <paramref name="isPinned"/> parameter.
        /// </summary>
        /// <param name="val"></param>
        /// <param name="isPinned"></param>
        private void PinUnpinEntry(IMRUEntryViewModel val, bool isPinned)
        {
            var oldIsPinnedValue = val.IsPinned;

            if (isPinned == true)
            {
                var newIsPinnedValue = _NextIsPinnedValue;

                val.SetIsPinned(newIsPinnedValue);

                // Increment next IsPinned order entry
                _NextIsPinnedValue += 1;   // since this entry is a newly pinned enty
            }
            else
            {
                val.SetIsPinned(0);

                DecrementPinnedValues(oldIsPinnedValue);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Method should be called on application start-up to read MRU
        /// data from persisted session object into its associated viewmodel.
        /// </summary>
        /// <param name="sessionData"></param>
        public void ReadMruFromSession(IProfile sessionData)
        {
            try  // Read back MRU data information
            {
                List.Entries.Clear();
                foreach (var item in sessionData.LastActiveSourceFiles)
                {
                    IMRUEntryViewModel mruItem =
                        MRULib.MRU_Service.Create_Entry(item.path,
                                                        item.LastTimeOfEdit);
                    mruItem.SetIsPinned(item.IsPinned);

                    List.UpdateEntry(mruItem);
                }
            }
            catch
            {
            }
        }