Skip to content

Commit

Permalink
#162 Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Mar 30, 2024
1 parent c491cf6 commit 627453e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
28 changes: 24 additions & 4 deletions src/ReaLTaiizor/Controls/Bubble/ChatBubbleLeft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ protected override void OnResize(EventArgs e)
Shape = new();

GraphicsPath _Shape = Shape;

_Shape.AddArc(9, 0, 10, 10, 180, 90);
_Shape.AddArc(Width - 11, 0, 10, 10, -90, 90);
_Shape.AddArc(Width - 11, Height - 11, 10, 10, 0, 90);
_Shape.AddArc(9, Height - 11, 10, 10, 90, 90);

_Shape.CloseAllFigures();

Invalidate();
Expand All @@ -118,33 +120,47 @@ protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

Size TS = TextRenderer.MeasureText(Text, Font);

if (_SizeAuto)
{
if (_SizeAutoW && _SizeAutoH)
{
Width = TextRenderer.MeasureText(Text, Font).Width + 15;
Height = TextRenderer.MeasureText(Text, Font).Height + 15;
Width = TS.Width + 15;
Height = TS.Height + 15;
}
else if (_SizeAutoW)
{
Width = TextRenderer.MeasureText(Text, Font).Width + 15;
Width = TS.Width + 15;
}
else
{
Height = TextRenderer.MeasureText(Text, Font).Height + 15;
int TH = 0;

using (Graphics CG = CreateGraphics())
{
SizeF SF = CG.MeasureString(Text, Font, Width - 17);
TH = (int)SF.Height;
}

Height = TH + 15;
//Height = TS.Height + 15;
}
}

Bitmap B = new(Width, Height);
Graphics G = Graphics.FromImage(B);

Graphics _G = G;

_G.SmoothingMode = SmoothingMode.HighQuality;
_G.PixelOffsetMode = PixelOffsetMode.HighQuality;

_G.Clear(BackColor);

// Fill the body of the bubble with the specified color
_G.FillPath(new SolidBrush(_BubbleColor), Shape);

// Draw the string specified in 'Text' property
_G.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(15, 7, Width - 17, Height - 5));

Expand All @@ -157,12 +173,16 @@ protected override void OnPaint(PaintEventArgs e)
new Point(0, Height - 25),
new Point(9, Height - 30)
};

_G.FillPolygon(new SolidBrush(_BubbleColor), p);
_G.DrawPolygon(new(new SolidBrush(_BubbleColor)), p);
}

G.Dispose();

e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
e.Graphics.DrawImageUnscaled(B, 0, 0);

B.Dispose();
}
}
Expand Down
29 changes: 25 additions & 4 deletions src/ReaLTaiizor/Controls/Bubble/ChatBubbleRight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ protected override void OnResize(EventArgs e)
Shape = new();

GraphicsPath _with1 = Shape;

_with1.AddArc(0, 0, 10, 10, 180, 90);
_with1.AddArc(Width - 18, 0, 10, 10, -90, 90);
_with1.AddArc(Width - 18, Height - 11, 10, 10, 0, 90);
_with1.AddArc(0, Height - 11, 10, 10, 90, 90);

_with1.CloseAllFigures();

Invalidate();
Expand All @@ -129,42 +131,58 @@ protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

Size TS = TextRenderer.MeasureText(Text, Font);

if (_SizeAuto)
{
int WW = Width;
if (_SizeAutoW && _SizeAutoH)
{
Width = TextRenderer.MeasureText(Text, Font).Width + 15;
Height = TextRenderer.MeasureText(Text, Font).Height + 15;
Width = TS.Width + 15;
Height = TS.Height + 15;

if (_SizeWidthLeft)
{
Location = new(Location.X - (Width - WW), Location.Y);
}
}
else if (_SizeAutoW)
{
Width = TextRenderer.MeasureText(Text, Font).Width + 15;
Width = TS.Width + 15;

if (_SizeWidthLeft)
{
Location = new(Location.X - (Width - WW), Location.Y);
}
}
else
{
Height = TextRenderer.MeasureText(Text, Font).Height + 15;
int TH = 0;

using (Graphics CG = CreateGraphics())
{
SizeF SF = CG.MeasureString(Text, Font, Width - 17);
TH = (int)SF.Height;
}

Height = TH + 15;
//Height = TS.Height + 15;
}
}

Bitmap B = new(Width, Height);
Graphics G = Graphics.FromImage(B);

Graphics _G = G;

_G.SmoothingMode = SmoothingMode.HighQuality;
_G.PixelOffsetMode = PixelOffsetMode.HighQuality;

_G.Clear(BackColor);

// Fill the body of the bubble with the specified color
_G.FillPath(new SolidBrush(_BubbleColor), Shape);

// Draw the string specified in 'Text' property
_G.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(6, 7, Width - 15, Height));

Expand All @@ -177,13 +195,16 @@ protected override void OnPaint(PaintEventArgs e)
new Point(Width, Height - 25),
new Point(Width - 8, Height - 30)
};

_G.FillPolygon(new SolidBrush(_BubbleColor), p);
_G.DrawPolygon(new(new SolidBrush(_BubbleColor)), p);
}

G.Dispose();

e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
e.Graphics.DrawImageUnscaled(B, 0, 0);

B.Dispose();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ReaLTaiizor/ReaLTaiizor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Creator: Taiizor
// Website: www.Vegalya.com
// Created: 15.May.2019
// Changed: 29.Mar.2024
// Changed: 30.Mar.2024
// Version: 3.8.0.5
//
// |---------DO-NOT-REMOVE---------|
Expand Down

0 comments on commit 627453e

Please sign in to comment.