[WIP] fixing profile ILV

Fixing text position and sorting
out the selection rectangle. Have
fixed the shortcut library window
and working fine now.
This commit is contained in:
Terry MacDonald 2021-03-01 21:35:03 +13:00
parent c3fe6c5b50
commit fad79cd315
2 changed files with 50 additions and 40 deletions

View File

@ -6,6 +6,7 @@ using System.Drawing.Imaging;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
using Manina.Windows.Forms; using Manina.Windows.Forms;
namespace DisplayMagician.UIForms namespace DisplayMagician.UIForms
@ -16,29 +17,22 @@ namespace DisplayMagician.UIForms
{ {
// Returns item size for the given view mode. // Returns item size for the given view mode.
#pragma warning disable CS3001 // Argument type is not CLS-compliant #pragma warning disable CS3001 // Argument type is not CLS-compliant
public override Size MeasureItem(View view) public override Size MeasureItem(Manina.Windows.Forms.View view)
#pragma warning restore CS3001 // Argument type is not CLS-compliant #pragma warning restore CS3001 // Argument type is not CLS-compliant
{ {
Size itemPadding = new Size(4, 4); // Reference text height
Size sz = ImageListView.ThumbnailSize + int textHeight = ImageListView.Font.Height;
itemPadding + itemPadding;
return sz;
/*if (view == View.Thumbnails) Size itemSize = new Size();
{
//Size itemPadding = new Size(4, 4); itemSize.Height = ImageListView.ThumbnailSize.Height + 2 * textHeight + 4 * 3;
//Size sz = ImageListView.ThumbnailSize + itemSize.Width = ImageListView.ThumbnailSize.Width + 4 * 3;
// itemPadding + itemPadding; return itemSize;
Size sz = ImageListView.ThumbnailSize;
return sz;
}
else
return base.MeasureItem(view);*/
} }
// Draws the background of the control. // Draws the background of the control.
public override void DrawBackground(Graphics g, Rectangle bounds) public override void DrawBackground(Graphics g, Rectangle bounds)
{ {
if (ImageListView.View == View.Thumbnails) if (ImageListView.View == Manina.Windows.Forms.View.Thumbnails)
g.Clear(Color.FromArgb(255, 255, 255)); g.Clear(Color.FromArgb(255, 255, 255));
else else
base.DrawBackground(g, bounds); base.DrawBackground(g, bounds);
@ -60,13 +54,19 @@ namespace DisplayMagician.UIForms
Size itemPadding = new Size(4, 4); Size itemPadding = new Size(4, 4);
bool alternate = (item.Index % 2 == 1); bool alternate = (item.Index % 2 == 1);
Point imagePoint = new Point(bounds.X+3, bounds.Y+3);
Size imageSize = new Size();
imageSize.Height = ImageListView.ThumbnailSize.Height;
imageSize.Width = ImageListView.ThumbnailSize.Width;
Rectangle imageBounds = new Rectangle(imagePoint, imageSize);
// Paint background // Paint background
if (ImageListView.Enabled) if (ImageListView.Enabled)
{ {
using (Brush bItemBack = new SolidBrush(alternate && ImageListView.View == View.Details ? using (Brush bItemBack = new SolidBrush(alternate && ImageListView.View == Manina.Windows.Forms.View.Details ?
ImageListView.Colors.AlternateBackColor : ImageListView.Colors.BackColor)) ImageListView.Colors.AlternateBackColor : ImageListView.Colors.BackColor))
{ {
//g.FillRectangle(bItemBack, bounds);
g.FillRectangle(bItemBack, bounds); g.FillRectangle(bItemBack, bounds);
} }
} }
@ -74,16 +74,18 @@ namespace DisplayMagician.UIForms
{ {
using (Brush bItemBack = new SolidBrush(ImageListView.Colors.DisabledBackColor)) using (Brush bItemBack = new SolidBrush(ImageListView.Colors.DisabledBackColor))
{ {
//g.FillRectangle(bItemBack, bounds);
g.FillRectangle(bItemBack, bounds); g.FillRectangle(bItemBack, bounds);
} }
} }
if ((state & ItemState.Selected) != ItemState.None) if ((state & ItemState.Selected) != ItemState.None)
{ {
//using (Brush bSelected = new LinearGradientBrush(bounds, ImageListView.Colors.SelectedColor1, ImageListView.Colors.SelectedColor2, LinearGradientMode.Vertical)) //using (Brush bSelected = new LinearGradientBrush(bounds, Color.WhiteSmoke, Color.LightGray, LinearGradientMode.Vertical))
using (Brush bSelected = new LinearGradientBrush(bounds, Color.WhiteSmoke, Color.LightGray, LinearGradientMode.Vertical)) using (Brush bSelected = new LinearGradientBrush(bounds, Color.WhiteSmoke, Color.LightGray, LinearGradientMode.Vertical))
{ {
Utility.FillRoundedRectangle(g, bSelected, bounds, 12); //Utility.FillRoundedRectangle(g, bSelected, bounds, 12);
Utility.FillRoundedRectangle(g, bSelected, imageBounds, 12);
} }
} }
@ -134,13 +136,19 @@ namespace DisplayMagician.UIForms
else else
foreColor = ImageListView.Colors.UnFocusedForeColor; foreColor = ImageListView.Colors.UnFocusedForeColor;
} }
Size szt = TextRenderer.MeasureText(item.Text, ImageListView.Font);
Rectangle rt = new Rectangle(bounds.Left + itemPadding.Width, bounds.Top + itemPadding.Height + ImageListView.ThumbnailSize.Height, ImageListView.ThumbnailSize.Width, 3 * szt.Height);
TextFormatFlags flags = TextFormatFlags.EndEllipsis | TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak;
TextRenderer.DrawText(g, item.Text, ImageListView.Font, rt, foreColor, flags);
if ((state & ItemState.Selected) != ItemState.None) if ((state & ItemState.Selected) != ItemState.None)
{ {
using (Pen pSelectedBorder = new Pen(Color.Brown,4)) using (Pen pSelectedBorder = new Pen(Color.Brown,4))
{ {
//DrawRoundedRectangle(g, pSelectedBorder, bounds, 9); //DrawRoundedRectangle(g, pSelectedBorder, bounds, 9);
Utility.DrawRoundedRectangle(g, pSelectedBorder, bounds.Left+3, bounds.Top+3, bounds.Width - 5, bounds.Height - 5, 10); //Utility.DrawRoundedRectangle(g, pSelectedBorder, bounds.Left+3, bounds.Top+3, bounds.Width - 5, bounds.Height - 5, 10);
Utility.DrawRoundedRectangle(g, pSelectedBorder, imageBounds.Left, imageBounds.Top, imageBounds.Width, imageBounds.Height, 10);
} }
} }
} }
@ -170,29 +178,22 @@ namespace DisplayMagician.UIForms
{ {
// Returns item size for the given view mode. // Returns item size for the given view mode.
#pragma warning disable CS3001 // Argument type is not CLS-compliant #pragma warning disable CS3001 // Argument type is not CLS-compliant
public override Size MeasureItem(View view) public override Size MeasureItem(Manina.Windows.Forms.View view)
#pragma warning restore CS3001 // Argument type is not CLS-compliant #pragma warning restore CS3001 // Argument type is not CLS-compliant
{ {
Size itemPadding = new Size(4, 4); // Reference text height
Size sz = ImageListView.ThumbnailSize + int textHeight = ImageListView.Font.Height;
itemPadding + itemPadding;
return sz;
/*if (view == View.Thumbnails) Size itemSize = new Size();
{
//Size itemPadding = new Size(4, 4); itemSize.Height = ImageListView.ThumbnailSize.Height + 2 * textHeight + 4 * 3;
//Size sz = ImageListView.ThumbnailSize + itemSize.Width = ImageListView.ThumbnailSize.Width + 4 * 3;
// itemPadding + itemPadding; return itemSize;
Size sz = ImageListView.ThumbnailSize;
return sz;
}
else
return base.MeasureItem(view);*/
} }
// Draws the background of the control. // Draws the background of the control.
public override void DrawBackground(Graphics g, Rectangle bounds) public override void DrawBackground(Graphics g, Rectangle bounds)
{ {
if (ImageListView.View == View.Thumbnails) if (ImageListView.View == Manina.Windows.Forms.View.Thumbnails)
g.Clear(Color.FromArgb(255, 255, 255)); g.Clear(Color.FromArgb(255, 255, 255));
else else
base.DrawBackground(g, bounds); base.DrawBackground(g, bounds);
@ -214,11 +215,16 @@ namespace DisplayMagician.UIForms
Size itemPadding = new Size(4, 4); Size itemPadding = new Size(4, 4);
bool alternate = (item.Index % 2 == 1); bool alternate = (item.Index % 2 == 1);
Point imagePoint = new Point(bounds.X + 3, bounds.Y + 3);
Size imageSize = new Size();
imageSize.Height = ImageListView.ThumbnailSize.Height;
imageSize.Width = ImageListView.ThumbnailSize.Width;
Rectangle imageBounds = new Rectangle(imagePoint, imageSize);
// Paint background // Paint background
if (ImageListView.Enabled) if (ImageListView.Enabled)
{ {
using (Brush bItemBack = new SolidBrush(alternate && ImageListView.View == View.Details ? using (Brush bItemBack = new SolidBrush(alternate && ImageListView.View == Manina.Windows.Forms.View.Details ?
ImageListView.Colors.AlternateBackColor : ImageListView.Colors.BackColor)) ImageListView.Colors.AlternateBackColor : ImageListView.Colors.BackColor))
{ {
g.FillRectangle(bItemBack, bounds); g.FillRectangle(bItemBack, bounds);
@ -237,7 +243,7 @@ namespace DisplayMagician.UIForms
//using (Brush bSelected = new LinearGradientBrush(bounds, ImageListView.Colors.SelectedColor1, ImageListView.Colors.SelectedColor2, LinearGradientMode.Vertical)) //using (Brush bSelected = new LinearGradientBrush(bounds, ImageListView.Colors.SelectedColor1, ImageListView.Colors.SelectedColor2, LinearGradientMode.Vertical))
using (Brush bSelected = new LinearGradientBrush(bounds, Color.WhiteSmoke, Color.LightGray, LinearGradientMode.Vertical)) using (Brush bSelected = new LinearGradientBrush(bounds, Color.WhiteSmoke, Color.LightGray, LinearGradientMode.Vertical))
{ {
Utility.FillRoundedRectangle(g, bSelected, bounds, 12); Utility.FillRoundedRectangle(g, bSelected, imageBounds, 12);
} }
} }
@ -288,13 +294,17 @@ namespace DisplayMagician.UIForms
else else
foreColor = ImageListView.Colors.UnFocusedForeColor; foreColor = ImageListView.Colors.UnFocusedForeColor;
} }
Size szt = TextRenderer.MeasureText(item.Text, ImageListView.Font);
Rectangle rt = new Rectangle(bounds.Left + itemPadding.Width, bounds.Top + itemPadding.Height + ImageListView.ThumbnailSize.Height + 4, ImageListView.ThumbnailSize.Width, 3 * szt.Height);
TextFormatFlags flags = TextFormatFlags.EndEllipsis | TextFormatFlags.HorizontalCenter | TextFormatFlags.Top | TextFormatFlags.WordBreak;
TextRenderer.DrawText(g, item.Text, ImageListView.Font, rt, foreColor, flags);
if ((state & ItemState.Selected) != ItemState.None) if ((state & ItemState.Selected) != ItemState.None)
{ {
using (Pen pSelectedBorder = new Pen(Color.Brown, 4)) using (Pen pSelectedBorder = new Pen(Color.Brown, 4))
{ {
//DrawRoundedRectangle(g, pSelectedBorder, bounds, 9); //DrawRoundedRectangle(g, pSelectedBorder, bounds, 9);
Utility.DrawRoundedRectangle(g, pSelectedBorder, bounds.Left + 3, bounds.Top + 3, bounds.Width - 5, bounds.Height - 5, 10); Utility.DrawRoundedRectangle(g, pSelectedBorder, imageBounds.Left + 3, imageBounds.Top + 3, imageBounds.Width - 5, imageBounds.Height - 5, 10);
} }
} }
} }

View File

@ -264,7 +264,7 @@
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false; this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(1150, 755); this.MaximumSize = new System.Drawing.Size(1150, 755);
this.MinimumSize = new System.Drawing.Size(756, 375); this.MinimumSize = new System.Drawing.Size(848, 390);
this.Name = "ShortcutLibraryForm"; this.Name = "ShortcutLibraryForm";
this.ShowIcon = false; this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;