本文整理汇总了C#中SortableBindingList.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# SortableBindingList.Clear方法的具体用法?C# SortableBindingList.Clear怎么用?C# SortableBindingList.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortableBindingList
的用法示例。
在下文中一共展示了SortableBindingList.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public bool Load(SortableBindingList<PlayListData> playlist, string fileName)
{
string basePath = String.Empty;
Stream stream;
basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
playlist.Clear();
Encoding fileEncoding = Encoding.Default;
StreamReader file = new StreamReader(stream, fileEncoding, true);
if (file == null)
{
return false;
}
string line;
line = file.ReadLine();
if (line == null)
{
file.Close();
return false;
}
string strLine = line.Trim();
//CUtil::RemoveCRLF(strLine);
if (strLine != START_PLAYLIST_MARKER)
{
fileEncoding = Encoding.Default;
stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
file = new StreamReader(stream, fileEncoding, true);
}
string infoLine = "";
string durationLine = "";
fileName = "";
line = file.ReadLine();
while (line != null)
{
strLine = line.Trim();
//CUtil::RemoveCRLF(strLine);
int equalPos = strLine.IndexOf("=");
if (equalPos > 0)
{
string leftPart = strLine.Substring(0, equalPos);
equalPos++;
string valuePart = strLine.Substring(equalPos);
leftPart = leftPart.ToLower();
if (leftPart.StartsWith("file"))
{
if (valuePart.Length > 0 && valuePart[0] == '#')
{
line = file.ReadLine();
continue;
}
if (fileName.Length != 0)
{
PlayListData newItem = new PlayListData(infoLine, fileName, "0");
playlist.Add(newItem);
fileName = "";
infoLine = "";
durationLine = "";
}
fileName = valuePart;
}
if (leftPart.StartsWith("title"))
{
infoLine = valuePart;
}
else
{
if (infoLine == "")
{
infoLine = Path.GetFileName(fileName);
}
}
if (leftPart.StartsWith("length"))
{
durationLine = valuePart;
}
if (durationLine.Length > 0 && infoLine.Length > 0 && fileName.Length > 0)
{
string duration = durationLine;
// Remove trailing slashes. Might cause playback issues
if (fileName.EndsWith("/"))
{
fileName = fileName.Substring(0, fileName.Length - 1);
}
Util.GetQualifiedFilename(basePath, ref fileName);
PlayListData newItem = new PlayListData(infoLine, fileName, Util.SecondsToHMSString(duration));
playlist.Add(newItem);
fileName = "";
infoLine = "";
durationLine = "";
}
}
//.........这里部分代码省略.........
示例2: Load
public bool Load(SortableBindingList<PlayListData> incomingPlaylist, string playlistFileName)
{
if (playlistFileName == null)
{
return false;
}
playlist = incomingPlaylist;
playlist.Clear();
try
{
basePath = Path.GetDirectoryName(Path.GetFullPath(playlistFileName));
using (file = new StreamReader(playlistFileName, Encoding.Default, true))
{
if (file == null)
{
return false;
}
string line = file.ReadLine();
if (line == null || line.Length == 0)
{
return false;
}
string trimmedLine = line.Trim();
if (trimmedLine != M3U_START_MARKER)
{
string fileName = trimmedLine;
if (!AddItem("", "0", fileName))
{
return false;
}
}
line = file.ReadLine();
while (line != null)
{
trimmedLine = line.Trim();
if (trimmedLine != "")
{
if (trimmedLine.StartsWith(M3U_INFO_MARKER))
{
string songName = null;
string lDuration = "0";
if (ExtractM3uInfo(trimmedLine, ref songName, ref lDuration))
{
line = file.ReadLine();
if (!AddItem(songName, Util.SecondsToHMSString(lDuration), line))
{
break;
}
}
}
else
{
if (!AddItem("", "0", trimmedLine))
{
break;
}
}
}
line = file.ReadLine();
}
}
}
catch (Exception ex)
{
log.Error("exception loading playlist {0} err:{1} stack:{2}", playlistFileName, ex.Message, ex.StackTrace);
return false;
}
return true;
}