예제 #1
0
        private void ComboZoom_SelectedIndexChanged(object sender, EventArgs e)
        {
            Zoom.ApplyZoom(Zoom.avaibleZooms[comboZoom.SelectedIndex]);

            ResizePaper();
            Objects.RenderAll();
        }
예제 #2
0
        private void RecalculateRealPosition()
        {
            Point p = Holder.Location;

            //
            // Recalculate the real position
            //
            if (IsCenter())
            {
                p.X += (int)((float)Holder.Width * 0.5);
            }
            if (IsRight())
            {
                p.X += (int)((float)Holder.Width);
            }
            //
            if (IsMiddle())
            {
                p.Y += (int)((float)Holder.Height * 0.5);
            }
            if (IsDown())
            {
                p.Y += (int)((float)Holder.Height);
            }
            //
            // Calculate the Real position without zoom
            RealLocation = Zoom.CalculateReal(p);
            //
        }
예제 #3
0
        public void ResizePaper()
        {
            //Set paper name
            if (Paper.UsingCustomPaper)
            {
                lab_paperSize.Text = $"Paper size : {Paper.Width} x {Paper.Height}";
            }
            else
            {
                lab_paperSize.Text = $"Paper kind : {Paper.SelectedPaper.PaperName} {(Paper.IsLandScape ? "(Landscape)" : "")}";
            }

            // Optional : Setting a tooltip to know the Dimensions
            toolTip.SetToolTip(lab_paperSize, $"Dimension : {Paper.Width}x{Paper.Height} pixels");

            thePaper.Size = Zoom.GetPaperSize();   //Get paper size relative to the zoom percent
            CenterPaper();                         //Center paper for better view
        }
예제 #4
0
        public override void RenderObject()
        {
            int realLength;

            if (!SizeInPercent)
            {
                realLength = (int)Length;
            }
            else
            {
                realLength = (int)(((float)Length / 100.0F) *
                                   (float)(IsVertical ? Paper.Height : Paper.Width));
            }

            Size lineDimentions = Zoom.Calculate(new Size(realLength, Thickness));

            // Initialize the bitmap
            Bitmap b = new Bitmap(lineDimentions.Width, lineDimentions.Height);

            // Initialize the graphics and render settings
            Graphics g = Graphics.FromImage(b);

            g.ApplyGraphicsQuality();

            Pen drawingPen = new Pen(LineColor, lineDimentions.Height);

            drawingPen.DashPattern = DashPattern.GetFloatList(' ');

            g.DrawLine(drawingPen, new Point(0, lineDimentions.Height / 2), new Point(lineDimentions.Width, lineDimentions.Height / 2));

            if (IsVertical)
            {
                b.RotateFlip(RotateFlipType.Rotate90FlipNone);
            }

            // Set the image
            Holder.Image = b;
            Holder.Size  = Holder.Image.Size;

            base.RenderObject();
        }
예제 #5
0
        public virtual void RenderObject()
        {
            Point p = Zoom.Calculate(RealLocation);

            if (IsCenter())
            {
                p.X -= (int)((float)Holder.Width * 0.5);
            }
            if (IsRight())
            {
                p.X -= (int)((float)Holder.Width);
            }

            if (IsMiddle())
            {
                p.Y -= (int)((float)Holder.Height * 0.5);
            }
            if (IsDown())
            {
                p.Y -= (int)((float)Holder.Height);
            }

            // Clamp Position to inside the document
            p.X = Funcs.Clamp(p.X, 0, Zoom.paperSize.Width - Holder.Width);
            p.Y = Funcs.Clamp(p.Y, 0, Zoom.paperSize.Height - Holder.Height);

            // Finally set theposition clamped and with zoom applied
            Holder.Location = p;
            RecalculateRealPosition();

            // Set the BackColor
            Holder.BackColor = BackColor;

#if DEBUG
            Console.WriteLine("Rendering : " + Name);
#endif
        }
예제 #6
0
        /*
         * public override void RenderObject()
         * {
         *  Thread thread = new Thread(new ThreadStart(ExRenderObject));
         *  thread.Start();
         *
         * }
         */

        public override void RenderObject()
        {
            Size   realObjectSize;
            double xOffset, yOffset;

            if (!SizeInPercent)
            {
                realObjectSize = new Size((int)Width, (int)Height);
            }
            else
            {
                realObjectSize = new Size((int)((float)Paper.Width * Width / 100.0f),
                                          (int)((float)Paper.Height * Height / 100.0f));
            }

            // Limit Size to a minimum of 1
            realObjectSize = realObjectSize.Max(1);

            Bitmap c = new Bitmap(realObjectSize.Width, realObjectSize.Height);
            Bitmap i = new Bitmap(Resources.Get(ResourceID));

            Graphics g = Graphics.FromImage(c);

            if (IsVertical)
            {
                i.RotateFlip(RotateFlipType.Rotate90FlipNone);
            }

            if (IsTurned180)
            {
                i.RotateFlip(RotateFlipType.Rotate180FlipNone);
            }

            switch (drawingType)
            {
            case DrawingTypes.Tiles:
                using (TextureBrush brush = new TextureBrush(i, WrapMode.Tile))
                {
                    g.FillRectangle(brush, 0, 0, realObjectSize.Width, realObjectSize.Height);
                }
                break;

            case DrawingTypes.Stretch:

                g.DrawImage(i, 0, 0, realObjectSize.Width, realObjectSize.Height);
                break;

            case DrawingTypes.Center:

                xOffset = (double)(c.Width - i.Width) / 2.0d;
                yOffset = (double)(c.Height - i.Height) / 2.0d;

                g.DrawImage(i, (int)xOffset, (int)yOffset, i.Width, i.Height);

                break;

            case DrawingTypes.Zoom:

                Size newSize;

                double cRatio = (double)c.Width / c.Height;
                double iRatio = (double)i.Width / i.Height;

                if (cRatio > iRatio)
                {
                    newSize = new Size((int)(i.Width * ((double)c.Height / i.Height)), c.Height);
                }
                else
                {
                    newSize = new Size(c.Width, (int)(i.Height * ((double)c.Width / i.Width)));
                }

                xOffset = (double)(c.Width - newSize.Width) / 2.0d;
                yOffset = (double)(c.Height - newSize.Height) / 2.0d;

                g.DrawImage(i, (int)xOffset, (int)yOffset, newSize.Width, newSize.Height);

                break;

            default:
                break;
            }

            // To prevent bitmap-ception, anchors will be off when zooming in/out for ImageObjects
            // After thinking I left the anchors to be shown even if zoomed but they become blurry (whatever) :/
            // Draw the anchor point for this label
            //
            Point anchor = new Point(0, 0);

            if (Config.ShowAnchorPoints /*&& Zoom.currentAppliedZoom == 100*/)
            {
                // Reset rotation for anchors (only if show [Optimisation :3])
                g.ResetTransform();

                if (IsCenter())
                {
                    anchor.X = (int)(c.Width * 0.5F);
                }
                if (IsRight())
                {
                    anchor.X = (int)c.Width - 1;
                }

                if (IsMiddle())
                {
                    anchor.Y = (int)(c.Height * 0.5F);
                }
                if (IsDown())
                {
                    anchor.Y = (int)c.Height - 1;
                }

                g.DrawLine(Config.AnchorPen, anchor.X - Config.ANCHOR_SIZE, anchor.Y, anchor.X + Config.ANCHOR_SIZE, anchor.Y);
                g.DrawLine(Config.AnchorPen, anchor.X, anchor.Y - Config.ANCHOR_SIZE, anchor.X, anchor.Y + Config.ANCHOR_SIZE);
            }

            // Release previous rendered bitmap (A lil bit of memore'h :3)
            if (Holder.Image != null)
            {
                Holder.Image.Dispose();
            }



            // Dispose of the copy
            i.Dispose();

            Holder.Image = c;
            Holder.Size  = Zoom.Calculate(realObjectSize);

            base.RenderObject();
        }
예제 #7
0
        public override void RenderObject()
        {
            Point anchor = new Point(0, 0);

            Font font = Fonts.GetFont(FontID, Zoom.GetFontSize(FontSize), (FontStyle)FontStyle);

            Graphics g = Graphics.FromHwnd(IntPtr.Zero);

            g.ApplyGraphicsQuality();

            // Measure label size
            SizeF s = g.MeasureString(ContentTable[Languages.UsedLanguages[0]], font);

            s = new SizeF((float)Math.Ceiling(s.Width), (float)Math.Ceiling(s.Height));

            g.Dispose();

            // Is Object Vertical
            if (IsVertical)
            {
                s.Flip();
            }

            Bitmap b = new Bitmap((int)s.Width, (int)s.Height);

            g = Graphics.FromImage(b);
            g.ApplyGraphicsQuality();

            Point trans = Point.Empty;
            int   angle = 0;

            if (IsVertical)
            {
                if (!IsTurned180)
                {
                    trans.X = (int)s.Width;
                }
                angle += 90;
            }

            if (IsTurned180)
            {
                if (!IsVertical)
                {
                    trans = new Point((int)s.Width, (int)s.Height);
                }
                else
                {
                    trans.Y = Funcs.ToInt(s.Height);
                }

                angle += 180;
            }

            // Apply transformation when label is rotated
            g.TranslateTransform(trans.X, trans.Y);
            g.RotateTransform(angle);

            // Draw the string
            g.DrawString(ContentTable[Languages.UsedLanguages[0]],
                         font,
                         new SolidBrush(TextColor),
                         Point.Empty);

            // Remove the transformation for next drawing methods
            g.ResetTransform();

            // Draw the anchor point for this label
            if (Config.ShowAnchorPoints)
            {
                if (IsCenter())
                {
                    anchor.X = (int)(s.Width * 0.5F);
                }
                if (IsRight())
                {
                    anchor.X = (int)s.Width - 1;
                }

                if (IsMiddle())
                {
                    anchor.Y = (int)(s.Height * 0.5F);
                }
                if (IsDown())
                {
                    anchor.Y = (int)s.Height - 1;
                }

                g.DrawLine(Config.AnchorPen, anchor.X - Config.ANCHOR_SIZE, anchor.Y, anchor.X + Config.ANCHOR_SIZE, anchor.Y);
                g.DrawLine(Config.AnchorPen, anchor.X, anchor.Y - Config.ANCHOR_SIZE, anchor.X, anchor.Y + Config.ANCHOR_SIZE);
            }

            // Release previous rendered bitmap (A lil bit of memore'h :3)
            if (Holder.Image != null)
            {
                Holder.Image.Dispose();
            }

            // Set Canvas Image
            Holder.Image = b;
            Holder.Size  = Holder.Image.Size;

            base.RenderObject();
        }