Subversion Repositories Code-Repo

Compare Revisions

No changes between revisions

Ignore whitespace Rev 47 → Rev 48

/SWAT Office App/trunk/SWAT Office App/AboutBox.cs
15,7 → 15,7
InitializeComponent();
this.Text = "Program Info";
this.labelProductName.Text = "SWAT Office App";
this.labelVersion.Text = "Version 2.4.1";
this.labelVersion.Text = "Version 2.5";
this.labelCopyright.Text = "Copyright to Kevin Lee @ Virginia Tech";
this.labelCompanyName.Text = "Author: Kevin Lee";
this.textBoxDescription.Text = "This program has been written by Kevin Lee for use " +
/SWAT Office App/trunk/SWAT Office App/DriveLogger_Form.Designer.cs
51,7 → 51,6
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(548, 111);
this.ControlBox = false;
this.Controls.Add(this.listView_Drives);
this.MaximizeBox = false;
this.Name = "DriveLogger_Form";
/SWAT Office App/trunk/SWAT Office App/DriveLogger_Form.cs
30,6 → 30,7
{
// Disable thread safe checking
CheckForIllegalCrossThreadCalls = false;
 
driveEntryList.Clear();
InitializeComponent();
 
60,44 → 61,45
}
void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
// Compares a list of drives detected previously with the a list of current
// drives on the computer. If a change in length is detected, a drive is either
// added or removed so the drive in question is found and operated upon
List<string> drivesPreviouslyDetected = new List<string>();
List<string> drivesPreviouslyDetectedList = new List<string>();
DriveInfo[] newlyDetectedDrives = DriveInfo.GetDrives();
 
// Resets both lists to hold the same drives
drivesPreviouslyDetectedList.Clear();
foreach (DriveInfo drive in newlyDetectedDrives)
drivesPreviouslyDetected.Add(drive.Name);
drivesPreviouslyDetectedList.Add(drive.Name);
 
while (true)
{
// Pulls list of new drives
// Cancels thread if DriveLogger form is closed
if (!instanceAlreadyRunning)
{
//MessageBox.Show("Thread Stopped");
e.Cancel = true;
break;
}
// Pulls new list of current drives on computer
newlyDetectedDrives = DriveInfo.GetDrives();
if (newlyDetectedDrives.Length > drivesPreviouslyDetected.Count)
if (newlyDetectedDrives.Length > drivesPreviouslyDetectedList.Count)
{
// Applies if a drive is attached to the computer
// Goes through each list and finds the drive that was recently attached
bool attachedDriveExisted = false;
bool newDrivesDetected = false;
string driveOwner = "";
string driveDock = "";
foreach (DriveInfo drive in newlyDetectedDrives)
{
attachedDriveExisted = false;
// Loop here checks for non-matching entries in the two lists
foreach (string str in drivesPreviouslyDetected)
// Skips the drive if it is in the list of drives to ignore
if (Settings_Form.driveLoggerDrivesToIgnore.Contains(drive.Name))
continue;
 
// Check for non-matching entries in the two lists
if (!drivesPreviouslyDetectedList.Contains(drive.Name))
{
// If entries match, drive is unchanged
if (str == drive.Name)
{
attachedDriveExisted = true;
break;
}
}
// If list mismatch is detected, adds new entry to driveEntryList
if (attachedDriveExisted == false)
{
// Creates and populates a new DriveEntry
DriveEntry newEntry = new DriveEntry();
if (newDrivesDetected == false)
156,19 → 158,23
}
}
// Clears and refreshes the drivesPreviouslyDetected list
drivesPreviouslyDetected.Clear();
drivesPreviouslyDetectedList.Clear();
foreach (DriveInfo drive in newlyDetectedDrives)
{
drivesPreviouslyDetected.Add(drive.Name);
drivesPreviouslyDetectedList.Add(drive.Name);
}
}
else if (newlyDetectedDrives.Length < drivesPreviouslyDetected.Count)
if (newlyDetectedDrives.Length < drivesPreviouslyDetectedList.Count)
{
// Applies if a drive is removed to the computer
// Goes through each list and finds the drive that was recently removed
bool removedDriveFound = false;
foreach (string str in drivesPreviouslyDetected)
foreach (string str in drivesPreviouslyDetectedList)
{
// Skips the drive if it is in the list of drives to ignore
if (Settings_Form.driveLoggerDrivesToIgnore.Contains(str))
continue;
removedDriveFound = false;
// Loop here checks for non-matching entries in the two lists
foreach (DriveInfo drive in newlyDetectedDrives)
201,22 → 207,13
}
}
// Clears and refreshes the drivesPreviouslyDetected list
drivesPreviouslyDetected.Clear();
drivesPreviouslyDetectedList.Clear();
foreach (DriveInfo drive in newlyDetectedDrives)
{
drivesPreviouslyDetected.Add(drive.Name);
drivesPreviouslyDetectedList.Add(drive.Name);
}
}
else
{
// Sets the two lists to hold the same drives
drivesPreviouslyDetected.Clear();
foreach (DriveInfo drive in newlyDetectedDrives)
{
drivesPreviouslyDetected.Add(drive.Name);
}
}
 
// Sleeps the thread for a specified amount of time
Thread.Sleep(Settings_Form.driveLoggerRefreshInterval);
}
/SWAT Office App/trunk/SWAT Office App/Manage_User_Accounts.cs
228,6 → 228,40
MessageBox.Show(e.ToString(), "Error");
}
}
public static long GetShareSize(string username)
{
DirectoryInfo dir = new DirectoryInfo(Settings_Form.sharedFolderLocation + @"\" + username);
long size = GetDirSize(dir);
return size;
}
private static long GetDirSize(DirectoryInfo input)
{
try
{
if (input.Exists)
{
long size = 0;
FileInfo[] files = input.GetFiles();
foreach (FileInfo file in files)
{
size += file.Length;
}
DirectoryInfo[] dirs = input.GetDirectories();
foreach (DirectoryInfo dir in dirs)
{
size += GetDirSize(dir);
}
return size;
}
else
return 0;
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Error");
return 0;
}
}
public static void ChangeUserPassword(string username, string password)
{
try
/SWAT Office App/trunk/SWAT Office App/Manage_User_Accounts_Form.Designer.cs
50,7 → 50,7
this.lst_UserAccounts.HideSelection = false;
this.lst_UserAccounts.Location = new System.Drawing.Point(12, 12);
this.lst_UserAccounts.Name = "lst_UserAccounts";
this.lst_UserAccounts.Size = new System.Drawing.Size(277, 348);
this.lst_UserAccounts.Size = new System.Drawing.Size(327, 348);
this.lst_UserAccounts.TabIndex = 0;
this.lst_UserAccounts.UseCompatibleStateImageBehavior = false;
this.lst_UserAccounts.View = System.Windows.Forms.View.Details;
58,7 → 58,7
// btn_Add
//
this.btn_Add.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_Add.Location = new System.Drawing.Point(303, 46);
this.btn_Add.Location = new System.Drawing.Point(353, 46);
this.btn_Add.Name = "btn_Add";
this.btn_Add.Size = new System.Drawing.Size(75, 40);
this.btn_Add.TabIndex = 2;
69,7 → 69,7
// btn_Delete
//
this.btn_Delete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_Delete.Location = new System.Drawing.Point(303, 99);
this.btn_Delete.Location = new System.Drawing.Point(353, 99);
this.btn_Delete.Name = "btn_Delete";
this.btn_Delete.Size = new System.Drawing.Size(75, 40);
this.btn_Delete.TabIndex = 3;
81,7 → 81,7
//
this.btn_Exit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btn_Exit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btn_Exit.Location = new System.Drawing.Point(328, 338);
this.btn_Exit.Location = new System.Drawing.Point(378, 338);
this.btn_Exit.Name = "btn_Exit";
this.btn_Exit.Size = new System.Drawing.Size(50, 22);
this.btn_Exit.TabIndex = 7;
92,7 → 92,7
// btn_Pass
//
this.btn_Pass.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_Pass.Location = new System.Drawing.Point(303, 152);
this.btn_Pass.Location = new System.Drawing.Point(353, 152);
this.btn_Pass.Name = "btn_Pass";
this.btn_Pass.Size = new System.Drawing.Size(75, 40);
this.btn_Pass.TabIndex = 4;
103,7 → 103,7
// btn_Share
//
this.btn_Share.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_Share.Location = new System.Drawing.Point(303, 205);
this.btn_Share.Location = new System.Drawing.Point(353, 205);
this.btn_Share.Name = "btn_Share";
this.btn_Share.Size = new System.Drawing.Size(75, 40);
this.btn_Share.TabIndex = 5;
115,7 → 115,7
//
this.btn_Refresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_Refresh.Image = global::SWAT_Office_App.Properties.Resources.Refresh;
this.btn_Refresh.Location = new System.Drawing.Point(303, 12);
this.btn_Refresh.Location = new System.Drawing.Point(353, 12);
this.btn_Refresh.Name = "btn_Refresh";
this.btn_Refresh.Size = new System.Drawing.Size(23, 23);
this.btn_Refresh.TabIndex = 1;
125,7 → 125,7
// btn_OpenShare
//
this.btn_OpenShare.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_OpenShare.Location = new System.Drawing.Point(303, 258);
this.btn_OpenShare.Location = new System.Drawing.Point(353, 258);
this.btn_OpenShare.Name = "btn_OpenShare";
this.btn_OpenShare.Size = new System.Drawing.Size(75, 40);
this.btn_OpenShare.TabIndex = 6;
138,7 → 138,7
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btn_Exit;
this.ClientSize = new System.Drawing.Size(390, 372);
this.ClientSize = new System.Drawing.Size(440, 372);
this.Controls.Add(this.btn_OpenShare);
this.Controls.Add(this.btn_Refresh);
this.Controls.Add(this.btn_Share);
/SWAT Office App/trunk/SWAT Office App/Manage_User_Accounts_Form.cs
30,10 → 30,15
Column_3.TextAlign = HorizontalAlignment.Center;
this.lst_UserAccounts.Columns.Add(Column_3);
ColumnHeader Column_4 = new ColumnHeader();
Column_4.Text = "Date Created";
Column_4.Width = 80;
Column_4.Text = "Size";
Column_4.Width = 50;
Column_4.TextAlign = HorizontalAlignment.Center;
this.lst_UserAccounts.Columns.Add(Column_4);
ColumnHeader Column_5 = new ColumnHeader();
Column_5.Text = "Date Created";
Column_5.Width = 80;
Column_5.TextAlign = HorizontalAlignment.Center;
this.lst_UserAccounts.Columns.Add(Column_5);
 
PaintUserListbox();
this.btn_Delete.Enabled = false;
93,6 → 98,13
else
s_share.Text = "No";
entry.SubItems.Add(s_share);
ListViewItem.ListViewSubItem s_size = new ListViewItem.ListViewSubItem();
long size = ManageUserAccounts.GetShareSize(user);
if ((size / 1073741824) > 0)
s_size.Text = (size / 1073741824).ToString() + " GB";
else
s_size.Text = (size / 1048576).ToString() + " MB";
entry.SubItems.Add(s_size);
ListViewItem.ListViewSubItem s_datecreated = new ListViewItem.ListViewSubItem();
s_datecreated.Text = extraUserInformation[1];
entry.SubItems.Add(s_datecreated);
/SWAT Office App/trunk/SWAT Office App/Settings.xml
1,11 → 1,13
<?xml version="1.0" encoding="utf-8"?>
<Settings>
<ProgramSettings>
<ShowGuestAccounts>false</ShowGuestAccounts>
<SystemAccounts>Administrators,Administrator</SystemAccounts>
<HiddenAccounts>Administrator</HiddenAccounts>
<SharedFolderLocation>C:\</SharedFolderLocation>
<USBMasterCopyx32Location>C:\</USBMasterCopyx32Location>
<USBMasterCopyx64Location>C:\</USBMasterCopyx64Location>
</ProgramSettings>
<ProgramSettings>
<SystemAccounts>Administrators,Administrator</SystemAccounts>
<HiddenAccounts>Administrator,Guest</HiddenAccounts>
<SharedFolderLocation>C:\</SharedFolderLocation>
<USBMasterCopyx32Location>C:\</USBMasterCopyx32Location>
<USBMasterCopyx64Location>C:\</USBMasterCopyx64Location>
<DockLabels>Dock 1,Dock 2,Dock 3,External USB</DockLabels>
<DockRefreshInterval>1000</DockRefreshInterval>
<DockDrivesToIgnore>C:\</DockDrivesToIgnore>
</ProgramSettings>
</Settings>
/SWAT Office App/trunk/SWAT Office App/Settings_Form.cs
21,6 → 21,7
public static string usbMasterx64CopyLocation { get; set; }
public static List<string> driveLoggerDockLabels = new List<string>();
public static int driveLoggerRefreshInterval { get; set; }
public static List<string> driveLoggerDrivesToIgnore = new List<string>();
 
private static Settings_Form _Settings_Form = null;
// Singleton instance so the settings file isnt loaded every time
44,6 → 45,7
this.listBox_SystemAccounts.SelectedIndexChanged += new EventHandler(this.listBox_SystemAccounts_SelectedIndexChanged);
this.listBox_HiddenAccounts.SelectedIndexChanged += new EventHandler(this.listBox_HiddenAccounts_SelectedIndexChanged);
this.Load += new EventHandler(Settings_Form_Load);
}
private void Settings_Form_Load(object sender, EventArgs e)
{
88,6 → 90,12
 
driveLoggerRefreshInterval = int.Parse(Settings.Element("ProgramSettings").Element("DockRefreshInterval").Value);
 
driveLoggerDrivesToIgnore.Clear();
string tempDrivesToIgnore = Settings.Element("ProgramSettings").Element("DockDrivesToIgnore").Value;
tempStringArray = tempDrivesToIgnore.Split(new char[] { ',' });
foreach (string str in tempStringArray)
driveLoggerDrivesToIgnore.Add(str.Trim());
 
sharedFolderLocation = Settings.Element("ProgramSettings").Element("SharedFolderLocation").Value;
usbMasterx32CopyLocation = Settings.Element("ProgramSettings").Element("USBMasterCopyx32Location").Value;
usbMasterx64CopyLocation = Settings.Element("ProgramSettings").Element("USBMasterCopyx64Location").Value;
163,7 → 171,8
new XElement("USBMasterCopyx32Location", "C:\\"),
new XElement("USBMasterCopyx64Location", "C:\\"),
new XElement("DockLabels", "Dock 1,Dock 2,Dock 3,External USB"),
new XElement("DockRefreshInterval", 1000)
new XElement("DockRefreshInterval", 1000),
new XElement("DockDrivesToIgnore", "C:\\")
)
);
Settings.Save("Settings.xml");
/SWAT Office App/trunk/SWAT Office App/bin/Debug/SWAT Office App.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/SWAT Office App/trunk/SWAT Office App/bin/Debug/SWAT Office App.pdb
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/SWAT Office App/trunk/SWAT Office App/bin/Debug/Settings.xml
8,5 → 8,6
<USBMasterCopyx64Location>C:\</USBMasterCopyx64Location>
<DockLabels>Dock 1,Dock 2,Dock 3,External USB</DockLabels>
<DockRefreshInterval>1000</DockRefreshInterval>
<DockDrivesToIgnore>C:\</DockDrivesToIgnore>
</ProgramSettings>
</Settings>
/SWAT Office App/trunk/SWAT Office App/bin/Release/SWAT Office App.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/SWAT Office App/trunk/SWAT Office App/bin/Release/SWAT Office App.pdb
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/SWAT Office App/trunk/SWAT Office App/bin/Release/Settings.xml
8,5 → 8,6
<USBMasterCopyx64Location>C:\</USBMasterCopyx64Location>
<DockLabels>Dock 1,Dock 2,Dock 3,External USB</DockLabels>
<DockRefreshInterval>1000</DockRefreshInterval>
<DockDrivesToIgnore>C:\</DockDrivesToIgnore>
</ProgramSettings>
</Settings>
/SWAT Office App/trunk/SWAT Office App/obj/x86/Debug/SWAT Office App.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/SWAT Office App/trunk/SWAT Office App/obj/x86/Debug/SWAT Office App.pdb
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/SWAT Office App/trunk/SWAT Office App/obj/x86/Release/SWAT Office App.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/SWAT Office App/trunk/SWAT Office App/obj/x86/Release/SWAT Office App.pdb
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/SWAT Office App/trunk/SWAT Office App.suo
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream