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,705 times
Add to favorites
6/20/2014
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
#region Copyright
//=======================================================================================
// Microsoft Business Platform Division 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.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
#endregion

namespace Microsoft.WindowsAzure.CAT.Samples.ServiceBusForWindowsServer.Client
{
    /// <summary>
    /// Modified GroupBox with editable border colour
    /// </summary>
    class CustomGroupBox : GroupBox
    {
        #region Private Fields
        private Color borderColor;
        private Color borderColorLight;
        private Int32 borderRadius; 
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets or sets the color of the border.
        /// </summary>
        public Color BorderColor
        {
            get { return borderColor; }
            set { borderColor = value; }
        }

        /// <summary>
        /// Gets or sets the color of the of second border for decoration purposes.
        /// </summary>
        public Color BorderColorLight
        {
            get { return borderColorLight; }
            set { borderColorLight = value; }
        }

        /// <summary>
        /// Gets or sets the radius of the border.
        /// </summary>
        public Int32 BorderRadius
        {
            get { return borderRadius; }
            set { borderRadius = value; }
        } 
        #endregion

        #region Public Constructor
        public CustomGroupBox()
        {
            // default colours
            borderColor = SystemColors.ControlDarkDark;
            borderColorLight = SystemColors.ControlLightLight;
            borderRadius = 5;

            DoubleBuffered = true; // prevent flickering
            ResizeRedraw = true;   // prevent pixel errors when window moves/resizes
        } 
        #endregion

        #region Event Handlers
        protected override void OnPaint(PaintEventArgs e)
        {
            // don't modify if visual styles are disabled   (in this case the default border has a good visibility)
            if (Application.RenderWithVisualStyles == false)
            {
                base.OnPaint(e);
                return;
            }

            Size textSize = TextRenderer.MeasureText(Text, Font);

            // dark border (main)
            var borderRect = new Rectangle(
                0,
                textSize.Height / 2,
                ClientRectangle.Width - 1,
                ClientRectangle.Height - (textSize.Height / 2) - 2
                );

            // light border (decoration)
            var borderRect2 = new Rectangle(
                1,
                borderRect.Y + 1,
                borderRect.Width - 2,
                borderRect.Height
                );

            // create path
            GraphicsPath gPathDark = CreatePath(borderRect, borderRadius);
            GraphicsPath gPathLight = CreatePath(borderRect2, borderRadius);

            // draw border
            e.Graphics.FillPath(new SolidBrush(BackColor), gPathDark);  // background
            e.Graphics.DrawPath(new Pen(borderColorLight), gPathLight); // light line
            e.Graphics.DrawPath(new Pen(borderColor), gPathDark);       // dark line


            // draw text
            RectangleF textRect = e.ClipRectangle;
            textRect.X += 6;
            textRect.Width = textSize.Width;
            textRect.Width += 5;  // be shure to draw the last letter
            textRect.Height = textSize.Height;
            e.Graphics.FillRectangle(new SolidBrush(BackColor), textRect);
            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), textRect);

            // NOTE:
            // To avoid flickering and pixel errors
            // enable the flags "DoubleBuffered" and "ResizeRedraw" in the constructor of this class.

        } //  OnPaint() 
        #endregion

        #region Private Methods
        /// <summary>
        /// Create "box" with round corners
        /// </summary>
        private GraphicsPath CreatePath(Rectangle borderRectangle, Int32 radius)
        {
            return CreatePath(borderRectangle.X, borderRectangle.Y, borderRectangle.Width, borderRectangle.Height, radius);
        }

        /// <summary>
        /// Create "box" with round corners
        /// </summary>
        private GraphicsPath CreatePath(Int32 x, Int32 y, Int32 width, Int32 height, Int32 radius)
        {
            // originally published by:  deep.ashar
            // source:  http://social.msdn.microsoft.com/forums/en-US/winforms/thread/cfd34dd1-b6e5-4b56-9901-0dc3d2ca5788
            // modified by Beauty

            var xw = x + width;
            var yh = y + height;
            var xwr = xw - radius;
            var yhr = yh - radius;
            var xr = x + radius;
            var yr = y + radius;
            var r2 = radius * 2;
            var xwr2 = xw - r2;
            var yhr2 = yh - r2;

            var p = new GraphicsPath();
            p.StartFigure();

            //Top Left Corner
            p.AddArc(x, y, r2, r2, 180, 90);

            //Top Edge
            p.AddLine(xr, y, xwr, y);

            //Top Right Corner
            p.AddArc(xwr2, y, r2, r2, 270, 90);

            //Right Edge
            p.AddLine(xw, yr, xw, yhr);

            //Bottom Right Corner
            p.AddArc(xwr2, yhr2, r2, r2, 0, 90);


            //Bottom Edge
            p.AddLine(xwr, yh, xr, yh);

            //Bottom Left Corner           
            p.AddArc(x, yhr2, r2, r2, 90, 90);


            //Left Edge
            p.AddLine(x, yhr, x, yr);

            p.CloseFigure();
            return p;

        } //  CreatePath()

        /// <summary>
        /// Manual refresh of modified GroupBox controls (to avoid pixel faults). <br/>
        /// This should be called when main window was activated, moved or resized. <br/>
        /// For this create callback method by the events Form.Activated, Form.Resize and Form.Move 
        /// which calls this method.
        /// If you have more than 1 panel (or other controls), which contains the GroupBoxMOD,
        /// then call this method for each panel. 
        /// </summary>
        /// <param name="controlWithGroupboxes">Control, which contains GroupBoxMOD controls</param>
        public static void RedrawGroupBoxDisplay(Control controlWithGroupboxes)
        {
            foreach (var control in controlWithGroupboxes.Controls)
            {
                if (control.GetType() == typeof (CustomGroupBox))
                {
                    ((CustomGroupBox) control).Invalidate();
                }
            }
        } 
        #endregion
    }
}