download MyTestResultViewWindow.cs
Language: C#
License: MSVSSDK
LOC: 52
Project Info
C# Example.MyTestTypeSample
Server: Visual Studio SDK
Type: filesystem
...xtensibility\MyTest\MyTest\
   assembly.cs
   MyHostAdapter.cs
   ...pterRunConfigControl.cs
   ...nfigControl.Designer.cs
   ...erRunConfigControl.resx
   MyTest.cs
   MyTest.csproj
   MyTestAdapter.cs
   MyTestAssertHelper.cs
   MyTestEditorControl.cs
   ...itorControl.Designer.cs
   MyTestEditorControl.resx
   MyTestEditorFactory.cs
   MyTestPackage.cs
   MyTestResourceIds.cs
   MyTestResult.cs
   MyTestResultViewControl.cs
   ...ViewControl.designer.cs
   ...tResultViewControl.resx
   MyTestResultViewWindow.cs
   MyTestRunConfigControl.cs
   ...nfigControl.Designer.cs
   ...stRunConfigControl.resx
   MyTestTip.cs
   MyTestTuip.cs
   MyTestWizard.cs

/***************************************************************************
 
Copyright (c) Microsoft Corporation. All rights reserved.
This code is licensed under the Visual Studio SDK license terms.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
 
***************************************************************************/
//*************************************************************************************************
// MyTestResultViewWindow.cs
//
// This file defines the MyTestResultViewWindow class.
//
// Copyright(c) Microsoft Corporation, 2004
//*************************************************************************************************

namespace Microsoft.VisualStudio.TestTools.Samples
{
	using System;
	using System.Diagnostics;
	using System.Runtime.InteropServices;
	using System.Windows.Forms;

	using Microsoft.VisualStudio.TestTools.Vsip;
	using Microsoft.VisualStudio.TestTools.Tips.TuipPackage;
	using Microsoft.VisualStudio.Shell;

	/// <summary>
	/// MyTest result details view tool window implementation.
	/// This class is simply a host for the control that does
	/// the heavy lifting for displaying the result details.
	/// </summary>
	[Guid("59F33709-25B1-4997-9221-D3EEA4835F02")] // GUID to idenify this class
	internal sealed class MyTestResultViewWindow : ToolWindowPane
	{
		/// <summary>
		/// Default constructor. Calls base class with Package Instance
		/// </summary>
		public MyTestResultViewWindow()	
			: base(MyTestPackage.Instance as System.IServiceProvider)
		{ } 

	
		/// <summary>
		/// Called when VS is closed. This cleans up any Result windows in the background and
		/// removes any mappings from the list of open windows
		/// </summary>
		protected override void OnClose()
		{
			Debug.Assert(m_myResultControl != null);

			if (m_myResultControl != null)
			{
				// Remove the window mapping
				MyTestTuip.ResultWindowMapping.Remove(m_myResultControl.Result.Id);
			}

			base.OnClose();
		}

		DetailedResultsControl m_resultControl = null;
		MyTestResultViewControl m_myResultControl = null;

		/// <summary>
		/// This returns the actual Win32 Window that hosts the control. It is this
		/// window that Visual Studio hosts in a document window to display the result
		/// </summary>
		public override IWin32Window Window
		{
			get
			{
				// If we haven't already displayed, return
				// the simple DetailedResults -- We do the heavy
				// lifting in Load Result
				if (m_resultControl == null)
				{
					m_resultControl = new DetailedResultsControl();
				}
				return (m_resultControl);
			}
		}

		// Holds the result for this window to ensure
		// we dont reload the result if it's the one
		// we already loaded
		MyTestResult m_result = null;

		/// <summary>
		/// Loads the result into the controls that do the leg work
		/// </summary>
		/// <param name="result">The Test Result to load</param>
		public void LoadResult(MyTestResult result)
		{
			// Create the Controls if they dont already exist
			if (m_resultControl == null)
				m_resultControl = new DetailedResultsControl();

			if (m_myResultControl == null)
				m_myResultControl = new MyTestResultViewControl();

			// Check that we are not going to try and load a result we've already loaded
			if ((m_result != null) && (m_result.Id.ExecutionId.Id == result.Id.ExecutionId.Id))
				return;

			m_result = (MyTestResult)result.Clone();
			// Load the result into the custom control, and the initialise common header control
			m_myResultControl.LoadResult(result);
			m_resultControl.Init(result, MyTestPackage.Instance, this, m_myResultControl);
		}
	}
}

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us