Author Topic: WDE interaction Extension  (Read 2017 times)

Offline PFCCWA

  • Hero Member
  • *****
  • Posts: 655
  • Karma: -7
WDE interaction Extension
« on: July 24, 2019, 12:02:19 AM »
Hello,

Having a few problems with customizing WDE 8.5 to show a browser within the interaction extension window.  I have managed to do this separately (see other post) but want to see it within a WDE interaction window.
The provided sample (InteractionExtensionSample) is close to what I want to achieve so have used this as a template.
The aim to replace the existing 'MySampleView' content (yellow box, black circle, reset button) with a browser containing a url from an attached date field.

Generally speaking I think the following files are needed, or require amendments.
[b]MySampleView.xaml
MySampleView.xaml.cs
IMySampleView.cs
InteractionExtensionSampleModule.cs[/b]

What is confusing slightly is what code is required for each file.

[u]For MySampleView.xaml I have added a browser control to the existing content (removed the reset button/black circle and added the bold text below):[/u]
<UserControl x:Class="Genesyslab.Desktop.Modules.InteractionExtensionSample.MySample.MySampleView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Name="MySampleViewInteractionWorksheet"
    Loaded="MySampleView_Loaded"
    MinWidth="400.0"
    MinHeight="400.0"           
    MaxWidth="400.0"
    MaxHeight="400.0"           
    Height="220" Width="279" Background="Yellow">
<!--    MinWidth="{Binding ElementName=mySampleView, Path=MySampleViewSizeManager.MinSize.Width}"
    MinHeight="{Binding ElementName=mySampleView, Path=MySampleViewSizeManager.MinSize.Height}"           
-->
    <Grid>
[i][b]        <StackPanel>
            <WebBrowser x:Name="myWebBrowser" />
        </StackPanel>[/b][/i]
    </Grid>
</UserControl>


[u]For the MySampleView.xaml.cs, i have added code from a Genesys documentation on using URI from attached data, additional code in bold:[/u]
namespace Genesyslab.Desktop.Modules.InteractionExtensionSample.MySample
{
    /// <summary>
    /// Interaction logic for MySampleView.xaml
    /// </summary>
    public partial class MySampleView : UserControl, IMySampleView
    {
        readonly IObjectContainer container;

        public MySampleView(IMySampleViewModel mySampleViewModel, IObjectContainer container)
        {
            this.Model = mySampleViewModel;
            this.container = container;

            InitializeComponent();

            Width = Double.NaN;
            Height = Double.NaN;
            MinSize = new MSize() { Width = 400.0, Height = 400.0 };
        }

        MSize _MinSize;
        public MSize MinSize
        {
            get { return _MinSize; }  // (MSize)base.GetValue(MinSizeProperty); }
            set
            {
                _MinSize = value; // base.SetValue(MinSizeProperty, value);
                OnPropertyChanged("MinSize");
            }
        }


        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }

        #endregion
        #region IMySampleView Members

        /// <summary>
        /// Gets or sets the model.
        /// </summary>
        /// <value>The model.</value>
        public IMySampleViewModel Model
        {
            get { return this.DataContext as IMySampleViewModel; }
            set { this.DataContext = value; }
        }

        #endregion

        #region IView Members

        /// <summary>
        /// Gets or sets the context.
        /// </summary>
        /// <value>The context.</value>
        public object Context { get; set; }

        /// <summary>
        /// Creates this instance.
        /// </summary>
        public void Create()
[b]      {
            {
                IDictionary<string, object> contextDictionary = (Context as IDictionary<string, object>);
                object caseObject;
                if (contextDictionary.TryGetValue("Case", out caseObject))
                {
                    ICase theCase = caseObject as ICase;
                    // Get the URL from the interaction attached data
                    string urlField = theCase.MainInteraction.GetAttachedData("URL_Field") as string;
                    // Get URI to navigate to
                    Uri uri = new Uri(urlField, UriKind.RelativeOrAbsolute);
                    // Create the web browser control and add it to the view (here an UserControl)
                    System.Windows.Controls.WebBrowser myWebBrowser = new System.Windows.Controls.WebBrowser();
                    this.Content = myWebBrowser;
                    myWebBrowser.Navigate(uri);
                }
            }[/b]
        }

        /// <summary>
        /// Destroys this instance.
        /// </summary>
        public void Destroy()
        {
        }

        #endregion

        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Model.ResetCounter();
        }

        private void MySampleView_Loaded(object sender, RoutedEventArgs e)
        {
        }

    }
}


I have not changed the IMySampleView.cs or InteractionExtensionSampleModule.cs files as I don't think this is needed because the interaction extension is already placed within the location needed.
Am I on the right lines?  I know there is much more code within the 'xaml' and 'xaml cs' files but if I start to remove any snippets that I think are not needed - there are errors during build/debug.
There may also be a better or simpler way to do this.

thanks.