|
namespace SimpleControls.MRU.Model
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Collections.ObjectModel;
public class MRUList
{
#region constructor
public MRUList()
{
this.Entries = new List<MRUEntry>();
}
public MRUList(MRUList copySource)
{
if (copySource == null) return;
this.Entries = new List<MRUEntry>(copySource.Entries);
}
#endregion constructor
internal enum Spot
{
First = 0,
Last = 1
}
#region properties
[XmlArray(ElementName = "Entries", Namespace = "MRUList")]
[XmlArrayItem(ElementName = "Entry", Namespace = "MRUList")]
public List<MRUEntry> Entries { get; set; }
#endregion properties
#region AddRemoveEntries
internal bool AddEntry(MRUEntry emp,
MRUList.Spot addInSpot = MRUList.Spot.Last)
{
if(emp == null)
return false;
if(this.Entries == null)
this.Entries = new List<MRUEntry>();
switch (addInSpot)
{
case Spot.First:
this.Entries.Insert(0, new MRUEntry(emp));
return true;
case Spot.Last:
this.Entries.Add(new MRUEntry(emp));
return true;
default:
throw new NotImplementedException(addInSpot.ToString());
}
}
internal void RemoveEntry(Spot addInSpot)
{
if (this.Entries == null) return;
if (this.Entries.Count == 0) return;
switch (addInSpot)
{
case Spot.First:
this.Entries.RemoveAt(0);
break;
case Spot.Last:
this.Entries.RemoveAt(this.Entries.Count - 1);
break;
default:
break;
}
}
#endregion AddRemoveEntries
#region AddRemovePinnedEntries
internal void AddPinedEntry(MRUEntry emp)
{
if (emp == null)
return;
if (this.Entries == null)
this.Entries = new List<MRUEntry>();
this.Entries.Add(new MRUEntry(emp));
}
#endregion AddRemovePinnedEntries
internal void RemoveMruPath(string p)
{
if (this.Entries != null && p != null)
this.Entries.RemoveAll(item => p == item.PathFileName);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
The Windows Presentation Foundation (WPF) and C# are among my favorites and so I developed
Edi
and a few other projects on
GitHub. I am normally an algorithms and structure type but WPF has such interesting UI sides that I cannot help myself but get into it.
https://de.linkedin.com/in/dirkbahle