本文整理汇总了C#中Category.RenameFile方法的典型用法代码示例。如果您正苦于以下问题:C# Category.RenameFile方法的具体用法?C# Category.RenameFile怎么用?C# Category.RenameFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category.RenameFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainForm
//.........这里部分代码省略.........
}
};
CategoryListView.ListViewItemSorter = new ListViewIndexComparer();
CategoryListView.AllowDrop = true;
CategoryListView.MouseMove += (s, e) => {
if (e.Button == MouseButtons.Left) {
if (CategoryListView.SelectedItems.Count > 0) {
var item = CategoryListView.SelectedItems[0];
CategoryListView.DoDragDrop(item.Name, DragDropEffects.Move);
}
}
};
CategoryListView.DragEnter += (s, e) => {
if (e.Data.GetDataPresent(typeof(Data)) || e.Data.GetDataPresent(typeof(string)))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
};
CategoryListView.DragOver += (s, e) => {
var point = CategoryListView.PointToClient(new Point(e.X, e.Y));
var item = CategoryListView.GetItemAt(point.X, point.Y);
if (e.Data.GetDataPresent(typeof(Data)) && (item != null && item.Name != getSelectedCategory()))
e.Effect = DragDropEffects.Move;
else if(e.Data.GetDataPresent(typeof(string)) && (item.Name != getSelectedCategory()))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
};
CategoryListView.DragDrop += (s, e) => {
if (e.Data.GetDataPresent(typeof(Data))) {
var data = (Data)e.Data.GetData(typeof(Data));
var point = CategoryListView.PointToClient(new Point(e.X, e.Y));
var item = CategoryListView.GetItemAt(point.X, point.Y);
if (item != null && item.Name != getSelectedCategory()) {
DeleteItem(data.ID);
//category.getManger(item.Name).Insert(data);
}
}
else if (e.Data.GetDataPresent(typeof(string))) {
var name = (string)e.Data.GetData(typeof(string));
var point = CategoryListView.PointToClient(new Point(e.X, e.Y));
var item = CategoryListView.GetItemAt(point.X, point.Y);
var index = CategoryListView.Items.IndexOfKey(name);
if (index >= 0) {
var key = item.Name;
var removeitem = CategoryListView.Items[index];
var i = CategoryListView.Items.IndexOfKey(item.Name);
if (i == 0 || (i < CategoryListView.Items.Count - 1)) {
CategoryListView.Items.Remove(removeitem);
var ni = CategoryListView.Items.IndexOfKey(item.Name);
var ins = i == 0 ? 0 : ni + 1;
CategoryListView.Items.Insert(ins, removeitem);
//config.Categorys.Remove(name);
//config.Categorys.Insert(ins, name);
//CategoryListView.Sort();
}
removeitem.Selected = true;
}
}
};
CategoryListView.AfterLabelEdit += (s, e) => {
//e.CancelEdit = true;
if (File.Exists(Path.Combine(config.DataDirPath, e.Label + ".xml"))) {
e.CancelEdit = true;
}
else {
var item = CategoryListView.Items[e.Item];
if (category.RenameFile(item.Name, e.Label)) {
item.Text = e.Label;
item.Name = e.Label;
}
}
};
TabListViewEditItemToolStripMenuItem.Click += (s, e) => {
var lv = GetSelctedTabListViewControl();
if (lv.SelectedIndices.Count > 0) {
var index = lv.SelectedIndices[0];
EditItem(lv.DataItems[index].ID, true);
}
};
TabListViewNewItemToolStripMenuItem.Click += (s, e) => {
this.CreateItem();
};
TabListViewDeleteItemToolStripMenuItem.Click += (s, e) => {
this.DeleteItem();
};
TabListViewEditDateTimeToolStripMenuItem.Click += (s, e) => {
this.EditDateTime();
};
}