Пример #1
0
        public void SetPage(MNPage page)
        {
            pageEditView1.Page = page;
            pageEditView1.ClearSelection();
            if (!page.HasDimension(UserSelectedScreenDimension))
            {
                if (MessageBox.Show("Create new dimension?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    page.AvailableScreenDimensions.Add(UserSelectedScreenDimension);
                    page.CurrentScreenDimension = UserSelectedScreenDimension;
                    foreach (SMControl c in page.Objects)
                    {
                        SMRectangleArea area = c.Area;
                    }
                }
                else
                {
                    page.CurrentScreenDimension = SMScreen.Screen_1024_768__4_3;
                    DisplaySize = SMScreen.Screen_1024_768__4_3;
                    checkPagePlacement();
                    toolStripComboBox1.SelectedIndex = 0;
                }
            }
            page.CurrentScreenDimension = UserSelectedScreenDimension;

            MNNotificationCenter.CurrentPage = page;
        }
Пример #2
0
        private void DrawPageInto(Graphics graphics, MNPage p, Rectangle drawRect)
        {
            graphics.DrawRectangle(Pens.Black, drawRect);
            foreach (SMControl sc in p.Objects)
            {
                SMRectangleArea area = sc.Area;
                Rectangle       rect = area.GetBounds(PageEditDisplaySize.LandscapeBig);
                rect.X      = Convert.ToInt32(Convert.ToDouble(rect.X) * drawRect.Width / 1024);
                rect.Y      = Convert.ToInt32(Convert.ToDouble(rect.Y) * drawRect.Height / 768);
                rect.Width  = Convert.ToInt32(Convert.ToDouble(rect.Width) * drawRect.Width / 1024);
                rect.Height = Convert.ToInt32(Convert.ToDouble(rect.Height) * drawRect.Height / 768);
                rect.Y     += drawRect.Top;
                rect.X     += drawRect.Left;

                graphics.DrawRectangle(Pens.Gray, rect);
                if (sc is SMImage)
                {
                    graphics.DrawLine(Pens.Gray, rect.Left, rect.Bottom, rect.Right, rect.Top);
                    graphics.DrawLine(Pens.Gray, rect.Right, rect.Bottom, rect.Left, rect.Top);
                }
            }
        }
Пример #3
0
 public void WriteArea(StringBuilder S, SMRectangleArea A, int L)
 {
 }
Пример #4
0
        private void shrinkImagesToTheirCanvasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MNDocument doc = MNNotificationCenter.CurrentDocument;

            if (doc == null)
            {
                return;
            }

            Dictionary <long, Size> dsz = new Dictionary <long, Size>();
            Dictionary <long, MNReferencedImage> dri = new Dictionary <long, MNReferencedImage>();

            foreach (MNPage p in doc.Data.Pages)
            {
                foreach (SMControl c in p.Objects)
                {
                    if (c is SMImage)
                    {
                        MNReferencedImage img = (c as SMImage).Img.Image;
                        if (img != null && img.ImageData != null)
                        {
                            if (!img.Name.StartsWith("Image Pasted"))
                            {
                                continue;
                            }
                            SMRectangleArea area          = c.Area;
                            Rectangle       bounds        = area.GetBounds(PageEditDisplaySize.LandscapeBig);
                            Size            imageSize     = img.ImageData.Size;
                            Size            imageDrawSize = SMImage.GetImageDrawSize(bounds, img.ImageData);
                            if (imageSize.Width > imageDrawSize.Width || imageSize.Height > imageDrawSize.Height)
                            {
                                if (!dsz.ContainsKey(img.Id))
                                {
                                    Debugger.Log(0, "", "Image " + img.Id + " shrinked from " + imageSize.ToString() + " to " + imageDrawSize.ToString() + "\n");
                                    dsz[img.Id] = imageDrawSize;
                                    dri[img.Id] = img;
                                }
                                else
                                {
                                    Size storedSize = dsz[img.Id];
                                    if (storedSize.Width < imageDrawSize.Width ||
                                        storedSize.Height < imageDrawSize.Height)
                                    {
                                        dsz[img.Id] = imageDrawSize;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            foreach (long imageId in dsz.Keys)
            {
                string tempFileName = Path.GetTempFileName();
                if (dri.ContainsKey(imageId))
                {
                    Size newSize          = dsz[imageId];
                    MNReferencedImage img = dri[imageId];

                    //Debugger.Log(0, "", "  Size before shrink: " + GetImageSize(img.ImageData) + "\n");
                    ResizeImage(img.ImageData, newSize.Width, newSize.Height, tempFileName);

                    Image newImage = Image.FromFile(tempFileName);
                    img.ImageData = newImage;
                    //Debugger.Log(0, "", "  Size after shrink: " + GetImageSize(img.ImageData) + "\n");
                    doc.DefaultLanguage.Modified = true;

                    Debugger.Log(0, "", "Used file " + tempFileName + "\n");
                }
            }
        }
Пример #5
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);
        }