- integrator.zip
- Integrator
- Debug
- Integrator.Common
- Integrator.DynamicProxyModel
- Integrator.Module.LoadedServices
- Integrator.Module.Sequencer
- Integrator.Sequencer
- Integrator.ServiceManagerModel
- Integrator.Shell
- Integrator.sln
- Integrator.suo
- Integrator.TestServer
- Integrator.UI.ParameterEditor
- Release
- Resources
- Done.bmp
- In.ico
- Microsoft.Practices.CompositeUI.dll
- Microsoft.Practices.CompositeUI.WinForms.dll
- Microsoft.Practices.ObjectBuilder.dll
- Operation.ico
- Out.ico
- Paused.bmp
- Ready.bmp
- Service.ico
- Services.ico
- Start.bmp
- Started.bmp
- Stopped.bmp
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI.EventBroker;
using Integrator.Framework.ServiceManagerModel;
using Integrator.UI.Common;
namespace Integrator.UI.LoadedServices
{
public partial class LoadedServicesView : UserControl
{
TreeNode rootNode = new TreeNode("Loaded Services");
ContextMenu menu = null;
[EventPublication(EventTopicConstants.ADD_OPERATION, PublicationScope.Global)]
public event EventHandler<OperationEventArgs> AddOperationEvent;
[EventPublication(EventTopicConstants.SHOW_PARAMETER, PublicationScope.Global)]
public event EventHandler<ParameterEventArgs> ShowParameterEvent;
public LoadedServicesView()
{
InitializeComponent();
this.ConstructMenu();
}
private void ConstructMenu()
{
MenuItem item = new MenuItem("Add Operation");
item.Click += new EventHandler(item_Click);
MenuItem[] itemArray = new MenuItem[1];
itemArray[0] = item;
this.menu = new ContextMenu(itemArray);
}
void item_Click(object sender, EventArgs e)
{
if (this.AddOperationEvent != null)
{
this.AddOperationEvent(this, new OperationEventArgs((Operation)this.treeView.SelectedNode.Tag));
}
}
public void AddServiceInstance(ServiceProxy proxy)
{
if (proxy == null)
{
throw new ArgumentNullException();
}
if (!this.treeView.Nodes.Contains(this.rootNode))
{
this.rootNode.Name = "Services";
this.rootNode.SelectedImageKey = "Services";
this.rootNode.ImageKey = "Services";
this.treeView.Nodes.Add(this.rootNode);
}
TreeNode node = new TreeNode(proxy.Name);
node.Name = proxy.ToString();
node.Tag = proxy;
node.ImageKey = "Service";
this.rootNode.Nodes.Add(node);
this.AddOperationNode(node, proxy);
}
private void AddOperationNode(TreeNode node, ServiceProxy proxy)
{
IList operations = proxy.Operations;
foreach (Operation operation in operations)
{
TreeNode childNode = new TreeNode(operation.Name);
childNode.Name = operation.Name;
childNode.Tag = operation;
childNode.SelectedImageKey = "Operation";
childNode.ImageKey = "Operation";
node.Nodes.Add(childNode);
this.AddParameterNode(childNode, operation);
}
}
private void AddParameterNode(TreeNode node, Operation operation)
{
//Add Input Parameters first
for (int index=0; index<operation.Input.Length; index++)
{
Parameter input = operation.Input[index];
if (input != null)
{
TreeNode childNode = new TreeNode(input.Key);
childNode.Name = input.Key;
childNode.Tag = input;
childNode.SelectedImageKey = "InputParameter";
childNode.ImageKey = "InputParameter";
node.Nodes.Add(childNode);
}
}
//Add the output parmeter
if (operation.Output != null)
{
TreeNode childNode = new TreeNode("Output");
childNode.Name = "Output";
childNode.Tag = operation.Output;
childNode.SelectedImageKey = "OutputParameter";
childNode.ImageKey = "OutputParameter";
node.Nodes.Add(childNode);
}
}
private void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
treeView.SelectedNode = e.Node;
if (e.Button == MouseButtons.Right && e.Node.SelectedImageKey == "Operation")
{
this.menu.Show(this.treeView, new Point(e.X, e.Y));
}
else if (e.Button == MouseButtons.Left)
{
if (this.treeView.SelectedNode.Tag != null)
{
bool isParameterNode = this.treeView.SelectedNode.Tag is Parameter;
if (isParameterNode)
{
if (this.ShowParameterEvent != null)
{
this.ShowParameterEvent(this, new ParameterEventArgs((Parameter)this.treeView.SelectedNode.Tag));
}
}
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Yes, I design. Then, I code. Next, I refactor.