Example #1
0
        private void PageView_Paint(object sender, PaintEventArgs e)
        {
            if (CurrentPage == null)
            {
                return;
            }


            e.Graphics.Transform = Context.LastMatrix;

            Context.g                  = e.Graphics;
            Context.CurrentPage        = CurrentPage;
            Context.drawSelectionMarks = false;
            Context.ViewController     = ViewController;

            CurrentPage.PaintBackground(Context);
            CurrentPage.Paint(Context, false);
            CurrentPage.Paint(Context, true);

            //Debugger.Log(0, "", "Size of text with font size 24: " + e.Graphics.MeasureString("M", new Font("Times", 24f, FontStyle.Regular)) + "\n");

            if (CurrentPage.ShowMessageAlways)
            {
                Context.PaintMessageBox(false);
            }

            if (p_displayedMenu != null)
            {
                p_displayedMenu.Paint(Context);
            }
            else if (Context.messageBox.Visible && !CurrentPage.ShowMessageAlways)
            {
                Context.PaintMessageBox(true);
            }
            else
            {
                // painting dragged item
                switch (MouseContext.DragType)
                {
                case SMDragResponse.Drag:
                    PaintDraggedItem(Context, MouseContext);
                    break;

                case SMDragResponse.Line:
                    e.Graphics.DrawLine(Pens.Black, MouseContext.startPoint, MouseContext.lastPoint);
                    PaintDraggedItem(Context, MouseContext);
                    break;

                default:
                    break;
                }
            }
        }
Example #2
0
        private void PageView_Paint(object sender, PaintEventArgs e)
        {
            if (CurrentPage == null)
            {
                return;
            }

            e.Graphics.Transform = Context.LastMatrix;


            Rectangle Bounds        = new Rectangle(0, 0, Width, Height);
            double    ratio         = (double)Width / (double)Height;
            SMScreen  currentScreen = SMScreen.Screen_1024_768__4_3;

            if (ratio < 1.0 && CurrentPage.HasDimension(SMScreen.Screen_768_1024__3_4))
            {
                currentScreen = SMScreen.Screen_768_1024__3_4;
            }
            else if (ratio >= 16.0 / 9.0 && CurrentPage.HasDimension(SMScreen.Screen_1376_774__16_9))
            {
                currentScreen = SMScreen.Screen_1376_774__16_9;
            }
            else if (ratio >= 3.0 / 2.0 && CurrentPage.HasDimension(SMScreen.Screen_1152_768__3_2))
            {
                currentScreen = SMScreen.Screen_1152_768__3_2;
            }

            this.CurrentScreen = currentScreen;

            Size screenSize = SMRectangleArea.GetPageSize(currentScreen);

            Context.PageWidth  = screenSize.Width;
            Context.PageHeight = screenSize.Height;

            double scale = Math.Min(Bounds.Width / (double)screenSize.Width,
                                    Bounds.Height / (double)screenSize.Height);


            int drawingWidthP  = Convert.ToInt32(scale * screenSize.Width);
            int drawingHeightP = Convert.ToInt32(scale * screenSize.Height);
            int leftMarginP    = (Bounds.Width - drawingWidthP) / 2;
            int rightMarginP   = leftMarginP;
            int leftMarginL    = (int)(leftMarginP / scale);
            int rightMarginL   = (int)(rightMarginP / scale);

            Context.TopRectL         = new Rectangle(-leftMarginL, 0, screenSize.Width + leftMarginL + rightMarginL, 64);
            Context.SideRectLeftL    = new Rectangle(-leftMarginL, 0, leftMarginL, screenSize.Height);
            Context.SideRectRightL   = new Rectangle(screenSize.Width, 0, rightMarginL, screenSize.Height);
            Context.BackButtonRectL  = new Rectangle(-leftMarginL, 0, 64, 64); // context.TopRectL.Left, context.PageHeight / 2 - 100, 80, 200
            Context.BackAreaRectL    = new Rectangle(-leftMarginL, screenSize.Height / 2 - 100, 80, 200);
            Context.MenuButtonRectL  = new Rectangle(-leftMarginL + 64, 0, 64, 64);
            Context.FwdButtonRectL   = new Rectangle(screenSize.Width - 64 + rightMarginL, 0, 64, 64);
            Context.FwdAreaRectL     = new Rectangle(screenSize.Width - 80 + rightMarginL, screenSize.Height / 2 - 100, 80, 200);
            Context.HelpButtonRectL  = new Rectangle(screenSize.Width - 128 + rightMarginL, 0, 64, 64);
            Context.AudioButtonRectL = new Rectangle(screenSize.Width - 192 + rightMarginL, 0, 64, 64);
            Context.xoffset          = leftMarginP;
            Context.yoffset          = 0;
            Context.zoom             = (float)scale;

            //e.Graphics.Offset((float)(leftMarginP * scale), 0);
            //e.Graphics.ScaleCTM((float)scale, (float)scale);

            Context.g                  = e.Graphics;
            Context.CurrentPage        = CurrentPage;
            Context.drawSelectionMarks = false;
            Context.ViewController     = ViewController;

            //eGraphics.DrawLine(Pens.Black, 0, 0, 1024, 768);
            //eGraphics.DrawLine(Pens.Black, 1024, 0, 0, 768);
            //eGraphics.DrawRectangle(Pens.Black, 0, 0, 1024, 768);

            //AppDelegate.Log("Rectangle for paint: {0},{1},{2},{3}\n", rect.X, rect.Y, rect.Width, rect.Height);
            CurrentPage.CurrentScreenDimension = currentScreen;



            //----
            CurrentPage.PaintBackground(Context);
            CurrentPage.Paint(Context, false);
            CurrentPage.Paint(Context, true);

            if (CurrentPage.ShowMessageAlways)
            {
                Context.PaintMessageBox(false);
            }

            if (p_displayedMenu != null)
            {
                p_displayedMenu.Paint(Context);
            }
            else if (Context.messageBox.Visible && !CurrentPage.ShowMessageAlways)
            {
                Context.PaintMessageBox(true);
            }
            else
            {
                // painting dragged item
                switch (MouseContext.DragType)
                {
                case SMDragResponse.Drag:
                    PaintDraggedItem(Context, MouseContext);
                    break;

                case SMDragResponse.Line:
                    e.Graphics.DrawLine(Pens.Black, MouseContext.startPoint, MouseContext.lastPoint);
                    PaintDraggedItem(Context, MouseContext);
                    break;

                default:
                    break;
                }
            }

            // draw side rect if screen ratio is not 4:3
            if (Context.SideRectLeftL.Width != 0)
            {
                e.Graphics.FillRectangle(CurrentPage.BackgroundBrush, Context.SideRectLeftL);
            }
            if (Context.SideRectRightL.Width != 0)
            {
                e.Graphics.FillRectangle(CurrentPage.BackgroundBrush, Context.SideRectRightL);
            }

            CurrentPage.PaintUserControls(Context);
        }