-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restyle package details to show title and button
- Loading branch information
Showing
11 changed files
with
786 additions
and
568 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Windows.Forms; | ||
|
||
namespace Bonsai.NuGet.Design | ||
{ | ||
internal class ImageLinkLabel : LinkLabel | ||
{ | ||
public ImageLinkLabel() | ||
{ | ||
ImageAlign = ContentAlignment.MiddleLeft; | ||
TextAlign = ContentAlignment.MiddleRight; | ||
} | ||
|
||
public new Image Image | ||
{ | ||
get => base.Image; | ||
set | ||
{ | ||
base.Image = value; | ||
if (AutoSize) | ||
{ | ||
// force size calculation | ||
AutoSize = false; | ||
AutoSize = true; | ||
} | ||
} | ||
} | ||
|
||
public override Size GetPreferredSize(Size proposedSize) | ||
{ | ||
var size = base.GetPreferredSize(proposedSize); | ||
if (Image != null) | ||
{ | ||
using var graphics = CreateGraphics(); | ||
var imageSize = Size.Ceiling(graphics.GetImageSize(Image)); | ||
size.Width += imageSize.Width; | ||
size.Height = Math.Max(size.Height, imageSize.Height); | ||
} | ||
return size; | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.