Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / C#

Dual Pane File Manager

Rate me:
Please Sign up or sign in to vote.
4.64/5 (28 votes)
21 Dec 2010CPOL8 min read 140.3K   2.2K   119  
A dual pane file manager for Windows XP.
using System;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace JFileManager
{
	//	Put the extra info we need in the TreeNode
	public class cTNode : TreeNode
	{
		public string Path = "";
		public ObjectType ObjectType = ObjectType.NONE;
		public DriveType DriveType = DriveType.Unknown;
		public FileAttributes Attributes;
		public bool ObjectIsEditable = false;
		public bool CanDropOnObject = false;
		public int Mask = 0;
		public int StateMask = 0;
		public int State = 0;

		public cTNode(ObjectType oType)
		{
			if (oType == ObjectType.COMPUTER)
				GetComputerInformation();
			else if (oType == ObjectType.DUMMY)
				GetDummyInformation();
		}

		public cTNode(DriveInfo drivInfo)
		{
			bool blnDriveIsReady = false;
			bool blnDriveIsWriteable = false;

			cJDriveInfo jDriveInfo = new cJDriveInfo(drivInfo, false);

			this.Text = jDriveInfo.DisplayName;
			this.Path = jDriveInfo.Path;
			this.ImageIndex = jDriveInfo.IconIndex;
			this.SelectedImageIndex = jDriveInfo.SelectedIconIndex;
			this.ObjectType = jDriveInfo.ObjectType;
			this.DriveType = drivInfo.DriveType;
			blnDriveIsReady = drivInfo.IsReady;
			blnDriveIsWriteable = (drivInfo.DriveType == DriveType.Fixed) || (drivInfo.DriveType == DriveType.Removable) || (drivInfo.DriveType == DriveType.Network);
			this.CanDropOnObject = (blnDriveIsWriteable && blnDriveIsReady);
			this.ObjectIsEditable = false;
			cCommon.GetTVImageMask(this.Path, out this.Mask, out this.StateMask, out this.State);
		}

		public cTNode(DirectoryInfo dInfo)
		{
			cJDirectoryInfo jDirectoryInfo = new cJDirectoryInfo(dInfo, false);

			this.Text = jDirectoryInfo.DisplayName;
			this.Path = jDirectoryInfo.Path;
			this.ImageIndex = jDirectoryInfo.IconIndex;
			this.SelectedImageIndex = jDirectoryInfo.SelectedIconIndex;
			this.ObjectType = jDirectoryInfo.ObjectType;
			this.Attributes = jDirectoryInfo.Attributes;
			this.ObjectIsEditable = cCommon.IsObjectEditable(dInfo);
			this.CanDropOnObject = this.ObjectIsEditable;
			cCommon.GetTVImageMask(this.Path, out this.Mask, out this.StateMask, out this.State);
		}

		private void GetComputerInformation()
		{
			cJComputerInfo jComputerInfo = new cJComputerInfo(false);

			this.Text = jComputerInfo.DisplayName;
			this.Path = jComputerInfo.Path;
			this.ImageIndex = jComputerInfo.IconIndex;
			this.SelectedImageIndex = jComputerInfo.SelectedIconIndex;
			this.ObjectType = jComputerInfo.ObjectType;
			this.ObjectIsEditable = false;
		}

		private void GetDummyInformation()
		{
			this.Text = "Dummy";
			this.Path = "Dummy";
			this.ImageIndex = 0;
			this.ObjectType = ObjectType.DUMMY;
			this.ObjectIsEditable = false;
		}

		

	}
}







By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Retired
United Kingdom United Kingdom
I have been a keen hobbyist programmer since getting my first computer - a Vic 20 (you had to be able to write programs then since few programs were available and all were expensive).
Retired and now living in Pewsey, Wiltshire, where I spend (far too much of) my time writing computer programs to keep my mind active.

Comments and Discussions