Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / Designers / ConditionalDesigner.cs / 1305376 / ConditionalDesigner.cs
namespace System.Workflow.Activities { using System; using System.Text; using System.Reflection; using System.Collections; using System.Collections.ObjectModel; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Design; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Runtime.Serialization; using System.Diagnostics; #region Class ConditionalToolboxItem [Serializable] internal sealed class IfElseToolboxItem: ActivityToolboxItem { public IfElseToolboxItem(Type type) : base(type) { } private IfElseToolboxItem(SerializationInfo info, StreamingContext context) { Deserialize(info, context); } protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost) { CompositeActivity conditionalActivity = new IfElseActivity(); conditionalActivity.Activities.Add(new IfElseBranchActivity()); conditionalActivity.Activities.Add(new IfElseBranchActivity()); return (IComponent[])new IComponent[] { conditionalActivity }; } } #endregion #region Class ConditionalDesigner [ActivityDesignerTheme(typeof(IfElseDesignerTheme))] internal sealed class IfElseDesigner : ParallelActivityDesigner { #region Properties and Methods public override bool CanInsertActivities(HitTestInfo insertLocation, ReadOnlyCollectionactivitiesToInsert) { foreach (Activity activity in activitiesToInsert) { if (!(activity is IfElseBranchActivity)) return false; } return base.CanInsertActivities(insertLocation, activitiesToInsert); } public override bool CanRemoveActivities(ReadOnlyCollection activitiesToRemove) { if ((ContainedDesigners.Count - activitiesToRemove.Count) < 1) return false; return true; } public override bool CanMoveActivities(HitTestInfo moveLocation, ReadOnlyCollection activitiesToMove) { if ((ContainedDesigners.Count - activitiesToMove.Count) < 1) { if (moveLocation != null && moveLocation.AssociatedDesigner != this) return false; } return true; } protected override CompositeActivity OnCreateNewBranch() { return new IfElseBranchActivity(); } protected override void OnPaint(ActivityDesignerPaintEventArgs e) { base.OnPaint(e); if (!Expanded || ContainedDesigners.Count == 0 || this != ActiveView.AssociatedDesigner) return; CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme; Debug.Assert(compositeDesignerTheme != null); if (compositeDesignerTheme == null) return; //Draw the Icon and Text Rectangle bounds = Bounds; Rectangle imageRectangle = ImageRectangle; Rectangle diamondRectangle = Rectangle.Empty; diamondRectangle.Width = compositeDesignerTheme.ConnectorSize.Height - 2 * e.AmbientTheme.Margin.Height + 2; diamondRectangle.Height = diamondRectangle.Width; diamondRectangle.X = bounds.Left + bounds.Width / 2 - diamondRectangle.Width / 2; diamondRectangle.Y = bounds.Top + TitleHeight + (compositeDesignerTheme.ConnectorSize.Height * 3 / 2 - diamondRectangle.Height) / 2 + 1; using (GraphicsPath decisionDiamond = GetDiamondPath(diamondRectangle)) { e.Graphics.FillPath(compositeDesignerTheme.ForegroundBrush, decisionDiamond); e.Graphics.DrawPath(compositeDesignerTheme.ForegroundPen, decisionDiamond); } diamondRectangle.Y = bounds.Bottom - compositeDesignerTheme.ConnectorSize.Height * 3 / 2 + (compositeDesignerTheme.ConnectorSize.Height * 3 / 2 - diamondRectangle.Height) / 2 + 1; using (GraphicsPath decisionDiamond = GetDiamondPath(diamondRectangle)) { e.Graphics.FillPath(compositeDesignerTheme.ForegroundBrush, decisionDiamond); e.Graphics.DrawPath(compositeDesignerTheme.ForegroundPen, decisionDiamond); } } private GraphicsPath GetDiamondPath(Rectangle rectangle) { Point[] diamondPoints = { new Point(rectangle.Left + rectangle.Width / 2, rectangle.Top), new Point(rectangle.Right - 1, rectangle.Top + rectangle.Height / 2), new Point(rectangle.Left + rectangle.Width / 2, rectangle.Bottom - 1), new Point(rectangle.Left, rectangle.Top + rectangle.Height / 2), new Point(rectangle.Left + rectangle.Width / 2, rectangle.Top) }; GraphicsPath diamondPath = new GraphicsPath(); diamondPath.AddLines(diamondPoints); diamondPath.CloseFigure(); return diamondPath; } #endregion } #endregion #region IfElseDesignerTheme internal sealed class IfElseDesignerTheme : CompositeDesignerTheme { public IfElseDesignerTheme(WorkflowTheme theme) : base(theme) { this.ShowDropShadow = false; this.ConnectorStartCap = LineAnchor.None; this.ConnectorEndCap = LineAnchor.None; this.ForeColor = Color.FromArgb(0xFF, 0x00, 0x64, 0x00); this.BorderColor = Color.FromArgb(0xFF, 0xE0, 0xE0, 0xE0); this.BorderStyle = DashStyle.Dash; this.BackColorStart = Color.FromArgb(0x00, 0x00, 0x00, 0x00); this.BackColorEnd = Color.FromArgb(0x00, 0x00, 0x00, 0x00); } } #endregion } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Workflow.Activities { using System; using System.Text; using System.Reflection; using System.Collections; using System.Collections.ObjectModel; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Design; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Runtime.Serialization; using System.Diagnostics; #region Class ConditionalToolboxItem [Serializable] internal sealed class IfElseToolboxItem: ActivityToolboxItem { public IfElseToolboxItem(Type type) : base(type) { } private IfElseToolboxItem(SerializationInfo info, StreamingContext context) { Deserialize(info, context); } protected override IComponent[] CreateComponentsCore(IDesignerHost designerHost) { CompositeActivity conditionalActivity = new IfElseActivity(); conditionalActivity.Activities.Add(new IfElseBranchActivity()); conditionalActivity.Activities.Add(new IfElseBranchActivity()); return (IComponent[])new IComponent[] { conditionalActivity }; } } #endregion #region Class ConditionalDesigner [ActivityDesignerTheme(typeof(IfElseDesignerTheme))] internal sealed class IfElseDesigner : ParallelActivityDesigner { #region Properties and Methods public override bool CanInsertActivities(HitTestInfo insertLocation, ReadOnlyCollection activitiesToInsert) { foreach (Activity activity in activitiesToInsert) { if (!(activity is IfElseBranchActivity)) return false; } return base.CanInsertActivities(insertLocation, activitiesToInsert); } public override bool CanRemoveActivities(ReadOnlyCollection activitiesToRemove) { if ((ContainedDesigners.Count - activitiesToRemove.Count) < 1) return false; return true; } public override bool CanMoveActivities(HitTestInfo moveLocation, ReadOnlyCollection activitiesToMove) { if ((ContainedDesigners.Count - activitiesToMove.Count) < 1) { if (moveLocation != null && moveLocation.AssociatedDesigner != this) return false; } return true; } protected override CompositeActivity OnCreateNewBranch() { return new IfElseBranchActivity(); } protected override void OnPaint(ActivityDesignerPaintEventArgs e) { base.OnPaint(e); if (!Expanded || ContainedDesigners.Count == 0 || this != ActiveView.AssociatedDesigner) return; CompositeDesignerTheme compositeDesignerTheme = e.DesignerTheme as CompositeDesignerTheme; Debug.Assert(compositeDesignerTheme != null); if (compositeDesignerTheme == null) return; //Draw the Icon and Text Rectangle bounds = Bounds; Rectangle imageRectangle = ImageRectangle; Rectangle diamondRectangle = Rectangle.Empty; diamondRectangle.Width = compositeDesignerTheme.ConnectorSize.Height - 2 * e.AmbientTheme.Margin.Height + 2; diamondRectangle.Height = diamondRectangle.Width; diamondRectangle.X = bounds.Left + bounds.Width / 2 - diamondRectangle.Width / 2; diamondRectangle.Y = bounds.Top + TitleHeight + (compositeDesignerTheme.ConnectorSize.Height * 3 / 2 - diamondRectangle.Height) / 2 + 1; using (GraphicsPath decisionDiamond = GetDiamondPath(diamondRectangle)) { e.Graphics.FillPath(compositeDesignerTheme.ForegroundBrush, decisionDiamond); e.Graphics.DrawPath(compositeDesignerTheme.ForegroundPen, decisionDiamond); } diamondRectangle.Y = bounds.Bottom - compositeDesignerTheme.ConnectorSize.Height * 3 / 2 + (compositeDesignerTheme.ConnectorSize.Height * 3 / 2 - diamondRectangle.Height) / 2 + 1; using (GraphicsPath decisionDiamond = GetDiamondPath(diamondRectangle)) { e.Graphics.FillPath(compositeDesignerTheme.ForegroundBrush, decisionDiamond); e.Graphics.DrawPath(compositeDesignerTheme.ForegroundPen, decisionDiamond); } } private GraphicsPath GetDiamondPath(Rectangle rectangle) { Point[] diamondPoints = { new Point(rectangle.Left + rectangle.Width / 2, rectangle.Top), new Point(rectangle.Right - 1, rectangle.Top + rectangle.Height / 2), new Point(rectangle.Left + rectangle.Width / 2, rectangle.Bottom - 1), new Point(rectangle.Left, rectangle.Top + rectangle.Height / 2), new Point(rectangle.Left + rectangle.Width / 2, rectangle.Top) }; GraphicsPath diamondPath = new GraphicsPath(); diamondPath.AddLines(diamondPoints); diamondPath.CloseFigure(); return diamondPath; } #endregion } #endregion #region IfElseDesignerTheme internal sealed class IfElseDesignerTheme : CompositeDesignerTheme { public IfElseDesignerTheme(WorkflowTheme theme) : base(theme) { this.ShowDropShadow = false; this.ConnectorStartCap = LineAnchor.None; this.ConnectorEndCap = LineAnchor.None; this.ForeColor = Color.FromArgb(0xFF, 0x00, 0x64, 0x00); this.BorderColor = Color.FromArgb(0xFF, 0xE0, 0xE0, 0xE0); this.BorderStyle = DashStyle.Dash; this.BackColorStart = Color.FromArgb(0x00, 0x00, 0x00, 0x00); this.BackColorEnd = Color.FromArgb(0x00, 0x00, 0x00, 0x00); } } #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
- ValueChangedEventManager.cs
- PriorityBinding.cs
- RemoteWebConfigurationHostStream.cs
- XmlReaderSettings.cs
- SQLRoleProvider.cs
- WebRequestModuleElementCollection.cs
- XamlReader.cs
- COM2ExtendedUITypeEditor.cs
- TextTabProperties.cs
- IteratorDescriptor.cs
- Attributes.cs
- FileFormatException.cs
- CustomDictionarySources.cs
- BindingCollection.cs
- CodeTypeReferenceSerializer.cs
- ParseChildrenAsPropertiesAttribute.cs
- SmtpLoginAuthenticationModule.cs
- SymmetricKey.cs
- ToolStripPanelRow.cs
- Gdiplus.cs
- XmlSiteMapProvider.cs
- XmlUtf8RawTextWriter.cs
- NotSupportedException.cs
- MonthChangedEventArgs.cs
- TheQuery.cs
- RoleService.cs
- SqlUnionizer.cs
- AnnotationHighlightLayer.cs
- EventLogWatcher.cs
- TraceContextRecord.cs
- UInt16Storage.cs
- DateTimeFormatInfo.cs
- DocumentXmlWriter.cs
- Journal.cs
- CheckBoxPopupAdapter.cs
- BoundingRectTracker.cs
- WebBrowserUriTypeConverter.cs
- COM2PropertyDescriptor.cs
- TextBoxAutoCompleteSourceConverter.cs
- ValidationRuleCollection.cs
- CollectionBase.cs
- ComponentDispatcherThread.cs
- DecimalAnimationUsingKeyFrames.cs
- SafeFileMappingHandle.cs
- StackOverflowException.cs
- DataGridItemEventArgs.cs
- SQLBytes.cs
- DPAPIProtectedConfigurationProvider.cs
- LoginName.cs
- OptimisticConcurrencyException.cs
- ExpressionWriter.cs
- MimeXmlImporter.cs
- TypeHelpers.cs
- XmlSchemaElement.cs
- ChannelManagerBase.cs
- HostingPreferredMapPath.cs
- WebPartCloseVerb.cs
- LinkDesigner.cs
- CodeTypeParameterCollection.cs
- HttpServerProtocol.cs
- FixedSOMPageElement.cs
- AssemblyBuilder.cs
- InputGestureCollection.cs
- UserMapPath.cs
- CodeCompiler.cs
- FunctionMappingTranslator.cs
- XmlNavigatorStack.cs
- BrowserCapabilitiesCompiler.cs
- CopyNamespacesAction.cs
- FixedSOMPageConstructor.cs
- TypedReference.cs
- XmlHierarchicalEnumerable.cs
- FirstMatchCodeGroup.cs
- XmlMembersMapping.cs
- ServiceMemoryGates.cs
- safemediahandle.cs
- Events.cs
- SamlAdvice.cs
- TextElement.cs
- SiteMapProvider.cs
- COSERVERINFO.cs
- ParsedAttributeCollection.cs
- safemediahandle.cs
- EmptyCollection.cs
- Array.cs
- MobileUserControlDesigner.cs
- TextFormatter.cs
- WizardForm.cs
- TextDocumentView.cs
- ContentDefinition.cs
- FontFamily.cs
- TagMapInfo.cs
- DbConnectionInternal.cs
- XmlBinaryWriterSession.cs
- EndOfStreamException.cs
- FixedSOMContainer.cs
- ImageMap.cs
- QuotaThrottle.cs
- AssemblyInfo.cs
- ImageAutomationPeer.cs