Example #1
0
        protected override void InternalRender(ImageElement element, MusicPlayer.AudioPlayer audioPlayer, DrawGraphicsEventArgs renderArgs)
        {
            if (element.Initializing)
            {
                return;
            }
            if (!ImageElements.ContainsKey(element))
            {
                InitImage(element, renderArgs.Graphics);
                return;
            }
            var gfx = renderArgs.Graphics;

            gfx.DrawImage(ImageElements[element], element.AbsoluteRenderArea.ToOverlayRectangle(), element.Opacity);
        }
        protected override void InternalRender(StackPanelElement element, MusicPlayer.AudioPlayer audioPlayer, DrawGraphicsEventArgs renderArgs)
        {
            Point childLocation    = new Point(0, 0);
            Point childElementSize = new Point(0, 0);

            for (int index = 0; index < element.ChildElements.Count; index++)
            {
                switch (element.ItemsOrientation)
                {
                case StackPanelItemRenderRotation.UpToBottom:
                    childLocation = new Point(0, childLocation.Y + childElementSize.Y);
                    break;

                case StackPanelItemRenderRotation.LeftToRight:
                    childLocation = new Point(childLocation.X + childElementSize.X, 0);
                    break;

                case StackPanelItemRenderRotation.RightToLeft:
                    childLocation = new Point(element.Size.X - childLocation.X - childElementSize.X, 0);
                    break;

                case StackPanelItemRenderRotation.BottomToUp:
                    childLocation = new Point(0, element.Size.X - childLocation.X - childElementSize.X);
                    break;
                }

                var child = element.ChildElements[index];
                child.Location   = childLocation.ToFloatPoint();
                childElementSize = child.Size.ToOverlayPoint();
            }

            if (element.AutoSize && element.ChildElements.Any())
            {
                var lastElement = (element.ItemsOrientation == StackPanelItemRenderRotation.UpToBottom || element.ItemsOrientation == StackPanelItemRenderRotation.LeftToRight) ?
                                  element.ChildElements.Last() : element.ChildElements.First();

                var size       = new Point(lastElement.Location.X + lastElement.Size.X, lastElement.Location.Y + lastElement.Size.Y);
                var parentSize = element.ParentElement.Size;
                element.Size = new System.Drawing.Point((int)(parentSize.X < size.X ? parentSize.X : size.X), (int)(parentSize.Y < size.Y ? parentSize.Y : size.Y));
            }
        }