本文整理汇总了C#中IStatusLogger.SetProgress方法的典型用法代码示例。如果您正苦于以下问题:C# IStatusLogger.SetProgress方法的具体用法?C# IStatusLogger.SetProgress怎么用?C# IStatusLogger.SetProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStatusLogger
的用法示例。
在下文中一共展示了IStatusLogger.SetProgress方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetStatus
public static bool SetStatus(IStatusLogger slLogger, uint uPercent)
{
if(slLogger != null) return slLogger.SetProgress(uPercent);
else return true;
}
示例2: ExportGroup
private static void ExportGroup(PwGroup pg, string strDir, IStatusLogger slLogger,
uint uTotalEntries, ref uint uEntriesProcessed)
{
foreach(PwEntry pe in pg.Entries)
{
ExportEntry(pe, strDir);
++uEntriesProcessed;
if(slLogger != null)
slLogger.SetProgress(((uEntriesProcessed * 50U) /
uTotalEntries) + 50U);
}
foreach(PwGroup pgSub in pg.Groups)
{
string strGroup = UrlUtil.FilterFileName(pgSub.Name);
string strSub = (UrlUtil.EnsureTerminatingSeparator(strDir, false) +
(!string.IsNullOrEmpty(strGroup) ? strGroup : KPRes.Group));
ExportGroup(pgSub, strSub, slLogger, uTotalEntries, ref uEntriesProcessed);
}
}
示例3: DeletePreviousExport
private static void DeletePreviousExport(string strDir, IStatusLogger slLogger)
{
List<string> vDirsToDelete = new List<string>();
try
{
string[] vFiles = Directory.GetFiles(strDir, "*.url",
SearchOption.AllDirectories);
for(int iFile = 0; iFile < vFiles.Length; ++iFile)
{
string strFile = vFiles[iFile];
try
{
IniFile ini = IniFile.Read(strFile, Encoding.Default);
string strType = ini.Get(PwDefs.ShortProductName, IniTypeKey);
if((strType != null) && (strType == IniTypeValue))
{
File.Delete(strFile);
string strCont = UrlUtil.GetFileDirectory(strFile, false, true);
if(vDirsToDelete.IndexOf(strCont) < 0)
vDirsToDelete.Add(strCont);
}
}
catch(Exception) { Debug.Assert(false); }
if(slLogger != null)
slLogger.SetProgress(((uint)iFile * 50U) / (uint)vFiles.Length);
}
bool bDeleted = true;
while(bDeleted)
{
bDeleted = false;
for(int i = (vDirsToDelete.Count - 1); i >= 0; --i)
{
try
{
Directory.Delete(vDirsToDelete[i]);
WaitForDirCommit(vDirsToDelete[i], false);
vDirsToDelete.RemoveAt(i);
bDeleted = true;
}
catch(Exception) { } // E.g. not empty
}
}
}
catch(Exception) { Debug.Assert(false); }
}
示例4: Import
public override void Import(PwDatabase pwStorage, Stream sInput,
IStatusLogger slLogger)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(sInput);
XmlNode xmlRoot = xmlDoc.DocumentElement;
Debug.Assert(xmlRoot.Name == ElemRoot);
Stack<PwGroup> vGroups = new Stack<PwGroup>();
vGroups.Push(pwStorage.RootGroup);
int nNodeCount = xmlRoot.ChildNodes.Count;
for(int i = 0; i < nNodeCount; ++i)
{
XmlNode xmlChild = xmlRoot.ChildNodes[i];
if(xmlChild.Name == ElemGroup)
ReadGroup(xmlChild, vGroups, pwStorage);
else { Debug.Assert(false); }
if(slLogger != null)
slLogger.SetProgress((uint)(((i + 1) * 100) / nNodeCount));
}
}
示例5: Import
public override void Import(PwDatabase pwStorage, Stream sInput,
IStatusLogger slLogger)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(sInput);
XmlNode xmlRoot = xmlDoc.DocumentElement;
Debug.Assert(xmlRoot.Name == ElemRoot);
Dictionary<string, PwGroup> dictGroups = new Dictionary<string, PwGroup>();
int nNodeCount = xmlRoot.ChildNodes.Count;
for(int i = 0; i < nNodeCount; ++i)
{
XmlNode xmlChild = xmlRoot.ChildNodes[i];
if(xmlChild.Name == ElemEntry)
ReadEntry(xmlChild, pwStorage, dictGroups);
else { Debug.Assert(false); }
if(slLogger != null)
slLogger.SetProgress((uint)(((i + 1) * 100) / nNodeCount));
}
}
示例6: DeletePreviousExport
private static void DeletePreviousExport(string strDir, IStatusLogger slLogger)
{
List<string> vDirsToDelete = new List<string>();
try
{
List<string> lUrlFiles = UrlUtil.GetFilePaths(strDir, "*.url",
SearchOption.AllDirectories);
List<string> lLnkFiles = UrlUtil.GetFilePaths(strDir, "*.lnk",
SearchOption.AllDirectories);
List<string> lFiles = new List<string>();
lFiles.AddRange(lUrlFiles);
lFiles.AddRange(lLnkFiles);
for(int iFile = 0; iFile < lFiles.Count; ++iFile)
{
string strFile = lFiles[iFile];
try
{
bool bDelete = false;
if(strFile.EndsWith(".url", StrUtil.CaseIgnoreCmp))
{
IniFile ini = IniFile.Read(strFile, Encoding.Default);
string strType = ini.Get(PwDefs.ShortProductName, IniTypeKey);
bDelete = ((strType != null) && (strType == IniTypeValue));
}
else if(strFile.EndsWith(".lnk", StrUtil.CaseIgnoreCmp))
{
ShellLinkEx sl = ShellLinkEx.Load(strFile);
if(sl != null)
bDelete = ((sl.Description != null) &&
sl.Description.EndsWith(LnkDescSuffix));
}
else { Debug.Assert(false); }
if(bDelete)
{
File.Delete(strFile);
string strCont = UrlUtil.GetFileDirectory(strFile, false, true);
if(vDirsToDelete.IndexOf(strCont) < 0)
vDirsToDelete.Add(strCont);
}
}
catch(Exception) { Debug.Assert(false); }
if(slLogger != null)
slLogger.SetProgress(((uint)iFile * 50U) / (uint)lFiles.Count);
}
bool bDeleted = true;
while(bDeleted)
{
bDeleted = false;
for(int i = (vDirsToDelete.Count - 1); i >= 0; --i)
{
try
{
Directory.Delete(vDirsToDelete[i], false);
WaitForDirCommit(vDirsToDelete[i], false);
vDirsToDelete.RemoveAt(i);
bDeleted = true;
}
catch(Exception) { } // E.g. not empty
}
}
}
catch(Exception) { Debug.Assert(false); }
}