예제 #1
0
		public Layers()
		{
			Layer layer = new Layer(true);
			layer.Name = "Default";
			Add(layer);
			CurrentLayer = layer;
		}
예제 #2
0
		public Layer(Layer prototype)
		{
			mElements = new LayerElements(typeof(Element),"Element");
			mElements.SetModifiable(false);

			mOpacity = prototype.Opacity;
			mVisible = prototype.Visible;
			mName = prototype.Name;
			mDrawShadows = prototype.DrawShadows;
			mShadowOffset = prototype.ShadowOffset;
			mShadowColor = prototype.ShadowColor;
			mSoftShadows = prototype.SoftShadows;
		}
예제 #3
0
		//Removes an Layer from the list
		public virtual void Remove(Layer value )  
		{
			if (value.Default) throw new LayerException("The default layer cannot be removed.");
			Collapse(value,this["default"]);
		}
예제 #4
0
		//Inserts an elelemnt into the list
		public virtual void Insert(int index, Layer value)  
		{
			List.Insert(index, value);
		}
예제 #5
0
		//Adds an Layer to the list 
		public virtual int Add(Layer value)  
		{
			return List.Add(value);
		}
예제 #6
0
		//Use the OnDeserialization callback so that we have direct access to the objects
		public virtual void OnDeserialization(object sender)
		{
			// All objects in the stream have been deserialized.
			// We can now populate the inner arraylist

			Object[] values = (Object[]) mSavedInfo.GetValue("Values",typeof(Object));

			SuspendEvents = true;

			for (int i=0; i<values.Length; i++)
			{
				Add((Layer) values[i]);
			}
			
			CurrentLayer = (Layer) mSavedInfo.GetValue("CurrentLayer",typeof(Layer));

			mSavedInfo = null;
			SuspendEvents = false;
		}
예제 #7
0
		public virtual void MoveElement(Element element, Layer source, Layer target)
		{
            target.Elements.SetModifiable(true);
            source.Elements.SetModifiable(true);

			target.Elements.Add(element.Key,element);
			source.Elements.Remove(element.Key);
            element.SetLayer(target);

            target.Elements.SetModifiable(false);
            source.Elements.SetModifiable(false);
		}
예제 #8
0
		//Loop through layers and elements and render
		public virtual void RenderDiagramElements(Graphics graphics)
		{
			bool isup = false;
			bool isdown = false;
			RectangleF region = new RectangleF(0,0,DiagramSize.Width,DiagramSize.Height);
			
			foreach (Tab tab in Tabs)
			{
				if (tab.Visible) 
				{
					//Determine if an up or down arrow should be drawn
					if (isup)
					{
						isdown = true; //set down
						isup = false; //reset up
						region.Height = tab.Rectangle.Top - region.Top;
					}
					//Reset down
					if (isdown) isdown = false;

					//Set up
					if (Tabs.CurrentTab == tab)
					{
						isup = true;
						region.Y = tab.Rectangle.Bottom+1;
					}

					RenderTab(graphics,tab);
				}
				
				if (tab.ButtonStyle != ButtonStyle.None && DrawScroll)
				{
					RenderButton(graphics, tab.ButtonStyle, tab.ButtonRectangle, tab.ButtonPressed, tab.ButtonEnabled);
				}
			}

			///Draw final button
			if (ScrollTab.Visible && DrawScroll)
			{
				RenderButton(graphics,ButtonStyle.Down,ScrollTab.ButtonRectangle,ScrollTab.ButtonPressed,ScrollTab.ButtonEnabled);
			}

			//Set up the region to confine the elements drawn
			graphics.Clip = new Region(region);

			foreach (Layer layer in mLayers)
			{
				if (layer.Visible) 
				{
					mWorldOpacity = layer.Opacity;
					mCurrentLayer = layer;
					
					//Render shadows
					if (layer.DrawShadows)
					{
						foreach (Element element in mElementRenderList)
						{
							if (element.Layer == layer && element.DrawShadow && element.Visible)
							{
								graphics.TranslateTransform(element.Rectangle.X+layer.ShadowOffset.X ,element.Rectangle.Y+layer.ShadowOffset.Y);
								graphics.SmoothingMode = element.SmoothingMode;
								element.RenderShadow(graphics,this);
								graphics.TranslateTransform(-element.Rectangle.X-layer.ShadowOffset.X,-element.Rectangle.Y-layer.ShadowOffset.Y);
							}
						}
					}

					//Draw each element by checking if it is renderable and calling the render method
					foreach (Element element in mElementRenderList)
					{
						if (element.Layer == layer && element.Visible)
						{
							//Draw shapes
							GraphicsState graphicsState = graphics.Save();

							graphics.TranslateTransform(element.Rectangle.X,element.Rectangle.Y);
							graphics.SmoothingMode = element.SmoothingMode;
							element.Render(graphics,this);
							
							graphics.Restore(graphicsState);
						}
					}
				}
			}
			
			//Reset current layer
			mCurrentLayer = null;
			graphics.ResetClip();
		}
예제 #9
0
		//Returns the index of an Layer
		public virtual int IndexOf(Layer value)  
		{
			return List.IndexOf(value);
		}
예제 #10
0
		protected virtual void RenderDiagramElementsLayer(Graphics graphics, RenderList renderlist, Layer layer)
		{
			foreach (Element element in renderlist)
			{
				if (element.Layer == layer && element.Visible)
				{
					//Draw shapes
					graphics.TranslateTransform(element.Rectangle.X,element.Rectangle.Y);
					RenderElement(graphics,element);

					//Render any elements in the container
					if (element is IContainer)
					{
						IContainer container = (IContainer) element;

						Region region = new Region(element.GetPathInternal());
						Region current = graphics.Clip;
						graphics.SetClip(region,CombineMode.Intersect);

						RenderDiagramElementsLayer(graphics,container.RenderList,layer);			

						//reset clip
						graphics.Clip = current;
					}

					graphics.TranslateTransform(-element.Rectangle.X,-element.Rectangle.Y);
				}
			}
		}
예제 #11
0
		//Loop through layers and elements and render
		public virtual void RenderDiagramElements(Graphics graphics)
		{
			foreach (Layer layer in Layers)
			{
				if (layer.Visible) 
				{
					mWorldOpacity = layer.Opacity;
					mCurrentLayer = layer;
					
					//Draw each element by checking if it is renderable and calling the render method
					RenderDiagramElementsLayer(graphics,mElementRenderList,layer);
				}
			}
			
			//Reset current layer
			mCurrentLayer = null;
		}
예제 #12
0
		//Loop through layers and elements and render
		public virtual void RenderDiagramElements(Graphics graphics)
		{
			OnPreRender(graphics);

			//Set graphics
			graphics.InterpolationMode = InterpolationMode;
			graphics.CompositingMode = CompositingMode;
			graphics.CompositingQuality = CompositingQuality;
			graphics.SmoothingMode = SmoothingMode;
			graphics.PixelOffsetMode = PixelOffsetMode;

			bool drawBackgroundTemp = false;

			foreach (Layer layer in mLayers)
			{
				if (layer.Visible) 
				{
					mWorldOpacity = layer.Opacity;
					mCurrentLayer = layer;

					//Draw each element by checking if it is renderable and calling the render method
					if (DrawShadows && layer.DrawShadows)
					{
						foreach (Element element in mElementRenderList)
						{
							if (element.Layer == layer && element.Visible)
							{
								if (SelectForPrint(element))
								{
									//Draw shapes
									GraphicsState graphicsState = graphics.Save();

									graphics.TranslateTransform(element.Rectangle.X,element.Rectangle.Y);
									element.RenderShadow(graphics,this);
									graphics.Restore(graphicsState);
								}
							}
						}
					}
					
					//Draw each element by checking if it is renderable and calling the render method
					foreach (Element element in mElementRenderList)
					{
						if (element.Layer == layer && element.Visible)
						{
							if (SelectForPrint(element))
							{
								//Draw shapes
								GraphicsState graphicsState = graphics.Save();
								SolidElement solid = null;

								if (element is SolidElement)
								{
									solid = (SolidElement) element;	
									drawBackgroundTemp = solid.DrawBackground;
									solid.mDrawBackground = DrawBackground;								
								}

								graphics.TranslateTransform(element.Rectangle.X,element.Rectangle.Y);
								element.Render(graphics,this);
								graphics.Restore(graphicsState);

								if (element is SolidElement) solid.mDrawBackground = drawBackgroundTemp;
							}
						}
					}
				}
			}
			
			//Reset current layer
			mCurrentLayer = null;

			OnPostRender(graphics);
		}
예제 #13
0
		//Loop through layers and elements and render
		public virtual void RenderDiagramElements(Graphics graphics)
		{
			foreach (Layer layer in mLayers)
			{
				if (layer.Visible) 
				{
					mWorldOpacity = layer.Opacity;
					mCurrentLayer = layer;

					//Render shadows
					if (layer.DrawShadows)
					{
						foreach (Element element in mElementRenderList)
						{
							if (element.Layer == layer && element.DrawShadow && element.Visible)
							{
								GraphicsState graphicsState = graphics.Save();
								Matrix matrix = graphics.Transform;
								matrix.Translate(element.Rectangle.X+layer.ShadowOffset.X ,element.Rectangle.Y+layer.ShadowOffset.Y);

								//Shadow is not rotated
								graphics.Transform = matrix;
								graphics.SmoothingMode = element.SmoothingMode;
								element.RenderShadow(graphics,this);
								graphics.Restore(graphicsState);
							}
						}
					}

					//Draw each element by checking if it is renderable and calling the render method
					foreach (Element element in mElementRenderList)
					{
						if (element.Layer == layer && element.Visible)
						{
							//Draw shapes
							GraphicsState graphicsState = graphics.Save();
							Matrix matrix = graphics.Transform;

							matrix.Translate(element.Rectangle.X,element.Rectangle.Y);
							
							//Set up rotation and other transforms
							if (element is ITransformable)
							{
								ITransformable rotatable = (ITransformable) element;
								PointF center = new PointF(element.Rectangle.Width / 2, element.Rectangle.Height /2);
								matrix.RotateAt(rotatable.Rotation, center);
							}

							//Apply transform, mode, and render element
							graphics.Transform = matrix;
							graphics.SmoothingMode = element.SmoothingMode;
							element.Render(graphics,this);

							graphics.Restore(graphicsState);
						}
					}

					//Render selections
					if (DrawSelections)
					{
						foreach (Element element in mElementRenderList)
						{
							if (element is ISelectable && element.Visible)
							{
								ISelectable selectable = (ISelectable) element;
								
								if (element.Layer == layer && selectable.Selected && selectable.DrawSelected)
								{
									PointF transform;

									//Calculate the transform
									if (element is ITransformable)
									{
										ITransformable transformable = (ITransformable) element;
										transform = new PointF(transformable.TransformRectangle.X, transformable.TransformRectangle.Y);
									}
									else
									{
										transform = new PointF(element.Rectangle.X,element.Rectangle.Y);
									}
									
									//Apply and render
									graphics.TranslateTransform(transform.X, transform.Y);
									graphics.SmoothingMode = element.SmoothingMode;
									element.RenderSelection(graphics,this,this);
									graphics.TranslateTransform(-transform.X, -transform.Y);
								}
							}
						}
					}
				}
			}
			
			//Reset current layer
			mCurrentLayer = null;
		}
예제 #14
0
		//Sets the current layer the element is in
		protected internal void SetLayer(Layer layer)
		{
			mCurrentLayer = layer;
		}
예제 #15
0
		//Returns true if list contains Layer
		public virtual bool Contains(Layer value)  
		{
			return List.Contains(value);
		}
예제 #16
0
		//Methods
		//Moves all shape references to the target layer and removes the source layer
		public virtual void Collapse(Layer source, Layer target)
		{
			if (source.Default) throw new LayerException("Default layer cannot be collapsed.");
			foreach (Element element in source.Elements)
			{
				target.Elements.Add(element.Key,element);
			}
			List.Remove(source);
		}
예제 #17
0
 //Constructor
 public LayerRenderEventArgs(Graphics graphics, Rectangle renderRectangle, Layer layer) : base(graphics, renderRectangle)
 {
     _layer = layer;
 }