Skip to content
Permalink
Browse files

Added TFS Visualizers

  • Loading branch information
Gordon-Beeming committed Jul 25, 2014
1 parent 9e40c9b commit eddbb47baa633acae7101fa729b83096bf7b85d9
@@ -32,6 +32,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />

Some generated files are not rendered by default. Learn more.

@@ -1,28 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DotNetPretty.DesktopTestApp
namespace DotNetPretty.DesktopTestApp
{
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

public partial class frmMain : Form
{
#region Constructors and Destructors

public frmMain()
{
InitializeComponent();
this.InitializeComponent();
}

#endregion

#region Methods

private void btnMicrosoftTeamFoundationWorkItemTrackingClientWorkItem_Click(object sender, EventArgs e)
{
var tfs = new TfsTeamProjectCollection(new Uri(string.Format("http://{0}:8080/tfs", Environment.MachineName)), new TfsClientCredentials(new WindowsCredential(true), true));
var store = new WorkItemStore(tfs);
var workItemList = new List<WorkItem>(store.Query("SELECT Id, Title, [Work Item Type] FROM WorkItems").Cast<WorkItem>());
if (workItemList.Count > 0)
{
workItemList[0].PartialOpen();
workItemList[0].Title = string.Format("changed the title to show the date - {0}", DateTime.Now.ToString("dd MMM yyyy"));
workItemList[0].Description = "bob is the description";
}
Debugger.Break();
}

private void btnSystemDataSqlClientSqlConnection_Click(object sender, EventArgs e)
{
var conn = new SqlConnection(@"Server=.;Database=master;Integrated security=SSPI");
Debugger.Break();
}

#endregion
}
}
}
@@ -30,20 +30,66 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.Controls, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v4.5\Microsoft.TeamFoundation.WorkItemTracking.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.ControlsCore, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v4.5\Microsoft.TeamFoundation.WorkItemTracking.ControlsCore.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.DebuggerVisualizers, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.VisualStudio.DebuggerVisualizers.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="Visualizers\DebuggerDisplay\SqlConnectionDebuggerDisplay.cs" />
<Compile Include="Framework\Forms.cs" />
<Compile Include="Visualizers\SQL\DebuggerDisplay\SqlConnectionDebuggerDisplay.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Visualizers\TFS\DebuggerDisplay\WorkItemTypeDebuggerDisplay.cs" />
<Compile Include="Visualizers\TFS\DebuggerDisplay\WorkItemDebuggerDisplay.cs" />
<Compile Include="Visualizers\TFS\DebuggerVisualizer\DialogDebuggerVisualizers\WorkItemVisualizer.cs" />
<Compile Include="Visualizers\TFS\DebuggerVisualizer\Surrogates\WorkItemSurrogate.cs" />
<Compile Include="Visualizers\TFS\DebuggerVisualizer\VisualizerObjectSources\WorkItemVisualizerObjectSource.cs" />
<Compile Include="Visualizers\TFS\DebuggerVisualizer\Windows\WorkItemWindow.xaml.cs">
<DependentUpon>WorkItemWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Visualizers\TFS\DebuggerVisualizer\WorkItemDebuggerVisualizer.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Visualizers\DebuggerVisualizer\" />
<Folder Include="Visualizers\SQL\DebuggerVisualizer\" />
<Folder Include="Visualizers\TFS\DebuggerVisualizer\Forms\" />
</ItemGroup>
<ItemGroup>
<Page Include="Visualizers\TFS\DebuggerVisualizer\Windows\WorkItemWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
@@ -0,0 +1,22 @@
using System.Windows;
using System.Windows.Forms;

public static class Forms
{
#region Public Methods and Operators

public static Form AsForm(this Window window)
{
var frm = new Form();
frm.Load += (s, e) =>
{
window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
window.WindowStyle = WindowStyle.ToolWindow;
window.ShowDialog();
frm.DialogResult = DialogResult.OK;
};
return frm;
}

#endregion
}
@@ -1,10 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("DotNetPretty")]
[assembly: AssemblyDescription("Lots of \"stuff\" to make it easier to work with .net applications")]
[assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("d85b3558-84f0-4701-9f03-027858ee2d05")]

// Version information for an assembly consists of the following four values:
@@ -31,4 +33,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.1.*")]
@@ -0,0 +1,5 @@
using System.Diagnostics;

using Microsoft.TeamFoundation.WorkItemTracking.Client;

[assembly: DebuggerDisplay("[{State,nq}] {Id}: {Title,nq}", Target = typeof(WorkItem))]
@@ -0,0 +1,5 @@
using System.Diagnostics;

using Microsoft.TeamFoundation.WorkItemTracking.Client;

[assembly: DebuggerDisplay("{Name,nq}", Target = typeof(WorkItemType))]
@@ -0,0 +1,44 @@
namespace DotNetPretty.Visualizers.TFS.DebuggerVisualizer.DialogDebuggerVisualizers
{
using System;
using System.Collections.Generic;

using DotNetPretty.Visualizers.TFS.DebuggerVisualizer.Surrogates;
using DotNetPretty.Visualizers.TFS.DebuggerVisualizer.Windows;

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.VisualStudio.DebuggerVisualizers;

public class WorkItemVisualizer : DialogDebuggerVisualizer
{
#region Methods

protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
var surrogate = objectProvider.GetObject() as WorkItemSurrogate;
var tfs = new TfsTeamProjectCollection(new Uri(surrogate.TfsUri), new TfsClientCredentials(new WindowsCredential(true), surrogate.FederatedClientCredential, true));
var store = new WorkItemStore(tfs);
WorkItem workItem = store.GetWorkItem(surrogate.Id);
if (surrogate.IsDirty)
{
foreach (KeyValuePair<string, object> item in surrogate.Fields)
{
try
{
workItem.Fields[item.Key].Value = item.Value;
}
catch
{
// set what we can =(
}
}
}
var window = new WorkItemWindow(workItem);

windowService.ShowDialog(window.AsForm());
}

#endregion
}
}
@@ -0,0 +1,25 @@
namespace DotNetPretty.Visualizers.TFS.DebuggerVisualizer.Surrogates
{
using System;
using System.Collections.Generic;

using Microsoft.TeamFoundation.Client;

[Serializable]
public class WorkItemSurrogate
{
#region Public Properties

public FederatedCredential FederatedClientCredential { get; set; }

public Dictionary<string, object> Fields { get; set; }

public int Id { get; set; }

public bool IsDirty { get; set; }

public string TfsUri { get; set; }

#endregion
}
}
@@ -0,0 +1,38 @@
namespace DotNetPretty.Visualizers.TFS.DebuggerVisualizer.VisualizerObjectSources
{
using System.Collections.Generic;
using System.IO;
using System.Linq;

using DotNetPretty.Visualizers.TFS.DebuggerVisualizer.Surrogates;

using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.VisualStudio.DebuggerVisualizers;

public class WorkItemVisualizerObjectSource : VisualizerObjectSource
{
#region Public Methods and Operators

public override void GetData(object target, Stream outgoingData)
{
var targetObject = target as WorkItem;
Dictionary<string, object> fields = targetObject.Fields.Cast<Field>().ToDictionary(field => field.ReferenceName, field => field.Value);
var surrogate = new WorkItemSurrogate
{
Fields = fields,
TfsUri = targetObject.Store.TeamProjectCollection.Uri.ToString(),
Id = targetObject.Id,
IsDirty = targetObject.IsDirty,
FederatedClientCredential = targetObject.Store.TeamProjectCollection.ClientCredentials.Federated,
};
base.GetData(surrogate, outgoingData);
}

public override string ToString()
{
return "Test";
}

#endregion
}
}
@@ -0,0 +1,6 @@
<Window x:Class="DotNetPretty.Visualizers.TFS.DebuggerVisualizer.Windows.WorkItemWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WorkItemWindow" Height="650" Width="1150" Loaded="Window_Loaded">
<Grid x:Name="GridContent" />
</Window>

0 comments on commit eddbb47

Please sign in to comment.
You can’t perform that action at this time.