Crainiate Community

Support and discussion for users of Crainiate component software products
Welcome to Crainiate Community Sign in | Join | Help
in Search

Collapse complex shape

Last post 09-22-2007 11:43 AM by James Westgate. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-21-2007 7:27 PM

    • jchau
    • Top 10 Contributor
    • Joined on 05-23-2007
    • Posts 22

    Collapse complex shape

    Is it possible to create a complex shape that can be collapsed/expanded like a Table?

    • 64.149.247.66
  • 09-22-2007 11:43 AM In reply to

    Re: Collapse complex shape

    Yes it is. You need to inherit from ComplexShape and implement the IExpandable interface.

    The GraphicsPath (local to the shape) returned from the Expander method determines the location of the expander and this will automatically expand the shape if DrawExpand is set to true.

    The following code will render an expander (_expandPath is the variable for the Expander property) :

    private void RenderExpand(Graphics graphics, Render render)
    {
    	//Obtain a reference to IExpandable interface
    	IExpandable expand = (IExpandable) this;
    			
    	if (!expand.DrawExpand) return;
    
    	//Draw the expander
    	Pen pen = new Pen(Color.FromArgb(128,Color.Gray),1);
    	SolidBrush brush = new SolidBrush(Color.White);
    			
    	//Set up the expand path
    	_expandPath = new GraphicsPath();
    	_expandPath.AddEllipse(Width-20,5,14,14);
    
    	SmoothingMode smoothing = graphics.SmoothingMode;
    	graphics.SmoothingMode = SmoothingMode.HighQuality;
    	graphics.FillPath(brush,_expandPath); //Fill Circle
    	graphics.DrawPath(pen,_expandPath); //Outline
    		
    	pen.Color = Color.FromArgb(128,Color.Navy);
    	pen.Width = 2;
    	PointF[] points;
    	if (expand.Expanded)
    	{
    		points = new PointF[] {new PointF(Width-16,11),new PointF(Width-13,8),new PointF(Width-10,11)};
    	}
    	else
    	{
    		points = new PointF[] {new PointF(Width-16,8),new PointF(Width-13,11),new PointF(Width-10,8)};
    	}
    	graphics.DrawLines(pen,points);
    	points[0].Y += 5;
    			points[1].Y += 5;
    			points[2].Y += 5;
    	graphics.DrawLines(pen,points);
    	graphics.SmoothingMode = smoothing;
    }

     

    • 81.156.199.203
Page 1 of 1 (2 items)