找回密码
 立即注册

QQ登录

只需一步,快速开始

thrall

超级版主

11

主题

170

帖子

1867

积分

超级版主

Rank: 8Rank: 8

积分
1867

活字格认证微信认证勋章

thrall
超级版主   /  发表于:2013-5-7 12:04  /   查看:5855  /  回复:0
介绍从Vista开始,地址栏就有了很大的改变,不知道大家有什么感觉,笔者觉得很方便,同时又兼容之前的功能,是个很不错的创新。不过,微软并不打算把这一很酷的功能提供给广大的开发人员。
本文提供了一个简单的Address Bar实现,使用.NET 2.0和VS2008. 它是基于一个简单的树型遍历实现的,同时适用于各种级联数据。

Demo中提供的是一个非常简单的示例,可以浏览文件系统。这里这是展示它是如何工作的。
使用代码了解实现最简单的办法就是直接下载源代码,然后打开玩玩看~
在Design-Time下将Address Bar Control拖入Form,然后再构造器中加入下面一行代码:

  1. //Initialize the bar with a root node type.
  2. this.AdBar.InitializeRoot(new FileSystemNode());
复制代码


你只需要传入一个根节点,然后根节点就会为control提供信息。FileSystemNode包含Windows系统安装后的第一个逻辑盘信息。 要实现IAddressNode类型,有如下三个重要的方法需要自己实现:

  1. UpdateNode() - Used to update the node itself for any changes (e.g. in the FileSystemNode it checks for child folder changes and folder name changes)

  2. GetChild() - Searches for a given child node based on a unique ID (A Unique ID being whatever you define it as. In FileSystemNode, we use an absolute path for a folder as the unique ID).

  3. Clone() - Clones a given node as a separate value copy (rather than just by reference).
复制代码


总结示例很简单,相对来说也是轻量级的实现。如果想用它操作输了FileSystemNode以外的数据,你只需要实现IAddressNode接口,任何级联结构(hierarchical structure)的数据都可以用它来呈现。 许可证本文以及示例代码文件遵循The Code Project Open License(CPOL)。 源码下载附件:AddressBarExt2_1.zip
英文链接:Vista Style Address Bar for .NET 2.0/WinForms

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部