Assisted Solutions - Active Org-Chart - Demos
Active Org-Chart 1.0 Demos
© 2006-2010 Info Mason. All rights reserved

Return To Menu Making my own entity Next Demo

ABOUT THIS DEMO:
One of Active Org-Charts greatest strength lies in the ability to create custom styles by simply implementing its interfaces or inheriting its members. In this demo, a custom Entity has been created inheriting from DefaultDrawnEntity, and the Render method has been overridden to produce an elliptical Entity.


Demo Area

   

    internal class MyCustomDrawnEntity : DefaultDrawnEntity
    {
        public MyCustomDrawnEntity(string Text, DrawnOrgChart chart) : base(Text, chart) { }

        protected override void Render(Graphics g, Rectangle rect)
        {
            Rectangle rectNoLocation = new Rectangle(0, 0, rect.Width, rect.Height);

            //  Offset so fill will begin at the box's correct position.  Rectangle is set to
            //  0/0 X/Y. This is so that any brushes will have the correct point of origin
            Matrix LastTransform = g.Transform;
            g.TranslateTransform(rect.X, rect.Y, MatrixOrder.Append);
            g.FillEllipse(FillBrush, rectNoLocation);
            g.DrawEllipse(BorderPen, rectNoLocation);
            g.Transform = LastTransform;

            StringFormat f = new StringFormat();
            f.Alignment = StringAlignment.Center;
            f.LineAlignment = StringAlignment.Center;

            g.DrawString("Title Here", TitleFont, TitleBrush, rect, f);
        }

        public override IEntity Clone()
        {
            IEntity newEntity = new MyCustomDrawnEntity(Title, Chart);
            CopySettings(newEntity);
            return newEntity;
        }
    }