Made code neater and fixed Address Book bugs!

This commit is contained in:
Alex-TIMEHACK 2017-11-04 10:51:45 +00:00
parent e7a1221130
commit fd13d9d4f6
4 changed files with 162 additions and 444 deletions

View file

@ -397,228 +397,89 @@ void OpenApplication(string appname, string path)
}
}
string ReturnType(string extension) {
string returnVal = "File";
fileType = 0;
int ReturnType(string extension) {
switch (extension) {
case ".txt":
fileType = 1;
returnVal = "Text Document \n createtext";
break;
case ".dat":
fileType = 1;
returnVal = "Text Document \n createtext";
break;
case ".rtf":
fileType = 2;
returnVal = "Rich Text Document \n createtext";
break;
case ".cfg":
fileType = 1;
returnVal = "Config file \n createtext";
break;
case ".log":
fileType = 1;
returnVal = "log text file \n createtext";
break;
case ".ini":
fileType = 1;
returnVal = "initialization \n createtext";
break;
case ".properties":
fileType = 1;
returnVal = "Config file \n createtext";
break;
case ".json":
fileType = 1;
returnVal = "Config file \n createtext";
break;
case ".dat":
return 1;
case ".rtf":
return 2;
case ".doc":
fileType = 3;
returnVal = "Word Document \n word";
break;
return 3;
case ".docm":
fileType = 3;
returnVal = "Macro-Enabled Word Document \n word";
break;
return 3;
case ".xls":
fileType = 4;
returnVal = "Excel Spreadsheets \n excel";
break;
return 4;
case ".ppt":
fileType = 5;
returnVal = "Powerpoint Presentation \n powerpoint";
break;
return 5;
case ".pub":
fileType = 7;
returnVal = "Publisher Document \n powerpoint";
break;
return 7;
case ".xps":
fileType = 8;
returnVal = "XPS Document \n xpsview";
break;
return 8;
case ".htm":
fileType = 9;
returnVal = "HTML web page \n html";
break;
return 9;
case ".html":
fileType = 9;
returnVal = "HTML web page \n html";
break;
return 9;
case ".wps":
fileType = 10;
returnVal = "Works document \n works";
break;
return 10;
case ".wmf":
fileType = 11;
returnVal = "Windows Metafile (A picture) \n createart";
break;
case ".emf":
fileType = 11;
returnVal = "Enhanced Metafile (A picture) \n createart";
break;
case ".png":
fileType = 11;
returnVal = "Picture file (Portable Network Graphics) \n createart";
break;
case ".jpg":
fileType = 11;
returnVal = "Picture file \n createart";
break;
case ".jpeg":
fileType = 11;
returnVal = "Picture file \n createart";
break;
case ".gif":
fileType = 12;
returnVal = "Picture file \n gifman";
break;
case ".tif":
fileType = 11;
returnVal = "Picture file \n createart";
break;
case ".bmp":
fileType = 11;
returnVal = "Picture file \n createart";
break;
case ".zip":
fileType = 11;
returnVal = "Compressed ZIP file \n winrar";
break;
return 11;
case ".exe":
fileType = 12;
returnVal = "Program \n exe";
break;
case ".avi":
fileType = 15;
returnVal = "Video \n video";
break;
return 12;
case ".avi":
case ".m4v":
fileType = 15;
returnVal = "Video (MPEG-4) \n video";
break;
case ".mp4":
fileType = 15;
returnVal = "Video (MPEG-4) \n video";
break;
case ".wmv":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m2v":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m3u":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mts":
fileType = 15;
returnVal = "Video \n video";
break;
case ".dv":
fileType = 15;
returnVal = "Video (Digital Video) \n video";
break;
case ".flv":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m1v":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m2ts":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mkv":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mov":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mpeg4":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mpeg":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mpg":
fileType = 15;
returnVal = "Video \n video";
break;
case ".3gp":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m4p":
fileType = 15;
returnVal = "Video \n video";
break;
return 15;
case ".mp2":
fileType = 21;
returnVal = "Audio \n video";
break;
case ".mp3":
fileType = 21;
returnVal = "Audio \n video";
break;
case ".wav":
fileType = 21;
returnVal = "Audio \n video";
break;
return 21;
case ".nls":
fileType = 16;
returnVal = "Font file \n font";
break;
return 16;
case ".dll":
fileType = 17;
returnVal = "System File \n sys";
break;
return 17;
case ".bat":
fileType = 18;
returnVal = "MS-DOS Batch File \n winterm";
break;
return 18;
case ".url":
fileType = 19;
returnVal = "Shortcut \n short";
break;
return 19;
case ".sh":
fileType = 20;
returnVal = "BASH file \n winterm";
break;
return 20;
case ".win":
fileType = 17;
returnVal = "System file \n sys";
break;
return 17;
}
return returnVal;
return 0;
}
//Private Sub windows_explorer_Closed(sender As Object, e As EventArgs) Handles Me.Closed

View file

@ -105,67 +105,67 @@ private void InitializeComponent()
// newContactToolStripMenuItem
//
this.newContactToolStripMenuItem.Name = "newContactToolStripMenuItem";
this.newContactToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.newContactToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.newContactToolStripMenuItem.Text = "New contact...";
this.newContactToolStripMenuItem.Click += new System.EventHandler(this.newContactToolStripMenuItem_Click);
//
// newFolderToolStripMenuItem
//
this.newFolderToolStripMenuItem.Name = "newFolderToolStripMenuItem";
this.newFolderToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.newFolderToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.newFolderToolStripMenuItem.Text = "New folder...";
this.newFolderToolStripMenuItem.Click += new System.EventHandler(this.newFolderToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(147, 6);
//
// propertiesToolStripMenuItem
//
this.propertiesToolStripMenuItem.Name = "propertiesToolStripMenuItem";
this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.propertiesToolStripMenuItem.Text = "Properties";
this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.propertiesToolStripMenuItem_Click);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
this.toolStripSeparator2.Size = new System.Drawing.Size(147, 6);
//
// importToolStripMenuItem
//
this.importToolStripMenuItem.Name = "importToolStripMenuItem";
this.importToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.importToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.importToolStripMenuItem.Text = "Import...";
//
// exportToolStripMenuItem
//
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
this.exportToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.exportToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.exportToolStripMenuItem.Text = "Export...";
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(149, 6);
this.toolStripSeparator3.Size = new System.Drawing.Size(147, 6);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6);
this.toolStripSeparator4.Size = new System.Drawing.Size(147, 6);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.exitToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
@ -247,6 +247,7 @@ private void InitializeComponent()
this.aboutAddressBookToolStripMenuItem.Name = "aboutAddressBookToolStripMenuItem";
this.aboutAddressBookToolStripMenuItem.Size = new System.Drawing.Size(182, 22);
this.aboutAddressBookToolStripMenuItem.Text = "About Address Book";
this.aboutAddressBookToolStripMenuItem.Click += new System.EventHandler(this.aboutAddressBookToolStripMenuItem_Click);
//
// contactsView
//

View file

@ -42,7 +42,7 @@ public WinClassicAddressBook()
{
new AddressBookContactList()
{
AttachedNode = treeView1.Nodes[0].Text,
AttachedNode = treeView1.Nodes[0].Text
}
};
}
@ -82,17 +82,8 @@ public void UpdateContactListFromNodeName(string NodeName)
{
foreach (AddressBookContact contact in ContactList.Contacts)
{
if (contact != null)
{
if (contact.FirstName != null)
{
contactsView.Items.Add(contact.FirstName + " " + contact.MiddleName + " " + contact.LastName);
}
}
else
{
MessageBox.Show("Null contact!");
}
if (contact.FirstName != null)
contactsView.Items.Add(contact.FirstName + " " + contact.MiddleName + " " + contact.LastName);
}
}
}
@ -182,9 +173,16 @@ void OpenProperties()
{
foreach (AddressBookContact Contact in ContactList.Contacts)
{
if ((Contact.FirstName + " " + Contact.MiddleName + " " + Contact.LastName) == contactsView.FocusedItem.Text)
if (contactsView.FocusedItem == null)
{ // Most likely they are trying to view a whole folder!
wm.StartInfobox95("Properties of a folder", "You cannot view the properties of a contact folder.", InfoboxType.Warning, InfoboxButtons.OK);
}
else
{
abnc.toSet = Contact;
if ((Contact.FirstName + " " + Contact.MiddleName + " " + Contact.LastName) == contactsView.FocusedItem.Text)
{
abnc.toSet = Contact;
}
}
}
}
@ -228,22 +226,38 @@ private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
void DeleteContact()
{
if (treeView1.SelectedNode != null)
try
{
foreach (AddressBookContactList ContactList in AddressBookObjects)
if (treeView1.SelectedNode != null)
{
if (ContactList.AttachedNode == treeView1.SelectedNode.Text)
foreach (AddressBookContactList ContactList in AddressBookObjects)
{
foreach (AddressBookContact Contact in ContactList.Contacts)
if (ContactList.AttachedNode == treeView1.SelectedNode.Text)
{
if ((Contact.FirstName + " " + Contact.MiddleName + " " + Contact.LastName) == contactsView.FocusedItem.Text)
foreach (AddressBookContact Contact in ContactList.Contacts)
{
ContactList.Contacts.Remove(Contact);
if (contactsView.FocusedItem == null)
{ // Most likely they are trying to delete a whole folder!
if (treeView1.SelectedNode.Text != "Shared Contacts")
if (treeView1.SelectedNode != null)
{
AddressBookObjects.Remove(ContactList);
treeView1.Nodes.Remove(treeView1.SelectedNode);
UpdateContactListFromNodeName("Shared Contacts");
}
}
else
{
if ((Contact.FirstName + " " + Contact.MiddleName + " " + Contact.LastName) == contactsView.FocusedItem.Text)
{
ContactList.Contacts.Remove(Contact);
}
}
}
}
}
}
}
} catch { }
}
private void toolDelete_Click(object sender, EventArgs e)
@ -278,7 +292,12 @@ private void exitToolStripMenuItem_Click(object sender, EventArgs e)
private void toolNew_Click(object sender, EventArgs e)
{
newContext.Show();
newContext.Show(MousePosition);
}
private void aboutAddressBookToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}

View file

@ -346,301 +346,96 @@ void OpenApplication(string appname, string path)
}
}
string ReturnType(string extension) {
string returnVal = "";
fileType = 1;
switch (extension) {
int ReturnType(string extension)
{
switch (extension)
{
case ".txt":
fileType = 1;
returnVal = "Text Document \n createtext";
break;
case ".dat":
fileType = 1;
returnVal = "Text Document \n createtext";
break;
case ".rtf":
fileType = 2;
returnVal = "Rich Text Document \n createtext";
break;
case ".cfg":
fileType = 1;
returnVal = "Config file \n createtext";
break;
case ".log":
fileType = 1;
returnVal = "log text file \n createtext";
break;
case ".ini":
case ".properties":
fileType = 1;
returnVal = "Config file \n createtext";
break;
case ".json":
fileType = 1;
returnVal = "Config file \n createtext";
break;
case ".dat":
return 1;
case ".rtf":
return 2;
case ".doc":
fileType = 3;
returnVal = "Word Document (Old) \n word";
break;
case ".docx":
fileType = 3;
returnVal = "Word Document \n word";
break;
return 3;
case ".docm":
fileType = 3;
returnVal = "Macro-Enabled Word Document \n word";
break;
return 3;
case ".xls":
fileType = 4;
returnVal = "Excel Spreadsheets (Old) \n excel";
break;
case ".xlsx":
fileType = 4;
returnVal = "Excel Spreadsheets \n excel";
break;
return 4;
case ".ppt":
fileType = 5;
returnVal = "Powerpoint Presentation (Old) \n powerpoint";
break;
case ".pptx":
fileType = 5;
returnVal = "Powerpoint Presentation \n powerpoint";
break;
return 5;
case ".pub":
fileType = 7;
returnVal = "Publisher Document \n powerpoint";
break;
return 7;
case ".xps":
fileType = 8;
returnVal = "XPS Document \n xpsview";
break;
return 8;
case ".htm":
fileType = 9;
returnVal = "HTML web page \n html";
break;
return 9;
case ".html":
fileType = 9;
returnVal = "HTML web page \n html";
break;
return 9;
case ".wps":
fileType = 10;
returnVal = "Works document \n works";
break;
return 10;
case ".wmf":
fileType = 11;
returnVal = "Windows Metafile (A picture) \n createart";
break;
case ".emf":
fileType = 11;
returnVal = "Enhanced Metafile (A picture) \n createart";
break;
case ".png":
fileType = 11;
returnVal = "Picture file (Portable Network Graphics) \n createart";
break;
case ".jpg":
fileType = 11;
returnVal = "Picture file \n createart";
break;
case ".jpeg":
fileType = 11;
returnVal = "Picture file \n createart";
break;
case ".gif":
fileType = 12;
returnVal = "Picture file \n gifman";
break;
case ".tif":
fileType = 11;
returnVal = "Picture file \n createart";
break;
case ".bmp":
fileType = 11;
returnVal = "Picture file \n createart";
break;
case ".zip":
fileType = 11;
returnVal = "Compressed ZIP file \n winrar";
break;
case ".rar":
fileType = 11;
returnVal = "WINRAR Compressed file \n winrar";
break;
case ".gz":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".7z":
fileType = 11;
returnVal = "7ZIP file \n 7z";
break;
case ".ace":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".arj":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".bz2":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".gzip":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".lzh":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".tar":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".uue":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".xz":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".z":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
case ".001":
fileType = 11;
returnVal = "WINRAR file \n winrar";
break;
return 11;
case ".exe":
fileType = 12;
returnVal = "Program \n exe";
break;
case ".jar":
fileType = 13;
returnVal = "Java file \n java";
break;
case ".iso":
fileType = 14;
returnVal = "CD Image file \n iso";
break;
return 12;
case ".avi":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m4v":
fileType = 15;
returnVal = "Video (MPEG-4) \n video";
break;
case ".mp4":
fileType = 15;
returnVal = "Video (MPEG-4) \n video";
break;
case ".wmv":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m2v":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m3u":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mts":
fileType = 15;
returnVal = "Video \n video";
break;
case ".dv":
fileType = 15;
returnVal = "Video (Digital Video) \n video";
break;
case ".flv":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m1v":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m2ts":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mkv":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mov":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mpeg4":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mpeg":
fileType = 15;
returnVal = "Video \n video";
break;
case ".mpg":
fileType = 15;
returnVal = "Video \n video";
break;
case ".3gp":
fileType = 15;
returnVal = "Video \n video";
break;
case ".m4p":
fileType = 15;
returnVal = "Video \n video";
break;
return 15;
case ".mp2":
fileType = 21;
returnVal = "Audio \n video";
break;
case ".mp3":
fileType = 21;
returnVal = "Audio \n video";
break;
case ".wav":
fileType = 21;
returnVal = "Audio \n video";
break;
return 21;
case ".nls":
fileType = 16;
returnVal = "Font file \n font";
break;
return 16;
case ".dll":
fileType = 17;
returnVal = "System File \n sys";
break;
return 17;
case ".bat":
fileType = 18;
returnVal = "MS-DOS Batch file \n winterm";
break;
return 18;
case ".url":
fileType = 19;
returnVal = "Shortcut \n short";
break;
return 19;
case ".sh":
fileType = 20;
returnVal = "BASH file \n winterm";
break;
return 20;
case ".win":
fileType = 17;
returnVal = "System file \n sys";
break;
return 17;
}
return returnVal;
return 0;
}
//Private Sub windows_explorer_Closed(sender As Object, e As EventArgs) Handles Me.Closed
// IsFileDialog = False
//End Sub
//Private Sub windows_explorer_Closed(sender As Object, e As EventArgs) Handles Me.Closed
// IsFileDialog = False
//End Sub
void mainView_DoubleClick(object sender, EventArgs e)
{
@ -966,7 +761,7 @@ private void mainView_SelectedIndexChanged(object sender, EventArgs e)
FileInfo fi = new FileInfo(Path.Combine(CurrentDirectory, mainView.FocusedItem.Text));
txtInfoDescName.Text = mainView.FocusedItem.Text;
txtInfoDescType.Text = ReturnType(fi.Extension).Split('\n')[0];
txtInfoDescType.Text = GetDescription(ReturnType(fi.Extension));
txtInfoDescModified.Text = fi.CreationTime.ToString();
txtInfoDescSize.Show();
@ -988,6 +783,48 @@ private void mainView_SelectedIndexChanged(object sender, EventArgs e)
}
}
public string GetDescription(int type)
{
switch (type)
{
case 1:
return "Text Document";
case 2:
return "Rich Text Document";
case 3:
return "Word Document";
case 4:
return "Excel Document";
case 5:
return "Powerpoint Document";
case 7:
return "Publisher Document";
case 8:
return "XPS File";
case 9:
return "HTML Document";
case 10:
return "Microsoft Works Document";
case 11:
return "Image File";
case 12:
return "Executable File";
case 21:
return "Video File";
case 16:
case 17:
return "System File";
case 18:
return "Batch File";
case 19:
return "Online Shortcut";
case 20:
return "Bash Script";
}
return "File";
}
private void CutCtrlXToolStripMenuItem_Click(object sender, EventArgs e)
{
try