コード例 #1
0
        private bool EvalWindow(int hWnd, int lParam)
        {
            if (!User32.IsWindowVisible(hWnd))
            {
                return(true);
            }
            if (this.Handle == new IntPtr(hWnd))
            {
                return(false);
            }

            /*StringBuilder title = new StringBuilder(256);
             * User32.GetWindowText(hWnd, title, 256);
             * if (title.Length == 0) return true;
             * System.Diagnostics.Debug.Print(title.ToString());*/

            /*User32.EnumWindowsProc ewp = new User32.EnumWindowsProc(EvalWindow);
             * User32.EnumChildWindows(hWnd, ewp, 0);*/

            User32.RECT rect = new User32.RECT();
            User32.GetWindowRect(new IntPtr(hWnd), ref rect);
            Rectangle r = GuiRectangle.GetGuiRectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

            windows.Enqueue(new KeyValuePair <int, Rectangle>(hWnd, r));

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// This will create the textbox exactly to the inner size of the element
        /// is a bit of a hack, but for now it seems to work...
        /// </summary>
        private void UpdateTextBoxPosition()
        {
            if (_textBox == null)
            {
                return;
            }
            int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);

            int lineWidth  = (int)Math.Floor(lineThickness / 2d);
            int correction = (lineThickness + 1) % 2;

            if (lineThickness <= 1)
            {
                lineWidth  = 1;
                correction = -1;
            }
            Rectangle absRectangle = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            _textBox.Left = absRectangle.Left + lineWidth;
            _textBox.Top  = absRectangle.Top + lineWidth;
            if (lineThickness <= 1)
            {
                lineWidth = 0;
            }
            _textBox.Width  = absRectangle.Width - 2 * lineWidth + correction;
            _textBox.Height = absRectangle.Height - 2 * lineWidth + correction;
        }
コード例 #3
0
ファイル: TextContainer.cs プロジェクト: sp1r00000/ShareX
        public override bool ClickableAt(int x, int y)
        {
            Rectangle r = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            r.Inflate(5, 5);
            return(r.Contains(x, y));
        }
コード例 #4
0
        /// <summary>
        /// Helper method to create the bubble GraphicsPath, so we can also calculate the bounds
        /// </summary>
        /// <param name="lineThickness"></param>
        /// <returns></returns>
        private GraphicsPath CreateBubble(int lineThickness)
        {
            GraphicsPath bubble = new GraphicsPath();
            Rectangle    rect   = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            Rectangle bubbleRect = GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height);
            // adapt corner radius to small rectangle dimensions
            int smallerSideLength = Math.Min(bubbleRect.Width, bubbleRect.Height);
            int cornerRadius      = Math.Min(30, smallerSideLength / 2 - lineThickness);

            if (cornerRadius > 0)
            {
                bubble.AddArc(bubbleRect.X, bubbleRect.Y, cornerRadius, cornerRadius, 180, 90);
                bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y, cornerRadius, cornerRadius, 270, 90);
                bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 0, 90);
                bubble.AddArc(bubbleRect.X, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 90, 90);
            }
            else
            {
                bubble.AddRectangle(bubbleRect);
            }
            bubble.CloseAllFigures();
            using (Matrix bubbleMatrix = new Matrix())
            {
                bubbleMatrix.Translate(rect.Left, rect.Top);
                bubble.Transform(bubbleMatrix);
            }
            return(bubble);
        }
コード例 #5
0
        void PictureBoxMouseMove(object sender, MouseEventArgs e)
        {
            cursorPos.X = e.X;
            cursorPos.Y = e.Y;

            if (capturingWindows)
            {
                IEnumerator enumerator = windows.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    KeyValuePair <int, Rectangle> kv = (KeyValuePair <int, Rectangle>)enumerator.Current;
                    int       hwnd = kv.Key;
                    Rectangle r    = kv.Value;
                    if (r.Contains(Cursor.Position))
                    {
                        mouseOverHwnd = hwnd;
                        captureRect   = r;
                        break;
                    }
                }
            }
            else if (mouseDown)
            {
                Rectangle r = GuiRectangle.GetGuiRectangle(e.X + this.Left, e.Y + this.Top, mX - e.X, mY - e.Y);
                captureRect = r;
            }

            pictureBox.Invalidate();
        }
コード例 #6
0
        /// <summary>
        /// Override the parent, calculate the label number, than draw
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="rm"></param>
        public override void Draw(Graphics graphics, RenderMode rm)
        {
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.None;
            graphics.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;
            string    text      = ((Surface)Parent).CountStepLabels(this).ToString();
            Rectangle rect      = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
            Color     fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
            Color     lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);

            if (_drawAsRectangle)
            {
                RectangleContainer.DrawRectangle(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
            }
            else
            {
                EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
            }
            using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name))
            {
                using (Font _font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel))
                {
                    TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, _font);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Helper method to create the tail of the bubble, so we can also calculate the bounds
        /// </summary>
        /// <returns></returns>
        private GraphicsPath CreateTail()
        {
            Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            int tailLength = GeometryHelper.Distance2D(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2), TargetGripper.Left, TargetGripper.Top);
            int tailWidth  = (Math.Abs(rect.Width) + Math.Abs(rect.Height)) / 20;

            // This should fix a problem with the tail being to wide
            tailWidth = Math.Min(Math.Abs(rect.Width) / 2, tailWidth);
            tailWidth = Math.Min(Math.Abs(rect.Height) / 2, tailWidth);

            GraphicsPath tail = new GraphicsPath();

            tail.AddLine(-tailWidth, 0, tailWidth, 0);
            tail.AddLine(tailWidth, 0, 0, -tailLength);
            tail.CloseFigure();

            int tailAngle = 90 + (int)GeometryHelper.Angle2D(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2), TargetGripper.Left, TargetGripper.Top);

            using (Matrix tailMatrix = new Matrix())
            {
                tailMatrix.Translate(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
                tailMatrix.Rotate(tailAngle);
                tail.Transform(tailMatrix);
            }

            return(tail);
        }
コード例 #8
0
ファイル: TextContainer.cs プロジェクト: sp1r00000/ShareX
        public override void Draw(Graphics graphics, RenderMode rm)
        {
            base.Draw(graphics, rm);
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.None;
            graphics.TextRenderingHint  = TextRenderingHint.SystemDefault;

            Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            if (Selected && rm == RenderMode.EDIT)
            {
                DrawSelectionBorder(graphics, rect);
            }

            if (text == null || text.Length == 0)
            {
                return;
            }

            // we only draw the shadow if there is no background
            bool  shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            Color fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            bool  drawShadow    = shadow && (fillColor == Color.Transparent || fillColor == Color.Empty);

            DrawText(graphics, rect, lineThickness, lineColor, drawShadow, _stringFormat, text, _font);
        }
コード例 #9
0
        public override bool ClickableAt(int x, int y)
        {
            Rectangle rect                    = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
            int       lineThickness           = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            int       lineThicknessPlusSafety = lineThickness + 10;

            // If we clicked inside the rectangle and it's visible we are clickable at.
            Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);

            if (!Color.Transparent.Equals(fillColor))
            {
                if (Contains(x, y))
                {
                    return(true);
                }
            }

            // check the rest of the lines
            if (lineThicknessPlusSafety > 0)
            {
                using (Pen pen = new Pen(Color.White, lineThicknessPlusSafety))
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddEllipse(rect);
                        return(path.IsOutlineVisible(x, y, pen));
                    }
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #10
0
 // Use this for initialization
 void Start()
 {
     Instance      = this;
     unitManager   = UnitManager.Instance;
     selectionList = new List <ISelectObject>();
     border        = new GuiRectangle(1, 1);
     border.SetColor(Color.yellow);
 }
コード例 #11
0
        public override bool ClickableAt(int x, int y)
        {
            int       lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) + 10;
            Color     fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            Rectangle rect          = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            return(EllipseClickableAt(rect, lineThickness, fillColor, x, y));
        }
コード例 #12
0
ファイル: TextContainer.cs プロジェクト: sisco035/ShareX
 private void UpdateTextBoxPosition()
 {
     Rectangle absRectangle = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
     _textBox.Left = absRectangle.Left;
     _textBox.Top = absRectangle.Top;
     _textBox.Width = absRectangle.Width;
     _textBox.Height = absRectangle.Height;
 }
コード例 #13
0
ファイル: TextContainer.cs プロジェクト: SupremeGenius/espUrl
        public override void Draw(Graphics g, RenderMode rm)
        {
            base.Draw(g, rm);
            UpdateFont();

            Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            if (Selected && rm == RenderMode.EDIT)
            {
                DrawSelectionBorder(g, rect);
            }

            if (text == null || text.Length == 0)
            {
                return;
            }

            // we only draw the shadow if there is no background
            bool  shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            Color fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            int   textOffset    = (lineThickness > 0) ? (int)Math.Ceiling(lineThickness / 2d) : 0;

            // draw shadow before anything else
            if (shadow && (fillColor == Color.Transparent || fillColor == Color.Empty))
            {
                int basealpha   = 100;
                int alpha       = basealpha;
                int steps       = 5;
                int currentStep = 1;
                while (currentStep <= steps)
                {
                    int       offset     = currentStep;
                    Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + offset, Top + offset, Width, Height);
                    if (lineThickness > 0)
                    {
                        shadowRect.Inflate(-textOffset, -textOffset);
                    }
                    using (Brush fontBrush = new SolidBrush(Color.FromArgb(alpha, 100, 100, 100))) {
                        g.DrawString(text, font, fontBrush, shadowRect);
                        currentStep++;
                        alpha = alpha - basealpha / steps;
                    }
                }
            }

            Color     lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
            Rectangle fontRect  = rect;

            if (lineThickness > 0)
            {
                fontRect.Inflate(-textOffset, -textOffset);
            }
            using (Brush fontBrush = new SolidBrush(lineColor)) {
                g.DrawString(text, font, fontBrush, fontRect);
            }
        }
コード例 #14
0
ファイル: RectangleContainer.cs プロジェクト: yoykiee/ShareX
        public override void Draw(Graphics graphics, RenderMode rm)
        {
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.None;

            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            Color fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            bool  shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            bool  lineVisible   = (lineThickness > 0 && Colors.IsVisible(lineColor));

            if (shadow && (lineVisible || Colors.IsVisible(fillColor)))
            {
                //draw shadow first
                int basealpha   = 100;
                int alpha       = basealpha;
                int steps       = 5;
                int currentStep = lineVisible ? 1 : 0;
                while (currentStep <= steps)
                {
                    using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100)))
                    {
                        shadowPen.Width = lineVisible ? lineThickness : 1;
                        Rectangle shadowRect = GuiRectangle.GetGuiRectangle(
                            Left + currentStep,
                            Top + currentStep,
                            Width,
                            Height);
                        graphics.DrawRectangle(shadowPen, shadowRect);
                        currentStep++;
                        alpha = alpha - (basealpha / steps);
                    }
                }
            }

            Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            if (Colors.IsVisible(fillColor))
            {
                using (Brush brush = new SolidBrush(fillColor))
                {
                    graphics.FillRectangle(brush, rect);
                }
            }

            graphics.SmoothingMode = SmoothingMode.HighSpeed;
            if (lineVisible)
            {
                using (Pen pen = new Pen(lineColor, lineThickness))
                {
                    graphics.DrawRectangle(pen, rect);
                }
            }
        }
コード例 #15
0
        public override void Draw(Graphics graphics, RenderMode rm)
        {
            int       lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color     lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            Color     fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            bool      shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            Rectangle rect          = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            DrawRectangle(rect, graphics, rm, lineThickness, lineColor, fillColor, shadow);
        }
コード例 #16
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            Pen pen = new Pen(foreColor);

            pen.Width = thickness;
            Brush     brush = new SolidBrush(backColor);
            Rectangle rect  = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            g.FillRectangle(brush, rect);
            g.DrawRectangle(pen, rect);
        }
コード例 #17
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            if (Selected && rm.Equals(RenderMode.EDIT))
            {
                DrawSelectionBorder(g, rect);
            }
            Brush fontBrush = new SolidBrush(foreColor);

            g.DrawString(childLabel.Text, childLabel.Font, fontBrush, rect);
        }
コード例 #18
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            Pen pen = new Pen(foreColor);

            pen.Width = thickness;
            Brush     brush = new SolidBrush(backColor);
            Rectangle rect  = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            g.FillEllipse(brush, rect);
            g.DrawEllipse(pen, rect);
        }
コード例 #19
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            g.FillRectangle(GetBrush(rect), rect);
            Pen pen = new Pen(foreColor)
            {
                Width = thickness
            };

            g.DrawRectangle(pen, rect);
        }
コード例 #20
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            g.SmoothingMode = SmoothingMode.HighQuality;
            Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            g.FillEllipse(GetBrush(rect), rect);
            Pen pen = new Pen(foreColor)
            {
                Width = thickness
            };

            g.DrawEllipse(pen, rect);
        }
コード例 #21
0
        /// <summary>
        /// This method can be used from other containers
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="drawingRectange"></param>
        /// <param name="lineThickness"></param>
        /// <param name="fontColor"></param>
        /// <param name="drawShadow"></param>
        /// <param name="stringFormat"></param>
        /// <param name="text"></param>
        /// <param name="font"></param>
        public static void DrawText(Graphics graphics, Rectangle drawingRectange, int lineThickness, Color fontColor, bool drawShadow, StringFormat stringFormat, string text, Font font)
        {
#if DEBUG
            Debug.Assert(font != null);
#else
            if (font == null)
            {
                return;
            }
#endif
            int textOffset = lineThickness > 0 ? (int)Math.Ceiling(lineThickness / 2d) : 0;
            // draw shadow before anything else
            if (drawShadow)
            {
                int basealpha   = 100;
                int alpha       = basealpha;
                int steps       = 5;
                int currentStep = 1;
                while (currentStep <= steps)
                {
                    int       offset     = currentStep;
                    Rectangle shadowRect = GuiRectangle.GetGuiRectangle(drawingRectange.Left + offset, drawingRectange.Top + offset, drawingRectange.Width, drawingRectange.Height);
                    if (lineThickness > 0)
                    {
                        shadowRect.Inflate(-textOffset, -textOffset);
                    }
                    using (Brush fontBrush = new SolidBrush(Color.FromArgb(alpha, 100, 100, 100)))
                    {
                        graphics.DrawString(text, font, fontBrush, shadowRect, stringFormat);
                        currentStep++;
                        alpha = alpha - basealpha / steps;
                    }
                }
            }

            if (lineThickness > 0)
            {
                drawingRectange.Inflate(-textOffset, -textOffset);
            }
            using (Brush fontBrush = new SolidBrush(fontColor))
            {
                if (stringFormat != null)
                {
                    graphics.DrawString(text, font, fontBrush, drawingRectange, stringFormat);
                }
                else
                {
                    graphics.DrawString(text, font, fontBrush, drawingRectange);
                }
            }
        }
コード例 #22
0
        public override void Draw(Graphics graphics, RenderMode renderMode)
        {
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;

            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            Color fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            bool  shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            bool  lineVisible   = (lineThickness > 0 && Colors.IsVisible(lineColor));

            // draw shadow before anything else
            if (shadow && (lineVisible || Colors.IsVisible(fillColor)))
            {
                int basealpha   = 100;
                int alpha       = basealpha;
                int steps       = 5;
                int currentStep = lineVisible ? 1 : 0;
                while (currentStep <= steps)
                {
                    using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
                        shadowPen.Width = lineVisible ? lineThickness : 1;
                        Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + currentStep, Top + currentStep, Width, Height);
                        graphics.DrawEllipse(shadowPen, shadowRect);
                        currentStep++;
                        alpha = alpha - basealpha / steps;
                    }
                }
            }

            //draw the original shape
            Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            if (!Color.Transparent.Equals(fillColor))
            {
                using (Brush brush = new SolidBrush(fillColor)) {
                    graphics.FillEllipse(brush, rect);
                }
            }

            using (Pen pen = new Pen(lineColor)) {
                pen.Width = lineThickness;
                if (pen.Width > 0)
                {
                    graphics.DrawEllipse(pen, rect);
                }
            }
        }
コード例 #23
0
        public override bool ClickableAt(int x, int y)
        {
            Rectangle rect      = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
            Color     fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);

            if (_drawAsRectangle)
            {
                return(RectangleContainer.RectangleClickableAt(rect, 0, fillColor, x, y));
            }
            else
            {
                return(EllipseContainer.EllipseClickableAt(rect, 0, fillColor, x, y));
            }
        }
コード例 #24
0
        /// <summary>
        /// This method can also be used from other containers, if the right values are passed!
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="graphics"></param>
        /// <param name="rm"></param>
        /// <param name="lineThickness"></param>
        /// <param name="lineColor"></param>
        /// <param name="fillColor"></param>
        /// <param name="shadow"></param>
        public static void DrawRectangle(Rectangle rect, Graphics graphics, RenderMode rm, int lineThickness, Color lineColor, Color fillColor, bool shadow)
        {
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.None;

            bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));

            if (shadow && (lineVisible || Colors.IsVisible(fillColor)))
            {
                //draw shadow first
                int basealpha   = 100;
                int alpha       = basealpha;
                int steps       = 5;
                int currentStep = lineVisible ? 1 : 0;
                while (currentStep <= steps)
                {
                    using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100)))
                    {
                        shadowPen.Width = lineVisible ? lineThickness : 1;
                        Rectangle shadowRect = GuiRectangle.GetGuiRectangle(
                            rect.Left + currentStep,
                            rect.Top + currentStep,
                            rect.Width,
                            rect.Height);
                        graphics.DrawRectangle(shadowPen, shadowRect);
                        currentStep++;
                        alpha = alpha - (basealpha / steps);
                    }
                }
            }

            if (Colors.IsVisible(fillColor))
            {
                using (Brush brush = new SolidBrush(fillColor))
                {
                    graphics.FillRectangle(brush, rect);
                }
            }

            graphics.SmoothingMode = SmoothingMode.HighSpeed;
            if (lineVisible)
            {
                using (Pen pen = new Pen(lineColor, lineThickness))
                {
                    graphics.DrawRectangle(pen, rect);
                }
            }
        }
コード例 #25
0
        public override void Draw(Graphics graphics, RenderMode renderMode)
        {
            graphics.SmoothingMode      = SmoothingMode.HighQuality;
            graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.PixelOffsetMode    = PixelOffsetMode.None;

            int       lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color     lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            Color     fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            bool      shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            Rectangle rect          = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            DrawEllipse(rect, graphics, renderMode, lineThickness, lineColor, fillColor, shadow);
        }
コード例 #26
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            int   lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
            Color lineColor     = GetFieldValueAsColor(FieldType.LINE_COLOR);
            Color fillColor     = GetFieldValueAsColor(FieldType.FILL_COLOR);
            bool  shadow        = GetFieldValueAsBool(FieldType.SHADOW);
            bool  lineVisible   = (lineThickness > 0 && Colors.IsVisible(lineColor));

            if (shadow && (lineVisible || Colors.IsVisible(fillColor)))
            {
                //draw shadow first
                int basealpha   = 100;
                int alpha       = basealpha;
                int steps       = 5;
                int currentStep = lineVisible ? 1 : 0;
                while (currentStep <= steps)
                {
                    using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
                        shadowPen.Width = lineVisible ? lineThickness : 1;
                        Rectangle shadowRect = GuiRectangle.GetGuiRectangle(
                            this.Left + currentStep,
                            this.Top + currentStep,
                            this.Width,
                            this.Height);
                        g.DrawRectangle(shadowPen, shadowRect);
                        currentStep++;
                        alpha = alpha - (basealpha / steps);
                    }
                }
            }

            Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);

            if (!Color.Transparent.Equals(fillColor))
            {
                using (Brush brush = new SolidBrush(fillColor)) {
                    g.FillRectangle(brush, rect);
                }
            }

            if (lineThickness > 0)
            {
                using (Pen pen = new Pen(lineColor)) {
                    pen.Width = lineThickness;
                    g.DrawRectangle(pen, rect);
                }
            }
        }
コード例 #27
0
        /// <summary>
        /// Make sure the size of the font is scaled
        /// </summary>
        /// <param name="matrix"></param>
        public override void Transform(Matrix matrix)
        {
            Rectangle rect         = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
            int       widthBefore  = rect.Width;
            int       heightBefore = rect.Height;

            // Transform this container
            base.Transform(matrix);
            rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            int   widthAfter  = rect.Width;
            int   heightAfter = rect.Height;
            float factor      = ((float)widthAfter / widthBefore + (float)heightAfter / heightBefore) / 2;

            fontSize *= factor;
        }
コード例 #28
0
ファイル: TextContainer.cs プロジェクト: sp1r00000/ShareX
        /// <summary>
        /// Make sure the size of the font is scaled
        /// </summary>
        /// <param name="matrix"></param>
        public override void Transform(Matrix matrix)
        {
            Rectangle rect         = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
            int       pixelsBefore = rect.Width * rect.Height;

            // Transform this container
            base.Transform(matrix);
            rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);

            int   pixelsAfter = rect.Width * rect.Height;
            float factor      = pixelsAfter / (float)pixelsBefore;

            float fontSize = GetFieldValueAsFloat(FieldType.FONT_SIZE);

            fontSize *= factor;
            SetFieldValue(FieldType.FONT_SIZE, fontSize);
            UpdateFormat();
        }
コード例 #29
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            using (Brush cropBrush = new SolidBrush(Color.FromArgb(100, 150, 150, 100))) {
                Rectangle r             = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
                Rectangle selectionRect = new Rectangle(r.Left - 1, r.Top - 1, r.Width + 1, r.Height + 1);

                DrawSelectionBorder(g, selectionRect);

                // top
                g.FillRectangle(cropBrush, new Rectangle(0, 0, parent.Width, r.Top));
                // left
                g.FillRectangle(cropBrush, new Rectangle(0, r.Top, r.Left, r.Height));
                // right
                g.FillRectangle(cropBrush, new Rectangle(r.Left + r.Width, r.Top, parent.Width - (r.Left + r.Width), r.Height));
                // bottom
                g.FillRectangle(cropBrush, new Rectangle(0, r.Top + r.Height, parent.Width, parent.Height - (r.Top + r.Height)));
            }
        }
コード例 #30
0
        public override void Draw(Graphics g, RenderMode rm)
        {
            using (Brush cropBrush = new SolidBrush(Color.FromArgb(100, 150, 150, 100))) {
                Rectangle cropRectangle = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
                Rectangle selectionRect = new Rectangle(cropRectangle.Left - 1, cropRectangle.Top - 1, cropRectangle.Width + 1, cropRectangle.Height + 1);

                DrawSelectionBorder(g, selectionRect);

                // top
                g.FillRectangle(cropBrush, new Rectangle(0, 0, _parent.Width, cropRectangle.Top));
                // left
                g.FillRectangle(cropBrush, new Rectangle(0, cropRectangle.Top, cropRectangle.Left, cropRectangle.Height));
                // right
                g.FillRectangle(cropBrush, new Rectangle(cropRectangle.Left + cropRectangle.Width, cropRectangle.Top, _parent.Width - (cropRectangle.Left + cropRectangle.Width), cropRectangle.Height));
                // bottom
                g.FillRectangle(cropBrush, new Rectangle(0, cropRectangle.Top + cropRectangle.Height, _parent.Width, _parent.Height - (cropRectangle.Top + cropRectangle.Height)));
            }
        }