Skip to content

Commit

Permalink
Whatever
Browse files Browse the repository at this point in the history
  • Loading branch information
acken committed Feb 22, 2013
1 parent 1c3d70b commit 7eb7439
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 109 deletions.
238 changes: 129 additions & 109 deletions addins/VisualStudio/AutoTest.VSAddin/FeedbackWindow.cs
@@ -1,109 +1,129 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using AutoTest.Core.Messaging;
using AutoTest.Messages;
using EnvDTE80;
using AutoTest.VS.Util.Debugger;
using EnvDTE;
using AutoTest.VS.Util.Navigation;

namespace AutoTest.VSAddin
{
[ProgId("AutoTestNet_FeedbackWindow"), ClassInterface(ClassInterfaceType.AutoDual), Guid("67663444-f874-401c-9e55-053bb0b5bd0d")]
public partial class FeedbackWindow : UserControl
{
private DTE2 _application;
private IMessageBus _bus;

public event EventHandler<UI.DebugTestArgs> DebugTest;

public FeedbackWindow()
{
InitializeComponent();
}

public void SetApplication(DTE2 application)
{
_application = application;
}

public void SetMessageBus(IMessageBus bus)
{
_bus = bus;
}

public void Consume(object message)
{
runFeedback.ConsumeMessage(message);
}

public void SetText(string text)
{
runFeedback.PrintMessage(new UI.RunMessages(UI.RunMessageType.Normal, text));
}

private void runFeedback_DebugTest(object sender, UI.DebugTestArgs e)
{
if (DebugTest != null)
DebugTest(sender, e);
}

private void runFeedback_GoToReference(object sender, UI.GoToReferenceArgs e)
{
try
{
var window = _application.OpenFile(EnvDTE.Constants.vsViewKindCode, e.Position.File);
window.Activate();
var selection = (TextSelection)_application.ActiveDocument.Selection;
selection.MoveToDisplayColumn(e.Position.LineNumber, e.Position.Column, false);
}
catch
{
}
}

private void runFeedback_GoToType(object sender, UI.GoToTypeArgs e)
{
try
{
new TypeNavigation().GoToType(_application, e.Assembly, e.TypeName);
}
catch (Exception ex)
{
}
}

public void PrepareForFocus()
{
runFeedback.PrepareForFocus();
}

public bool IsInFocus()
{
return runFeedback.IsInFocus();
}

public void Clear()
{
runFeedback.ClearList();
}

public void ClearBuilds(string project)
{
runFeedback.ClearBuilds(project);
}

private void FeedbackWindow_Resize(object sender, EventArgs e)
{
runFeedback.Resize();
}

private void runFeedback_CancelRun(object sender, EventArgs e)
{
_bus.Publish(new AbortMessage(""));
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using AutoTest.Core.Messaging;
using AutoTest.Messages;
using AutoTest.UI;
using EnvDTE80;
using AutoTest.VS.Util.Debugger;
using EnvDTE;
using AutoTest.VS.Util.Navigation;

namespace AutoTest.VSAddin
{
public class LabelItembehaviour : IListItemBehaviour
{
private Label _label;
public LabelItembehaviour(Label label) {
_label = label;
}
public int Left { get { return _label.Left; } set { _label.Left = value; } }
public int Width { get { return _label.Width; } set { _label.Width = value; } }
public string Name { get { return _label.Name; } }
public bool Visible { get { return _label.Visible; } set { _label.Visible = value; } }
}

[ProgId("AutoTestNet_FeedbackWindow"), ClassInterface(ClassInterfaceType.AutoDual), Guid("67663444-f874-401c-9e55-053bb0b5bd0d")]
public partial class FeedbackWindow : UserControl
{
private DTE2 _application;
private IMessageBus _bus;
private FeedbackProvider _provider;

public event EventHandler<UI.DebugTestArgs> DebugTest;

public FeedbackWindow()
{
InitializeComponent();
_provider = new FeedbackProvider(
new LabelItembehaviour(runFeedback.linkLabelCancelRun),
new LabelItembehaviour(runFeedback.linkLabelDebugTest),
new LabelItembehaviour(runFeedback.linkLabelTestDetails),
new LabelItembehaviour(runFeedback.linkLabelErrorDescription));
runFeedback.SetFeedbackProvider(_provider);
}

public void SetApplication(DTE2 application)
{
_application = application;
}

public void SetMessageBus(IMessageBus bus)
{
_bus = bus;
}

public void Consume(object message)
{
_provider.ConsumeMessage(message);
}

public void SetText(string text)
{
_provider.PrintMessage(new UI.RunMessages(UI.RunMessageType.Normal, text));
}

private void runFeedback_DebugTest(object sender, UI.DebugTestArgs e)
{
if (DebugTest != null)
DebugTest(sender, e);
}

private void runFeedback_GoToReference(object sender, UI.GoToReferenceArgs e)
{
try
{
var window = _application.OpenFile(EnvDTE.Constants.vsViewKindCode, e.Position.File);
window.Activate();
var selection = (TextSelection)_application.ActiveDocument.Selection;
selection.MoveToDisplayColumn(e.Position.LineNumber, e.Position.Column, false);
}
catch
{
}
}

private void runFeedback_GoToType(object sender, UI.GoToTypeArgs e)
{
try
{
new TypeNavigation().GoToType(_application, e.Assembly, e.TypeName);
}
catch (Exception ex)
{
}
}

public void PrepareForFocus()
{
_provider.PrepareForFocus();
}

public bool IsInFocus()
{
return _provider.IsInFocus();
}

public void Clear()
{
_provider.ClearList();
}

public void ClearBuilds(string project)
{
_provider.ClearBuilds(project);
}

private void FeedbackWindow_Resize(object sender, EventArgs e)
{
runFeedback.Resize();
}

private void runFeedback_CancelRun(object sender, EventArgs e)
{
_bus.Publish(new AbortMessage(""));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/AutoTest.UI/RunFeedback.cs
Expand Up @@ -15,6 +15,7 @@ public partial class RunFeedback : UserControl
{
private object _selected = null;
private FeedbackProvider _provider;

public void SetFeedbackProvider(FeedbackProvider provider) {
_provider = provider;

Expand Down

0 comments on commit 7eb7439

Please sign in to comment.