当前位置: 首页>>代码示例>>C#>>正文


C# Category.RenameFile方法代码示例

本文整理汇总了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();
            };
        }
开发者ID:mohammadul,项目名称:addondev,代码行数:101,代码来源:MainForm.cs


注:本文中的Category.RenameFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。