示例#1
0
            internal ComponentAndContentWindow(Component componentReference)
            {
                this.componentReference = componentReference;

                this.componentLocationSet = false;
                this.contentLocationSet   = false;
                this.componentSizeSet     = false;
                this.contentSizeSet       = false;

                this.component = new WindowStruct();
                this.content   = new WindowStruct();
            }
示例#2
0
        public Int32 GetChildComponentY(WindowStruct parentContentWindow, Int32 childComponentWindowHeight)
        {
            Int32 parentYOffset = parentContentWindow.y +
                                  ((parentAlign == AlignY.Top) ? -offset : offset);

            switch (parentAlign)
            {
            case AlignY.Bottom: switch (childAlign)
                {
                case AlignY.Bottom: return(parentYOffset);

                case AlignY.Middle: return(parentYOffset - childComponentWindowHeight / 2);

                case AlignY.Top: return(parentYOffset - childComponentWindowHeight);
                }
                throw new InvalidOperationException();

            case AlignY.Middle: switch (childAlign)
                {
                case AlignY.Bottom: return(parentYOffset + parentContentWindow.height / 2);

                case AlignY.Middle: return(parentYOffset + (parentContentWindow.height - childComponentWindowHeight) / 2);

                case AlignY.Top: return(parentYOffset + parentContentWindow.height / 2 - childComponentWindowHeight);
                }
                throw new InvalidOperationException();

            case AlignY.Top: switch (childAlign)
                {
                case AlignY.Bottom: return(parentYOffset + parentContentWindow.height);

                case AlignY.Middle: return(parentYOffset + parentContentWindow.height - childComponentWindowHeight / 2);

                case AlignY.Top: return(parentYOffset + parentContentWindow.height - childComponentWindowHeight);
                }
                throw new InvalidOperationException();
            }
            throw new InvalidOperationException();
        }
示例#3
0
        public Int32 GetChildComponentX(WindowStruct parentContentWindow, Int32 childComponentWindowWidth)
        {
            Int32 parentXOffset = parentContentWindow.x +
                                  ((parentAlign == AlignX.Right) ? -offset : offset);

            switch (parentAlign)
            {
            case AlignX.Left: switch (childAlign)
                {
                case AlignX.Left: return(parentXOffset);

                case AlignX.Center: return(parentXOffset - childComponentWindowWidth / 2);

                case AlignX.Right: return(parentXOffset - childComponentWindowWidth);
                }
                throw new InvalidOperationException();

            case AlignX.Center: switch (childAlign)
                {
                case AlignX.Left: return(parentXOffset + parentContentWindow.width / 2);

                case AlignX.Center: return(parentXOffset + (parentContentWindow.width - childComponentWindowWidth) / 2);

                case AlignX.Right: return(parentXOffset + parentContentWindow.width / 2 - childComponentWindowWidth);
                }
                throw new InvalidOperationException();

            case AlignX.Right: switch (childAlign)
                {
                case AlignX.Left: return(parentXOffset + parentContentWindow.width);

                case AlignX.Center: return(parentXOffset + parentContentWindow.width - childComponentWindowWidth / 2);

                case AlignX.Right: return(parentXOffset + parentContentWindow.width - childComponentWindowWidth);
                }
                throw new InvalidOperationException();
            }
            throw new InvalidOperationException();
        }
示例#4
0
        public WindowStruct Intersection(WindowStruct other)
        {
            throw new NotImplementedException();
            if (x == other.x)
            {
                if (y == other.y)
                {
                    return(new WindowStruct(x, y,
                                            (width <= other.width) ? width : other.width,
                                            (height <= other.height) ? height : other.height));
                }
                else if (y < other.y)
                {
                }
                else
                {
                }
            }



            return(new WindowStruct());
        }
示例#5
0
        public void DrawComponent()
        {
            WindowStruct componentWindow = window.component;

            Console.WriteLine("Component {0} Component {1},{2} {3}x{4} Content {5},{6} {7}x{8}",
                              GetType().Name,
                              window.component.x, window.component.y, window.component.width, window.component.height,
                              window.content.x, window.content.y, window.content.width, window.content.height);

            //
            // Draw the border
            //
            if (border.top > 0 || border.right > 0 || border.bottom > 0 || border.left > 0)
            {
                //
                // Check if there is any content for the border
                //
                if (componentWindow.width > 0 || componentWindow.height > 0)
                {
                    GL.Begin(BeginMode.Quads);
                    GL.Color4(borderColor);
                    if (border.top > 0)
                    {
                        GL.Vertex2(componentWindow.x, componentWindow.y + componentWindow.height - border.top);                             // BottomLeft
                        GL.Vertex2(componentWindow.x, componentWindow.y + componentWindow.height);                                          // TopLeft
                        GL.Vertex2(componentWindow.x + componentWindow.width, componentWindow.y + componentWindow.height);                  // TopRight
                        GL.Vertex2(componentWindow.x + componentWindow.width, componentWindow.y + componentWindow.height - border.top);     // BottomRight
                    }
                    if (border.right > 0)
                    {
                        GL.Vertex2(componentWindow.x + componentWindow.width - border.right, componentWindow.y);                          // BottomLeft
                        GL.Vertex2(componentWindow.x + componentWindow.width - border.right, componentWindow.y + componentWindow.height); // TopLeft
                        GL.Vertex2(componentWindow.x + componentWindow.width, componentWindow.y + componentWindow.height);                // TopRight
                        GL.Vertex2(componentWindow.x + componentWindow.width, componentWindow.y);                                         // BottomRight
                    }
                    if (border.bottom > 0)
                    {
                        GL.Vertex2(componentWindow.x, componentWindow.y);                                             // BottomLeft
                        GL.Vertex2(componentWindow.x, componentWindow.y + border.bottom);                             // TopLeft
                        GL.Vertex2(componentWindow.x + componentWindow.width, componentWindow.y + border.bottom);     // TopRight
                        GL.Vertex2(componentWindow.x + componentWindow.width, componentWindow.y);                     // BottomRight
                    }
                    if (border.left > 0)
                    {
                        GL.Vertex2(componentWindow.x, componentWindow.y);                                        // BottomLeft
                        GL.Vertex2(componentWindow.x, componentWindow.y + componentWindow.height);               // TopLeft
                        GL.Vertex2(componentWindow.x + border.left, componentWindow.y + componentWindow.height); // TopRight
                        GL.Vertex2(componentWindow.x + border.left, componentWindow.y);                          // BottomRight
                    }
                    GL.End();
                }
            }

            //
            // Draw the background
            //
            if (backgroundSetting != Color4.Transparent)
            {
                if (componentWindow.width > 0 && componentWindow.height > 0)
                {
                    GL.Color4(backgroundSetting);
                    GL.Begin(BeginMode.Quads);
                    GL.Vertex2(componentWindow.x + border.left, componentWindow.y + border.bottom);                                                // BottomLeft
                    GL.Vertex2(componentWindow.x + border.left, componentWindow.y + componentWindow.height - border.top);                          // TopLeft
                    GL.Vertex2(componentWindow.x + componentWindow.width - border.right, componentWindow.y + componentWindow.height - border.top); // TopRight
                    GL.Vertex2(componentWindow.x + componentWindow.width - border.right, componentWindow.y + border.bottom);                       // BottomRight
                    GL.End();
                }
            }

            //
            // Call the classes DrawPaddedContent to draw the inner content of the component
            //
            DrawContent();
        }