Switch to full style
Project under GPL source codes are posted here
Post a reply

A tool to change the default source control client

Fri Nov 07, 2008 1:19 pm

 Project Name:   A tool to change the default source control client
 Programmer:   Baloghp
 Type:   Application
 Technology:  C#
 IDE:   NONE
 Description:   I just wanted to use two different source control providers on the same machine. I installed both clients but I discovered that the later installed is always the default. I searched the net all over for a tool, but no usable application was found.

sample code :
csharp code
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FileTypeAndIcon
{
public partial class IconForm : Form
{
#region PROPERTIES

/// <summary>
/// Used for containing file types and thier icons information.
/// </summary>
private Hashtable icons;

/// <summary>
/// USed for getting registered file types and their icons information.
/// </summary>
private RegisteredFileType fileType;

#endregion

#region CONSTRUCTORS

public IconForm()
{
InitializeComponent();
this.fileType = new RegisteredFileType();
}

#endregion

#region GUI EVENTS

private void IconForm_Load(object sender, EventArgs e)
{
try
{
//Gets file type and icon info.
this.icons = this.fileType.GetFileTypeAndIcon();

//Loads file types to ListBox.
foreach (object objString in this.icons.Keys)
{
this.lbxFileType.Items.Add(objString);
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}

private void btnSearch_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.txtSearch.Text.Trim()))
return;
string searchName = "";
if (!this.txtSearch.Text.Contains("."))
searchName = "." + this.txtSearch.Text; //Add a dot if the search text does not have it.
else
searchName = this.txtSearch.Text;

//Searches in the collections of file types and icons.
object objName = this.icons[searchName];
if (objName != null)
{
this.lbxFileType.SelectedItem = searchName;
}
}

private void lbxFileType_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (this.lbxFileType.Items.Count <= 0 || this.lbxFileType.SelectedItem == null)
return;
string fileType = this.lbxFileType.SelectedItem.ToString();
this.showIcon(fileType);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}

private void txtSearch_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.txtSearch.Text.Trim()))
{
this.btnSearch.Enabled = false;
}
else
{
this.btnSearch.Enabled = true;
}
}

/// <summary>
/// Shows the icon associates with a specific file type.
/// </summary>
/// <param name="fileType">The type of file (or file extension).</param>
private void showIcon(string fileType)
{
try
{
string fileAndParam = (this.icons[fileType]).ToString();
if (String.IsNullOrEmpty(fileAndParam))
return;

//Use to store the file contains icon.
string fileName = "";

//The index of the icon in the file.
int iconIndex = 0;
string iconIndexString = "";

int index = fileAndParam.IndexOf(",");
//if fileAndParam is some thing likes that: "C:\\Program Files\\NetMeeting\\conf.exe,1".
if (index > 0)
{
fileName = fileAndParam.Substring(0, index);
iconIndexString = fileAndParam.Substring(index + 1);
}
else
fileName = fileAndParam;

if (!string.IsNullOrEmpty(iconIndexString))
{
//Get the index of icon.
iconIndex = int.Parse(iconIndexString);
if (iconIndex < 0)
iconIndex = 0; //To avoid the invalid index.
}

//Gets the handle of the icon.
IntPtr lIcon = RegisteredFileType.ExtractIcon(this.Handle.ToInt32(), fileName, iconIndex);

//The handle cannot be zero.
if (lIcon != IntPtr.Zero)
{
//Gets the real icon.
Icon icon = Icon.FromHandle(lIcon);

//Draw the icon to the picture box.
this.pbIconView.Image = icon.ToBitmap();
}
else //if the icon is invalid, show an error image.
this.pbIconView.Image = this.pbIconView.ErrorImage;
}
catch (Exception exc)
{
throw exc;
}
}

#endregion
}
}

SCCswitch.gif
SCCswitch.gif (4.52 KiB) Viewed 4735 times



Attachments
SCCswitch.zip
(4.27 KiB) Downloaded 812 times
SCCswitch_src.zip
(8.21 KiB) Downloaded 843 times

Re: A tool to change the default source control client

Sun Jan 20, 2013 10:59 pm

updated.

Post a reply
  Related Posts  to : A tool to change the default source control client
 Change the default underline style of link     -  
 How to change the default order on forums from ascending to     -  
 Change letters to upper case by default     -  
 Help on Urchin tool ?     -  
 using pen tool in photoshop     -  
 Globus tool kit     -  
 client server client     -  
 How to work with PowerDesigner tool to design ERD model?     -  
 Use the 'default' case     -  
 Assign default property value     -  

Topic Tags

C# Projects