public RoundedRectangleF(float x, float y, float width, float height, float radiusX, float radiusY)
 {
     InternalRoundedRectangle = new RoundedRectangle();
     Left = x;
     Top = y;
     Right = Left + width;
     Bottom = Top + height;
     RadiusX = radiusX;
     RadiusY = radiusY;
 }
 public RoundedRectangleF(float x, float y, SizeF size, SizeF radius)
 {
     InternalRoundedRectangle = new RoundedRectangle();
     Left = x;
     Top = y;
     Right = Left + size.Width;
     Bottom = Top + size.Height;
     RadiusX = radius.Width;
     RadiusY = radius.Height;
 }
Beispiel #3
0
 /* CONSTRUCTOR & DESTRUCTOR METHODS */
 /// <summary>
 /// Constructs a generic 2D rectangular panel that will be displayed as a flat, image-like rendering in the 3D rendering window.
 /// </summary>
 /// <param name="window">A reference to a Direct3D-capable rendering window in which this entity will be displayed.</param>
 protected Panel(Window3D window)
     : base(window)
 {
     BackgroundBrush = Tag(new SolidColorBrush(RenderTarget, Color.SlateGray));
     BorderBrush = Tag(new SolidColorBrush(RenderTarget, Color.SlateGray));
     Rectangle = new RoundedRectangle()
     {
         RadiusX = 0f,
         RadiusY = 0f,
         Rect = new RectangleF(0, 0, 100, 100),
     };
 }
 /// <summary>	
 ///  Creates an <see cref="SharpDX.Direct2D1.RoundedRectangleGeometry"/>. 	
 /// </summary>	
 /// <param name="factory">an instance of <see cref = "SharpDX.Direct2D1.Factory" /></param>
 /// <param name="roundedRectangle">The coordinates and corner radii of the rounded rectangle geometry.</param>
 public RoundedRectangleGeometry(Factory factory, RoundedRectangle roundedRectangle)
     : base(IntPtr.Zero)
 {
     factory.CreateRoundedRectangleGeometry(ref roundedRectangle, this);
 }
Beispiel #5
0
 /// <summary>	
 /// Paints the interior of the specified rounded rectangle.	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{FillRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="roundedRect">The dimensions of the rounded rectangle to paint, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the interior of the rounded rectangle. </param>
 /// <unmanaged>void ID2D1RenderTarget::FillRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush)</unmanaged>
 public void FillRoundedRectangle(RoundedRectangle roundedRect, Brush brush)
 {
     FillRoundedRectangle(ref roundedRect, brush);
 }
Beispiel #6
0
 /// <summary>	
 /// Draws the outline of the specified rounded rectangle.	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="roundedRect">The dimensions of the rounded rectangle to draw, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the rounded rectangle's outline.  </param>
 /// <param name="strokeWidth">The width of the rounded rectangle's stroke. The stroke is centered on the rounded rectangle's outline. The default value is 1.0f.  </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>
 public void DrawRoundedRectangle(RoundedRectangle roundedRect, Brush brush, float strokeWidth)
 {
     DrawRoundedRectangle(ref roundedRect, brush, strokeWidth, null);
 }
 /// <summary>
 ///  Creates an <see cref="SharpDX.Direct2D1.RoundedRectangleGeometry"/>.
 /// </summary>
 /// <param name="factory">an instance of <see cref = "SharpDX.Direct2D1.Factory" /></param>
 /// <param name="roundedRectangle">The coordinates and corner radii of the rounded rectangle geometry.</param>
 public RoundedRectangleGeometry(Factory factory, RoundedRectangle roundedRectangle)
     : base(IntPtr.Zero)
 {
     factory.CreateRoundedRectangleGeometry(ref roundedRectangle, this);
 }
Beispiel #8
0
        public OverlayForm()
        {
            InitializeComponent();

            // ANTI BATTLEYE SIG SCAN ;)
            this.Text = Guid.NewGuid().ToString().Replace("-", "");

            // TRANSPARENCY KEY
            this.BackColor = System.Drawing.Color.Black;

            // SETTINGS
            this.FormBorderStyle = FormBorderStyle.None;
            this.ShowIcon        = false;
            this.ShowInTaskbar   = false;
            this.TopMost         = true;
            this.WindowState     = FormWindowState.Maximized;

            // MAKE WINDOW TRANSPARENT
            Win32.SetWindowLong(this.Handle, Win32.GWL_EXSTYLE, (IntPtr)(Win32.GetWindowLong(this.Handle, Win32.GWL_EXSTYLE) ^ Win32.WS_EX_LAYERED ^ Win32.WS_EX_TRANSPARENT));

            // MAKE WINDOW SOLID
            Win32.SetLayeredWindowAttributes(this.Handle, 0, 255, Win32.LWA_ALPHA);

            var targetProperties = new HwndRenderTargetProperties
            {
                Hwnd           = this.Handle,
                PixelSize      = new Size2(this.Bounds.Right - this.Bounds.Left, this.Bounds.Bottom - this.Bounds.Top),
                PresentOptions = PresentOptions.Immediately
            };

            var prop = new RenderTargetProperties(RenderTargetType.Hardware, new PixelFormat(Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);

            var d3dFactory = new SharpDX.Direct2D1.Factory();

            var device = new WindowRenderTarget(d3dFactory, prop, targetProperties)
            {
                TextAntialiasMode = TextAntialiasMode.Cleartype,
                AntialiasMode     = AntialiasMode.Aliased
            };

            var dxthread = new Thread(() =>
            {
                var brushWhite  = new SolidColorBrush(device, RawColorFromColor(Color.White));
                var brushBlack  = new SolidColorBrush(device, RawColorFromColor(Color.Black));
                var brushGreen  = new SolidColorBrush(device, RawColorFromColor(Color.Green));
                var brushRed    = new SolidColorBrush(device, RawColorFromColor(Color.Red));
                var brushPurple = new SolidColorBrush(device, RawColorFromColor(Color.Purple));

                var fontFactory = new SharpDX.DirectWrite.Factory();

                var fontConsolas = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 15);
                var fontESP      = new SharpDX.DirectWrite.TextFormat(fontFactory, "Consolas", 10);

                while (true)
                {
                    device.BeginDraw();
                    device.Clear(null);

                    if (CheatSettings.Visuals)
                    {
                        var ulocalplayer     = G.OwningGameInstance.LocalPlayer;
                        var localplayer      = AActor.GetLocalPlayer();
                        var vecLocalLocation = localplayer.Location;

                        //DrawText($"BodyHitImpact: {localplayer.WeaponProcessor.EquippedWeapons.ReadValue(0, true).WeaponConfig.PhysicalBodyHitImpactPower}", 50, 50, brushWhite, fontFactory, fontESP, device);

                        #region RADAR
                        int radarX          = 20;
                        int radarY          = 140;
                        int radarSize       = 200;
                        int radarBorder     = 1;
                        Vector2 centerpoint = new Vector2(radarX + radarSize / 2, radarY + radarSize / 2);

                        // TODO: INTEGRATE INTO MINIMAP
                        if (CheatSettings.RadarESP)
                        {
                            var radarOuterRectangle = new RawRectangleF(radarX, radarY, radarX + radarSize, radarY + radarSize);
                            var radarRectangle      = new RawRectangleF(radarX + radarBorder, radarY + radarBorder, radarX + radarSize - radarBorder, radarY + radarSize - radarBorder);

                            var radarCenterRectangle = new RoundedRectangle()
                            {
                                RadiusX = 4,
                                RadiusY = 4,
                                Rect    = new RawRectangleF(centerpoint.X, centerpoint.Y, centerpoint.X + 4, centerpoint.Y + 4)
                            };

                            device.FillRectangle(radarRectangle, brushBlack);
                            device.DrawRectangle(radarRectangle, brushWhite);

                            device.FillRoundedRectangle(radarCenterRectangle, brushGreen);
                        }
                        #endregion

                        #region DEBUG
                        if (CheatSettings.LogIDs)
                        {
                            foreach (var Actor in G.Entities.ToList())
                            {
                                var vecActorLocation = Actor.Location;
                                var vecRelativePos   = vecLocalLocation - vecActorLocation;

                                Vector2 screenlocation;
                                WorldToScreen(vecActorLocation, ulocalplayer.PlayerController.PlayerCameraManager, out screenlocation);

                                DrawText($"[{Actor.Id}] {G.Names[Actor.Id]}", (int)screenlocation.X, (int)screenlocation.Y, brushWhite, fontFactory, fontESP, device);
                            }
                        }
                        #endregion

                        #region VEHICLE ESP
                        if (CheatSettings.VehicleESP)
                        {
                            foreach (var Actor in G.Vehicles.ToList())
                            {
                                var vecActorLocation = Actor.Location;
                                var vecRelativePos   = vecLocalLocation - vecActorLocation;
                                var lDeltaInMeters   = vecRelativePos.Length / 100;

                                Vector2 screenlocation;
                                WorldToScreen(vecActorLocation, ulocalplayer.PlayerController.PlayerCameraManager, out screenlocation);

                                /*
                                 * UAZ: 76152 - 76156 - 76166 - 76165
                                 * Dacia: 75657 - 75653 - 75665 - 75679
                                 * Buggy: 75371 - 75375 - 75379
                                 * Jeep: 76157
                                 * Motorbike: 75820
                                 * Boat: 75301
                                 */

                                string szVehicleName = string.Empty;

                                switch (Actor.Id)
                                {
                                /*UAZ*/
                                case 76152:
                                case 76156:
                                case 76166:
                                case 76165:
                                case 76169:
                                    szVehicleName = "UAZ";
                                    break;

                                /*Dacia*/
                                case 75657:
                                case 75653:
                                case 75665:
                                case 75679:
                                case 75675:
                                    szVehicleName = "Dacia";
                                    break;

                                /*Buggy*/
                                case 75371:
                                case 75375:
                                case 75379:
                                case 75401:
                                    szVehicleName = "Buggy";
                                    break;

                                /*Jeep*/
                                case 76157:
                                    szVehicleName = "Jeep";
                                    break;

                                /*Boat*/
                                case 75301:
                                    szVehicleName = "Boat";
                                    break;

                                /*Motorbike*/
                                case 75820:
                                    szVehicleName = "Motorbike";
                                    break;
                                }

                                if (szVehicleName != string.Empty)
                                {
                                    DrawText($"[{szVehicleName}] {(int)lDeltaInMeters}m", (int)screenlocation.X, (int)screenlocation.Y, brushRed, fontFactory, fontESP, device);
                                }
                            }
                        }
                        #endregion

                        #region LOOT ESP
                        // Doesnt work
                        if (CheatSettings.LootESP)
                        {
                            foreach (var DroppedItemGroup in G.Entities.ToList().Where(x => x.IsDroppedItemGroup))
                            {
                                TArray <pADroppedItem> array = DroppedItemGroup.DroppedItemArray;

                                for (int nIndex = 0; nIndex < array.Count; nIndex++)
                                {
                                    var item  = array.ReadValue(nIndex, false);
                                    var actor = M.Read <AActor>(item.pActor);

                                    if (actor.IsDroppedItemInteractionComponent)
                                    {
                                        var vecItemLocation = DroppedItemGroup.RootComponent.RelativeLocation + M.Read <Vector3>(actor.BasePointer + 0x0230);
                                        var pUItem          = M.Read <IntPtr>(actor.BasePointer + 0x0220);
                                        string szName       = M.Read <FText>(pUItem + 0x0040).fstring.ToString();

                                        Vector2 screenlocation;
                                        WorldToScreen(vecItemLocation, ulocalplayer.PlayerController.PlayerCameraManager, out screenlocation);
                                        DrawText(szName, (int)screenlocation.X, (int)screenlocation.Y, brushWhite, fontFactory, fontESP, device);
                                        Console.WriteLine($"Drawing {szName}/{G.Names[actor.Id]} at {vecItemLocation}");
                                    }
                                }
                            }
                        }
                        #endregion

                        #region PlAYER LOOP
                        if (CheatSettings.DistanceESP || CheatSettings.RadarESP || CheatSettings.LineESP)
                        {
                            var vecLocalEyeLocation = localplayer.EyeLocation;
                            var myangles            = ulocalplayer.PlayerController.ControlRotation;

                            foreach (var player in G.Players.ToList())
                            {
                                var vecPlayerLocation = player.Location;
                                var vecRelativePos    = vecLocalLocation - vecPlayerLocation;
                                var lDeltaInMeters    = vecRelativePos.Length / 100;

                                #region Line ESP
                                if (CheatSettings.LineESP)
                                {
                                    Vector2 screenlocation;
                                    WorldToScreen(vecPlayerLocation, ulocalplayer.PlayerController.PlayerCameraManager, out screenlocation);

                                    device.DrawLine(new RawVector2(1920 / 2, 1080), new RawVector2(screenlocation.X, screenlocation.Y), brushWhite);
                                }
                                #endregion

                                #region Distance ESP
                                if (CheatSettings.DistanceESP)
                                {
                                    Vector2 screenlocation;
                                    WorldToScreen(vecPlayerLocation, ulocalplayer.PlayerController.PlayerCameraManager, out screenlocation);

                                    DrawText($"[Player] {(int)lDeltaInMeters}m", (int)screenlocation.X, (int)screenlocation.Y, brushPurple, fontFactory, fontESP, device);
                                }
                                #endregion

                                #region Radar
                                if (CheatSettings.RadarESP)
                                {
                                    if (lDeltaInMeters <= radarSize / 2 /*DISTANCE FROM CENTER TO EDGE*/)
                                    {
                                        Vector2 screenpos = centerpoint + vecRelativePos.To2D() / 100;

                                        var radarPlayerRectangle = new RoundedRectangle()
                                        {
                                            RadiusX = 4,
                                            RadiusY = 4,
                                            Rect    = new RawRectangleF(screenpos.X, screenpos.Y, screenpos.X + 5, screenpos.Y + 5)
                                        };

                                        // DRAW ENEMY
                                        device.FillRoundedRectangle(radarPlayerRectangle, brushRed);
                                    }
                                }
                                #endregion
                            }
                        }
                        #endregion
                    }

                    // DRAW END
                    device.EndDraw();

                    Thread.Sleep(1000 / 60);
                }
            });

            dxthread.IsBackground = true;
            dxthread.Start();

            var marg = new Win32.Margins();

            marg.Left   = 0;
            marg.Top    = 0;
            marg.Right  = this.Width;
            marg.Bottom = this.Height;
            Win32.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
        }
Beispiel #9
0
 /// <summary>
 ///  Draws the outline of the specified rounded rectangle</summary>
 /// <param name="roundedRect">The dimensions of the rounded rectangle to draw, in pixels</param>
 /// <param name="brush">The brush used to paint the rounded rectangle's outline</param>
 /// <param name="strokeWidth">The width of the rounded rectangle's stroke. The stroke is centered on the
 /// rounded rectangle's outline.</param>
 /// <param name="strokeStyle">The style of the rounded rectangle's stroke, or null to paint a solid stroke</param>
 public void DrawRoundedRectangle(D2dRoundedRect roundedRect, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
 {
     var roundrect = new RoundedRectangle();
     roundrect.RadiusX = roundedRect.RadiusX;
     roundrect.RadiusY = roundedRect.RadiusY;
     roundrect.Rect.Top = roundedRect.Rect.Top;
     roundrect.Rect.Left = roundedRect.Rect.Left;
     roundrect.Rect.Right = roundedRect.Rect.Right;
     roundrect.Rect.Bottom = roundedRect.Rect.Bottom;
     m_renderTarget.DrawRoundedRectangle(roundrect, brush.NativeBrush, strokeWidth,
         strokeStyle != null ? strokeStyle.NativeStrokeStyle : null);
 }
Beispiel #10
0
 public void DrawRoundedRectangle(RoundedRectangle roundedRect, Brush brush) => _renderTarget?.DrawRoundedRectangle(roundedRect, brush);
Beispiel #11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            label1.MaximumSize = new Size((this.Width - panel1.Width - 21) / 2, 0);
            label1.Width       = this.Width - panel1.Width - 21;

            //if (label1.Height < panel2.Height + 1)
            //{
            //    this.MinimumSize = new Size(0, panel2.Height + 11);
            //    this.Height = panel2.Height + 11;
            //}
            //else
            //{
            //    this.MinimumSize = new Size(0, label1.Height + 20);
            //    this.Height = label1.Height + 20;
            //}
            if (label1.Height < panel2.Height + 1)
            {
                this.MinimumSize = new Size(0, panel2.Height + 11 + 15);
                this.Height      = panel2.Height + 11 + 15;
            }
            else
            {
                this.MinimumSize = new Size(0, label1.Height + 10 + 15);
                this.Height      = label1.Height + 10 + 15;
            }

            if (!isAdded)
            {
                messageBottom.Size      = new Size(0, 15);
                messageBottom.Dock      = DockStyle.Bottom;
                messageBottom.Padding   = new Padding(47, 0, 0, 0);
                messageBottom.BackColor = Color.Transparent;
                messageBottom.ForeColor = Color.White;

                time.Dock = DockStyle.Left;
                SetTimeWidth();

                msgStatus.Dock     = DockStyle.Left;
                msgStatus.SizeMode = PictureBoxSizeMode.StretchImage;
                msgStatus.Size     = new Size(15, 15);


                messageBottom.Controls.Add(msgStatus);
                messageBottom.Controls.Add(time);


                this.Controls.Add(messageBottom);
                SetMsgStatus();
                isAdded = true;
            }

            GraphicsPath gr = RoundedRectangle.Create(panel2.ClientRectangle, 16, RoundedRectangle.RectangleCorners.All);

            panel2.Region = new Region(gr);

            GraphicsPath gr1 = RoundedRectangle.Create(pictureBox1.ClientRectangle, 16, RoundedRectangle.RectangleCorners.All);

            pictureBox1.Region = new Region(gr1);

            GraphicsPath path = RoundedRectangle.Create(label1.ClientRectangle, 5, RoundedRectangle.RectangleCorners.All);

            label1.Region = new Region(path);

            base.OnPaint(e);
        }
        public override void Draw(Graphics gr)
        {
            string PlayerA = FMatch.PlayerA.Label;
            string PlayerB = FMatch.PlayerB.Label;

            Font      FontA        = null;
            Font      FontB        = null;
            FontStyle winner_style = FontStyle.Bold;
            FontStyle looser_style = FontStyle.Regular;
            FontStyle normal_style = FontStyle.Regular;
            Font      winner_font  = new Font(SwissPainterSettings.FontFamily, SwissPainterSettings.FontSize, winner_style);
            Font      looser_font  = new Font(SwissPainterSettings.FontFamily, SwissPainterSettings.FontSize, looser_style);
            Font      normal_font  = new Font(SwissPainterSettings.FontFamily, SwissPainterSettings.FontSize, normal_style);

            switch (FMatch.Winner)
            {
            case MatchLabel.PlayerLetters.A:
                FontA     = winner_font;
                FontB     = looser_font;
                BackColor = SwissPainterSettings.MatchLabelColors.Finished;
                break;

            case MatchLabel.PlayerLetters.B:
                FontA     = looser_font;
                FontB     = winner_font;
                BackColor = SwissPainterSettings.MatchLabelColors.Finished;
                break;

            case MatchLabel.PlayerLetters.Draw:
                FontA     = winner_font;
                FontB     = winner_font;
                BackColor = SwissPainterSettings.MatchLabelColors.Finished;
                break;

            case MatchLabel.PlayerLetters.Unknown:
                FontA     = normal_font;
                FontB     = normal_font;
                BackColor = SwissPainterSettings.MatchLabelColors.Started;
                break;
            }

            //int match_label_width = SwissPainterSettings.Scaled(30);

            //------------------------------------------------------------------------------------
            SmoothingMode sm = gr.SmoothingMode;

            gr.SmoothingMode = SmoothingMode.HighQuality;
            int x = Left; int y = Top;
            int small_width = SwissPainterSettings.PointsWidth;
            int large_width = SwissPainterSettings.NameWidth;
            int distance    = SwissPainterSettings.Distance;
            int h           = Size.Height;
            int sStep       = SwissPainterSettings.ShadowStep;

            GraphicsPath shadowPath = RoundedRectangle.Create(x + sStep, y + sStep, small_width, h);

            shadowPath.AddPath(RoundedRectangle.Create(x + (small_width + distance) + sStep, y + sStep, large_width, h), true);
            shadowPath.AddPath(RoundedRectangle.Create(x + (small_width + large_width + distance * 2) + sStep, y + sStep, small_width, h), true);
            shadowPath.AddPath(RoundedRectangle.Create(x + (small_width * 2 + large_width + distance * 3) + sStep, y + sStep, small_width, h), true);
            shadowPath.AddPath(RoundedRectangle.Create(x + (small_width * 3 + large_width + distance * 4) + sStep, y + sStep, large_width, h), true);
            gr.FillPath(new SolidBrush(SwissPainterSettings.ShadowColor), shadowPath);

            GraphicsPath boxPath = RoundedRectangle.Create(x, y, small_width, h);

            boxPath.AddPath(RoundedRectangle.Create(x + (small_width + distance), y, large_width, h), true);
            boxPath.AddPath(RoundedRectangle.Create(x + (small_width + large_width + distance * 2), y, small_width, h), true);
            boxPath.AddPath(RoundedRectangle.Create(x + (small_width * 2 + large_width + distance * 3), y, small_width, h), true);
            boxPath.AddPath(RoundedRectangle.Create(x + (small_width * 3 + large_width + distance * 4), y, large_width, h), true);
            gr.FillPath(new SolidBrush(BackColor), boxPath);
            gr.DrawPath(new Pen(SwissPainterSettings.BorderColor), boxPath);
            gr.SmoothingMode = sm;

            int    textTop     = SwissPainterSettings.Scaled(2) + Top;
            string match_label = Match.Label.MatchNo.ToString();
            Size   ls          = Size.Round(gr.MeasureString(match_label, normal_font));
            Brush  text_brush  = new SolidBrush(SwissPainterSettings.MatchLabelColors.ForeColor);

            gr.DrawString(match_label, normal_font, text_brush, new Point(x + (small_width - ls.Width) / 2, textTop));

            gr.DrawString(PlayerA, FontA, text_brush, new Point(x + small_width + distance + SwissPainterSettings.Scaled(3), textTop));

            SizeF playerBsize = gr.MeasureString(PlayerB, FontB);

            gr.DrawString(PlayerB, FontB, text_brush, new PointF(x + Size.Width - playerBsize.Width - SwissPainterSettings.Scaled(3), textTop));

            if (FMatch.Winner == MatchLabel.PlayerLetters.Unknown)
            {
                return;
            }

            SizeF pointsASize = gr.MeasureString(PointsA, FontA);

            gr.DrawString(PointsA, FontA, text_brush, new PointF(x + small_width + large_width + distance * 2 + (small_width - 3 - pointsASize.Width) / 2, textTop));

            SizeF pointsBSize = gr.MeasureString(PointsB, FontB);

            gr.DrawString(PointsB, FontB, text_brush, new PointF(x + small_width * 2 + large_width + distance * 3 + (small_width - 3 - pointsBSize.Width) / 2, textTop));
        }
 protected override void OnSizeChanged(EventArgs e)
 {
     base.OnSizeChanged(e);
     UpdateGraphics();
     _path = RoundedRectangle.Create(0, 0, this.Width - 1, this.Height - 3, 2);
 }
Beispiel #14
0
 public RoundedRectangleGeometry(RoundedRectangle roundedRectangle)
 {
     _roundedRectangle = roundedRectangle;
     InitializeShape();
 }
Beispiel #15
0
        /// <summary>
        /// Paint the actual visible parts
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnPaint(object sender, PaintEventArgs e)
        {
            Graphics  graphics      = e.Graphics;
            Rectangle clipRectangle = e.ClipRectangle;

            //graphics.BitBlt((Bitmap)buffer, Point.Empty);
            graphics.DrawImageUnscaled(_capture.Image, Point.Empty);
            // Only draw Cursor if it's (partly) visible
            if (_capture.Cursor != null && _capture.CursorVisible && clipRectangle.IntersectsWith(new Rectangle(_capture.CursorLocation, _capture.Cursor.Size)))
            {
                graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y);
            }

            if (_mouseDown || _captureMode == CaptureMode.Window || isAnimating(_windowAnimator))
            {
                _captureRect.Intersect(new Rectangle(Point.Empty, _capture.ScreenBounds.Size));                 // crop what is outside the screen

                Rectangle fixedRect;
                //if (captureMode == CaptureMode.Window) {
                if (isAnimating(_windowAnimator))
                {
                    // Use the animator
                    fixedRect = _windowAnimator.Current;
                }
                else
                {
                    fixedRect = _captureRect;
                }

                // TODO: enable when the screen capture code works reliable
                //if (capture.CaptureDetails.CaptureMode == CaptureMode.Video) {
                //	graphics.FillRectangle(RedOverlayBrush, fixedRect);
                //} else {
                graphics.FillRectangle(GreenOverlayBrush, fixedRect);
                //}
                graphics.DrawRectangle(OverlayPen, fixedRect);

                // rulers
                const int dist = 8;

                string captureWidth;
                string captureHeight;
                // The following fixes the very old incorrect size information bug
                if (_captureMode == CaptureMode.Window)
                {
                    captureWidth  = _captureRect.Width.ToString(CultureInfo.InvariantCulture);
                    captureHeight = _captureRect.Height.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    captureWidth  = (_captureRect.Width + 1).ToString(CultureInfo.InvariantCulture);
                    captureHeight = (_captureRect.Height + 1).ToString(CultureInfo.InvariantCulture);
                }
                using (Font rulerFont = new Font(FontFamily.GenericSansSerif, 8)) {
                    Size  measureWidth  = TextRenderer.MeasureText(captureWidth, rulerFont);
                    Size  measureHeight = TextRenderer.MeasureText(captureHeight, rulerFont);
                    int   hSpace        = measureWidth.Width + 3;
                    int   vSpace        = measureHeight.Height + 3;
                    Brush bgBrush       = new SolidBrush(Color.FromArgb(200, 217, 240, 227));
                    Pen   rulerPen      = new Pen(Color.SeaGreen);

                    // horizontal ruler
                    if (fixedRect.Width > hSpace + 3)
                    {
                        using (GraphicsPath p = RoundedRectangle.Create2(
                                   fixedRect.X + (fixedRect.Width / 2 - hSpace / 2) + 3,
                                   fixedRect.Y - dist - 7,
                                   measureWidth.Width - 3,
                                   measureWidth.Height,
                                   3)) {
                            graphics.FillPath(bgBrush, p);
                            graphics.DrawPath(rulerPen, p);
                            graphics.DrawString(captureWidth, rulerFont, rulerPen.Brush, fixedRect.X + (fixedRect.Width / 2 - hSpace / 2) + 3, fixedRect.Y - dist - 7);
                            graphics.DrawLine(rulerPen, fixedRect.X, fixedRect.Y - dist, fixedRect.X + (fixedRect.Width / 2 - hSpace / 2), fixedRect.Y - dist);
                            graphics.DrawLine(rulerPen, fixedRect.X + (fixedRect.Width / 2 + hSpace / 2), fixedRect.Y - dist, fixedRect.X + fixedRect.Width, fixedRect.Y - dist);
                            graphics.DrawLine(rulerPen, fixedRect.X, fixedRect.Y - dist - 3, fixedRect.X, fixedRect.Y - dist + 3);
                            graphics.DrawLine(rulerPen, fixedRect.X + fixedRect.Width, fixedRect.Y - dist - 3, fixedRect.X + fixedRect.Width, fixedRect.Y - dist + 3);
                        }
                    }

                    // vertical ruler
                    if (fixedRect.Height > vSpace + 3)
                    {
                        using (GraphicsPath p = RoundedRectangle.Create2(
                                   fixedRect.X - measureHeight.Width + 1,
                                   fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2) + 2,
                                   measureHeight.Width - 3,
                                   measureHeight.Height - 1,
                                   3)) {
                            graphics.FillPath(bgBrush, p);
                            graphics.DrawPath(rulerPen, p);
                            graphics.DrawString(captureHeight, rulerFont, rulerPen.Brush, fixedRect.X - measureHeight.Width + 1, fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2) + 2);
                            graphics.DrawLine(rulerPen, fixedRect.X - dist, fixedRect.Y, fixedRect.X - dist, fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2));
                            graphics.DrawLine(rulerPen, fixedRect.X - dist, fixedRect.Y + (fixedRect.Height / 2 + vSpace / 2), fixedRect.X - dist, fixedRect.Y + fixedRect.Height);
                            graphics.DrawLine(rulerPen, fixedRect.X - dist - 3, fixedRect.Y, fixedRect.X - dist + 3, fixedRect.Y);
                            graphics.DrawLine(rulerPen, fixedRect.X - dist - 3, fixedRect.Y + fixedRect.Height, fixedRect.X - dist + 3, fixedRect.Y + fixedRect.Height);
                        }
                    }

                    rulerPen.Dispose();
                    bgBrush.Dispose();
                }

                // Display size of selected rectangle
                // Prepare the font and text.
                using (Font sizeFont = new Font(FontFamily.GenericSansSerif, 12)) {
                    // When capturing a Region we need to add 1 to the height/width for correction
                    string sizeText;
                    if (_captureMode == CaptureMode.Region)
                    {
                        // correct the GUI width to real width for the shown size
                        sizeText = (_captureRect.Width + 1) + " x " + (_captureRect.Height + 1);
                    }
                    else
                    {
                        sizeText = _captureRect.Width + " x " + _captureRect.Height;
                    }

                    // Calculate the scaled font size.
                    SizeF extent  = graphics.MeasureString(sizeText, sizeFont);
                    float hRatio  = _captureRect.Height / (extent.Height * 2);
                    float wRatio  = _captureRect.Width / (extent.Width * 2);
                    float ratio   = (hRatio < wRatio ? hRatio : wRatio);
                    float newSize = sizeFont.Size * ratio;

                    if (newSize >= 4)
                    {
                        // Only show if 4pt or larger.
                        if (newSize > 20)
                        {
                            newSize = 20;
                        }
                        // Draw the size.
                        using (Font newSizeFont = new Font(FontFamily.GenericSansSerif, newSize, FontStyle.Bold)) {
                            PointF sizeLocation = new PointF(fixedRect.X + (_captureRect.Width / 2) - (extent.Width / 2), fixedRect.Y + (_captureRect.Height / 2) - (newSizeFont.GetHeight() / 2));
                            graphics.DrawString(sizeText, newSizeFont, Brushes.LightSeaGreen, sizeLocation);
                        }
                    }
                }
            }
            else
            {
                if (!isTerminalServerSession)
                {
                    using (Pen pen = new Pen(Color.LightSeaGreen)) {
                        pen.DashStyle = DashStyle.Dot;
                        Rectangle screenBounds = _capture.ScreenBounds;
                        graphics.DrawLine(pen, _cursorPos.X, screenBounds.Y, _cursorPos.X, screenBounds.Height);
                        graphics.DrawLine(pen, screenBounds.X, _cursorPos.Y, screenBounds.Width, _cursorPos.Y);
                    }

                    string xy = _cursorPos.X + " x " + _cursorPos.Y;
                    using (Font f = new Font(FontFamily.GenericSansSerif, 8)) {
                        Size xySize = TextRenderer.MeasureText(xy, f);
                        using (GraphicsPath gp = RoundedRectangle.Create2(_cursorPos.X + 5, _cursorPos.Y + 5, xySize.Width - 3, xySize.Height, 3)) {
                            using (Brush bgBrush = new SolidBrush(Color.FromArgb(200, 217, 240, 227))) {
                                graphics.FillPath(bgBrush, gp);
                            }
                            using (Pen pen = new Pen(Color.SeaGreen)) {
                                graphics.DrawPath(pen, gp);
                                Point coordinatePosition = new Point(_cursorPos.X + 5, _cursorPos.Y + 5);
                                graphics.DrawString(xy, f, pen.Brush, coordinatePosition);
                            }
                        }
                    }
                }
            }

            // Zoom
            if (_zoomAnimator != null && (isAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window))
            {
                const int zoomSourceWidth  = 25;
                const int zoomSourceHeight = 25;

                Rectangle sourceRectangle = new Rectangle(_cursorPos.X - (zoomSourceWidth / 2), _cursorPos.Y - (zoomSourceHeight / 2), zoomSourceWidth, zoomSourceHeight);

                Rectangle destinationRectangle = _zoomAnimator.Current;
                destinationRectangle.Offset(_cursorPos);
                DrawZoom(graphics, sourceRectangle, destinationRectangle);
            }
        }
 /// <summary>
 /// Draws the outline of the specified rounded rectangle using the specified stroke style.
 /// </summary>
 /// <remarks>
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.
 /// </remarks>
 /// <param name="roundedRect">The dimensions of the rounded rectangle to draw, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the rounded rectangle's outline.  </param>
 /// <param name="strokeWidth">The width of the rounded rectangle's stroke. The stroke is centered on the rounded rectangle's outline. The default value is 1.0f.  </param>
 /// <param name="strokeStyle">The style of the rounded rectangle's stroke, or NULL to paint a solid stroke. The default value is NULL. </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>
 public void DrawRoundedRectangle(RoundedRectangle roundedRect, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
 {
     DrawRoundedRectangle(ref roundedRect, brush, strokeWidth, strokeStyle);
 }
Beispiel #17
0
 public void DrawRoundedRectangle(RoundedRectangle roundedRect, Brush brush, float strokeWidth) => _renderTarget?.DrawRoundedRectangle(roundedRect, brush, strokeWidth);
Beispiel #18
0
        internal override void DrawTabs(HeaderStrip control, PaintEventArgs e)
        {
            if (control.Tabs.Count == 0)
            {
                return;
            }
            Size size = control.Size;

            size.Height -= HeaderSelectedTabStrip * ScaleFactor.Height;

            IList <HeaderTab> tabs = control.Tabs;
            int bottomHeight       = 15 * ScaleFactor.Height;

            Point offset       = new Point(2 * ScaleFactor.Width, 2 * ScaleFactor.Width);
            int   defaultWidth = 42 * ScaleFactor.Width;
            Size  corner       = new Size(8 * ScaleFactor.Width, 8 * ScaleFactor.Height);

            Pen penBorder = new Pen(Strings.ToColor(BorderLineColor));

            try
            {
                HeaderTab selected = null;
                foreach (HeaderTab tab in tabs)
                {
                    tab.area = new Rectangle(offset.X + tab.TabIndex * defaultWidth, offset.Y, defaultWidth, size.Height - offset.Y + corner.Height);
                    if (tab.Selected)
                    {
                        selected = tab;
                        using (SolidBrush backColor = new SolidBrush(Color.Black))
                            RoundedRectangle.Fill(e.Graphics, penBorder, backColor, tab.area, corner);
                    }

                    if (tab.Image != null)
                    {
                        //draw icon
                        Rectangle destImg = new Rectangle(0, 0, tab.Image.Width, tab.Image.Height);
                        if (tab.Image.Size.Height > tab.area.Height || tab.Image.Size.Width > tab.area.Width)
                        {
                            int oX = 8 * ScaleFactor.Width;
                            int oY = 8 * ScaleFactor.Height;

                            int imageSize = tab.area.Height - ((tab.area.Y + oY) * 2);
                            destImg = new Rectangle(tab.area.X + oX, tab.area.Y + oY, imageSize, imageSize);
                        }

                        destImg = new Rectangle(tab.area.X + (tab.area.Width / 2) - (destImg.Width / 2), (tab.area.Height / 2) - (destImg.Height / 2), destImg.Width, destImg.Height);

                        using (AlphaImage image = new AlphaImage(tab.Image))
                        {
                            image.Draw(e.Graphics, destImg);
                        }
                    }

                    if (!tab.Selected && (tab.TabIndex == tabs.Count - 1 || !tabs[tab.TabIndex + 1].Selected))
                    {
                        Point sep = new Point(tab.area.Right, offset.Y);
                        DrawSeparator(e, sep, size.Height - (sep.Y * 2), Orientation.Vertical);
                    }
                }

                Font       font   = new Font(FontFamily.GenericSansSerif, HeaderSelectedTabStripFontSize, FontStyle.Regular);
                SolidBrush brush  = new SolidBrush(ControlBackColor);
                SolidBrush fBrush = new SolidBrush(Strings.ToColor(HeaderSelectedTabStripFontColor));
                Rectangle  rect   = new Rectangle(0, size.Height, control.Width, control.Height - size.Height);
                e.Graphics.FillRectangle(brush, rect);
                SizeF textSize = e.Graphics.MeasureString(selected.Text, font);

                Rectangle stringRect = rect;
                stringRect.X = Convert.ToInt32(selected.area.X + ((selected.area.Width / 2) - (textSize.Width / 2)));
                if (stringRect.X < 0)
                {
                    stringRect.X = 2 * ScaleFactor.Width;
                }

                e.Graphics.DrawString(selected.Text, font, fBrush, stringRect);
                e.Graphics.DrawLine(new Pen(Strings.ToColor(HeaderSelectedTabStripBorderColor)), rect.Left, rect.Bottom - 1, rect.Right, rect.Bottom - 1);
                brush.Dispose(); fBrush.Dispose(); font.Dispose();
            }
            finally
            {
                penBorder.Dispose();
            }
        }
Beispiel #19
0
 public void DrawRoundedRectangle(ref RoundedRectangle roundedRect, Brush brush, float strokeWidth, StrokeStyle strokeStyle) => _renderTarget?.DrawRoundedRectangle(ref roundedRect, brush, strokeWidth, strokeStyle);
Beispiel #20
0
        public void Stroke(
			Rectangle rectangleRegion,
			Size roundedRectangleRadius,
			Brush brush,
			StrokeStyle style,
			float strokeWidth)
        {
            Contract.Requires(Check.IsPositive(roundedRectangleRadius.Width));
            Contract.Requires(Check.IsPositive(roundedRectangleRadius.Height));
            Contract.Requires(brush != null);
            Contract.Requires(style != null);
            Contract.Requires(Check.IsPositive(strokeWidth));
            Contract.Assert(_Target != null);

            Rectangle newRegion;

            ToStrokeable(ref rectangleRegion, strokeWidth, strokeWidth, out newRegion);

            FitStroke(ref newRegion, strokeWidth, strokeWidth, out newRegion);

            RectangleF rectangle = RectangleF.Empty;

            rectangle.Left = newRegion.Left;
            rectangle.Top = newRegion.Top;
            rectangle.Right = newRegion.Right;
            rectangle.Bottom = newRegion.Bottom;

            RoundedRectangle roundedRectangle = new RoundedRectangle
            {
                Rect = rectangle,
                RadiusX = roundedRectangleRadius.Width,
                RadiusY = roundedRectangleRadius.Height
            };

            _Target.DrawRoundedRectangle(roundedRectangle, brush, strokeWidth, style);
        }
Beispiel #21
0
 public void FillRoundedRectangle(RoundedRectangle roundedRect, Brush brush) => _renderTarget?.FillRoundedRectangle(roundedRect, brush);
Beispiel #22
0
        private void PaintVisual(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;

            base.Paint(g);

            var taskbarLocation = this.MainForm.TaskbarLocation;

            bool horizontal = taskbarLocation == Native.ABEdge.Top ||
                              taskbarLocation == Native.ABEdge.Bottom;

            int spaceAfterX = horizontal ? ButtonConstants.SpaceAfter : 1;
            int spaceAfterY = horizontal ? 0 : ButtonConstants.SpaceAfter;

            if (!MainForm.IsHidden)
            {
                // paint background
                Region originalClip = g.Clip;
                using (Region r = new System.Drawing.Region(g.ClipBounds))
                {
                    // exclude corners since they should be rounded
                    r.Exclude(new Rectangle(0, 0, 2, 2));
                    r.Exclude(new Rectangle(Width - spaceAfterX - 1, 0, 2, 2));
                    r.Exclude(new Rectangle(0, Height - 2, 2, 2));
                    r.Exclude(new Rectangle(Width - spaceAfterX - 1, Height - 2, 2, 2));
                    g.Clip = r;

                    ProgressBarDecorator.Paint(g, _buttonBounds, _progress);

                    if (_flashActive)
                    {
                        g.FillRectangle(new LinearGradientBrush(_buttonBounds, Theme.ButtonFlashBackgroundFrom, Theme.ButtonFlashBackgroundTo, 90f), _buttonBounds);
                    }
                    else if (Hover)
                    {
                        HotTrackDecorator.Paint(g, this.Tag as SecondDisplayProcess, this.Image as Bitmap, _buttonBounds, this.PointToClient(Cursor.Position));
                    }

                    HighlightDecorator.Paint(g, _buttonBounds);

                    if ((this.Focused || this._isClicked) && !_flashActive)
                    {
                        g.FillRectangle(Theme.ButtonBackgroundFocused, 2, 2, Width - spaceAfterX - 2, Height - spaceAfterY - 2);
                    }
                }
                g.Clip = originalClip;
            }

            #region Border
            // draw border over background
            GraphicsPath path = RoundedRectangle.Create(new Rectangle(0, 0, Width - spaceAfterX, Height - spaceAfterY - 1), 2, RoundedRectangle.RectangleCorners.All);
            g.DrawPath(Theme.ButtonOuterBorder, path);

            path = RoundedRectangle.Create(new Rectangle(1, 1, Width - spaceAfterX - 2, Height - spaceAfterY - 3), 2, RoundedRectangle.RectangleCorners.All);
            g.DrawPath(Theme.ButtonInnerBorder, path);

            #endregion

            if (MainForm.IsHidden)
            {
                return;
            }

            DrawImageAndText(g, horizontal, spaceAfterX, spaceAfterY);
        }
Beispiel #23
0
        private void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device)
        {
            // the render loop will call device.BeginScene() and device.EndScene() for us

            if (!device.IsDrawing)
            {
                _initializeGraphicObjects = true;
                return;
            }

            // clear the scene / fill it with our background

            device.ClearScene(_backgroundColor);


            if (!CanDraw)
            {
                return;
            }
            // text

            // the background is dynamically adjusted to the text's size
            var esp     = Program.IsEspEnabled ? '+' : '-';
            var radar   = Program.IsRadarEnabled ? '+' : '-';
            var trigger = Program.IsTriggerBot ? '+' : '-';
            var aim     = Program.IsAimEnabled ? '+' : '-';
            var cross   = Program.IsCrosshairDraw ? '+' : '-';
            var bunny   = Program.IsBunnyHopEnabled ? '+' : '-';

            device.DrawTextWithBackground(
                $"Fps: {device.FramesPerSecond} [ Esp(F5): {esp} ] [ Radar(F6): {radar} ] [ Trigger(F7): {trigger} ] [ Aim(F8): {aim} ] [ Cross(F9): {cross} ] [ Bunny(F10): {bunny} ]",
                10, 50, _font, _redBrush, _blackBrush);

            if (IsInGame())
            {
                if (LocalPlayer == null)
                {
                    return;
                }


                device.DrawTextWithBackground(
                    $"Me: (Map: {_mapName}) {Closed?.Name} {LocalPlayer.Health} {LocalPlayer.Team} {LocalPlayer.Position} Max:{MaxPlayersOnMap}",
                    10, 80, _font, _redBrush, _blackBrush);

                if (Program.IsCrosshairDraw)
                {
                    device.FillCircle(_sizeX / 2f, _sizeY / 2f, Fov, _blueBrush);
                    device.DrawCrosshair(CrosshairStyle.Plus, new Point(_sizeX / 2f, _sizeY / 2f), 15, 1, _blackBrush);
                }

                foreach (var justEntity in ListOfGlow.ToList())
                {
                    try
                    {
                        var w2S = justEntity.W2SPosition;
                        if (w2S.X <= 0 || w2S.Y <= 0 || w2S.X >= Program.ScreenSize.X || w2S.Y >= Program.ScreenSize.Y)
                        {
                            continue;
                        }

                        /*if (Program.IsEspEnabled)
                         * {
                         *  var classId = justEntity.ClassId;
                         *
                         *  device.DrawTextWithBackground($"[{classId}]", w2S.X, w2S.Y, _font, _redBrush,
                         *      _blackBrush);
                         * }*/
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            else
            {
                device.DrawTextWithBackground($"Not in game", 10, 70, _font, _redBrush, _blackBrush);
            }
            return;

            // primitives

            device.DrawCircle(100, 100, 50, 2.0f, _redBrush);
            device.DrawDashedCircle(250, 100, 50, 2.0f, _greenBrush);

            // Rectangle.Create offers a method to create rectangles with x, y, width, heigth
            device.DrawRectangle(Rectangle.Create(350, 50, 100, 100), 2.0f, _blueBrush);
            device.DrawRoundedRectangle(RoundedRectangle.Create(500, 50, 100, 100, 6.0f), 2.0f, _redBrush);

            device.DrawTriangle(650, 150, 750, 150, 700, 50, _greenBrush, 2.0f);

            // lines

            device.DrawLine(50, 175, 750, 175, 2.0f, _blueBrush);
            device.DrawDashedLine(50, 200, 750, 200, 2.0f, _redBrush);

            // outlines & filled

            device.OutlineCircle(100, 275, 50, 4.0f, _redBrush, _blackBrush);
            device.FillCircle(250, 275, 50, _greenBrush);

            device.OutlineRectangle(Rectangle.Create(350, 225, 100, 100), 4.0f, _blueBrush, _blackBrush);

            _gradient.SetRange(500, 225, 600, 325);
            device.FillRoundedRectangle(RoundedRectangle.Create(500, 225, 100, 100, 6.0f), _gradient);

            device.FillTriangle(650, 325, 750, 325, 700, 225, _greenBrush);


            // images

            //device.DrawImage(_image, 310, 375);
        }
Beispiel #24
0
 /// <summary>	
 /// Draws the outline of the specified rounded rectangle using the specified stroke style.	
 /// </summary>	
 /// <remarks>	
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.  	
 /// </remarks>	
 /// <param name="roundedRect">The dimensions of the rounded rectangle to draw, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the rounded rectangle's outline.  </param>
 /// <param name="strokeWidth">The width of the rounded rectangle's stroke. The stroke is centered on the rounded rectangle's outline. The default value is 1.0f.  </param>
 /// <param name="strokeStyle">The style of the rounded rectangle's stroke, or NULL to paint a solid stroke. The default value is NULL. </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>
 public void DrawRoundedRectangle(RoundedRectangle roundedRect, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
 {
     DrawRoundedRectangle(ref roundedRect, brush, strokeWidth, strokeStyle);
 }
Beispiel #25
0
        void FillItemGeometry(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;

            RawRectangleF    rect        = new RawRectangleF(1, 1, Width - 1, Height - 1);
            RoundedRectangle roundedRect = new RoundedRectangle()
            {
                RadiusX = this.RadiusX,
                RadiusY = this.RadiusY,
                Rect    = rect
            };

            GradientStop[] gradientStops = new GradientStop[5];

            gradientStops[0].Color    = GDIDataD2DUtils.TransToRawColor4(colors[0]);
            gradientStops[0].Position = 0f;

            gradientStops[1].Color    = GDIDataD2DUtils.TransToRawColor4(colors[1]);
            gradientStops[1].Position = 0.4f;

            gradientStops[2].Color    = GDIDataD2DUtils.TransToRawColor4(colors[2]);
            gradientStops[2].Position = 0.5f;

            gradientStops[3].Color    = GDIDataD2DUtils.TransToRawColor4(colors[1]);
            gradientStops[3].Position = 0.6f;

            gradientStops[4].Color    = GDIDataD2DUtils.TransToRawColor4(colors[0]);
            gradientStops[4].Position = 1f;

            //
            GradientStopCollection gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp);

            //
            LinearGradientBrushProperties props = new LinearGradientBrushProperties()
            {
                StartPoint = new RawVector2(rect.Left, rect.Top),
                EndPoint   = new RawVector2(rect.Left, rect.Bottom)
            };

            SharpDX.Direct2D1.LinearGradientBrush linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection);
            g.RenderTarget.FillRoundedRectangle(roundedRect, linearGradientBrush);

            //
            gradientStops = new GradientStop[5];

            gradientStops[0].Color    = GDIDataD2DUtils.TransToRawColor4(colors[2]);
            gradientStops[0].Position = 0f;

            gradientStops[1].Color    = GDIDataD2DUtils.TransToRawColor4(colors[1]);
            gradientStops[1].Position = 0.1f;

            gradientStops[2].Color    = GDIDataD2DUtils.TransToRawColor4(colors[0]);
            gradientStops[2].Position = 0.5f;

            gradientStops[3].Color    = GDIDataD2DUtils.TransToRawColor4(colors[1]);
            gradientStops[3].Position = 0.9f;


            gradientStops[4].Color    = GDIDataD2DUtils.TransToRawColor4(colors[2]);
            gradientStops[4].Position = 1f;

            //
            gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp);

            //
            props = new LinearGradientBrushProperties()
            {
                StartPoint = new RawVector2(rect.Left, rect.Top),
                EndPoint   = new RawVector2(rect.Right, rect.Top)
            };

            linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection);
            g.RenderTarget.FillRoundedRectangle(roundedRect, linearGradientBrush);



            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(SideShadowAlpha, 0, 0, 0));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRoundedRectangle(roundedRect, brush);
        }
        private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (IsNameRow(e.RowIndex))
            {
                return;
            }

            e.Graphics.FillRectangle(Brushes.White, e.CellBounds);                                                                    //background
            e.Graphics.DrawLine(Pens.Black, e.CellBounds.Left, e.CellBounds.Bottom - 1, e.CellBounds.Right, e.CellBounds.Bottom - 1); //border

            var action = GetStakeholderActionForRow(e.RowIndex);


            //var horizontalRectMargin = (e.CellBounds.Width - RectangleWidth)/2;
            var horizontalRectMargin = (e.CellBounds.Width - RectangleWidth - ActionWidth - ArrowWidth) / 2;
            var verticalRectMargin   = 5;

            var actionColor = DecisionStateColor.ConvertStateToColor(action.Decision.State);

            if (_currentSortState == SortState.Stakeholder)
            {
                actionColor = GetColorForAction(action.Action);
            }


            //draw action button
            var actionRectangle = new Rectangle(
                e.CellBounds.X + horizontalRectMargin,
                e.CellBounds.Y + verticalRectMargin,
                ActionWidth,
                dataGridView1.RowTemplate.Height - 2 * verticalRectMargin);
            var actionPath = RoundedRectangle.Create(actionRectangle);

            e.Graphics.FillPath(new SolidBrush(actionColor), actionPath);

            var text = GetActionButtonText(action);

            DrawText(e.Graphics, text, actionRectangle);

            //draw arrow between
            var arrowPen = new Pen(Color.Black, 5f);

            arrowPen.StartCap = LineCap.Flat;
            arrowPen.EndCap   = LineCap.ArrowAnchor;
            e.Graphics.DrawLine(arrowPen,
                                e.CellBounds.X + horizontalRectMargin + ActionWidth + ArrowMargin,
                                e.CellBounds.Y + (e.CellBounds.Height / 2),
                                e.CellBounds.X + horizontalRectMargin + ActionWidth + ArrowWidth - ArrowMargin,
                                e.CellBounds.Y + (e.CellBounds.Height / 2)
                                );

            var color = DecisionStateColor.ConvertStateToColor(action.Decision.State);

            if (_currentSortState == SortState.Decision)
            {
                color = GetColorForAction(action.Action);
            }
            var decisionRectangle = new Rectangle(
                e.CellBounds.X + horizontalRectMargin + ActionWidth + ArrowWidth,
                e.CellBounds.Y + verticalRectMargin,
                RectangleWidth,
                dataGridView1.RowTemplate.Height - 2 * verticalRectMargin);


            text = GetReceiverButtonText(action);
            var path = RoundedRectangle.Create(decisionRectangle);

            e.Graphics.FillPath(new SolidBrush(color), path);
            DrawText(e.Graphics, text, decisionRectangle);

            //var text = ActionToSentence(action.Action, action.Decision);
            //var stringSize = e.Graphics.MeasureString(text, DefaultFont);
            //var horizontalMargin = (rectangle.Width - stringSize.Width) / 2;
            //var verticalMargin = (rectangle.Height - stringSize.Height) / 2;



            //textRectangle = new RectangleF(rectangle.X + horizontalMargin, rectangle.Y + verticalMargin, stringSize.Width, stringSize.Height);
            //e.Graphics.DrawString(text, DefaultFont, Brushes.Black, textRectangle);
            e.Handled = true;
        }
Beispiel #27
0
        private void panelTitle_Paint(object sender, PaintEventArgs e)
        {
            SecondDisplayProcess proc = _button.Tag as SecondDisplayProcess;

            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;

            bool showLivePreview = ShowPreview();

            bool isVisualTheme = Native.IsThemeActive() != 0;

            if (_panelHover)
            {
                if (isVisualTheme)
                {
                    GraphicsPath path = RoundedRectangle.Create(new Rectangle(0, 0, panelTitle.Width - 1, panelTitle.Height - 1), 3, RoundedRectangle.RectangleCorners.All);

                    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

                    e.Graphics.FillPath(Theme.TooltipBackground, path);
                    e.Graphics.DrawPath(Theme.TooltipBorder, path);
                }
                else
                {
                    ButtonBorderDecorator.DrawSingle(e.Graphics, 0, 0, panelTitle.Width - 1, panelTitle.Height - 1);
                }

                if (_overCloseButton)
                {
                    _closeForm.Draw(DualMonitor.Properties.Resources.close_hover);
                }
                else
                {
                    _closeForm.Draw(DualMonitor.Properties.Resources.close);
                }
            }

            if (proc == null)
            {
                return;
            }

            if (!showLivePreview)
            {
                if (proc.SmallIcon != null)
                {
                    e.Graphics.DrawIcon(proc.SmallIcon, new Rectangle(ThumbnailConstants.IconMargin, 9, ThumbnailConstants.IconSize, ThumbnailConstants.IconSize));
                }

                if (proc.Title != null)
                {
                    e.Graphics.DrawString(proc.Title, this.Font, _fontColor,
                                          new RectangleF(ThumbnailConstants.LiveIconMargin + 5 + ThumbnailConstants.IconSize, 9f, panelTitle.Width - (ThumbnailConstants.IconMargin + 5 + ThumbnailConstants.IconSize) * 2, this.Font.Height),
                                          _appTitleStringFormat);
                }
            }
            else
            {
                if (proc.SmallIcon != null)
                {
                    e.Graphics.DrawIcon(proc.SmallIcon, new Rectangle(ThumbnailConstants.LiveIconMargin, 7, ThumbnailConstants.IconSize, ThumbnailConstants.IconSize));
                }

                if (proc.Title != null)
                {
                    e.Graphics.DrawString(proc.Title, this.Font, _fontColor,
                                          new RectangleF(ThumbnailConstants.LiveIconMargin + 5 + ThumbnailConstants.IconSize, 9f, panelTitle.Width - (ThumbnailConstants.LiveIconMargin + 5 + ThumbnailConstants.IconSize) * 2, this.Font.Height),
                                          _appTitleStringFormat);
                }
            }
        }
Beispiel #28
0
        protected override void OnPaint(PaintEventArgs e)
        {
            bool flag;

            try
            {
                e.Graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                e.Graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                switch (this.fMode)
                {
                case MapViewMode.Normal:
                case MapViewMode.Thumbnail:
                {
                    Color color  = Color.FromArgb(240, 240, 240);
                    Color color1 = Color.FromArgb(170, 170, 170);
                    Brush linearGradientBrush = new LinearGradientBrush(base.ClientRectangle, color, color1, LinearGradientMode.Vertical);
                    e.Graphics.FillRectangle(linearGradientBrush, base.ClientRectangle);
                    break;
                }

                case MapViewMode.Plain:
                {
                    e.Graphics.FillRectangle(Brushes.White, base.ClientRectangle);
                    break;
                }

                case MapViewMode.PlayerView:
                {
                    e.Graphics.FillRectangle(Brushes.Black, base.ClientRectangle);
                    break;
                }
                }
                if (this.fMap == null || this.fMap.Image == null)
                {
                    e.Graphics.DrawString("(no map selected)", this.Font, Brushes.Black, base.ClientRectangle, this.fCentred);
                }
                else
                {
                    RectangleF mapRectangle = this.MapRectangle;
                    e.Graphics.DrawImage(this.fMap.Image, mapRectangle);
                    if (this.fShowLocations)
                    {
                        foreach (MapLocation location in this.fMap.Locations)
                        {
                            if (location == null || this.fHighlightedLocation != null && location.ID != this.fHighlightedLocation.ID)
                            {
                                continue;
                            }
                            Color white = Color.White;
                            if (location == this.fHoverLocation)
                            {
                                white = Color.Blue;
                            }
                            if (location == this.fSelectedLocation)
                            {
                                white = Color.Blue;
                            }
                            RectangleF locRect = this.get_loc_rect(location, mapRectangle);
                            e.Graphics.DrawEllipse(new Pen(Color.Black, 5f), locRect);
                            e.Graphics.DrawEllipse(new Pen(white, 2f), locRect);
                        }
                    }
                    if (this.fPlot != null)
                    {
                        foreach (PlotPoint point in this.fPlot.Points)
                        {
                            if (point.RegionalMapID != this.fMap.ID)
                            {
                                continue;
                            }
                            MapLocation mapLocation = this.fMap.FindLocation(point.MapLocationID);
                            if (mapLocation == null)
                            {
                                continue;
                            }
                            PointF     locPt      = this.get_loc_pt(mapLocation, mapRectangle);
                            RectangleF rectangleF = this.get_loc_rect(mapLocation, mapRectangle);
                            rectangleF.Inflate(-5f, -5f);
                            foreach (Guid link in point.Links)
                            {
                                PlotPoint plotPoint = this.fPlot.FindPoint(link);
                                if (plotPoint == null || plotPoint.RegionalMapID != this.fMap.ID)
                                {
                                    continue;
                                }
                                MapLocation mapLocation1 = this.fMap.FindLocation(plotPoint.MapLocationID);
                                if (mapLocation1 == null)
                                {
                                    continue;
                                }
                                PointF pointF = this.get_loc_pt(mapLocation1, mapRectangle);
                                e.Graphics.DrawLine(new Pen(Color.Red, 3f), locPt, pointF);
                                RectangleF locRect1 = this.get_loc_rect(mapLocation1, mapRectangle);
                                locRect1.Inflate(-5f, -5f);
                                e.Graphics.FillEllipse(Brushes.Red, rectangleF);
                                e.Graphics.FillEllipse(Brushes.Red, locRect1);
                            }
                        }
                    }
                    if (this.fShowLocations)
                    {
                        foreach (MapLocation location1 in this.fMap.Locations)
                        {
                            if (this.fHighlightedLocation != null && location1 != this.fHighlightedLocation || location1 != this.fHoverLocation && location1 != this.fSelectedLocation && location1 != this.fHighlightedLocation)
                            {
                                continue;
                            }
                            if (location1.Category == "")
                            {
                                flag = false;
                            }
                            else
                            {
                                flag = (this.fMode == MapViewMode.Normal ? true : this.fMode == MapViewMode.Thumbnail);
                            }
                            bool       flag1       = flag;
                            RectangleF rectangleF1 = this.get_loc_rect(location1, mapRectangle);
                            SizeF      sizeF       = e.Graphics.MeasureString(location1.Name, this.Font);
                            SizeF      sizeF1      = e.Graphics.MeasureString(location1.Category, this.Font);
                            float      single      = (flag1 ? Math.Max(sizeF.Width, sizeF1.Width) : sizeF.Width);
                            SizeF      sizeF2      = new SizeF(single, (flag1 ? sizeF.Height + sizeF1.Height : sizeF.Height))
                            {
                                Width  = sizeF1.Width + 2f,
                                Height = sizeF1.Height + 2f
                            };
                            float x   = rectangleF1.X + rectangleF1.Width / 2f - sizeF2.Width / 2f;
                            float top = rectangleF1.Top - sizeF2.Height - 5f;
                            if (top < (float)base.ClientRectangle.Top)
                            {
                                top = rectangleF1.Bottom + 5f;
                            }
                            x = Math.Max(x, 0f);
                            float width = x + sizeF2.Width - (float)base.ClientRectangle.Right;
                            if (width > 0f)
                            {
                                x -= width;
                            }
                            RectangleF   rectangleF2  = new RectangleF(new PointF(x, top), sizeF2);
                            GraphicsPath graphicsPath = RoundedRectangle.Create(rectangleF2, (float)this.Font.Height * 0.35f);
                            e.Graphics.FillPath(Brushes.LightYellow, graphicsPath);
                            e.Graphics.DrawPath(Pens.Black, graphicsPath);
                            if (!flag1)
                            {
                                e.Graphics.DrawString(location1.Name, this.Font, Brushes.Black, rectangleF2, this.fCentred);
                            }
                            else
                            {
                                float      height      = rectangleF2.Height / 2f;
                                float      y           = rectangleF2.Y + height;
                                RectangleF rectangleF3 = new RectangleF(rectangleF2.X, rectangleF2.Y, rectangleF2.Width, height);
                                RectangleF rectangleF4 = new RectangleF(rectangleF2.X, y, rectangleF2.Width, height);
                                e.Graphics.DrawLine(Pens.Gray, rectangleF2.X, y, rectangleF2.X + rectangleF2.Width, y);
                                e.Graphics.DrawString(location1.Name, this.Font, Brushes.Black, rectangleF3, this.fCentred);
                                e.Graphics.DrawString(location1.Category, this.Font, Brushes.DarkGray, rectangleF4, this.fCentred);
                            }
                        }
                    }
                    if (this.fMode == MapViewMode.Normal && this.fMap.Locations.Count == 0)
                    {
                        string       str             = "Double-click on the map to set a location.";
                        float        single1         = 10f;
                        Rectangle    clientRectangle = base.ClientRectangle;
                        float        width1          = (float)clientRectangle.Width - 2f * single1;
                        SizeF        sizeF3          = e.Graphics.MeasureString(str, this.Font, (int)width1);
                        float        height1         = sizeF3.Height * 2f;
                        RectangleF   rectangleF5     = new RectangleF(single1, single1, width1, height1);
                        GraphicsPath graphicsPath1   = RoundedRectangle.Create(rectangleF5, height1 / 3f);
                        e.Graphics.FillPath(new SolidBrush(Color.FromArgb(200, Color.Black)), graphicsPath1);
                        e.Graphics.DrawPath(Pens.Black, graphicsPath1);
                        e.Graphics.DrawString(str, this.Font, Brushes.White, rectangleF5, this.fCentred);
                    }
                }
            }
            catch (Exception exception)
            {
                LogSystem.Trace(exception);
            }
        }
Beispiel #29
0
        public Form1()
        {
            InitializeComponent();


            renderForm = new RenderForm("My form");
            var windowSize = new Size(600, 600);

            ClientSize = windowSize;
            //this.size = new Size2F(30, 70);

            //using (SharpDX.DirectWrite.Factory textFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared))
            //{
            //    textFormat = new Text(
            //        textFactory,
            //        "MS Sans Serif",
            //        SharpDX.DirectWrite.FontWeight.SemiBold,
            //        SharpDX.DirectWrite.FontStyle.Normal,
            //        SharpDX.DirectWrite.FontStretch.Medium,
            //        20.0f);
            //}
            CreateBars();
            SwapChainDescription chainDescription = new SwapChainDescription()
            {
                BufferCount     = 1,
                Flags           = SwapChainFlags.None,
                IsWindowed      = true,
                ModeDescription = new ModeDescription(
                    windowSize.Width,
                    windowSize.Height,
                    new Rational(60, 1),
                    Format.R8G8B8A8_UNorm),

                OutputHandle = this.Handle,

                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput
            };

            Device.CreateWithSwapChain(
                SharpDX.Direct3D.DriverType.Hardware,
                DeviceCreationFlags.BgraSupport,
                new SharpDX.Direct3D.FeatureLevel[] { SharpDX.Direct3D.FeatureLevel.Level_10_0 },
                chainDescription,
                out _device,
                out swapChain);

            d2dFactory = new SharpDX.Direct2D1.Factory();

            var width  = this.Width;
            var height = this.Height;

            Factory factory = swapChain.GetParent <Factory>();

            factory.MakeWindowAssociation(this.Handle, WindowAssociationFlags.IgnoreAll);

            target     = SharpDX.Direct3D11.Resource.FromSwapChain <Texture2D>(swapChain, 0);
            targetveiw = new RenderTargetView(_device, target);

            Surface surface = target.QueryInterface <Surface>();

            var pixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied);

            d2dRenderTarget = new RenderTarget(d2dFactory, surface,
                                               new RenderTargetProperties(pixelFormat));

            var brush = new SolidColorBrush(d2dRenderTarget, Color.Black);

            var barBearBrush = new SolidColorBrush(d2dRenderTarget, Color.Red);
            var barBullBrush = new SolidColorBrush(d2dRenderTarget, Color.Green);


            //bool isDrawed = false;

            //var centerForChart = Height / 2 - size.Height / 2;
            //this.MouseMove += MouseHoverHandler;

            //this.KeyPress += (sender, args) =>
            //{
            //    if (args.KeyChar == 'q' && ! isDrawed)
            //    {
            //        isDrawed = true;
            //        //DrawLine();
            //    }
            //    else
            //    {
            //        isDrawed = false;
            //    }
            //};

            //this.ResizeEnd += (sender, args) =>
            //{
            //    width = this.Width;
            //    height = this.Height;
            //};


            var rightXPaddingChart = width * 0.9f;
            var leftXPaddingChart  = width * 0.1f;


            var topYPaddingChart    = height * 0.9f;
            var bottomYPaddingChart = height * 0.1f;

            var touchingPointOfAxes = new Vector2(rightXPaddingChart, topYPaddingChart);
            var chartAxeVectorX     = new Vector2(leftXPaddingChart, topYPaddingChart);
            var chartAxeVectorY     = new Vector2(rightXPaddingChart, bottomYPaddingChart);


            var pointPaddingFrom = width * 0.88f;
            var pointPaddingTo   = width * 0.04f;


            var chartAxeYPaddingsTop    = 0.1f;
            var chartAxeYPaddingsBotton = 0.1f;
            var yAxePaddingChart        = chartAxeYPaddingsTop + chartAxeYPaddingsBotton;
            var chartHeight             = height * (1 - yAxePaddingChart);
            var partY     = chartHeight * 0.05f;
            var countYAxe = chartHeight / partY;

            var barSizeRatio           = 0.02f;
            var spaceBetweenBarsRatio  = 0.05f;
            var chartAxeXPaddingsLeft  = 0.1f;
            var chartAxeXPaddingsRight = 0.1f;
            var xAxePaddingChart       = chartAxeXPaddingsLeft + chartAxeXPaddingsRight;
            var chartWidth             = width * (1 - xAxePaddingChart);
            var barSize          = chartWidth * barSizeRatio;
            var spaceBetweenBars = chartWidth * spaceBetweenBarsRatio;

            var partX  = barSize + spaceBetweenBars;
            var countX = (int)(chartWidth / partX);
            var countY = (int)(chartHeight / partY);
            var startDrawPointLinesFrom = touchingPointOfAxes.X;
            var startPositionY          = height * 0.88f;
            var finishPositionY         = startPositionY + height * 0.04f;


            var rectangle = new RoundedRectangle()
            {
                RadiusX = 1,
                RadiusY = 1,
                Rect    = new RawRectangleF(width * .12f, height * .1f, width * .14f, height * .2f)
            };

            //var line = new CustomLine();

            RenderLoop.Run(this, () =>
            {
                d2dRenderTarget.BeginDraw();
                d2dRenderTarget.Clear(Color.AliceBlue);

                d2dRenderTarget.DrawLine(chartAxeVectorX, touchingPointOfAxes, brush, 2);
                d2dRenderTarget.DrawLine(chartAxeVectorY, touchingPointOfAxes, brush, 2);

                foreach (var bar in _bars)
                {
                    d2dRenderTarget.DrawLine(bar.Line.VectorLow, bar.Line.VectorHigh, brush);

                    d2dRenderTarget.FillRoundedRectangle(bar.Rectangle, bar._isBear == true ? barBearBrush : barBullBrush);
                }

                ////d2dRenderTarget.DrawRoundedRectangle(rectangle, brush);

                //int j = 0;
                //for (float i = 1; i <= chartHeight; i += partY)
                //{
                //    d2dRenderTarget.DrawLine(_bars[j].Line,brush);
                //    j++;
                //}



                //var part = height * 0.05f;
                //var part2 = width * 0.05f + width * 0.02f;
                //var startPos = touchingPointOfAxes.Y - part;

                //for (float i = startPos; i > leftXPaddingChart; i -= part)
                //{
                //    var vectorPoint1 = new Vector2(pointPaddingFrom, i);
                //    var vectorPoint2 = new Vector2(pointPaddingFrom + pointPaddingTo, i);

                //    d2dRenderTarget.DrawLine(vectorPoint1, vectorPoint2, brush, 2);
                //}



                for (float i = 1; i > countY; i++)
                {
                    var vectorPoint1 = new Vector2(pointPaddingFrom, startDrawPointLinesFrom);
                    var vectorPoint2 = new Vector2(pointPaddingFrom + pointPaddingTo, i);

                    d2dRenderTarget.DrawLine(vectorPoint1, vectorPoint2, brush, 2);
                }

                for (float i = 1; i <= countX; i++)
                {
                    var vectorPoint1 = new Vector2(startDrawPointLinesFrom - (partX * i), startPositionY);
                    var vectorPoint2 = new Vector2(startDrawPointLinesFrom - partX * i, finishPositionY);

                    d2dRenderTarget.DrawLine(vectorPoint1, vectorPoint2, brush, 2);
                }



                //d2dRenderTarget.DrawLine(new Vector2(0, this.Height / 2), new Vector2(width, this.Height / 2), brush); // center

                //if (isDrawed)
                //{
                //    using (var brush2 = new SolidColorBrush(d2dRenderTarget, Color.RosyBrown))
                //    {
                //        for (int x = 0; x < d2dRenderTarget.Size.Width; x += 30)
                //        {
                //            d2dRenderTarget.DrawLine(new Vector2(x, 0), new Vector2(x, d2dRenderTarget.Size.Height), brush2);
                //        }

                //        for (int y = 0; y < d2dRenderTarget.Size.Height; y += 30)
                //        {
                //            d2dRenderTarget.DrawLine(new Vector2(0, y), new Vector2(d2dRenderTarget.Size.Width, y), brush2);
                //        }
                //    }
                //}

                //d2dRenderTarget.DrawText(textPosition, textFormat, new SharpDX.Mathematics.Interop.RawRectangleF(30,30, d2dRenderTarget.Size.Width, d2dRenderTarget.Size.Height), brush);

                d2dRenderTarget.EndDraw();


                swapChain.Present(1, PresentFlags.None);
            });
        }
Beispiel #30
0
        protected override void OnPaint(PaintEventArgs e)
        {
            RoundedRectangle rect = new RoundedRectangle(0, 0,
                                                         this.Width, this.Height, 10);

            if (_map == null)
            {
                _map = new Bitmap(this.Width, this.Height);
            }
            Graphics g = Graphics.FromImage(_map);

            rect.Shrink(5);
            Border.Border border = new Border.Border3D();
            border.DrawBorder(g, rect.GetGraphicsPath());
            Pen p = new Pen(Color.DarkGray);
            LinearGradientBrush b = new LinearGradientBrush(rect.ClientRect, Color.WhiteSmoke, _backgrdColor, 90f);

            g.FillPath(b, rect.GetGraphicsPath());
            g.DrawPath(p, rect.GetGraphicsPath());
            g.Clip = new Region(rect.GetGraphicsPath());
            if (_backgrdImage != null)
            {
                g.DrawImage(_backgrdImage, rect.ClientRect);
            }
            rect.Shrink(5);
            g.Clip = new Region(rect.GetGraphicsPath());
            int left = 0;

            _panelLength = rect.Width / (_numberOfPanel + 2);
            _panelHeight = rect.Height;
            if (_location == location.FILL)
            {
                _panelLength = rect.Width / (_numberOfPanel) - 1;
                int totalLength = (_numberOfPanel * _panelLength) / 2;
                if (rect.Width / 2 > totalLength)
                {
                    left = rect.Left + (rect.Width / 2 - totalLength);
                }
            }
            else if (_location == location.LEFT)
            {
                left = rect.Left + 3;
            }
            else if (_location == location.CENTER)
            {
                int totalLength = (_numberOfPanel * _panelLength) / 2;
                if (rect.Width / 2 > totalLength)
                {
                    left = rect.Left + (rect.Width / 2 - totalLength);
                }
            }
            else
            {
                left = rect.Left + rect.Width - (_numberOfPanel * _panelLength);
            }
            int i = 0;

            foreach (DigitalPanel dp in _collection)
            {
                dp.Left        = left + i * (_panelLength);
                dp.Top         = rect.Top;
                dp.Width       = _panelLength - 1;
                dp.Height      = _panelHeight;
                dp.MainColor   = _fontColor;
                dp.BackColor   = _panelColor;
                dp.EnableGlare = _enableGlare;
                dp.Draw(g);

                i++;
            }
            e.Graphics.DrawImage(_map, new Point(0, 0));
        }
        public override void DrawRoundedRectangle(Brush brush, Pen pen, Rect rectangle, double radiusX, double radiusY)
        {
            RoundedRectangle roundedRect = new RoundedRectangle
            {
                Rect = rectangle.ToSharpDX(),
                RadiusX = (float)radiusX,
                RadiusY = (float)radiusY,
            };

            if (brush != null)
            {
                using (var brush2D = brush.ToSharpDX(this.target))
                {
                    this.target.FillRoundedRectangle(roundedRect, brush2D);
                }
            }

            if (pen != null)
            {
                using (var brush2D = pen.Brush.ToSharpDX(this.target))
                {
                    this.target.DrawRoundedRectangle(roundedRect, brush2D, (float)pen.Thickness);
                }
            }
        }
 /// <summary>
 /// Draws the outline of the specified rounded rectangle.
 /// </summary>
 /// <remarks>
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{DrawRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.
 /// </remarks>
 /// <param name="roundedRect">The dimensions of the rounded rectangle to draw, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the rounded rectangle's outline.  </param>
 /// <param name="strokeWidth">The width of the rounded rectangle's stroke. The stroke is centered on the rounded rectangle's outline. The default value is 1.0f.  </param>
 /// <unmanaged>void ID2D1RenderTarget::DrawRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle)</unmanaged>
 public void DrawRoundedRectangle(RoundedRectangle roundedRect, Brush brush, float strokeWidth)
 {
     DrawRoundedRectangle(ref roundedRect, brush, strokeWidth, null);
 }
        public override void Draw(Graphics gr)
        {
            if (!Visible)
            {
                return;
            }
            string    PlayerA      = FMatch.PlayerA.Label;
            string    PlayerB      = FMatch.PlayerB.Label;
            Font      FontA        = null;
            Font      FontB        = null;
            FontStyle winner_style = FontStyle.Bold;
            FontStyle looser_style = FontStyle.Regular;
            FontStyle normal_style = FontStyle.Regular;
            Font      font_normal  = new Font(FontFamily.GenericSansSerif, OlympicPainterSettings.FontSize, FontStyle.Regular);
            Font      font_bold    = new Font(FontFamily.GenericSansSerif, OlympicPainterSettings.FontSize, FontStyle.Bold);

            switch (FMatch.Winner)
            {
            case MatchLabel.PlayerLetters.A:
                FontA     = new Font(FontFamily.GenericSansSerif, OlympicPainterSettings.FontSize, winner_style);
                FontB     = new Font(FontFamily.GenericSansSerif, OlympicPainterSettings.FontSize, looser_style);
                BackColor = OlympicPainterSettings.MatchLabelColors.Finished;
                break;

            case MatchLabel.PlayerLetters.B:
                FontA     = new Font(FontFamily.GenericSansSerif, OlympicPainterSettings.FontSize, looser_style);
                FontB     = new Font(FontFamily.GenericSansSerif, OlympicPainterSettings.FontSize, winner_style);
                BackColor = OlympicPainterSettings.MatchLabelColors.Finished;
                break;

            case MatchLabel.PlayerLetters.Unknown:
                FontA     = new Font(FontFamily.GenericSansSerif, OlympicPainterSettings.FontSize, normal_style);
                FontB     = new Font(FontFamily.GenericSansSerif, OlympicPainterSettings.FontSize, normal_style);
                BackColor = OlympicPainterSettings.MatchLabelColors.Started;
                break;
            }
            if (FMatch.PlayerA.Id == -1 || FMatch.PlayerB.Id == -1)
            {
                if (FMatch.PlayerA.Id == -1 && FMatch.PlayerB.Id == -1)
                {
                    BackColor = OlympicPainterSettings.MatchLabelColors.Empty;
                }
                else
                {
                    BackColor = OlympicPainterSettings.MatchLabelColors.Seeding;
                }
            }

            /*gr.FillRectangle(new SolidBrush(Color.LightGray), Left + 3, Top + 3, Size.Width, Size.Height);
             * gr.FillRectangle(new SolidBrush(BackColor), Left, Top, Size.Width, Size.Height);
             * gr.DrawRectangle(new Pen(Color.Black), Left, Top, Size.Width, Size.Height);*/

            //-----------------------------------------------------------------------------
            SmoothingMode sm = gr.SmoothingMode;

            gr.SmoothingMode = SmoothingMode.HighQuality;

            GraphicsPath shadowPath = RoundedRectangle.Create(Left + OlympicPainterSettings.ShadowStep, Top + OlympicPainterSettings.ShadowStep, Size.Width, Size.Height);

            gr.FillPath(new SolidBrush(OlympicPainterSettings.ShadowColor), shadowPath);

            GraphicsPath boxPath = RoundedRectangle.Create(Left, Top, Size.Width, Size.Height);

            gr.FillPath(new SolidBrush(BackColor), boxPath);
            gr.DrawPath(new Pen(OlympicPainterSettings.BorderColor), boxPath);
            gr.SmoothingMode = sm;
            //-----------------------------------------------------------------------------
            gr.DrawString(PlayerA, FontA, new SolidBrush(OlympicPainterSettings.MatchLabelColors.ForeColor), new Point(Left + 3, Top + 1));
            gr.DrawString(PlayerB, FontB, new SolidBrush(OlympicPainterSettings.MatchLabelColors.ForeColor), new Point(Left + 3, Top + OlympicPainterSettings.Scaled(17)));
            SizeF pointAsize = gr.MeasureString(PointsA, FontA);
            SizeF pointBsize = gr.MeasureString(PointsB, FontB);

            gr.DrawString(PointsA, font_normal, new SolidBrush(OlympicPainterSettings.MatchLabelColors.ForeColor), new PointF(Left + Size.Width - pointAsize.Width - OlympicPainterSettings.Scaled(5), Top + 1));
            gr.DrawString(PointsB, font_normal, new SolidBrush(OlympicPainterSettings.MatchLabelColors.ForeColor), new PointF(Left + Size.Width - pointBsize.Width - OlympicPainterSettings.Scaled(5), Top + OlympicPainterSettings.Scaled(17)));
            if (FMatch.Title != "")
            {
                SizeF titleSize = gr.MeasureString(FMatch.Title, font_bold);
                gr.DrawString(FMatch.Title, font_bold, new SolidBrush(OlympicPainterSettings.MatchLabelColors.ForeColor), new PointF(Left + (Size.Width - titleSize.Width) / 2, Top - titleSize.Height));
            }
        }
 /// <summary>
 /// Paints the interior of the specified rounded rectangle.
 /// </summary>
 /// <remarks>
 /// This method doesn't return an error code if it fails. To determine whether a drawing operation (such as {{FillRoundedRectangle}}) failed, check the result returned by the <see cref="M:SharpDX.Direct2D1.RenderTarget.EndDraw(System.Int64@,System.Int64@)" /> or <see cref="M:SharpDX.Direct2D1.RenderTarget.Flush(System.Int64@,System.Int64@)" /> methods.
 /// </remarks>
 /// <param name="roundedRect">The dimensions of the rounded rectangle to paint, in device-independent pixels. </param>
 /// <param name="brush">The brush used to paint the interior of the rounded rectangle. </param>
 /// <unmanaged>void ID2D1RenderTarget::FillRoundedRectangle([In] const D2D1_ROUNDED_RECT* roundedRect,[In] ID2D1Brush* brush)</unmanaged>
 public void FillRoundedRectangle(RoundedRectangle roundedRect, Brush brush)
 {
     FillRoundedRectangle(ref roundedRect, brush);
 }
Beispiel #35
0
        int ReadRectangle(XmlNode rectNode)
        {
            float  x = 0f, y = 0f, w = 0f, h = 0f, rx = -1f, ry = -1f;
            string attribute = GetAttributeContent(rectNode, "x");

            if (attribute == "ERROR")
            {
                return(0);
            }
            float.TryParse(attribute, out x);
            attribute = GetAttributeContent(rectNode, "y");
            if (attribute == "ERROR")
            {
                return(0);
            }
            float.TryParse(attribute, out y);
            attribute = GetAttributeContent(rectNode, "width");
            if (attribute == "ERROR")
            {
                return(0);
            }
            float.TryParse(attribute, out w);
            attribute = GetAttributeContent(rectNode, "height");
            if (attribute == "ERROR")
            {
                return(0);
            }
            float.TryParse(attribute, out h);
            attribute = GetAttributeContent(rectNode, "rx");
            if (attribute != "ERROR")
            {
                float.TryParse(attribute, out rx);
            }
            attribute = GetAttributeContent(rectNode, "ry");
            if (attribute != "ERROR")
            {
                float.TryParse(attribute, out ry);
            }
            else
            {
                ry = rx;
            }
            string elementName = GetAttributeContent(rectNode, "id");

            if (rx == -1f && ry == -1f)
            {
                Rectangle rect = new Rectangle();
                rect.offset = new Vector2(x + w / 2f, -y - h / 2f);
                rect.size   = new Vector2(w, h);
                if (elementName == "ERROR")
                {
                    elementName = fileName + "_rectangle" + (rectangles.Count + 1);
                }
                buffer = new SplineDefinition(elementName, rect.CreateSpline());
            }
            else
            {
                RoundedRectangle rect = new RoundedRectangle();
                rect.offset  = new Vector2(x + w / 2f, -y - h / 2f);
                rect.size    = new Vector2(w, h);
                rect.xRadius = rx;
                rect.yRadius = ry;
                if (elementName == "ERROR")
                {
                    elementName = fileName + "_roundedRectangle" + (rectangles.Count + 1);
                }
                buffer = new SplineDefinition(elementName, rect.CreateSpline());
            }
            int addedTransforms = ParseTransformation(rectNode);

            WriteBufferTo(rectangles);
            return(addedTransforms);
        }
Beispiel #36
0
 /// <summary>
 /// Paints the interior of the specified rounded rectangle</summary>
 /// <param name="roundedRect">The dimensions of the rounded rectangle to paint, in pixels</param>
 /// <param name="brush">The brush used to paint the interior of the rounded rectangle</param>
 public void FillRoundedRectangle(D2dRoundedRect roundedRect, D2dBrush brush)
 {
     var tmp = new RoundedRectangle();
     tmp.RadiusX = roundedRect.RadiusX;
     tmp.RadiusY = roundedRect.RadiusY;
     var r = new SharpDX.RectangleF(
         roundedRect.Rect.Left,
         roundedRect.Rect.Top,
         roundedRect.Rect.Right,
         roundedRect.Rect.Bottom);
     tmp.Rect = r;
     m_renderTarget.FillRoundedRectangle(ref tmp, brush.NativeBrush);
 }
        private static Image DrawWatermark(Image img, string drawText)
        {
            if (!string.IsNullOrEmpty(drawText))
            {
                if (0 == Engine.conf.WatermarkFont.Size)
                {
                    Adapter.ShowFontDialog();
                }
                try
                {
                    int   offset        = (int)Engine.conf.WatermarkOffset;
                    Font  font          = XMLSettings.DeserializeFont(Engine.conf.WatermarkFont);
                    Size  textSize      = TextRenderer.MeasureText(drawText, font);
                    Size  labelSize     = new Size(textSize.Width + 10, textSize.Height + 10);
                    Point labelPosition = FindPosition(Engine.conf.WatermarkPositionMode, offset, img.Size,
                                                       new Size(textSize.Width + 10, textSize.Height + 10), 1);
                    if (Engine.conf.WatermarkAutoHide && ((img.Width < labelSize.Width + offset) ||
                                                          (img.Height < labelSize.Height + offset)))
                    {
                        return(img);
                        //throw new Exception("Image size smaller than watermark size.");
                    }
                    Rectangle    labelRectangle = new Rectangle(Point.Empty, labelSize);
                    GraphicsPath gPath          = RoundedRectangle.Create(labelRectangle, (int)Engine.conf.WatermarkCornerRadius);

                    int      backTrans = (int)Engine.conf.WatermarkBackTrans;
                    int      fontTrans = (int)Engine.conf.WatermarkFontTrans;
                    Color    fontColor = XMLSettings.DeserializeColor(Engine.conf.WatermarkFontColor);
                    Bitmap   bmp       = new Bitmap(labelRectangle.Width + 1, labelRectangle.Height + 1);
                    Graphics g         = Graphics.FromImage(bmp);
                    g.SmoothingMode     = SmoothingMode.HighQuality;
                    g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                    LinearGradientBrush brush;
                    if (Engine.conf.WatermarkUseCustomGradient)
                    {
                        brush = GradientMaker.CreateGradientBrush(labelRectangle.Size, Engine.conf.GradientMakerOptions.GetBrushDataActive());
                    }
                    else
                    {
                        brush = new LinearGradientBrush(labelRectangle, Color.FromArgb(backTrans, XMLSettings.DeserializeColor(Engine.conf.WatermarkGradient1)),
                                                        Color.FromArgb(backTrans, XMLSettings.DeserializeColor(Engine.conf.WatermarkGradient2)), Engine.conf.WatermarkGradientType);
                    }
                    g.FillPath(brush, gPath);
                    g.DrawPath(new Pen(Color.FromArgb(backTrans, XMLSettings.DeserializeColor(Engine.conf.WatermarkBorderColor))), gPath);
                    StringFormat sf = new StringFormat {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    };
                    g.DrawString(drawText, font, new SolidBrush(Color.FromArgb(fontTrans, fontColor)), bmp.Width / 2, bmp.Height / 2, sf);
                    Graphics gImg = Graphics.FromImage(img);
                    gImg.SmoothingMode = SmoothingMode.HighQuality;
                    gImg.DrawImage(bmp, labelPosition);
                    if (Engine.conf.WatermarkAddReflection)
                    {
                        Bitmap bmp2 = AddReflection(bmp, 50, 200);
                        gImg.DrawImage(bmp2, new Rectangle(labelPosition.X, labelPosition.Y + bmp.Height - 1, bmp2.Width, bmp2.Height));
                    }
                }
                catch (Exception ex)
                {
                    FileSystem.AppendDebug("Errow while drawing watermark", ex);
                }
            }

            return(img);
        }
Beispiel #38
0
        /// <summary>
        ///     Paint the actual visible parts
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPaint(object sender, PaintEventArgs e)
        {
            var graphics      = e.Graphics;
            var clipRectangle = e.ClipRectangle;

            graphics.DrawImageUnscaled(_capture.Bitmap, Point.Empty);
            // Only draw Cursor if it's (partly) visible
            if (_capture.Cursor != null && _capture.CursorVisible && clipRectangle.IntersectsWith(new Rectangle(_capture.CursorLocation, _capture.Cursor.Size)))
            {
                graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y);
            }

            if (_mouseDown || UsedCaptureMode == CaptureMode.Window || IsAnimating(_windowAnimator))
            {
                _captureRect = _captureRect.Intersect(new Rectangle(Point.Empty, _capture.ScreenBounds.Size)); // crop what is outside the screen

                var fixedRect = IsAnimating(_windowAnimator) ? _windowAnimator.Current : _captureRect;

                // If the _windowScroller != null, we can (most likely) capture the window with a scrolling technique
                if (WindowScroller != null && Equals(WindowScroller.ScrollBarWindow, SelectedCaptureWindow))
                {
                    graphics.FillRectangle(ScrollingOverlayBrush, fixedRect);
                }
                else
                {
                    graphics.FillRectangle(GreenOverlayBrush, fixedRect);
                }
                graphics.DrawRectangle(OverlayPen, fixedRect);

                // rulers
                const int dist = 8;

                string captureWidth;
                string captureHeight;
                // The following fixes the very old incorrect size information bug
                if (UsedCaptureMode == CaptureMode.Window)
                {
                    captureWidth  = _captureRect.Width.ToString(CultureInfo.InvariantCulture);
                    captureHeight = _captureRect.Height.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    captureWidth  = (_captureRect.Width + 1).ToString(CultureInfo.InvariantCulture);
                    captureHeight = (_captureRect.Height + 1).ToString(CultureInfo.InvariantCulture);
                }
                using (var rulerFont = new Font(FontFamily.GenericSansSerif, 8))
                {
                    var   measureWidth  = TextRenderer.MeasureText(captureWidth, rulerFont);
                    var   measureHeight = TextRenderer.MeasureText(captureHeight, rulerFont);
                    var   hSpace        = measureWidth.Width + 3;
                    var   vSpace        = measureHeight.Height + 3;
                    Brush bgBrush       = new SolidBrush(Color.FromArgb(200, 217, 240, 227));
                    var   rulerPen      = new Pen(Color.SeaGreen);

                    // horizontal ruler
                    if (fixedRect.Width > hSpace + 3)
                    {
                        using (var p = RoundedRectangle.Create2(
                                   fixedRect.X + (fixedRect.Width / 2 - hSpace / 2) + 3,
                                   fixedRect.Y - dist - 7,
                                   measureWidth.Width - 3,
                                   measureWidth.Height,
                                   3))
                        {
                            graphics.FillPath(bgBrush, p);
                            graphics.DrawPath(rulerPen, p);
                            graphics.DrawString(captureWidth, rulerFont, rulerPen.Brush, fixedRect.X + (fixedRect.Width / 2 - hSpace / 2) + 3, fixedRect.Y - dist - 7);
                            graphics.DrawLine(rulerPen, fixedRect.X, fixedRect.Y - dist, fixedRect.X + (fixedRect.Width / 2 - hSpace / 2), fixedRect.Y - dist);
                            graphics.DrawLine(rulerPen, fixedRect.X + fixedRect.Width / 2 + hSpace / 2, fixedRect.Y - dist, fixedRect.X + fixedRect.Width, fixedRect.Y - dist);
                            graphics.DrawLine(rulerPen, fixedRect.X, fixedRect.Y - dist - 3, fixedRect.X, fixedRect.Y - dist + 3);
                            graphics.DrawLine(rulerPen, fixedRect.X + fixedRect.Width, fixedRect.Y - dist - 3, fixedRect.X + fixedRect.Width, fixedRect.Y - dist + 3);
                        }
                    }

                    // vertical ruler
                    if (fixedRect.Height > vSpace + 3)
                    {
                        using (var p = RoundedRectangle.Create2(
                                   fixedRect.X - measureHeight.Width + 1,
                                   fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2) + 2,
                                   measureHeight.Width - 3,
                                   measureHeight.Height - 1,
                                   3))
                        {
                            graphics.FillPath(bgBrush, p);
                            graphics.DrawPath(rulerPen, p);
                            graphics.DrawString(captureHeight, rulerFont, rulerPen.Brush, fixedRect.X - measureHeight.Width + 1, fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2) + 2);
                            graphics.DrawLine(rulerPen, fixedRect.X - dist, fixedRect.Y, fixedRect.X - dist, fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2));
                            graphics.DrawLine(rulerPen, fixedRect.X - dist, fixedRect.Y + fixedRect.Height / 2 + vSpace / 2, fixedRect.X - dist, fixedRect.Y + fixedRect.Height);
                            graphics.DrawLine(rulerPen, fixedRect.X - dist - 3, fixedRect.Y, fixedRect.X - dist + 3, fixedRect.Y);
                            graphics.DrawLine(rulerPen, fixedRect.X - dist - 3, fixedRect.Y + fixedRect.Height, fixedRect.X - dist + 3, fixedRect.Y + fixedRect.Height);
                        }
                    }

                    rulerPen.Dispose();
                    bgBrush.Dispose();
                }

                // Display size of selected rectangle
                // Prepare the font and text.
                using (var sizeFont = new Font(FontFamily.GenericSansSerif, 12))
                {
                    // When capturing a Region we need to add 1 to the height/width for correction
                    string sizeText;
                    if (UsedCaptureMode == CaptureMode.Region)
                    {
                        // correct the GUI width to real width for the shown size
                        sizeText = _captureRect.Width + 1 + " x " + (_captureRect.Height + 1);
                    }
                    else
                    {
                        sizeText = _captureRect.Width + " x " + _captureRect.Height;
                    }

                    // Calculate the scaled font size.
                    var extent  = graphics.MeasureString(sizeText, sizeFont);
                    var hRatio  = _captureRect.Height / (extent.Height * 2);
                    var wRatio  = _captureRect.Width / (extent.Width * 2);
                    var ratio   = hRatio < wRatio ? hRatio : wRatio;
                    var newSize = sizeFont.Size * ratio;

                    if (newSize >= 4)
                    {
                        // Only show if 4pt or larger.
                        if (newSize > 20)
                        {
                            newSize = 20;
                        }
                        // Draw the size.
                        using (var newSizeFont = new Font(FontFamily.GenericSansSerif, newSize, FontStyle.Bold))
                        {
                            var sizeLocation = new PointF(fixedRect.X + _captureRect.Width / 2 - extent.Width / 2, fixedRect.Y + _captureRect.Height / 2 - newSizeFont.GetHeight() / 2);
                            graphics.DrawString(sizeText, newSizeFont, Brushes.LightSeaGreen, sizeLocation);

                            if (_showDebugInfo && SelectedCaptureWindow != null)
                            {
                                using (var process = Process.GetProcessById(SelectedCaptureWindow.GetProcessId()))
                                {
                                    string title         = $"#{SelectedCaptureWindow.Handle.ToInt64():X} - {(SelectedCaptureWindow.Text.Length > 0 ? SelectedCaptureWindow.Text : process.ProcessName)}";
                                    var    debugLocation = new PointF(fixedRect.X, fixedRect.Y);
                                    graphics.DrawString(title, sizeFont, Brushes.DarkOrange, debugLocation);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                using (var pen = new Pen(Color.LightSeaGreen))
                {
                    pen.DashStyle = DashStyle.Dot;
                    var screenBounds = _capture.ScreenBounds;
                    graphics.DrawLine(pen, _cursorPos.X, screenBounds.Y, _cursorPos.X, screenBounds.Height);
                    graphics.DrawLine(pen, screenBounds.X, _cursorPos.Y, screenBounds.Width, _cursorPos.Y);
                }

                var xy = _cursorPos.X + " x " + _cursorPos.Y;
                using (var f = new Font(FontFamily.GenericSansSerif, 8))
                {
                    var xySize = TextRenderer.MeasureText(xy, f);
                    using (var gp = RoundedRectangle.Create2(_cursorPos.X + 5, _cursorPos.Y + 5, xySize.Width - 3, xySize.Height, 3))
                    {
                        using (Brush bgBrush = new SolidBrush(Color.FromArgb(200, 217, 240, 227)))
                        {
                            graphics.FillPath(bgBrush, gp);
                        }
                        using (var pen = new Pen(Color.SeaGreen))
                        {
                            graphics.DrawPath(pen, gp);
                            var coordinatePosition = new Point(_cursorPos.X + 5, _cursorPos.Y + 5);
                            graphics.DrawString(xy, f, pen.Brush, coordinatePosition);
                        }
                    }
                }
            }

            // Zoom
            if (_zoomAnimator == null || (!IsAnimating(_zoomAnimator) && UsedCaptureMode == CaptureMode.Window))
            {
                return;
            }
            const int zoomSourceWidth  = 25;
            const int zoomSourceHeight = 25;

            var sourceRectangle = new NativeRect(_cursorPos.X - zoomSourceWidth / 2, _cursorPos.Y - zoomSourceHeight / 2, zoomSourceWidth, zoomSourceHeight);

            var destinationRectangle = _zoomAnimator.Current.Offset(_cursorPos);

            DrawZoom(graphics, sourceRectangle, destinationRectangle);
        }
Beispiel #39
0
        public MainPage()
        {
            InitializeComponent();

            CurvedStackLayout curvedStackLayout = new CurvedStackLayout()
            {
                BackgroundColor = Color.White
                , Padding       = 15, Margin = 15
            };



            RoundedRectangle rr = new RoundedRectangle {
                WidthRequest = 100, HeightRequest = 50, Radius = 1, Color = Color.BlueViolet
            };



            curvedStackLayout.Children.Add(new CustomFontLabel
            {
                FontSize = 25,
                FontName = "agencyr",
                Text     = "This is a label with a custom Font"
            });


            CustomDatePicker customDatePicker = new CustomDatePicker {
                Text = "Pick a day"
            };


            CustomTimePicker ctp = new CustomTimePicker(DateTime.Now)
            {
                Text = "Pick a time"
            };



            Editor editor = new Editor
            {
                Text          = "regular editor",
                HeightRequest = 100,
                WidthRequest  = 200
            };


            CustomEditor customEditor = new CustomEditor
            {
                HeightRequest     = 200,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                FontSize          = 25,
                FontName          = "agencyr",
                Text = "This is a custom editor with a custom Font"
            };

            //   curvedStackLayout.Children.Add(editor);

            curvedStackLayout.Children.Add(customEditor);
            curvedStackLayout.Children.Add(new Circle
            {
                Radius            = 20,
                Color             = Color.Black,
                HeightRequest     = 100,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            });



            curvedStackLayout.Children.Add(rr);
            curvedStackLayout.Children.Add(customDatePicker);
            curvedStackLayout.Children.Add(ctp);

            curvedStackLayout.Children.Add(new Calendar {
                HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 200
            });


            Label label = new Label {
                Text = "This is an image from a database"
            };

            curvedStackLayout.Children.Add(label);
            ResourceImage ri = new ResourceImage
            {
                SourceType    = ResourceImage.SourceTypes.Database,
                ResourceName  = "2",
                HeightRequest = 300,
                WidthRequest  = 300
            };

            curvedStackLayout.Children.Add(ri);

            scrollyScroll.Content = curvedStackLayout;
        }
Beispiel #40
0
        public void Fill(Rectangle rectangleRegion, Size roundedRectangleRadius, Brush brush)
        {
            Contract.Requires(Check.IsPositive(roundedRectangleRadius.Width));
            Contract.Requires(Check.IsPositive(roundedRectangleRadius.Height));
            Contract.Requires(brush != null);
            Contract.Assert(_Target != null);

            RectangleF rectangle = RectangleF.Empty;

            rectangle.Left = rectangleRegion.Left;
            rectangle.Top = rectangleRegion.Top;
            rectangle.Right = rectangleRegion.Right;
            rectangle.Bottom = rectangleRegion.Bottom;

            RoundedRectangle roundedRect = new RoundedRectangle
            {
                Rect = rectangle,
                RadiusX = roundedRectangleRadius.Width,
                RadiusY = roundedRectangleRadius.Height
            };

            _Target.FillRoundedRectangle(roundedRect, brush);
        }
Beispiel #41
0
        public void RoundedRectangle(Rectangle rectangle, Size cornerRadius)
        {
            if (Filling)
            {
                // adjust corner radius if we do stroke afterwards.

                var filledCornerRadiusX = Stroking
                    ? Math.Max(0, cornerRadius.Width - _state.StrokeWeight/2)
                    : cornerRadius.Width;

                var filledCornerRadiusY = Stroking
                    ? Math.Max(0, cornerRadius.Height - _state.StrokeWeight / 2)
                    : cornerRadius.Height;

                var roundedRect = new RoundedRectangle
                {
                    Rect = fillRect(rectangle),
                    RadiusX = filledCornerRadiusX.import(),
                    RadiusY = filledCornerRadiusY.import()
                };

                _target.FillRoundedRectangle(roundedRect, _fillBrush.Brush);
            }

            if (Stroking)
            {
                var roundedRect = new RoundedRectangle
                {
                    Rect = strokeAlignedRect(rectangle),
                    RadiusX = cornerRadius.Width.import(),
                    RadiusY = cornerRadius.Height.import()
                };

                _target.DrawRoundedRectangle(roundedRect, _strokeBrush.Brush, StrokeWeight);
            }
        }
        public void Setup()
        {
            DispatcherCache.Clear();

            circle = new Circle();
            rect = new Rectangle();
            roundedRect = new RoundedRectangle();
            morph = new Morph();
            ellipse = new Ellipse();
        }
Beispiel #43
0
        /// <summary>
        /// Renders the frame rate data as text to the game window against a colored panel backdrop.
        /// </summary>
        /// <param name="gameEngine">A reference to the <see cref="Tesseract"/> game engine.</param>
        public void Render(Tesseract gameEngine)
        {
            // Set up the text rendering for the frame rate display
            var context = gameEngine.DeviceManager.Context2D;
            Camera camera = gameEngine.Camera;
            Rectangle textLocation = new Rectangle(Location.X, Location.Y, Location.X + LineLength, Location.Y + 5*Size);

            // Calculate the time elapsed since the last call
            float elapsedTime = (float)gameEngine.Clock.Elapsed.TotalSeconds - LastTime;
            float elapsedTimeMs = elapsedTime * 1000f;
            LastTime = (float)gameEngine.Clock.Elapsed.TotalSeconds;

            // Fill in values for the formatted string being displayed
            Text = String.Format(FormatStr,
                1 / (elapsedTime), elapsedTimeMs,
                camera.Position.X, camera.Position.Y, camera.Position.Z,
                camera.Facing.X, camera.Facing.Y, camera.Facing.Z,
                camera.Yaw,
                camera.Pitch);

            // Create a colored panel backdrop for the text
            RoundedRectangle textPanel = new RoundedRectangle()
                {
                    Rect = new RectangleF(Location.X - 10, Location.Y - 5, LineLength + 10, Location.Y + 5*Size + 10),
                    RadiusX = 10f,
                    RadiusY = 10f,
                };

            // Render the text
            context.BeginDraw();
            context.Transform = Matrix.Identity;
            context.DrawRoundedRectangle(textPanel, PanelColorBrush);
            context.FillRoundedRectangle(textPanel, PanelColorBrush);
            context.DrawText(Text, Format, textLocation, FontColorBrush);
            context.EndDraw();
        }