本文整理汇总了C#中ItemList.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# ItemList.Insert方法的具体用法?C# ItemList.Insert怎么用?C# ItemList.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList.Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KeepTogether
public void KeepTogether(ItemList Actionlist)
{
// for each of the items in rcl, do the same copy/move if for other items with the same
// base name, but different extensions
ItemList extras = new ItemList();
foreach (Item Action1 in Actionlist)
{
if (!(Action1 is ActionCopyMoveRename))
continue;
ActionCopyMoveRename Action = (ActionCopyMoveRename)(Action1);
try
{
DirectoryInfo sfdi = Action.From.Directory;
string basename = Action.From.Name;
int l = basename.Length;
basename = basename.Substring(0, l - Action.From.Extension.Length);
string toname = Action.To.Name;
int l2 = toname.Length;
toname = toname.Substring(0, l2 - Action.To.Extension.Length);
FileInfo[] flist = sfdi.GetFiles(basename + ".*");
foreach (FileInfo fi in flist)
{
// do case insensitive replace
string n = fi.Name;
int p = n.ToUpper().IndexOf(basename.ToUpper());
string newName = n.Substring(0, p) + toname + n.Substring(p + basename.Length);
if ((TVSettings.Instance.RenameTxtToSub) && (newName.EndsWith(".txt")))
newName = newName.Substring(0, newName.Length - 4) + ".sub";
ActionCopyMoveRename newitem = new ActionCopyMoveRename(Action.Operation, fi, FileHelper.FileInFolder(Action.To.Directory, newName), Action.Episode, null); // tidyup on main action, not this
// check this item isn't already in our to-do list
bool doNotAdd = false;
foreach (Item ai2 in Actionlist)
{
if (!(ai2 is ActionCopyMoveRename))
continue;
if (((ActionCopyMoveRename)(ai2)).SameSource(newitem))
{
doNotAdd = true;
break;
}
}
if (!doNotAdd)
{
if (!newitem.SameAs(Action)) // don't re-add ourself
extras.Add(newitem);
}
}
}
catch (System.IO.PathTooLongException e)
{
string t = "Path or filename too long. " + Action.From.FullName + ", " + e.Message;
MessageBox.Show(t, "Path or filename too long", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
foreach (Item action in extras)
{
// check we don't already have this in our list and, if we don't add it!
bool have = false;
foreach (Item action2 in Actionlist)
{
if (action2.SameAs(action))
{
have = true;
break;
}
if ((action is Action) && (action2 is Action) )
{
Action a1 = (Action)action;
Action a2 = (Action)action2;
if (a2.produces == a1.produces)
{
have = true;
break;
}
}
}
if (!have)
Actionlist.Insert(0, action); // put before other actions, so tidyup is run last
}
}