예제 #1
0
        public void RenderToOutputWindowPartialMode2(
            IRenderElement renderE,
            IntPtr destOutputHdc,
            int viewportX, int viewportY,
            int viewportWidth, int viewportHeight,
            Rectangle windowMsgInvalidateArea)
        {
            if (!_drawBoard.IsContentReady)
            {
                UpdateInvalidArea(_drawBoard, renderE);
            }

            Rectangle invalidateArea = _drawBoard.InvalidateArea;

            if (invalidateArea.Width == 0 || invalidateArea.Height == 0)
            {
                invalidateArea = windowMsgInvalidateArea;// new Rectangle(0, 0, _pageA.Width, _pageA.Height);
            }

            _drawBoard.RenderTo(destOutputHdc, invalidateArea.Left - _drawBoard.Left, invalidateArea.Top - _drawBoard.Top,
                                new Rectangle(invalidateArea.Left -
                                              viewportX, invalidateArea.Top - viewportY,
                                              invalidateArea.Width, invalidateArea.Height));
            _drawBoard.ResetInvalidateArea();
        }
예제 #2
0
        public void CompleteRendering(Rectangle parentContentDest,
                                      IUserInterfaceRenderContext renderContext, IRenderElement widget)
        {
            var animation = widget.Display.Animation;
            var display   = widget.Display;

            display.Animation.Buffer.RenderContext.SpriteBatch.End();

            // Now use the parent render target.
            renderContext.GraphicsDevice.SetRenderTarget(renderContext.RenderTarget);

            var screenRect = animation.AnimatedBorderRect;

            screenRect.X += parentContentDest.X;
            screenRect.Y += parentContentDest.Y;

            renderContext.SpriteBatch.Draw(
                animation.RenderTarget,
                screenRect,
                null,
                animation.Color,
                0,
                Vector2.Zero,
                SpriteEffects.None,
                animation.LayerDepth);
        }
예제 #3
0
        public void Apply(IRenderElement rootElement, string defaultTheme)
        {
            RenderElementStack parentStack = new RenderElementStack();

            void ApplyRecurse(IRenderElement element, ITheme theme)
            {
                theme = ThemeOf(element, theme);

                theme.Apply(element, parentStack);

                if (element.Children == null)
                {
                    return;
                }

                try
                {
                    parentStack.PushParent(element);

                    foreach (var child in element.Children)
                    {
                        ApplyRecurse(child, theme);
                    }
                }
                finally
                {
                    parentStack.PopParent();
                }
            }

            var initialTheme = ThemeOf(rootElement, themes[defaultTheme]);

            ApplyRecurse(rootElement, initialTheme);
        }
예제 #4
0
            private void GrowFlexItems(IList <IRenderElement> children, ref int extraSpace)
            {
                int totalFlexGrow = children.Sum(x => x.Style.FlexItem?.Grow ?? 0);

                if (extraSpace <= 0 || totalFlexGrow <= 0)
                {
                    return;
                }

                float fExtraSpace = extraSpace;

                for (int index = 0; index < children.Count; index++)
                {
                    IRenderElement item     = children[index];
                    int            flexGrow = item.Style.FlexItem?.Grow ?? 0;

                    if (flexGrow == 0)
                    {
                        continue;
                    }

                    float flexGrowFactor = flexGrow / (float)totalFlexGrow;
                    float expand         = extraSpace * flexGrowFactor;

                    Size currentSize = item.Display.Region.ContentRect.Size;
                    Size newSize     = SetSize(MainAxis(currentSize) + (int)expand, CrossAxis(currentSize));

                    item.Display.Region.SetContentSize(newSize);

                    fExtraSpace -= expand;
                }

                extraSpace = (int)fExtraSpace;
            }
예제 #5
0
        static void UpdateInvalidArea(GdiPlusDrawBoard d, IRenderElement rootElement)
        {
            int enter_canvasX = d.OriginX;
            int enter_canvasY = d.OriginY;

            d.SetCanvasOrigin(enter_canvasX - d.Left, enter_canvasY - d.Top);

            UpdateArea u = GetFreeUpdateArea();

            u.CurrentRect = d.InvalidateArea;

            if (u.Width > 0 && u.Height > 0)
            {
                rootElement.Render(d, u);
#if DEBUG
                rootElement.dbugShowRenderPart(d, u);
#endif
            }
            else
            {
            }


            d.IsContentReady = true;
            d.SetCanvasOrigin(enter_canvasX, enter_canvasY);//restore

            ReleaseUpdateArea(u);
        }
예제 #6
0
        private void Unmount(IRenderElement oldNode)
        {
            if (oldNode == null)
            {
                return;
            }

            oldNode.OnWillUnmount();
        }
예제 #7
0
        private void Mount(IRenderElement newNode)
        {
            if (newNode == null)
            {
                return;
            }

            newNode.OnDidMount();
        }
예제 #8
0
        public IEnumerable <IRenderElementStyleProperties> MatchElementStyle(
            IRenderElement element, RenderElementStack stack)
        {
            var match = MatchExecutor.FindMatch(element, stack);

            if (match != null)
            {
                yield return(new ThemeRenderElementStyle(this, match));
            }
        }
예제 #9
0
        private ITheme ThemeOf(IRenderElement element, ITheme theme)
        {
            if (!string.IsNullOrWhiteSpace(element.Props.Theme) &&
                themes.ContainsKey(element.Props.Theme))
            {
                return(themes[element.Props.Theme]);
            }

            return(theme);
        }
예제 #10
0
        public static void CalcIdealSize(IRenderElement item, IUserInterfaceRenderContext renderContext, Size parentMaxSize)
        {
            Size maxSize = ConstrainMaxSize(parentMaxSize, item.Style.Size);

            Size idealSize = item.CalcIdealContentSize(renderContext, maxSize);

            idealSize = ConstrainSize(idealSize, item.Style.Size);

            item.Display.Region.IdealContentSize = idealSize;
        }
예제 #11
0
 bool isClosed;//is this viewport closed
 public CanvasViewport(RootGraphic rootgfx,
                       Size viewportSize, int cachedPageNum)
 {
     this.rootGraphics        = rootgfx;
     this.topWindowBox        = rootgfx.TopWindowRenderBox;
     this.viewportWidth       = viewportSize.Width;
     this.viewportHeight      = viewportSize.Height;
     canvasSizeChangedHandler = Canvas_SizeChanged;
     viewportX = 0;
     viewportY = 0;
 }
        public void UpdateAnimation(IUserInterfaceRenderContext renderContext, IRenderElement element)
        {
            var animator = element.Display.Animation;

            bool finished = animator.Transition?.Update(element.Display, renderContext) ?? false;

            if (finished)
            {
                AdvanceTransitionState(element);
            }
        }
예제 #13
0
 bool isClosed;//is this viewport closed
 public CanvasViewport(RootGraphic rootgfx,
     Size viewportSize, int cachedPageNum)
 {
     this.rootGraphics = rootgfx;
     this.topWindowBox = rootgfx.TopWindowRenderBox;
     this.viewportWidth = viewportSize.Width;
     this.viewportHeight = viewportSize.Height;
     canvasSizeChangedHandler = Canvas_SizeChanged;
     viewportX = 0;
     viewportY = 0;
 }
예제 #14
0
        /// <summary>
        /// Draws the focus indicator.
        /// </summary>
        /// <param name="renderContext">Render Context (is this really necessary?)</param>
        /// <param name="focusElement">The element that has focus.</param>
        /// <param name="focusContentRect">The screen coordinates of the content area of the focus element.</param>
        public void DrawFocus(SpriteBatch spriteBatch, IRenderElement focusElement, Rectangle focusContentRect)
        {
            const int overlap = 1;

            Rectangle pointerDest = new Rectangle(
                focusContentRect.Left - texture.Width + overlap,
                (focusContentRect.Top + focusContentRect.Bottom - texture.Height) / 2,
                texture.Width,
                texture.Height);

            DrawPointer(spriteBatch, pointerDest);
        }
예제 #15
0
        bool _isClosed;//is this viewport closed
        public CanvasViewport(RootGraphic rootgfx, Size viewportSize)
        {
            _rootGraphics             = rootgfx;
            _topWindowBox             = rootgfx.TopWindowRenderBox;
            _viewportWidth            = viewportSize.Width;
            _viewportHeight           = viewportSize.Height;
            _canvasSizeChangedHandler = Canvas_SizeChanged;
            _viewportX = 0;
            _viewportY = 0;

            FullMode = true;
        }
예제 #16
0
        static void UpdateAllArea(PixelFarm.Drawing.Skia.MySkiaCanvas mycanvas, IRenderElement topWindowRenderBox)
        {
            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
            Rectangle rect = mycanvas.Rect;
            topWindowRenderBox.DrawToThisCanvas(mycanvas, rect);
#if DEBUG
            topWindowRenderBox.dbugShowRenderPart(mycanvas, rect);
#endif

            mycanvas.IsContentReady = true;
            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        }
예제 #17
0
        //private static void OnMouseLeft(Window source, Event e)
        //{
        //    while (MouseOverStack.TryPop(out var element))
        //        Raise(element, new MouseLeaveEventArgs((Vector2)Mouse.GetPosition(source)));
        //}

        //private static void OnTextEntered(Window source, Event e)
        //{
        //    var f = focusElement;
        //    if (null == f) return;
        //    var utf32 = unchecked((int)e.Text.Unicode);
        //    Raise(f, new TextInputEventArgs(char.ConvertFromUtf32(utf32)));
        //}

        //private static void OnMouseScroll(Window source, Event e)
        //{
        //    var position = new Vector2(e.MouseWheelScroll.X, e.MouseWheelScroll.Y);
        //    if (InputHitTest(position, source, out var element))
        //        Raise(element, new MouseScrollEventArgs(position, e.MouseWheelScroll.Delta, e.MouseWheelScroll.Wheel));
        //}

        //private static ModifierKeys GetModifiers(KeyEvent e)
        //{
        //    var result = ModifierKeys.None;
        //    result |= e.Alt > 0 ? ModifierKeys.Alt : ModifierKeys.None;
        //    result |= e.Control > 0 ? ModifierKeys.Control : ModifierKeys.None;
        //    result |= e.System > 0 ? ModifierKeys.System : ModifierKeys.None;
        //    result |= e.Shift > 0 ? ModifierKeys.Shift : ModifierKeys.None;
        //    return result;
        //}

        //private static void OnKeyUp(Window source, Event e)
        //{
        //    var f = focusElement;
        //    if (null != f)
        //        Raise(f, new KeyUpEventArgs(e.Key.Code, GetModifiers(e.Key)));
        //}

        //private static void OnKeyDown(Window source, Event e)
        //{
        //    var f = focusElement;
        //    if (null != f)
        //        Raise(f, new KeyDownEventArgs(e.Key.Code, GetModifiers(e.Key)));
        //}

        //private static void OnMouseButtonUp(Window source, Event e)
        //{
        //    var position = new Vector2(e.MouseButton.X, e.MouseButton.Y);
        //    if (!InputHitTest(position, source, out var element)) return;
        //    if (focusElement == element && e.MouseButton.Button == lastDownButton)
        //        Raise(element, new MouseButtonInputEventArgs(position, e.MouseButton.Button));
        //    Raise(element, new MouseUpEventArgs(position, e.MouseButton.Button));
        //}

        //private static void OnMouseButtonDown(Window window, Event e)
        //{
        //    var position = new Vector2(e.MouseButton.X, e.MouseButton.Y);
        //    if (!InputHitTest(position, window, out var element)) return;
        //    if (element.IsFocusable && focusElement != element)
        //        RequestFocus(element);
        //    lastDownButton = e.MouseButton.Button;
        //    Raise(element, new MouseDownEventArgs(position, e.MouseButton.Button));
        //}

        //private static void OnMouseMoved(Window window, Event e)
        //{
        //    var position = new Vector2(e.MouseMove.X, e.MouseMove.Y);
        //    if (!InputHitTest(position, window, out var element)) return;
        //    var localPosition = element.ToLocalCoords(position);
        //    Raise(element, new MouseEventArgs(localPosition));
        //    if (MouseOverStack.Count == 0)
        //    {
        //        MouseOverStack.Push(element);
        //        Raise(element, new MouseEnterEventArgs(localPosition));
        //        return;
        //    }

        //    while (MouseOverStack.TryPop(out var parent))
        //    {
        //        if (!element.IsChildOf(parent) && element != parent)
        //            Raise(parent, new MouseLeaveEventArgs(parent.ToLocalCoords(position)));
        //        else
        //        {
        //            MouseOverStack.Push(parent);
        //            if (element != parent)
        //            {
        //                MouseOverStack.Push(element);
        //                Raise(element, new MouseEnterEventArgs(localPosition));
        //            }

        //            break;
        //        }
        //    }
        //}

        private static bool IsChildOf(this IRenderElement potentialChild, IRenderElement potentialParent)
        {
            while (null != potentialChild)
            {
                potentialChild = potentialChild.Parent;
                if (potentialChild == potentialParent)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #18
0
        public void UpdateAnimation(IRenderElement element)
        {
            if (element.Display.Animation.State == AnimationState.TransitionIn)
            {
                element.Display.Animation.State = AnimationState.Static;
            }

            if (element.Display.Animation.State == AnimationState.TransitionOut)
            {
                element.Display.Animation.State = AnimationState.Dead;
            }
        }
예제 #19
0
        static void UpdateInvalidArea(MyScreenCanvas mycanvas, IRenderElement rootElement)
        {
            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
            Rectangle rect = mycanvas.InvalidateArea;

            rootElement.DrawToThisCanvas(mycanvas, rect);
#if DEBUG
            rootElement.dbugShowRenderPart(mycanvas, rect);
#endif

            mycanvas.IsContentReady = true;
            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        }
예제 #20
0
        static void UpdateAllArea(PixelFarm.Drawing.Skia.MySkiaDrawBoard mycanvas, IRenderElement topWindowRenderBox)
        {
            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
            Rectangle rect = mycanvas.Rect;

            topWindowRenderBox.DrawToThisCanvas(mycanvas, rect);
#if DEBUG
            topWindowRenderBox.dbugShowRenderPart(mycanvas, rect);
#endif

            mycanvas.IsContentReady = true;
            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        }
예제 #21
0
        private void Matches(IRenderElement tree, string selector,
                             IRenderElement renderElement, bool expectedResult = true)
        {
            var ex     = new CssWidgetSelector(selector);
            var result = ex.FindMatch(renderElement, GetStack(tree, renderElement));

            if (!expectedResult)
            {
                result.Should().Be(null);
                return;
            }

            result.Should().NotBe(null);
        }
예제 #22
0
        //PRESERVE***
        //        public void PaintMe(GdiPlusDrawBoard mycanvas)
        //        {
        //            if (this.IsClosed) { return; }
        //            //------------------------------------

        //            _rootGraphics.PrepareRender();
        //            //---------------
        //            _rootGraphics.IsInRenderPhase = true;
        //#if DEBUG
        //            _rootGraphics.dbug_rootDrawingMsg.Clear();
        //            _rootGraphics.dbug_drawLevel = 0;
        //#endif

        //            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
        //            Rectangle rect = mycanvas.Rect;
        //            _rootGraphics.TopWindowRenderBox.DrawToThisCanvas(mycanvas, rect);
        //#if DEBUG
        //            _rootGraphics.TopWindowRenderBox.dbugShowRenderPart(mycanvas, rect);
        //#endif

        //            mycanvas.IsContentReady = true;
        //            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        //            //if (this.FullMode)
        //            //{
        //            //    quadPages.RenderToOutputWindowFullMode(rootGraphics.TopWindowRenderBox, hdc,
        //            //        this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight);
        //            //}
        //            //else
        //            //{
        //            //    //temp to full mode
        //            //    //quadPages.RenderToOutputWindowFullMode(rootGraphics.TopWindowRenderBox, hdc, this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight);
        //            //    quadPages.RenderToOutputWindowPartialMode(rootGraphics.TopWindowRenderBox, hdc,
        //            //        this.ViewportX, this.ViewportY, this.ViewportWidth, this.ViewportHeight);

        //            //}
        //            _rootGraphics.IsInRenderPhase = false;
        //#if DEBUG

        //            RootGraphic visualroot = RootGraphic.dbugCurrentGlobalVRoot;
        //            if (visualroot.dbug_RecordDrawingChain)
        //            {
        //                List<dbugLayoutMsg> outputMsgs = dbugOutputWindow.dbug_rootDocDebugMsgs;
        //                outputMsgs.Clear();
        //                outputMsgs.Add(new dbugLayoutMsg(null as RenderElement, "[" + debug_render_to_output_count + "]"));
        //                visualroot.dbug_DumpRootDrawingMsg(outputMsgs);
        //                dbugOutputWindow.dbug_InvokeVisualRootDrawMsg();
        //                debug_render_to_output_count++;
        //            }


        //            if (dbugHelper01.dbugVE_HighlightMe != null)
        //            {
        //                dbugOutputWindow.dbug_HighlightMeNow(dbugHelper01.dbugVE_HighlightMe.dbugGetGlobalRect());
        //            }
        //#endif
        //        }
        //PRESERVE***

        public void RenderToOutputWindowFullMode(
            IRenderElement topWindowRenderBox,
            IntPtr destOutputHdc,
            int viewportX, int viewportY, int viewportWidth, int viewportHeight)
        {
            if (_drawBoard != null && !_drawBoard.IsContentReady)
            {
                UpdateAllArea(_drawBoard, topWindowRenderBox);
            }
            _drawBoard.RenderTo(destOutputHdc, viewportX - _drawBoard.Left,
                                viewportY - _drawBoard.Top,
                                new Rectangle(0, 0,
                                              viewportWidth,
                                              viewportHeight));
        }
예제 #23
0
        static void UpdateInvalidateArea(DrawBoard d, IRenderElement topWindowRenderBox, UpdateArea updateArea)
        {
            int enter_canvas_x = d.OriginX;
            int enter_canvas_y = d.OriginY;

            d.SetCanvasOrigin(enter_canvas_x - d.Left, enter_canvas_y - d.Top);
            topWindowRenderBox.Render(d, updateArea);

            //Rectangle rect = mycanvas.Rect;
            //topWindowRenderBox.DrawToThisCanvas(mycanvas, rect);
#if DEBUG
            dbugDrawDebugRedBoxes(d);
#endif
            d.SetCanvasOrigin(enter_canvas_x, enter_canvas_y);//restore
        }
예제 #24
0
        static void UpdateAllArea(DrawBoard mycanvas, IRenderElement topWindowRenderBox)
        {
            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
            Rectangle rect = mycanvas.Rect;

            topWindowRenderBox.DrawToThisCanvas(mycanvas, rect);


#if DEBUG
            dbugDrawDebugRedBoxes(mycanvas);
#endif


            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        }
        private void AdvanceTransitionState(IRenderElement widget)
        {
            var animator = widget.Display.Animation;

            switch (animator.State)
            {
            case AnimationState.TransitionIn:
                animator.State = AnimationState.Static;
                break;

            case AnimationState.TransitionOut:
                animator.State = AnimationState.Dead;
                break;
            }
        }
        static void UpdateAllArea(Canvas mycanvas, IRenderElement topWindowRenderBox)
        {
            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
            Rectangle rect = mycanvas.Rect;

            //mycanvas.FillRectangle(Color.Blue, 50, 50, 100, 100);
            topWindowRenderBox.DrawToThisCanvas(mycanvas, rect);

#if DEBUG
            topWindowRenderBox.dbugShowRenderPart(mycanvas, rect);
#endif

            mycanvas.IsContentReady = true;
            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        }
예제 #27
0
        public Point LocationOf(IRenderElement item)
        {
            if (item == null)
            {
                return(new Point(-1, -1));
            }

            var index = Children.IndexOf(item);

            if (index == -1)
            {
                return(new Point(-1, -1));
            }

            return(new Point(index % Columns, index / Columns));
        }
예제 #28
0
        public override void OnChildAction(IRenderElement child, UserInterfaceActionEventArgs action)
        {
            bool moved      = false;
            int  FocusIndex = focusChildren.IndexOf(child);
            var  button     = action.Action;

            if (Direction == FlexDirection.Column || Direction == FlexDirection.ColumnReverse)
            {
                if (button == UserInterfaceAction.Up)
                {
                    moved = MovePrevious();
                }
                if (button == UserInterfaceAction.Down)
                {
                    moved = MoveNext();
                }
            }
            else
            {
                if (button == UserInterfaceAction.Left)
                {
                    moved = MovePrevious();
                }
                if (button == UserInterfaceAction.Right)
                {
                    moved = MoveNext();
                }
            }

            action.Handled = moved;

            if (!moved)
            {
                if (button == UserInterfaceAction.Cancel && Props.OnCancel != null)
                {
                    Props.OnCancel(EventData);
                    action.Handled = moved;
                }
            }

            if (!Props.AllowNavigate)
            {
                action.Handled = true;
            }

            base.OnChildAction(this, action);
        }
예제 #29
0
        public ButtonElement(ButtonElementProps props) : base(props)
        {
            if (props.Children.Count == 1)
            {
                child = Finalize(props.Children.First());
            }
            else
            {
                child = new FlexBox(new FlexBoxProps {
                    Children = props.Children
                });
            }

            Children = new List <IRenderElement> {
                child
            };
        }
예제 #30
0
        public void RenderToOutputWindowPartialMode(
            IRenderElement renderE,
            IntPtr destOutputHdc,
            int viewportX, int viewportY,
            int viewportWidth, int viewportHeight)
        {
            if (!_drawBoard.IsContentReady)
            {
                UpdateInvalidArea(_drawBoard, renderE);
            }

            Rectangle invalidateArea = _drawBoard.InvalidateArea;

            _drawBoard.RenderTo(destOutputHdc, invalidateArea.Left - _drawBoard.Left, invalidateArea.Top - _drawBoard.Top,
                                new Rectangle(invalidateArea.Left -
                                              viewportX, invalidateArea.Top - viewportY,
                                              invalidateArea.Width, invalidateArea.Height));
            _drawBoard.ResetInvalidateArea();
        }
예제 #31
0
        static void UpdateInvalidArea(GdiPlusDrawBoard mycanvas, IRenderElement rootElement)
        {
            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
            Rectangle rect = mycanvas.InvalidateArea;

            if (rect.Width > 0 && rect.Height > 0)
            {
                rootElement.DrawToThisCanvas(mycanvas, rect);
#if DEBUG
                rootElement.dbugShowRenderPart(mycanvas, rect);
#endif
            }
            else
            {
            }


            mycanvas.IsContentReady = true;
            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        }
예제 #32
0
        //-------
        static void UpdateAllArea(GdiPlusDrawBoard d, IRenderElement topWindowRenderBox)
        {
            int enter_canvasX = d.OriginX;
            int enter_canvasY = d.OriginY;

            d.SetCanvasOrigin(enter_canvasX - d.Left, enter_canvasY - d.Top);

            UpdateArea u = GetFreeUpdateArea();

            u.CurrentRect = d.Rect;
            topWindowRenderBox.Render(d, u);

#if DEBUG
            topWindowRenderBox.dbugShowRenderPart(d, u);
#endif

            d.IsContentReady = true;
            d.SetCanvasOrigin(enter_canvasX, enter_canvasY);//restore

            ReleaseUpdateArea(u);
        }
예제 #33
0
        public void RenderToOutputWindowFullMode(
            IRenderElement topWindowRenderBox,
            IntPtr destOutputHdc,
            int viewportX, int viewportY, int viewportWidth, int viewportHeight)
        {
            int render_part = PAGE_A;
            if (pageA != null && !pageA.IsContentReady)
            {
                UpdateAllArea(pageA, topWindowRenderBox);
            }
            if (pageB != null)
            {
                render_part |= PAGE_AB;
                if (!pageB.IsContentReady)
                {
                    UpdateAllArea(pageB, topWindowRenderBox);
                }
            }
            if (pageC != null)
            {
                render_part |= PAGE_AC;
                if (!pageC.IsContentReady)
                {
                    UpdateAllArea(pageC, topWindowRenderBox);
                }
            }
            if (pageD != null)
            {
                render_part |= PAGE_ABCD;
                if (!pageD.IsContentReady)
                {
                    UpdateAllArea(pageD, topWindowRenderBox);
                }
            }


            switch (render_part)
            {
                case PAGE_A:
                    {
                        pageA.RenderTo(destOutputHdc, viewportX - pageA.Left,
                        viewportY - pageA.Top,
                            new Rectangle(0, 0,
                            viewportWidth,
                            viewportHeight));
                    }
                    break;
                case PAGE_AB:
                    {
                        int remainingHeightOfPageA = pageA.Bottom - viewportY;
                        pageA.RenderTo(destOutputHdc,
                            viewportX - pageA.Left, viewportY - pageA.Top,
                            new Rectangle(0, 0, viewportWidth, remainingHeightOfPageA));
                        pageB.RenderTo(destOutputHdc, 0, 0,
                            new Rectangle(0, remainingHeightOfPageA, viewportWidth, viewportHeight - remainingHeightOfPageA));
                    }
                    break;
                case PAGE_AC:
                    {
                        int remainingWidthOfPageA = pageA.Right - viewportX;
                        pageA.RenderTo(destOutputHdc,
                            viewportX - pageA.Left, viewportY - pageA.Top,
                            new Rectangle(0, 0, remainingWidthOfPageA, viewportHeight));
                        pageC.RenderTo(destOutputHdc, 0, 0,
                            new Rectangle(0, remainingWidthOfPageA, viewportWidth - remainingWidthOfPageA, viewportHeight));
                    }
                    break;
                case PAGE_ABCD:
                    {
                        int remainingHeightOfPageA = pageA.Bottom - viewportY;
                        pageA.RenderTo(destOutputHdc,
                            viewportX - pageA.Left, viewportY - pageA.Top,
                            new Rectangle(0, 0, viewportWidth, remainingHeightOfPageA));
                        pageB.RenderTo(destOutputHdc, 0, 0,
                            new Rectangle(0, remainingHeightOfPageA, viewportWidth, viewportHeight - remainingHeightOfPageA));
                    }
                    break;
            }
        }
예제 #34
0
        public void RenderToOutputWindowPartialMode(
            IRenderElement renderE,
            IntPtr destOutputHdc,
            int viewportX, int viewportY,
            int viewportWidth, int viewportHeight)
        {
            switch (render_parts)
            {
                case PAGE_A:
                    {
                        if (!pageA.IsContentReady)
                        {
                            UpdateInvalidArea(pageA, renderE);
                        }
                    }
                    break;
                case PAGE_AB:
                    {
                        if (!pageA.IsContentReady)
                        {
                            UpdateInvalidArea(pageA, renderE);
                        }
                        if (!pageB.IsContentReady)
                        {
                            UpdateInvalidArea(pageB, renderE);
                        }
                    }
                    break;
                case PAGE_AC:
                    {
                        if (!pageA.IsContentReady)
                        {
                            UpdateInvalidArea(pageA, renderE);
                        }
                        if (!pageC.IsContentReady)
                        {
                            UpdateInvalidArea(pageC, renderE);
                        }
                    }
                    break;
                case PAGE_ABCD:
                    {
                        if (!pageA.IsContentReady)
                        {
                            UpdateInvalidArea(pageA, renderE);
                        }
                        if (!pageB.IsContentReady)
                        {
                            UpdateInvalidArea(pageB, renderE);
                        }
                        if (!pageC.IsContentReady)
                        {
                            UpdateInvalidArea(pageC, renderE);
                        }
                        if (!pageD.IsContentReady)
                        {
                            UpdateInvalidArea(pageD, renderE);
                        }
                    }
                    break;
            }
            //----------------------------------------------------------------------------------------------------------
            switch (render_parts)
            {
                case PAGE_A:
                    {
                        Rectangle invalidateArea = pageA.InvalidateArea;
                        ////Console.WriteLine("update2:" + invalidateArea.ToString());


                        pageA.RenderTo(destOutputHdc, invalidateArea.Left - pageA.Left, invalidateArea.Top - pageA.Top,
                            new Rectangle(invalidateArea.Left -
                                viewportX, invalidateArea.Top - viewportY,
                                invalidateArea.Width, invalidateArea.Height));
                        pageA.ResetInvalidateArea();
                    }
                    break;
                case PAGE_AB:
                    {
                        int remainingHeightOfPageA = pageA.Top + pageA.Height - viewportY;
                        pageA.RenderTo(destOutputHdc, viewportX - pageA.Left, viewportY - pageA.Top,
                            new Rectangle(0, 0, viewportWidth, remainingHeightOfPageA));
                        pageB.RenderTo(destOutputHdc, 0, 0,
                            new Rectangle(0, remainingHeightOfPageA, viewportWidth, viewportHeight - remainingHeightOfPageA));
                    }
                    break;
                case PAGE_AC:
                    {
                    }
                    break;
                case PAGE_ABCD:
                    {
                    }
                    break;
            }
        }
예제 #35
0
        static void UpdateInvalidArea(MyGdiPlusCanvas mycanvas, IRenderElement rootElement)
        {
            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
            Rectangle rect = mycanvas.InvalidateArea;
            rootElement.DrawToThisCanvas(mycanvas, rect);
#if DEBUG
            rootElement.dbugShowRenderPart(mycanvas, rect);
#endif

            mycanvas.IsContentReady = true;
            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        }