Untitled

Random thoughts about everything and nothing

Archive for March 2006

Features missing in VSTS – Part One

without comments

Dear Easter Bungie,

What I would like for easter (and not as an egg):

- a simple compare directories in source explorer
- and once your at it…add open with…context menu too
- detach workspaces from pc + user
- maybe include connection to source safe
-

Written by Michael

March 30, 2006 at 9:17 pm

Posted in VSTS

Searching the MSDN blogs

without comments

We can now search through the MSDN blogs using the MSDN lab search….

Written by Michael

March 30, 2006 at 9:14 pm

Posted in Link, MSDN

Silly formatter

without comments

Why use padleft, when you can use formatters?!!!

private void button1_Click(object sender, System.EventArgs e)
{
string a = "aaa";
textBox1.Text = String.Format(new SillyFormat(), "{0:Z10}", a) ;
}
private void Dummy_Load(object sender, System.EventArgs e)
{

}
public class SillyFormat : IFormatProvider, ICustomFormatter
{

public object GetFormat (Type service)

{
if (service == typeof (ICustomFormatter))
{
return this;
}
else
{
return null;
}
}

public string Format (string format, object arg, IFormatProvider provider)
{
if (arg == null)
{
throw new ArgumentNullException("Please provide argument to format.");
}
if (format != null && arg is string)
{
string s = format.Trim().ToLower();
string ret = (string) arg;
if (s.StartsWith("z"))
{
format = format.Trim (new char [] {'Z'});
int pos = Convert.ToInt32( format ) - ret.Length;
if ( pos > 0 )
{
ArrayList items = ArrayList.Repeat("0", Convert.ToInt32( format ) - ret.Length);
items.Add(ret);
string[] strings = (string[]) items.ToArray(typeof(String));
ret = String.Join("",strings);
}
}
return ret;
}
else if (arg is IFormattable)
{
return ((IFormattable)arg).ToString(format, provider);
}
else
{
return arg.ToString();
}

}
}

Written by Michael

March 30, 2006 at 9:11 pm

Posted in .NET, CodeSnippet

Macros – Visual Studio 2003

without comments

Been going through my existing VS.NET 2003 macros the other day… Close all active documents:

Sub CloseAllDocuments()
Try
If DTE.ActiveDocument.Collection.Count > 0 Then
DTE.ActiveDocument.Collection.CloseAll()
End If
Catch
‘Lazy catch, we do nothing
End Try
End Sub

Or just use “>Edit.CloseAll” in the immediate window.

To collapse all projects in the solution explorer:

Sub CollapseAll()
Dim UIHSolutionExplorer As UIHierarchy
UIHSolutionExplorer = DTE.Windows.Item( _
Constants.vsext_wk_SProjectWindow).Object() If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
MsgBox(“Nothing to collapse. You must have an open solution.”)
Return
End If

Dim UIHSolutionRootNode As UIHierarchyItem
UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)

Dim UIHItem As UIHierarchyItem
For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
UIHItem.UIHierarchyItems.Expanded = False
Next

UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
End Sub

Written by Michael

March 19, 2006 at 12:21 am

Posted in VSX

Comparing folders in Team Foundation Source Control

without comments

1. go to VS2005 command prompt
2. tf diff path1 path2 /recursive /noprompt

Written by Michael

March 17, 2006 at 3:55 pm

Posted in VSTS