|
//*****************************************************************************
// Description.....WF4 Message Mediation Library
//
// Author..........Roman Kiss, rkiss@pathcom.com
// Copyright © 2009 ATZ Consulting Inc. (see included license.rtf file)
//
// Date Created: 07/07/09
//
// Date Modified By Description
//-----------------------------------------------------------------------------
// 07/07/09 Roman Kiss Initial Revision
//
//*****************************************************************************
//
#region Namespaces
using System;
using System.Activities;
using System.Activities.Presentation.Converters;
using System.Activities.Presentation.Model;
using System.Activities.Presentation.PropertyEditing;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Microsoft.VisualBasic.Activities;
using RKiss.MessageMediationActivityLibrary.Design.Dialogs.Forms;
#endregion
namespace RKiss.MessageMediationActivityLibrary.Design.Editors
{
public class MessageXPathEditor : XmlValueExpressionEditor
{
public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
{
try
{
if (propertyValue != null)
{
ModelPropertyEntryToOwnerActivityConverter converter = new ModelPropertyEntryToOwnerActivityConverter();
ModelItem activity = (ModelItem)converter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null);
ModelItem item2 = (ModelItem)converter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null);
// properties
var qSourceUri = item2.Properties.FirstOrDefault(p => p.Name == "SourceUri");
var qNamespaces = item2.Properties.FirstOrDefault(p => p.Name == "Namespaces");
// values
var ns = qNamespaces.ComputedValue as Dictionary<string, string>;
string sourceUri = qSourceUri == null ? string.Empty : qSourceUri.ComputedValue as string;
string xpath = propertyValue.Value == null ? string.Empty : ((propertyValue.Value as InArgument<string>).Expression as VisualBasicValue<string>).ExpressionText;
if (xpath.Trim().StartsWith("\""))
{
xpath = xpath.Trim(new char[] { '"' });
}
XPathForm dialog = new XPathForm(xpath, ns, sourceUri);
dialog.ShowDialog();
if (dialog.DialogResult == System.Windows.Forms.DialogResult.OK)
{
item2.Properties["SourceUri"].SetValue(dialog.SourceUri);
item2.Properties["Namespaces"].SetValue(dialog.Namespaces);
if (string.IsNullOrEmpty(dialog.XPath))
propertyValue.Value = null;
else
{
var vbv = new VisualBasicValue<string>("\"" + dialog.XPath + "\"");
propertyValue.Value = new InArgument<string>(vbv);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "MessageXPathEditor");
}
}
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.