//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using DslModeling = global::Microsoft.VisualStudio.Modeling;
using DslDesign = global::Microsoft.VisualStudio.Modeling.Design;
using DslDiagrams = global::Microsoft.VisualStudio.Modeling.Diagrams;

[module: global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Scope = "type", Target = "MDC.ProductionSystem.ProductionSystemDiagram")]

namespace MDC.ProductionSystem
{
	/// <summary>
	/// DomainClass ProductionSystemDiagram
	/// Description for MDC.ProductionSystem.ProductionSystemDiagram
	/// </summary>
	[DslDesign::DisplayNameResource("MDC.ProductionSystem.ProductionSystemDiagram.DisplayName", typeof(global::MDC.ProductionSystem.ProductionSystemDomainModel), "MDC.ProductionSystem.GeneratedCode.DomainModelResx")]
	[DslDesign::DescriptionResource("MDC.ProductionSystem.ProductionSystemDiagram.Description", typeof(global::MDC.ProductionSystem.ProductionSystemDomainModel), "MDC.ProductionSystem.GeneratedCode.DomainModelResx")]
	[DslModeling::DomainModelOwner(typeof(global::MDC.ProductionSystem.ProductionSystemDomainModel))]
	[global::System.CLSCompliant(true)]
	[DslModeling::DomainObjectId("28dbf134-1097-48f2-a03c-d2487c47e410")]
	public partial class ProductionSystemDiagram : DslDiagrams::Diagram
	{
		#region Diagram boilerplate
		private static DslDiagrams::StyleSet classStyleSet;
		private static global::System.Collections.Generic.IList<DslDiagrams::ShapeField> shapeFields;
		/// <summary>
		/// Per-class style set for this shape.
		/// </summary>
		protected override DslDiagrams::StyleSet ClassStyleSet
		{
			get
			{
				if (classStyleSet == null)
				{
					classStyleSet = CreateClassStyleSet();
				}
				return classStyleSet;
			}
		}
		
		/// <summary>
		/// Per-class ShapeFields for this shape
		/// </summary>
		public override global::System.Collections.Generic.IList<DslDiagrams::ShapeField> ShapeFields
		{
			get
			{
				if (shapeFields == null)
				{
					shapeFields = CreateShapeFields();
				}
				return shapeFields;
			}
		}
		#endregion
		#region Toolbox filters
		private static global::System.ComponentModel.ToolboxItemFilterAttribute[] toolboxFilters = new global::System.ComponentModel.ToolboxItemFilterAttribute[] {
					new global::System.ComponentModel.ToolboxItemFilterAttribute(global::MDC.ProductionSystem.ProductionSystemToolboxHelperBase.ToolboxFilterString, global::System.ComponentModel.ToolboxItemFilterType.Require) };
		
		/// <summary>
		/// Toolbox item filter attributes for this diagram.
		/// </summary>
		public override global::System.Collections.ICollection TargetToolboxItemFilterAttributes
		{
			get
			{
				return toolboxFilters;
			}
		}
		#endregion
		#region Auto-placement
		/// <summary>
		/// Indicate that child shapes should added through view fixup should be placed automatically.
		/// </summary>
		public override bool ShouldAutoPlaceChildShapes
		{
			get
			{
				return true;
			}
		}
		#endregion
		#region Shape mapping
		/// <summary>
		/// Called during view fixup to ask the parent whether a shape should be created for the given child element.
		/// </summary>
		/// <remarks>
		/// Always return true, since we assume there is only one diagram per model file for DSL scenarios.
		/// </remarks>
		protected override bool ShouldAddShapeForElement(DslModeling::ModelElement element)
		{
			return true;
		}
		
		/// <summary>
		/// Called during view fixup to configure the given child element, after it has been created.
		/// </summary>
		/// <remarks>
		/// Custom code for choosing the shapes attached to either end of a connector is called from here.
		/// </remarks>
		protected override void OnChildConfiguring(DslDiagrams::ShapeElement child, bool createdDuringViewFixup)
		{
			DslDiagrams::NodeShape sourceShape;
			DslDiagrams::NodeShape targetShape;
			DslDiagrams::BinaryLinkShape connector = child as DslDiagrams::BinaryLinkShape;
			if(connector == null)
			{
				base.OnChildConfiguring(child, createdDuringViewFixup);
				return;
			}
			this.GetSourceAndTargetForConnector(connector, out sourceShape, out targetShape);
			
			global::System.Diagnostics.Debug.Assert(sourceShape != null && targetShape != null, "Unable to find source and target shapes for connector.");
			connector.Connect(sourceShape, targetShape);
		}
		
		/// <summary>
		/// helper method to find the shapes for either end of a connector, including calling the user's custom code
		/// </summary>
		[global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
		internal void GetSourceAndTargetForConnector(DslDiagrams::BinaryLinkShape connector, out DslDiagrams::NodeShape sourceShape, out DslDiagrams::NodeShape targetShape)
		{
			sourceShape = null;
			targetShape = null;
			
			if (sourceShape == null || targetShape == null)
			{
				DslDiagrams::NodeShape[] endShapes = GetEndShapesForConnector(connector);
				if(sourceShape == null)
				{
					sourceShape = endShapes[0];
				}
				if(targetShape == null)
				{
					targetShape = endShapes[1];
				}
			}
		}
		
		/// <summary>
		/// Helper method to find shapes for either end of a connector by looking for shapes associated with either end of the relationship mapped to the connector.
		/// </summary>
		private DslDiagrams::NodeShape[] GetEndShapesForConnector(DslDiagrams::BinaryLinkShape connector)
		{
			DslModeling::ElementLink link = connector.ModelElement as DslModeling::ElementLink;
			DslDiagrams::NodeShape sourceShape = null, targetShape = null;
			if (link != null)
			{
				global::System.Collections.ObjectModel.ReadOnlyCollection<DslModeling::ModelElement> linkedElements = link.LinkedElements;
				if (linkedElements.Count == 2)
				{
					DslDiagrams::Diagram currentDiagram = this.Diagram;
					DslModeling::LinkedElementCollection<DslDiagrams::PresentationElement> presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[0]);
					foreach (DslDiagrams::PresentationElement presentationElement in presentationElements)
					{
						DslDiagrams::NodeShape shape = presentationElement as DslDiagrams::NodeShape;
						if (shape != null && shape.Diagram == currentDiagram)
						{
							sourceShape = shape;
							break;
						}
					}
					
					presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[1]);
					foreach (DslDiagrams::PresentationElement presentationElement in presentationElements)
					{
						DslDiagrams::NodeShape shape = presentationElement as DslDiagrams::NodeShape;
						if (shape != null && shape.Diagram == currentDiagram)
						{
							targetShape = shape;
							break;
						}
					}
		
				}
			}
			
			return new DslDiagrams::NodeShape[] { sourceShape, targetShape };
		}
		
		/// <summary>
		/// Creates a new shape for the given model element as part of view fixup
		/// </summary>
		[global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Generated code.")]
		[global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Generated code.")]
		protected override DslDiagrams::ShapeElement CreateChildShape(DslModeling::ModelElement element)
		{
			if(element is global::MDC.ProductionSystem.BodyGenerator)
			{
				global::MDC.ProductionSystem.BodyGenShape newShape = new global::MDC.ProductionSystem.BodyGenShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Assembler)
			{
				global::MDC.ProductionSystem.AssemblerShape newShape = new global::MDC.ProductionSystem.AssemblerShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.RepairBay)
			{
				global::MDC.ProductionSystem.RepairShape newShape = new global::MDC.ProductionSystem.RepairShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.QualityControl)
			{
				global::MDC.ProductionSystem.QualityShape newShape = new global::MDC.ProductionSystem.QualityShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.WheelGenerator)
			{
				global::MDC.ProductionSystem.WheelGenShape newShape = new global::MDC.ProductionSystem.WheelGenShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.TrackGenerator)
			{
				global::MDC.ProductionSystem.TrackGenShape newShape = new global::MDC.ProductionSystem.TrackGenShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.WaterGenerator)
			{
				global::MDC.ProductionSystem.WaterGenShape newShape = new global::MDC.ProductionSystem.WaterGenShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.GunGenerator)
			{
				global::MDC.ProductionSystem.GunGenShape newShape = new global::MDC.ProductionSystem.GunGenShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.ProcessingUnit)
			{
				global::MDC.ProductionSystem.ProcessingUnitShape newShape = new global::MDC.ProductionSystem.ProcessingUnitShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Gun)
			{
				global::MDC.ProductionSystem.GunShape newShape = new global::MDC.ProductionSystem.GunShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Wheel)
			{
				global::MDC.ProductionSystem.WheelShape newShape = new global::MDC.ProductionSystem.WheelShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Garage)
			{
				global::MDC.ProductionSystem.GarageShape newShape = new global::MDC.ProductionSystem.GarageShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Body)
			{
				global::MDC.ProductionSystem.BodyShape newShape = new global::MDC.ProductionSystem.BodyShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Track)
			{
				global::MDC.ProductionSystem.TrackShape newShape = new global::MDC.ProductionSystem.TrackShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Water)
			{
				global::MDC.ProductionSystem.WaterShape newShape = new global::MDC.ProductionSystem.WaterShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Operator)
			{
				global::MDC.ProductionSystem.OperatorShape newShape = new global::MDC.ProductionSystem.OperatorShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Machine)
			{
				global::MDC.ProductionSystem.MachineShape newShape = new global::MDC.ProductionSystem.MachineShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.ConveyorBelt)
			{
				global::MDC.ProductionSystem.ConveyorShape newShape = new global::MDC.ProductionSystem.ConveyorShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.Component)
			{
				global::MDC.ProductionSystem.ComponentShape newShape = new global::MDC.ProductionSystem.ComponentShape(this.Partition);
				if(newShape != null) newShape.Size = newShape.DefaultSize; // set default shape size
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.ConveyorBeltsConnectedToConveyorBelt)
			{
				global::MDC.ProductionSystem.ConveyorConveyor newShape = new global::MDC.ProductionSystem.ConveyorConveyor(this.Partition);
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.ComponentIsOnConveyorBelt)
			{
				global::MDC.ProductionSystem.ComponentConveyor newShape = new global::MDC.ProductionSystem.ComponentConveyor(this.Partition);
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.OperatorControlsProcessingUnits)
			{
				global::MDC.ProductionSystem.OperatorProcessingUnit newShape = new global::MDC.ProductionSystem.OperatorProcessingUnit(this.Partition);
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.ConveyorBeltsConnectedToMachines)
			{
				global::MDC.ProductionSystem.ConveyorMachine newShape = new global::MDC.ProductionSystem.ConveyorMachine(this.Partition);
				return newShape;
			}
			if(element is global::MDC.ProductionSystem.MachineIsConnectedToConveyorBelt)
			{
				global::MDC.ProductionSystem.MachineConveyor newShape = new global::MDC.ProductionSystem.MachineConveyor(this.Partition);
				return newShape;
			}
			return base.CreateChildShape(element);
		}
		#endregion
		#region Decorator mapping
		/// <summary>
		/// Initialize shape decorator mappings.  This is done here rather than in individual shapes because decorator maps
		/// are defined per diagram type rather than per shape type.
		/// </summary>
		protected override void InitializeShapeFields(global::System.Collections.Generic.IList<DslDiagrams::ShapeField> shapeFields)
		{
			base.InitializeShapeFields(shapeFields);
			global::MDC.ProductionSystem.AssemblerShape.DecoratorsInitialized += AssemblerShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.RepairShape.DecoratorsInitialized += RepairShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.QualityShape.DecoratorsInitialized += QualityShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.WheelGenShape.DecoratorsInitialized += WheelGenShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.TrackGenShape.DecoratorsInitialized += TrackGenShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.BodyGenShape.DecoratorsInitialized += BodyGenShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.GunGenShape.DecoratorsInitialized += GunGenShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.WaterGenShape.DecoratorsInitialized += WaterGenShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.OperatorShape.DecoratorsInitialized += OperatorShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.WheelShape.DecoratorsInitialized += WheelShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.TrackShape.DecoratorsInitialized += TrackShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.BodyShape.DecoratorsInitialized += BodyShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.GunShape.DecoratorsInitialized += GunShapeDecoratorMap.OnDecoratorsInitialized;
			global::MDC.ProductionSystem.WaterShape.DecoratorsInitialized += WaterShapeDecoratorMap.OnDecoratorsInitialized;
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for AssemblerShape.
		/// </summary>
		internal static partial class AssemblerShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for AssemblerShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.ProcessingUnit.IdleTimeDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "IdleTime").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for RepairShape.
		/// </summary>
		internal static partial class RepairShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for RepairShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.ProcessingUnit.IdleTimeDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "IdleTime").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for QualityShape.
		/// </summary>
		internal static partial class QualityShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for QualityShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.ProcessingUnit.IdleTimeDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "IdleTime").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for WheelGenShape.
		/// </summary>
		internal static partial class WheelGenShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for WheelGenShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Generator.OutputDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "Output").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for TrackGenShape.
		/// </summary>
		internal static partial class TrackGenShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for TrackGenShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Generator.OutputDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "Output").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for BodyGenShape.
		/// </summary>
		internal static partial class BodyGenShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for BodyGenShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Generator.OutputDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "Output").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for GunGenShape.
		/// </summary>
		internal static partial class GunGenShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for GunGenShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Generator.OutputDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "Output").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for WaterGenShape.
		/// </summary>
		internal static partial class WaterGenShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for WaterGenShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Generator.OutputDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "Output").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for OperatorShape.
		/// </summary>
		internal static partial class OperatorShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for OperatorShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Operator.StressDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "StressDecorator").AssociateValueWith(shape.Store, propertyInfo);
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Operator.NameDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "NameDecorator").AssociateValueWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for WheelShape.
		/// </summary>
		internal static partial class WheelShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for WheelShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateValueWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				propertyInfo.FilteringValues.Add("BROKEN");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateVisibilityWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for TrackShape.
		/// </summary>
		internal static partial class TrackShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for TrackShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateValueWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				propertyInfo.FilteringValues.Add("BROKEN");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateVisibilityWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for BodyShape.
		/// </summary>
		internal static partial class BodyShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for BodyShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateValueWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				propertyInfo.FilteringValues.Add("BROKEN");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateVisibilityWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Body.LoadoutDomainPropertyId);
				propertyInfo.FilteringValues.Add("RiotLoadout");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "RiotIcon").AssociateVisibilityWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Body.LoadoutDomainPropertyId);
				propertyInfo.FilteringValues.Add("NoLoadout");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "BodyIcon").AssociateVisibilityWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Body.LoadoutDomainPropertyId);
				propertyInfo.FilteringValues.Add("ArmyLoadout");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "ArmyIcon").AssociateVisibilityWith(shape.Store, propertyInfo);
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateValueWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				propertyInfo.FilteringValues.Add("BROKEN");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateVisibilityWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for GunShape.
		/// </summary>
		internal static partial class GunShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for GunShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateValueWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				propertyInfo.FilteringValues.Add("BROKEN");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateVisibilityWith(shape.Store, propertyInfo);
			}
		}
		
		/// <summary>
		/// Class containing decorator path traversal methods for WaterShape.
		/// </summary>
		internal static partial class WaterShapeDecoratorMap
		{
			/// <summary>
			/// Event handler called when decorator initialization is complete for WaterShape.  Adds decorator mappings for this shape or connector.
			/// </summary>
			public static void OnDecoratorsInitialized(object sender, global::System.EventArgs e)
			{
				DslDiagrams::ShapeElement shape = (DslDiagrams::ShapeElement)sender;
				DslDiagrams::AssociatedPropertyInfo propertyInfo;
				
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateValueWith(shape.Store, propertyInfo);
		
				propertyInfo = new DslDiagrams::AssociatedPropertyInfo(global::MDC.ProductionSystem.Component.isBrokenDomainPropertyId);
				propertyInfo.FilteringValues.Add("BROKEN");
				DslDiagrams::ShapeElement.FindDecorator(shape.Decorators, "isBroken").AssociateVisibilityWith(shape.Store, propertyInfo);
			}
		}
		
		#endregion
		
		#region Connect actions
		private bool changingMouseAction;
		private global::MDC.ProductionSystem.ComponentToConveyorConnectAction componentToConveyorConnectAction;
		private global::MDC.ProductionSystem.ConveyorToConveyorConnectAction conveyorToConveyorConnectAction;
		private global::MDC.ProductionSystem.ConveyorToMachineConnectAction conveyorToMachineConnectAction;
		private global::MDC.ProductionSystem.MachineToConveyorConnectAction machineToConveyorConnectAction;
		private global::MDC.ProductionSystem.OperatorToMachineConnectAction operatorToMachineConnectAction;
		/// <summary>
		/// Virtual method to provide a filter when to select the mouse action
		/// </summary>
		/// <param name="activeView">Currently active view</param>
		/// <param name="filter">filter string used to filter the toolbox items</param>
		protected virtual bool SelectedToolboxItemSupportsFilterString(DslDiagrams::DiagramView activeView, string filter)
		{
			return activeView.SelectedToolboxItemSupportsFilterString(filter);
		}
		/// <summary>
		/// Override to provide the right mouse action when trying
		/// to create links on the diagram
		/// </summary>
		/// <param name="pointArgs"></param>
		public override void OnViewMouseEnter(DslDiagrams::DiagramPointEventArgs pointArgs)
		{
			if (pointArgs  == null) throw new global::System.ArgumentNullException("pointArgs");
		
			DslDiagrams::DiagramView activeView = this.ActiveDiagramView;
			if(activeView != null)
			{
				DslDiagrams::MouseAction action = null;
				if (SelectedToolboxItemSupportsFilterString(activeView, global::MDC.ProductionSystem.ProductionSystemToolboxHelper.ComponentToConveyorFilterString))
				{
					if (this.componentToConveyorConnectAction == null)
					{
						this.componentToConveyorConnectAction = new global::MDC.ProductionSystem.ComponentToConveyorConnectAction(this);
						this.componentToConveyorConnectAction.MouseActionDeactivated += new DslDiagrams::MouseAction.MouseActionDeactivatedEventHandler(OnConnectActionDeactivated);
					}
					action = this.componentToConveyorConnectAction;
				} 
				else if (SelectedToolboxItemSupportsFilterString(activeView, global::MDC.ProductionSystem.ProductionSystemToolboxHelper.ConveyorToConveyorFilterString))
				{
					if (this.conveyorToConveyorConnectAction == null)
					{
						this.conveyorToConveyorConnectAction = new global::MDC.ProductionSystem.ConveyorToConveyorConnectAction(this);
						this.conveyorToConveyorConnectAction.MouseActionDeactivated += new DslDiagrams::MouseAction.MouseActionDeactivatedEventHandler(OnConnectActionDeactivated);
					}
					action = this.conveyorToConveyorConnectAction;
				} 
				else if (SelectedToolboxItemSupportsFilterString(activeView, global::MDC.ProductionSystem.ProductionSystemToolboxHelper.ConveyorToMachineFilterString))
				{
					if (this.conveyorToMachineConnectAction == null)
					{
						this.conveyorToMachineConnectAction = new global::MDC.ProductionSystem.ConveyorToMachineConnectAction(this);
						this.conveyorToMachineConnectAction.MouseActionDeactivated += new DslDiagrams::MouseAction.MouseActionDeactivatedEventHandler(OnConnectActionDeactivated);
					}
					action = this.conveyorToMachineConnectAction;
				} 
				else if (SelectedToolboxItemSupportsFilterString(activeView, global::MDC.ProductionSystem.ProductionSystemToolboxHelper.MachineToConveyorFilterString))
				{
					if (this.machineToConveyorConnectAction == null)
					{
						this.machineToConveyorConnectAction = new global::MDC.ProductionSystem.MachineToConveyorConnectAction(this);
						this.machineToConveyorConnectAction.MouseActionDeactivated += new DslDiagrams::MouseAction.MouseActionDeactivatedEventHandler(OnConnectActionDeactivated);
					}
					action = this.machineToConveyorConnectAction;
				} 
				else if (SelectedToolboxItemSupportsFilterString(activeView, global::MDC.ProductionSystem.ProductionSystemToolboxHelper.OperatorToMachineFilterString))
				{
					if (this.operatorToMachineConnectAction == null)
					{
						this.operatorToMachineConnectAction = new global::MDC.ProductionSystem.OperatorToMachineConnectAction(this);
						this.operatorToMachineConnectAction.MouseActionDeactivated += new DslDiagrams::MouseAction.MouseActionDeactivatedEventHandler(OnConnectActionDeactivated);
					}
					action = this.operatorToMachineConnectAction;
				} 
				else
				{
					action = null;
				}
				
				if (pointArgs.DiagramClientView.ActiveMouseAction != action)
				{
					try
					{
						this.changingMouseAction = true;
						pointArgs.DiagramClientView.ActiveMouseAction = action;
					}
					finally
					{
						this.changingMouseAction = false;
					}
				}
			}
		}
		
		/// <summary>
		/// Snap toolbox selection back to regular pointer after using a custom connect action.
		/// </summary>
		private void OnConnectActionDeactivated(object sender, DslDiagrams::DiagramEventArgs e)
		{
			OnMouseActionDeactivated();
		}
		
		/// <summary>
		/// Overridable method to manage the mouse deactivation. The default implementation snap stoolbox selection back to regular pointer 
		/// after using a custom connect action.
		/// </summary>
		protected virtual void OnMouseActionDeactivated()
		{
			DslDiagrams::DiagramView activeView = this.ActiveDiagramView;
		
			if (activeView != null && activeView.Toolbox != null)
			{
				// If we're not changing mouse action due to changing toolbox selection change,
				// reset toolbox selection.
				if (!this.changingMouseAction)
				{
					activeView.Toolbox.SelectedToolboxItemUsed();
				}
			}
		}
		#endregion
		
		/// <summary>
		/// Dispose of connect actions.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			try
			{
				if(disposing)
				{
					if(this.componentToConveyorConnectAction != null)
					{
						this.componentToConveyorConnectAction.Dispose();
						this.componentToConveyorConnectAction = null;
					}
					if(this.conveyorToConveyorConnectAction != null)
					{
						this.conveyorToConveyorConnectAction.Dispose();
						this.conveyorToConveyorConnectAction = null;
					}
					if(this.conveyorToMachineConnectAction != null)
					{
						this.conveyorToMachineConnectAction.Dispose();
						this.conveyorToMachineConnectAction = null;
					}
					if(this.machineToConveyorConnectAction != null)
					{
						this.machineToConveyorConnectAction.Dispose();
						this.machineToConveyorConnectAction = null;
					}
					if(this.operatorToMachineConnectAction != null)
					{
						this.operatorToMachineConnectAction.Dispose();
						this.operatorToMachineConnectAction = null;
					}
				}
			}
			finally
			{
				base.Dispose(disposing);
			}
		}
		#region Constructors, domain class Id
	
		/// <summary>
		/// ProductionSystemDiagram domain class Id.
		/// </summary>
		public static readonly new global::System.Guid DomainClassId = new global::System.Guid(0x28dbf134, 0x1097, 0x48f2, 0xa0, 0x3c, 0xd2, 0x48, 0x7c, 0x47, 0xe4, 0x10);
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="store">Store where new element is to be created.</param>
		/// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
		public ProductionSystemDiagram(DslModeling::Store store, params DslModeling::PropertyAssignment[] propertyAssignments)
			: this(store != null ? store.DefaultPartitionForClass(DomainClassId) : null, propertyAssignments)
		{
		}
		
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="partition">Partition where new element is to be created.</param>
		/// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
		public ProductionSystemDiagram(DslModeling::Partition partition, params DslModeling::PropertyAssignment[] propertyAssignments)
			: base(partition, propertyAssignments)
		{
		}
		#endregion
	}
}
namespace MDC.ProductionSystem
{
	
		/// <summary>
		/// Double derived implementation for the rule that initiates view fixup when an element that has an associated shape is added to the model.
		/// This now enables the DSL author to everride the SkipFixUp() method 
		/// </summary>
		internal partial class FixUpDiagramBase : DslModeling::AddRule
		{
			protected virtual bool SkipFixup(DslModeling::ModelElement childElement)
			{
				return childElement.IsDeleted;
			}
		}
	
		/// <summary>
		/// Rule that initiates view fixup when an element that has an associated shape is added to the model. 
		/// </summary>
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.TrackGenerator), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.WheelGenerator), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.GunGenerator), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.WaterGenerator), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Assembler), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.BodyGenerator), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.QualityControl), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.RepairBay), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.ProcessingUnit), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Body), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Track), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Water), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Gun), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Wheel), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Garage), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.OperatorControlsProcessingUnits), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.ComponentIsOnConveyorBelt), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.MachineIsConnectedToConveyorBelt), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.ConveyorBeltsConnectedToMachines), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.ConveyorBeltsConnectedToConveyorBelt), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Machine), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Operator), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Component), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.ConveyorBelt), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddShapeParentExistRulePriority, InitiallyDisabled=true)]
		internal sealed partial class FixUpDiagram : FixUpDiagramBase
		{
			[global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
			public override void ElementAdded(DslModeling::ElementAddedEventArgs e)
			{
				if(e == null) throw new global::System.ArgumentNullException("e");
			
				DslModeling::ModelElement childElement = e.ModelElement;
				if (this.SkipFixup(childElement))
					return;
				DslModeling::ModelElement parentElement;
				if(childElement is DslModeling::ElementLink)
				{
					parentElement = GetParentForRelationship((DslModeling::ElementLink)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.TrackGenerator)
				{
					parentElement = GetParentForTrackGenerator((global::MDC.ProductionSystem.TrackGenerator)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.WheelGenerator)
				{
					parentElement = GetParentForWheelGenerator((global::MDC.ProductionSystem.WheelGenerator)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.GunGenerator)
				{
					parentElement = GetParentForGunGenerator((global::MDC.ProductionSystem.GunGenerator)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.WaterGenerator)
				{
					parentElement = GetParentForWaterGenerator((global::MDC.ProductionSystem.WaterGenerator)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Assembler)
				{
					parentElement = GetParentForAssembler((global::MDC.ProductionSystem.Assembler)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.BodyGenerator)
				{
					parentElement = GetParentForBodyGenerator((global::MDC.ProductionSystem.BodyGenerator)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.QualityControl)
				{
					parentElement = GetParentForQualityControl((global::MDC.ProductionSystem.QualityControl)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.RepairBay)
				{
					parentElement = GetParentForRepairBay((global::MDC.ProductionSystem.RepairBay)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.ProcessingUnit)
				{
					parentElement = GetParentForProcessingUnit((global::MDC.ProductionSystem.ProcessingUnit)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Body)
				{
					parentElement = GetParentForBody((global::MDC.ProductionSystem.Body)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Track)
				{
					parentElement = GetParentForTrack((global::MDC.ProductionSystem.Track)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Water)
				{
					parentElement = GetParentForWater((global::MDC.ProductionSystem.Water)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Gun)
				{
					parentElement = GetParentForGun((global::MDC.ProductionSystem.Gun)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Wheel)
				{
					parentElement = GetParentForWheel((global::MDC.ProductionSystem.Wheel)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Garage)
				{
					parentElement = GetParentForGarage((global::MDC.ProductionSystem.Garage)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Machine)
				{
					parentElement = GetParentForMachine((global::MDC.ProductionSystem.Machine)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Operator)
				{
					parentElement = GetParentForOperator((global::MDC.ProductionSystem.Operator)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.Component)
				{
					parentElement = GetParentForComponent((global::MDC.ProductionSystem.Component)childElement);
				} else
				if(childElement is global::MDC.ProductionSystem.ConveyorBelt)
				{
					parentElement = GetParentForConveyorBelt((global::MDC.ProductionSystem.ConveyorBelt)childElement);
				} else
				{
					parentElement = null;
				}
				
				if(parentElement != null)
				{
					DslDiagrams::Diagram.FixUpDiagram(parentElement, childElement);
				}
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForConveyorBelt( global::MDC.ProductionSystem.ConveyorBelt root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Models;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForAssembler( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForRepairBay( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForQualityControl( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForWheelGenerator( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForTrackGenerator( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForBodyGenerator( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForGunGenerator( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForWaterGenerator( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForOperator( global::MDC.ProductionSystem.Operator root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Models;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForMachine( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForProcessingUnit( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForComponent( global::MDC.ProductionSystem.Component root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Models;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForWheel( global::MDC.ProductionSystem.Component root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Models;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForTrack( global::MDC.ProductionSystem.Component root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Models;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForBody( global::MDC.ProductionSystem.Component root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Models;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForGun( global::MDC.ProductionSystem.Component root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Models;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForWater( global::MDC.ProductionSystem.Component root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Models;
				if ( result == null ) return null;
				return result;
			}
			public static global::MDC.ProductionSystem.PS_Model GetParentForGarage( global::MDC.ProductionSystem.Machine root )
			{
				// Segments 0 and 1
				global::MDC.ProductionSystem.PS_Model result = root.PS_Model;
				if ( result == null ) return null;
				return result;
			}
			private static DslModeling::ModelElement GetParentForRelationship(DslModeling::ElementLink elementLink)
			{
				global::System.Collections.ObjectModel.ReadOnlyCollection<DslModeling::ModelElement> linkedElements = elementLink.LinkedElements;
	
				if (linkedElements.Count == 2)
				{
					DslDiagrams::ShapeElement sourceShape = linkedElements[0] as DslDiagrams::ShapeElement;
					DslDiagrams::ShapeElement targetShape = linkedElements[1] as DslDiagrams::ShapeElement;
	
					if(sourceShape == null)
					{
						DslModeling::LinkedElementCollection<DslDiagrams::PresentationElement> presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[0]);
						foreach (DslDiagrams::PresentationElement presentationElement in presentationElements)
						{
							DslDiagrams::ShapeElement shape = presentationElement as DslDiagrams::ShapeElement;
							if (shape != null)
							{
								sourceShape = shape;
								break;
							}
						}
					}
					
					if(targetShape == null)
					{
						DslModeling::LinkedElementCollection<DslDiagrams::PresentationElement> presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[1]);
						foreach (DslDiagrams::PresentationElement presentationElement in presentationElements)
						{
							DslDiagrams::ShapeElement shape = presentationElement as DslDiagrams::ShapeElement;
							if (shape != null)
							{
								targetShape = shape;
								break;
							}
						}
					}
					
					if(sourceShape == null || targetShape == null)
					{
						global::System.Diagnostics.Debug.Fail("Unable to find source and/or target shape for view fixup.");
						return null;
					}
	
					DslDiagrams::ShapeElement sourceParent = sourceShape.ParentShape;
					DslDiagrams::ShapeElement targetParent = targetShape.ParentShape;
	
					while (sourceParent != targetParent && sourceParent != null)
					{
						DslDiagrams::ShapeElement curParent = targetParent;
						while (sourceParent != curParent && curParent != null)
						{
							curParent = curParent.ParentShape;
						}
	
						if(sourceParent == curParent)
						{
							break;
						}
						else
						{
							sourceParent = sourceParent.ParentShape;
						}
					}
	
					while (sourceParent != null)
					{
						// ensure that the parent can parent connectors (i.e., a diagram or a swimlane).
						if(sourceParent is DslDiagrams::Diagram || sourceParent is DslDiagrams::SwimlaneShape)
						{
							break;
						}
						else
						{
							sourceParent = sourceParent.ParentShape;
						}
					}
	
					global::System.Diagnostics.Debug.Assert(sourceParent != null && sourceParent.ModelElement != null, "Unable to find common parent for view fixup.");
					return sourceParent.ModelElement;
				}
	
				return null;
			}
		}
		
	
		/// <summary>
		/// A rule which fires when data mapped to outer text decorators has changed,
		/// so we can update the decorator host's bounds.
		/// </summary>
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.Operator), InitiallyDisabled=true)]
		internal sealed class DecoratorPropertyChanged : DslModeling::ChangeRule
		{
			[global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Generated code.")]
			public override void ElementPropertyChanged(DslModeling::ElementPropertyChangedEventArgs e)
			{
				if(e == null) throw new global::System.ArgumentNullException("e");
				
				if (e.DomainProperty.Id == global::MDC.ProductionSystem.Operator.NameDomainPropertyId)
				{
					DslDiagrams::Decorator decorator = global::MDC.ProductionSystem.OperatorShape.FindOperatorShapeDecorator("NameDecorator");
					if(decorator != null)
					{
						decorator.UpdateDecoratorHostShapes(e.ModelElement, global::MDC.ProductionSystem.Operator.DomainClassId);
					}
				}
			}
		}
	
		/// <summary>
		/// Reroute a connector when the role players of its underlying relationship change
		/// </summary>
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.ConveyorBeltsConnectedToConveyorBelt), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.MachineIsConnectedToConveyorBelt), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.ConveyorBeltsConnectedToMachines), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.ComponentIsOnConveyorBelt), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		[DslModeling::RuleOn(typeof(global::MDC.ProductionSystem.OperatorControlsProcessingUnits), FireTime = DslModeling::TimeToFire.TopLevelCommit, Priority = DslDiagrams::DiagramFixupConstants.AddConnectionRulePriority, InitiallyDisabled=true)]
		internal sealed class ConnectorRolePlayerChanged : DslModeling::RolePlayerChangeRule
		{
			/// <summary>
			/// Reroute a connector when the role players of its underlying relationship change
			/// </summary>
			public override void RolePlayerChanged(DslModeling::RolePlayerChangedEventArgs e)
			{
				if (e == null) throw new global::System.ArgumentNullException("e");
	
				global::System.Collections.ObjectModel.ReadOnlyCollection<DslDiagrams::PresentationViewsSubject> connectorLinks = DslDiagrams::PresentationViewsSubject.GetLinksToPresentation(e.ElementLink);
				foreach (DslDiagrams::PresentationViewsSubject connectorLink in connectorLinks)
				{
					// Fix up any binary link shapes attached to the element link.
					DslDiagrams::BinaryLinkShape linkShape = connectorLink.Presentation as DslDiagrams::BinaryLinkShape;
					if (linkShape != null)
					{
						global::MDC.ProductionSystem.ProductionSystemDiagram diagram = linkShape.Diagram as global::MDC.ProductionSystem.ProductionSystemDiagram;
						if (diagram != null)
						{
							if (e.NewRolePlayer != null)
							{
								DslDiagrams::NodeShape fromShape;
								DslDiagrams::NodeShape toShape;
								diagram.GetSourceAndTargetForConnector(linkShape, out fromShape, out toShape);
								if (fromShape != null && toShape != null)
								{
									if (!object.Equals(fromShape, linkShape.FromShape))
									{
										linkShape.FromShape = fromShape;
									}
									if (!object.Equals(linkShape.ToShape, toShape))
									{
										linkShape.ToShape = toShape;
									}
								}
								else
								{
									// delete the connector if we cannot find an appropriate target shape.
									linkShape.Delete();
								}
							}
							else
							{
								// delete the connector if the new role player is null.
								linkShape.Delete();
							}
						}
					}
				}
			}
		}
	}
