Tuesday, February 19, 2013

TagIt

TagIt is a tool developed in C# .NET which helps to tag files or folders in an organized manner with meaningful name.

Download  TagIt_Code.zip
It can also be found in code.google.com here.

Introduction

TagIt helps to tag files or folders in an organized manner with meaningful name.

Most of the time, required files or folders are lost in the vast drive counting 100s of thousand files or folders. User can search files or folders but many a times, user don't even remember its name which makes searching difficult in the drive.

TagIt helps user to organize files or folders in category which are defined by tag names.


Features of TagIt

  • To tag a file(s)  or folder(s)
    • just drag it onto the TagIt application
    • navigate files or folders as user does in Windows Explorer
    • mention the valid URI in Address textbox
    • select file or folder in Windows Explorer and right click to get the context menu and select "Open TagIt for this file..." or "Open TagIt for this folder...".
  • Files and Folders will be displayed with its associated icons as displayed in Windows Explorer.
  • Tag can be added, changed or removed for each files and folders.
  • Multiple files or folders which are tagged with different names can be selected together to show there cumulative tags.
  • Multiple tags can be added to same files or folders.
  • Tag name, background color or foreground color can be added or edited.
  • Tag size increases as number of files or folders are added to a particular tag.
  • Click UP button to navigate to one level above the folder hierarchy.
  • Click Refresh button to refresh TagIt information.
  • Click Open button to open the file or folder which are selected in TagIt in Windows Explorer.
  • Click Import button to import TagIt database file from external location.
  • Click Export button to export TagIt database file to external location.
  • Tagged Deleted shows files or folders which were tagged earlier but now found to be deleted. Earlier files or folders would have been tagged. Later those files or folders would have been deleted or may be path has been changed for those files or folders. In this case, TagIt will display all those files and folders which does not exists for a particular tag.
  • First time user opens TagIt, it will configure itself in the hosted machine.
  • Last but not the least "Uninstall.bat" will be created in All Program folder to uninstall TagIt.

Background

I had so many files and folders in my computer, that it get lost after few days. It is very difficult to retrieve old files or folders which were not accessed for quite some time. This is when I thought of developing TagIt to keep all my files and folders in an organized manner and retrieve as soon as I want it just by clicking appropriate tag which I created earlier.

Screenshot

This is the first or initial screen which will be seen by user.
For the first time TagIt does required configuration to run it successfully in future. It does following steps.

  • Create DB Connection string with "Provider=Microsoft.Jet.OleDb.4.0"
  • Create directory in Program Files as Install Directory
  • Copy DB file (.mdb) in Install Directory
  • Copy TagIt Application file in Install Directory
  • Create Registry Key settings to open Files using Windows Explorer context menu
  • Create Registry Key settings to open Folders using Windows Explorer context menu
  • Create Shortcut file for TagIt in Start Menu
  • Create Shortcut file for TagIt in Quick Launch
  • Create Uninstall Batch file
User can right click in any file or folder to tag.


User can tag files and folders by dragging and dropping from Windows Explorer to TagIt.

User can Add or Edit tag by entering unique name. Foreground and Background color can be applied for each tag to identify it uniquely.
 

Select file(s) and/or folder(s) which needs to be tagged. Under TagIt section in left-lower panel, select required tag checkbox and click TagIt button to tag selected file(s) and/or folder(s). Use [ Ctrl+A ] to select all files and folders.



Select the required tag under All Tags in right panel to retrieve all files and folder which were tagged with that tag name. There are few features available with it.
  • The tag which is clicked will be displayed first. i.e. tags will be ordered in clicking order.
  • Tag size will increase as it contains more and more number of files and folders with an increment count of 10.
  • Only first tag in the All Tags panel can be edited. So whichever is in first order will be used to modify.

Sample code

Click Tag Label in All Tags panel to update the DateTime of selected tag and show all Files and Folders associated with that Tag

        OleDbCommand objOleDbCommand = null;
    OleDbDataReader objOleDbDataReader = null;
    String strSQL;

    string strTagID = null;
    string strTagText = null;
    try
    {
        objOleDbConnection = new OleDbConnection(strDBConnection);
        objOleDbConnection.ConnectionString = strDBConnection;
        objOleDbConnection.Open();

        DateTime strDateTime = DateTime.Now;
        strTagID = ((Control)sender).Tag.ToString();
        strTagText = ((Control)sender).Text;

        strSQL = "UPDATE TagProperty SET [Update] = '" + strDateTime + "' WHERE [ID] = " + strTagID + ";";

        objOleDbCommand = new OleDbCommand(strSQL, objOleDbConnection);
        objOleDbCommand.ExecuteNonQuery();

        if (objOleDbConnection != null)
        {
            objOleDbConnection.Close();
        }

        GetTagsFromDB_ShowAllTags();

        objOleDbConnection = new OleDbConnection(strDBConnection);
        objOleDbConnection.ConnectionString = strDBConnection;
        objOleDbConnection.Open();

        strSQL = "SELECT [Path] FROM TagDetail WHERE [TagProperty_ID] = " + strTagID + " ORDER BY [Path] ASC;";

        objOleDbCommand = new OleDbCommand(strSQL, objOleDbConnection);
        objOleDbDataReader = objOleDbCommand.ExecuteReader();

        if (ShowAllFoldersAndFiles(listViewFoldersFiles, imageListFoldersFiles, objOleDbDataReader))
        {
            txtAddress.Text = strAddress;

            EnableDisbaleUp(strAddress);

            EnableDisbaleOpen(strAddress);
        }

        txtAddress.Text = "Tag [" + strTagText + "]";
    }
    catch (Exception ee)
    {
        MessageBox.Show(ee.Message, "TagIt error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    finally
    {

        if (objOleDbConnection != null)
        {
            objOleDbConnection.Close();
        }
    } 


Click Add button to Add or Modify Tag in DB

OleDbConnection objOleDbConnection = null;
OleDbCommand objOleDbCommand = null;
String strSQL;

try
{
    if (this.Text == "Add Tag")
    {
        if (MessageBox.Show("Duplicate / Empty Tag Name will not be allowed to be added. Tag once added cannot be deleted / removed.\n\nDo you want to add this Tag?", "TagIt", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
        {
            DateTime strDateTime = DateTime.Now;

            objOleDbConnection = new OleDbConnection(strGlobalDBConnection);
            objOleDbConnection.ConnectionString = strGlobalDBConnection;
            objOleDbConnection.Open();

            strSQL = "INSERT INTO TagProperty ([TagName] , [ForegroundColor], [BackgroundColor], [Update] ) VALUES ( '" + txtTagName.Text + "' , '" + strGlobalForegroundColor + "' , '" + strGlobalBackgroundColor + "' , '" + strDateTime + "');";

            objOleDbCommand = new OleDbCommand(strSQL, objOleDbConnection);
            objOleDbCommand.ExecuteNonQuery();
        }
    }
    else
    {
        DateTime strDateTime = DateTime.Now;

        objOleDbConnection = new OleDbConnection(strGlobalDBConnection);
        objOleDbConnection.ConnectionString = strGlobalDBConnection;
        objOleDbConnection.Open();

        strSQL = "UPDATE TagProperty SET [TagName] = '" + txtTagName.Text + "', [ForegroundColor] = '" + strGlobalForegroundColor + "', [BackgroundColor] = '" + strGlobalBackgroundColor + "', [Update] = '" + strDateTime + "' WHERE [ID] = " + strGlobalTag + ";";

        objOleDbCommand = new OleDbCommand(strSQL, objOleDbConnection);
        objOleDbCommand.ExecuteNonQuery();
    }
}
catch (Exception ee)
{
    MessageBox.Show(ee.Message, "TagIt error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
    if (objOleDbConnection != null)
    {
        objOleDbConnection.Close();
    }

    this.Close();
}

Points of Interest

TagIt uses Microsoft Access to store all data. If you happen to chose some other DB, please get the connection string and authentication to implement in TagIt.

User can also see how to get folder and file icon associated with Windows Explorer.

History

This is the first version submitted on 19-Feb-2013.