📄 frmdemoexplorer.cs
字号:
/* *************************************************
* Development : Rajesh Lal(connectrajesh@hotmail.com)
* Date: 04/15/2007
* Company Info: www.csharptricks.com
* See EULA.txt and Copyright.txt for additional information
* **************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using ExpTreeLib;
namespace PenFlicksDemo
{
public partial class frmDemoExplorer : Form
{
CShItem LastSelectedCSI;
private ArrayList BackList;
public frmDemoExplorer()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SystemImageListManager.SetListViewImageList(lv1, true , false );
SystemImageListManager.SetListViewImageList(lv1, true , false );
}
private void SetUpComboBox(CShItem item)
{
BackList = new ArrayList();
CShItem CSI = item;
while (!(CSI.Parent == null))
{
CSI = CSI.Parent;
BackList.Add(CSI);
}
lv1.Focus();
}
private void expTree1_ExpTreeNodeSelected(string pathName, CShItem CSI)
{
ArrayList dirList = new ArrayList();
ArrayList fileList = new ArrayList();
int TotalItems;
LastSelectedCSI = CSI;
if (CSI.DisplayName.Equals(CShItem.strMyComputer)) {
dirList = CSI.GetDirectories(true );
}
else {
dirList = CSI.GetDirectories(true);
fileList = CSI.GetFiles();
}
SetUpComboBox(CSI);
TotalItems = (dirList.Count + fileList.Count);
if ((dirList.Count > 0))
{
sbr1.Text = "Location: " + pathName + ", " + dirList.Count + " Directorie(s) and " + fileList.Count + " File(s)";
ArrayList combList = new ArrayList(TotalItems);
combList.AddRange(dirList);
combList.AddRange(fileList);
// Build the ListViewItems & add to lv1
lv1.BeginUpdate();
lv1.Items.Clear();
imglpreviewForm.Images.Clear();
foreach (CShItem item in combList)
{
ListViewItem lvi = new ListViewItem(item.DisplayName);
if (item.IsFolder)
{
CShItem localitem = item;
imglpreviewForm.Images.Add(SystemImageListManager.GetIcon(localitem.IconIndexNormal, false));
lvi.ImageIndex = SystemImageListManager.GetIconIndex(ref localitem, false, false);
lvi.Tag = item;
lv1.Items.Add(lvi);
}
}
lv1.EndUpdate();
myPhotos1.SetFolder(lv1, imglpreviewForm);
myPhotos1.CaptionText = CSI.DisplayName;
}
else {
lv1.Items.Clear();
sbr1.Text = "Location: " + pathName + ", " + dirList.Count + " Directorie(s) and " + fileList.Count + " File(s)";
}
}
private void lv1_DoubleClick(object sender, EventArgs e)
{
ListViewItem lvi = lv1.SelectedItems[0];
if ((lvi == null))
{
return;
}
if (((lv1.SelectedItems == null)
|| (lv1.SelectedItems.Count < 1)))
{
return;
}
CShItem item = (CShItem)lv1.SelectedItems[0].Tag;
if (item.IsFolder)
{
expTree1.ExpandANode(item);
}
}
private void myPhotos1_SelectFolder(object sender, EventArgs e)
{
myPhotos1.ResetText();
ListViewItem lvi = myPhotos1.ExplorerSelectedItem;
if ((lvi == null))
{
return;
}
CShItem item = (CShItem)lvi.Tag;
if (item.IsFolder)
{
//Event1.WaitOne();
expTree1.ExpandANode(item);
}
}
private void myPhotos1_DoubleClick(object sender, EventArgs e)
{
}
private void myPhotos1_ImageChanged(object sender, EventArgs e)
{
}
private void myPhotos1_GoBack(object sender, EventArgs e)
{
if (BackList.Count > 0)
{
CShItem item = (CShItem)BackList[0];
BackList = new ArrayList();
//cb1.Items.Clear();
expTree1.RootItem = item;
}
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.codeproject.com/useritems/PenFlicksDemo.asp");
}
private void linkLabel2_MouseUp(object sender, MouseEventArgs e)
{
}
private void linkLabel2_DoubleClick(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.csharptricks.com");
}
private void myPhotos1_MouseUp(object sender, MouseEventArgs e)
{
}
private void myPhotos1_KeyDown(object sender, KeyEventArgs e)
{
}
private void myPhotos1_Load(object sender, EventArgs e)
{
}
private void myPhotos1_GoForward(object sender, EventArgs e)
{
myPhotos1_SelectFolder(sender, e);
}
private void expTree1_StartUpDirectoryChanged(ExpTree.StartDir newVal)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -