Skip to main content

How to integrate BizTalk Server 2010 / 2013 with Service Bus for Windows Server

This solution shows how to integrate a BizTalk Server 2010/2013 application with Service Bus for Windows Server using the WCF-Custom adapter to exchange messages with external systems in a reliable, flexible, and scalable manner.

C# (5.3 MB)
 
 
 
 
 
4.7 Star
(6)
1,708 times
Add to favorites
6/20/2014
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
#region Copyright
//=======================================================================================
//Microsoft Windows Server AppFabric Customer Advisory Team (CAT)  
//
// This sample is supplemental to the technical guidance published on the community
// blog at http://blogs.msdn.com/paolos. 
// 
// Author: Paolo Salvatori
//=======================================================================================
// Copyright � 2011 Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
// EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. YOU BEAR THE RISK OF USING IT.
//=======================================================================================
#endregion

#region Using References
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Text;
using System.Windows.Forms;
#endregion

namespace Microsoft.WindowsAzure.CAT.Samples.ServiceBusForWindowsServer.Client
{
    public partial class HeaderPanel : Panel
    {
        #region Private Fields
        private int headerHeight = 24;
        private string headerText = "header title";
        private Font headerFont = new Font("Arial", 10F, System.Drawing.FontStyle.Bold);
        private Color headerColor1 = SystemColors.InactiveCaption;
        private Color headerColor2 = SystemColors.ActiveCaption;
        private Color iconTransparentColor = Color.White;
        private Image icon = null;
        #endregion

        #region Public Properties
        [Browsable(true), Category("Custom")]
        public string HeaderText
        {
            get { return headerText; }
            set
            {
                headerText = value;
                Invalidate();
            }
        }

        [Browsable(true), Category("Custom")]
        public int HeaderHeight
        {
            get { return headerHeight; }
            set
            {
                headerHeight = value;
                Invalidate();
            }
        }

        [Browsable(true), Category("Custom")]
        public Font HeaderFont
        {
            get { return headerFont; }
            set
            {
                headerFont = value;
                Invalidate();
            }
        }

        [Browsable(true), Category("Custom")]
        public Color HeaderColor1
        {
            get { return headerColor1; }
            set
            {
                headerColor1 = value;
                Invalidate();
            }
        }

        [Browsable(true), Category("Custom")]
        public Color HeaderColor2
        {
            get { return headerColor2; }
            set
            {
                headerColor2 = value;
                Invalidate();
            }
        }

        [Browsable(true), Category("Custom")]
        public Image Icon
        {
            get { return icon; }
            set
            {
                icon = value;
                Invalidate();
            }
        }

        [Browsable(true), Category("Custom")]
        public Color IconTransparentColor
        {
            get { return iconTransparentColor; }
            set
            {
                iconTransparentColor = value;
                Invalidate();
            }
        }
        #endregion

        #region Public Constructors
        public HeaderPanel()
        {
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            InitializeComponent();
            this.Padding = new Padding(5, headerHeight + 4, 5, 4);
        }
        #endregion

        #region Private Methods
        private void OutlookPanelEx_Paint(object sender, PaintEventArgs e)
        {
            if (headerHeight > 1)
            {
                // Draw border;
                DrawBorder(e.Graphics);

                // Draw heaeder
                DrawHeader(e.Graphics);

                // Draw text
                DrawText(e.Graphics);

                // Draw Icon
                DrawIcon(e.Graphics);
            }
        }

        private void DrawBorder(Graphics graphics)
        {
            using (Pen pen = new Pen(this.headerColor2))
            {
                graphics.DrawRectangle(pen, 0, 0, this.Width - 1, this.Height - 1);
            }
        }

        private void DrawHeader(Graphics graphics)
        {
            Rectangle headerRect = new Rectangle(1, 1, this.Width - 2, this.headerHeight);
            using (Brush brush = new LinearGradientBrush(headerRect, headerColor1, headerColor2, LinearGradientMode.Vertical))
            {
                graphics.FillRectangle(brush, headerRect);
            }
        }

        private void DrawText(Graphics graphics)
        {
            if (!string.IsNullOrEmpty(this.headerText))
            {
                SizeF size = graphics.MeasureString(this.headerText, this.headerFont);
                using (Brush brush = new SolidBrush(ForeColor))
                {
                    float x;
                    if (this.icon != null)
                    {
                        x = this.icon.Width + 6;
                    }
                    else
                    {
                        x = 4;
                    }
                    graphics.DrawString(this.headerText, this.headerFont, brush, x, (headerHeight - size.Height) / 2);
                }
            }
        }

        private void DrawIcon(Graphics graphics)
        {
            if (this.icon != null)
            {
                Point point = new Point(4, (headerHeight - icon.Height) / 2);
                Bitmap bitmap = new Bitmap(icon);
                bitmap.MakeTransparent(iconTransparentColor);
                graphics.DrawImage(bitmap, point);
            }
        }
        #endregion
    }
}