Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Design / SequentialWorkflowHeaderFooter.cs / 1305376 / SequentialWorkflowHeaderFooter.cs
#pragma warning disable 1634, 1691
namespace System.Workflow.ComponentModel.Design
{
using System;
using System.IO;
using System.Drawing;
using System.CodeDom;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using System.ComponentModel;
using System.Globalization;
using System.Drawing.Design;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Windows.Forms.Design;
using System.ComponentModel.Design;
using System.Collections.Specialized;
using System.ComponentModel.Design.Serialization;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Workflow.ComponentModel.Design;
using System.Runtime.Serialization.Formatters.Binary;
//
#region Class Header/Footer
///
/// Base class for Header and Footer to be associated with SequentialWorkflowRootDesigner
///
public class SequentialWorkflowHeaderFooter
{
private SequentialWorkflowRootDesigner rootDesigner;
private Image image;
private string text = String.Empty;
private bool isHeader = true;
internal Size textSize = Size.Empty;
///
/// Default constructor
///
/// Parent designer associated with the Header or Footer
/// True if it is a header, false if it is a footer
public SequentialWorkflowHeaderFooter(SequentialWorkflowRootDesigner parent, bool isHeader)
{
this.rootDesigner = parent;
this.isHeader = isHeader;
}
///
/// Gets the image associated with Header/Footer
///
public virtual Image Image
{
get
{
return this.image;
}
set
{
if (this.image == value)
return;
this.image = value;
AssociatedDesigner.InternalPerformLayout();
}
}
///
/// Gets the text associated with Header/Footer
///
public virtual string Text
{
get
{
return this.text;
}
set
{
if (this.text == value)
return;
this.text = value;
AssociatedDesigner.InternalPerformLayout();
}
}
///
/// Gets the bonding rectangle for Header/Footer
///
public virtual Rectangle Bounds
{
get
{
Rectangle bounds = Rectangle.Empty;
Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin;
Rectangle textBounds = TextRectangle;
Rectangle imageBounds = ImageRectangle;
if (!textBounds.Size.IsEmpty || !imageBounds.Size.IsEmpty)
{
bounds.Width = Math.Max(imageBounds.Width, textBounds.Width) + 2 * margin.Width;
bounds.Height = margin.Height + imageBounds.Height;
bounds.Height += (imageBounds.Height > 0) ? margin.Height : 0;
bounds.Height += textBounds.Height;
bounds.Height += (textBounds.Height > 0) ? margin.Height : 0;
//Before returning we adjust the bounds based on the header / footer setting
Rectangle designerBounds = this.rootDesigner.Bounds;
bounds.X = designerBounds.Left + designerBounds.Width / 2 - bounds.Width / 2;
bounds.Y = (this.isHeader) ? designerBounds.Top : designerBounds.Bottom - bounds.Height;
}
return bounds;
}
}
///
/// Gets the bounding rectangle for text associated with Header/Footer
///
public virtual Rectangle TextRectangle
{
get
{
Rectangle bounds = Rectangle.Empty;
if (!String.IsNullOrEmpty(Text))
{
Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin;
Rectangle designerBounds = this.rootDesigner.Bounds;
bounds.Size = this.textSize;
bounds.X = designerBounds.Left + designerBounds.Width / 2 - this.textSize.Width / 2;
bounds.Y = (this.isHeader) ? designerBounds.Top + margin.Height : designerBounds.Bottom - margin.Height - this.textSize.Height;
}
return bounds;
}
}
///
/// Gets the bounding rectangle for Image associated with Header/Footer
///
public virtual Rectangle ImageRectangle
{
get
{
Rectangle bounds = Rectangle.Empty;
if (Image != null)
{
ActivityDesignerTheme designerTheme = this.rootDesigner.DesignerTheme;
Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin;
Rectangle designerBounds = this.rootDesigner.Bounds;
Rectangle textRectangle = TextRectangle;
bounds.Size = designerTheme.ImageSize;
bounds.X = designerBounds.Left + designerBounds.Width / 2 - bounds.Width / 2;
if (this.isHeader)
{
bounds.Y = designerBounds.Top + margin.Height;
bounds.Y += textRectangle.Height;
bounds.Y += (textRectangle.Height > 0) ? margin.Height : 0;
}
else
{
bounds.Y = designerBounds.Bottom - margin.Height;
bounds.Y -= textRectangle.Height;
bounds.Y -= (textRectangle.Height > 0) ? margin.Height : 0;
bounds.Y -= bounds.Height;
}
}
return bounds;
}
}
///
/// Layouts the visual cues inside Header/Footer
///
/// ActivityDesignerLayoutEventArgs holding layouting arguments
public virtual void OnLayout(ActivityDesignerLayoutEventArgs e)
{
if (e == null)
throw new ArgumentNullException("e");
if (!String.IsNullOrEmpty(Text) && e.DesignerTheme != null && e.DesignerTheme.Font != null)
{
using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1.0f, FontStyle.Bold))
this.textSize = ActivityDesignerPaint.MeasureString(e.Graphics, font, Text, StringAlignment.Center, Size.Empty);
}
}
///
/// Draws the Header/Footer associated with workflow root designer.
///
/// ActivityDesignerPaintEventArgs holding drawing arguments
public virtual void OnPaint(ActivityDesignerPaintEventArgs e)
{
if (e == null)
throw new ArgumentNullException("e");
if (!String.IsNullOrEmpty(Text) && !TextRectangle.Size.IsEmpty && e.DesignerTheme != null && e.DesignerTheme.Font != null)
{
//use bold or regular font based on mouse over status
using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1.0f, (this.AssociatedDesigner.SmartTagVisible) ? FontStyle.Bold : FontStyle.Regular))
ActivityDesignerPaint.DrawText(e.Graphics, font, Text, TextRectangle, StringAlignment.Center, TextQuality.AntiAliased, e.DesignerTheme.ForegroundBrush);
}
if (Image != null && !ImageRectangle.Size.IsEmpty)
ActivityDesignerPaint.DrawImage(e.Graphics, Image, ImageRectangle, DesignerContentAlignment.Fill);
}
///
/// Gets the designer associated with header/footer
///
protected SequentialWorkflowRootDesigner AssociatedDesigner
{
get
{
return this.rootDesigner;
}
}
}
#endregion
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
#pragma warning disable 1634, 1691
namespace System.Workflow.ComponentModel.Design
{
using System;
using System.IO;
using System.Drawing;
using System.CodeDom;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using System.ComponentModel;
using System.Globalization;
using System.Drawing.Design;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Windows.Forms.Design;
using System.ComponentModel.Design;
using System.Collections.Specialized;
using System.ComponentModel.Design.Serialization;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Workflow.ComponentModel.Design;
using System.Runtime.Serialization.Formatters.Binary;
//
#region Class Header/Footer
///
/// Base class for Header and Footer to be associated with SequentialWorkflowRootDesigner
///
public class SequentialWorkflowHeaderFooter
{
private SequentialWorkflowRootDesigner rootDesigner;
private Image image;
private string text = String.Empty;
private bool isHeader = true;
internal Size textSize = Size.Empty;
///
/// Default constructor
///
/// Parent designer associated with the Header or Footer
/// True if it is a header, false if it is a footer
public SequentialWorkflowHeaderFooter(SequentialWorkflowRootDesigner parent, bool isHeader)
{
this.rootDesigner = parent;
this.isHeader = isHeader;
}
///
/// Gets the image associated with Header/Footer
///
public virtual Image Image
{
get
{
return this.image;
}
set
{
if (this.image == value)
return;
this.image = value;
AssociatedDesigner.InternalPerformLayout();
}
}
///
/// Gets the text associated with Header/Footer
///
public virtual string Text
{
get
{
return this.text;
}
set
{
if (this.text == value)
return;
this.text = value;
AssociatedDesigner.InternalPerformLayout();
}
}
///
/// Gets the bonding rectangle for Header/Footer
///
public virtual Rectangle Bounds
{
get
{
Rectangle bounds = Rectangle.Empty;
Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin;
Rectangle textBounds = TextRectangle;
Rectangle imageBounds = ImageRectangle;
if (!textBounds.Size.IsEmpty || !imageBounds.Size.IsEmpty)
{
bounds.Width = Math.Max(imageBounds.Width, textBounds.Width) + 2 * margin.Width;
bounds.Height = margin.Height + imageBounds.Height;
bounds.Height += (imageBounds.Height > 0) ? margin.Height : 0;
bounds.Height += textBounds.Height;
bounds.Height += (textBounds.Height > 0) ? margin.Height : 0;
//Before returning we adjust the bounds based on the header / footer setting
Rectangle designerBounds = this.rootDesigner.Bounds;
bounds.X = designerBounds.Left + designerBounds.Width / 2 - bounds.Width / 2;
bounds.Y = (this.isHeader) ? designerBounds.Top : designerBounds.Bottom - bounds.Height;
}
return bounds;
}
}
///
/// Gets the bounding rectangle for text associated with Header/Footer
///
public virtual Rectangle TextRectangle
{
get
{
Rectangle bounds = Rectangle.Empty;
if (!String.IsNullOrEmpty(Text))
{
Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin;
Rectangle designerBounds = this.rootDesigner.Bounds;
bounds.Size = this.textSize;
bounds.X = designerBounds.Left + designerBounds.Width / 2 - this.textSize.Width / 2;
bounds.Y = (this.isHeader) ? designerBounds.Top + margin.Height : designerBounds.Bottom - margin.Height - this.textSize.Height;
}
return bounds;
}
}
///
/// Gets the bounding rectangle for Image associated with Header/Footer
///
public virtual Rectangle ImageRectangle
{
get
{
Rectangle bounds = Rectangle.Empty;
if (Image != null)
{
ActivityDesignerTheme designerTheme = this.rootDesigner.DesignerTheme;
Size margin = WorkflowTheme.CurrentTheme.AmbientTheme.Margin;
Rectangle designerBounds = this.rootDesigner.Bounds;
Rectangle textRectangle = TextRectangle;
bounds.Size = designerTheme.ImageSize;
bounds.X = designerBounds.Left + designerBounds.Width / 2 - bounds.Width / 2;
if (this.isHeader)
{
bounds.Y = designerBounds.Top + margin.Height;
bounds.Y += textRectangle.Height;
bounds.Y += (textRectangle.Height > 0) ? margin.Height : 0;
}
else
{
bounds.Y = designerBounds.Bottom - margin.Height;
bounds.Y -= textRectangle.Height;
bounds.Y -= (textRectangle.Height > 0) ? margin.Height : 0;
bounds.Y -= bounds.Height;
}
}
return bounds;
}
}
///
/// Layouts the visual cues inside Header/Footer
///
/// ActivityDesignerLayoutEventArgs holding layouting arguments
public virtual void OnLayout(ActivityDesignerLayoutEventArgs e)
{
if (e == null)
throw new ArgumentNullException("e");
if (!String.IsNullOrEmpty(Text) && e.DesignerTheme != null && e.DesignerTheme.Font != null)
{
using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1.0f, FontStyle.Bold))
this.textSize = ActivityDesignerPaint.MeasureString(e.Graphics, font, Text, StringAlignment.Center, Size.Empty);
}
}
///
/// Draws the Header/Footer associated with workflow root designer.
///
/// ActivityDesignerPaintEventArgs holding drawing arguments
public virtual void OnPaint(ActivityDesignerPaintEventArgs e)
{
if (e == null)
throw new ArgumentNullException("e");
if (!String.IsNullOrEmpty(Text) && !TextRectangle.Size.IsEmpty && e.DesignerTheme != null && e.DesignerTheme.Font != null)
{
//use bold or regular font based on mouse over status
using (Font font = new Font(e.DesignerTheme.Font.FontFamily, e.DesignerTheme.Font.SizeInPoints + 1.0f, (this.AssociatedDesigner.SmartTagVisible) ? FontStyle.Bold : FontStyle.Regular))
ActivityDesignerPaint.DrawText(e.Graphics, font, Text, TextRectangle, StringAlignment.Center, TextQuality.AntiAliased, e.DesignerTheme.ForegroundBrush);
}
if (Image != null && !ImageRectangle.Size.IsEmpty)
ActivityDesignerPaint.DrawImage(e.Graphics, Image, ImageRectangle, DesignerContentAlignment.Fill);
}
///
/// Gets the designer associated with header/footer
///
protected SequentialWorkflowRootDesigner AssociatedDesigner
{
get
{
return this.rootDesigner;
}
}
}
#endregion
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ToolBarButton.cs
- XmlSchemaElement.cs
- ComponentDispatcherThread.cs
- RegexCapture.cs
- TableCell.cs
- MemberAccessException.cs
- EmptyEnumerator.cs
- MeasurementDCInfo.cs
- SelectionEditingBehavior.cs
- ChooseAction.cs
- AppDomainFactory.cs
- GeometryGroup.cs
- PageSetupDialog.cs
- PtsCache.cs
- DataObject.cs
- DataDocumentXPathNavigator.cs
- _ContextAwareResult.cs
- PageAction.cs
- DocumentViewerBaseAutomationPeer.cs
- HttpDebugHandler.cs
- NetSectionGroup.cs
- GridLengthConverter.cs
- ReliableChannelBinder.cs
- RestHandler.cs
- SystemWebExtensionsSectionGroup.cs
- CurrentChangingEventArgs.cs
- TextFormatterHost.cs
- TraceHwndHost.cs
- FileInfo.cs
- PersonalizablePropertyEntry.cs
- CreateParams.cs
- HtmlSelect.cs
- XmlSerializerNamespaces.cs
- ObjRef.cs
- StackOverflowException.cs
- ManipulationDelta.cs
- FixUpCollection.cs
- TimeSpanValidator.cs
- DataBindingCollection.cs
- Int64.cs
- MetadataProperty.cs
- XmlResolver.cs
- PackageDigitalSignature.cs
- MetadataPropertyAttribute.cs
- FormViewInsertEventArgs.cs
- XPathDocumentNavigator.cs
- AdRotator.cs
- Point3DCollection.cs
- XmlAggregates.cs
- SpeakInfo.cs
- BinaryEditor.cs
- CapabilitiesSection.cs
- GenericUriParser.cs
- DataGridViewToolTip.cs
- OrderPreservingMergeHelper.cs
- DbDataAdapter.cs
- SystemIPv6InterfaceProperties.cs
- RouteValueExpressionBuilder.cs
- WebPart.cs
- FontUnit.cs
- PeerTransportListenAddressValidator.cs
- ToolStripTextBox.cs
- MsmqIntegrationInputMessage.cs
- ScriptHandlerFactory.cs
- DropTarget.cs
- SoapMessage.cs
- ToolBarButton.cs
- BaseParser.cs
- PasswordBoxAutomationPeer.cs
- DateTimeStorage.cs
- CursorConverter.cs
- DataViewManagerListItemTypeDescriptor.cs
- XmlSchemaAnnotation.cs
- SafeFileMappingHandle.cs
- GZipStream.cs
- ConversionContext.cs
- XmlSerializer.cs
- CompilerCollection.cs
- ErrorRuntimeConfig.cs
- Scene3D.cs
- CustomSignedXml.cs
- wgx_exports.cs
- MetabaseSettings.cs
- HMAC.cs
- SystemParameters.cs
- XPathNodeInfoAtom.cs
- UnknownMessageReceivedEventArgs.cs
- XmlSchemas.cs
- DataGridRow.cs
- PersonalizationStateInfo.cs
- ObjectItemCollection.cs
- UnaryNode.cs
- columnmapfactory.cs
- SelectedDatesCollection.cs
- DtrList.cs
- LoginStatusDesigner.cs
- SmiRequestExecutor.cs
- LambdaExpression.cs
- DataGridViewRowConverter.cs
- ValidationErrorInfo.cs