Skip to content

Commit ff63671

Browse files
committed
Update to scale based on DPI. Fixed crash when using locale other than en_US. Update to work with FD5.
1 parent 49c09f3 commit ff63671

21 files changed

+1616
-1577
lines changed

.gitattributes

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Set default behaviour, in case users don't have core.autocrlf set.
2+
* text=auto
3+
4+
*.cs text diff=csharp eol=crlf
5+
*.sln text merge=union eol=crlf
6+
*.csproj text eol=crlf
7+
*.xaml text eol=crlf
8+
*.resx text merge=union
9+
10+
# Denote all files that are truly binary and should not be modified.
11+
*.png binary
12+
*.jpg binary
13+
*.dll binary
14+
*.exe binary
15+
*.pdb binary

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Bb]in
2+
[Oo]bj
3+
[Tt]est[Rr]esult*
4+
build/
5+
packages/
6+
*AppPackages/
7+
*BundleArtifacts/
8+
*.userprefs
9+
*.suo
10+
*.sln.cache
11+
*.user
12+
*.orig
13+
*.nupkg
14+
.DS_Store
15+
Thumbs.db
16+
*.GhostDoc.xml
17+
*.sln.ide
18+
.vs/

Controls/GroupItems.cs

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,41 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Windows.Forms;
5-
using QuickLaunch.Controls;
6-
7-
namespace QuickLaunch.Controls
8-
{
9-
/// <summary>
10-
/// Contains a collection of ToolStripGroupItems.
11-
/// </summary>
12-
public class GroupItems
13-
{
14-
private string _name = string.Empty;
15-
private ToolStripItem[] _items = null;
16-
17-
public GroupItems(string name, List<ToolStripGroupItem> items)
18-
{
19-
List<ToolStripItem> groupItems = new List<ToolStripItem>();
20-
21-
// Add the group separator as the first item.
22-
groupItems.Add(new ToolStripGroupSeparator(string.Format("{0} ({1})", name, items.Count)));
23-
foreach (ToolStripItem item in items)
24-
groupItems.Add(item);
25-
_items = groupItems.ToArray();
26-
}
27-
28-
/// <summary>
29-
/// Gets the name of the group.
30-
/// </summary>
31-
public string Name
32-
{
33-
get { return _name; }
34-
}
35-
36-
/// <summary>
37-
/// Gets the items in the group.
38-
/// </summary>
39-
public ToolStripItem[] Items
40-
{
41-
get { return _items; }
42-
}
43-
}
44-
}
1+
using System.Collections.Generic;
2+
using System.Windows.Forms;
3+
4+
namespace QuickLaunch.Controls
5+
{
6+
/// <summary>
7+
/// Contains a collection of ToolStripGroupItems.
8+
/// </summary>
9+
public class GroupItems
10+
{
11+
private string _name = string.Empty;
12+
private ToolStripItem[] _items = null;
13+
14+
public GroupItems(string name, List<ToolStripGroupItem> items)
15+
{
16+
List<ToolStripItem> groupItems = new List<ToolStripItem>();
17+
18+
// Add the group separator as the first item.
19+
groupItems.Add(new ToolStripGroupSeparator(string.Format("{0} ({1})", name, items.Count)));
20+
foreach (ToolStripItem item in items)
21+
groupItems.Add(item);
22+
_items = groupItems.ToArray();
23+
}
24+
25+
/// <summary>
26+
/// Gets the name of the group.
27+
/// </summary>
28+
public string Name
29+
{
30+
get { return _name; }
31+
}
32+
33+
/// <summary>
34+
/// Gets the items in the group.
35+
/// </summary>
36+
public ToolStripItem[] Items
37+
{
38+
get { return _items; }
39+
}
40+
}
41+
}

Controls/ToolStripGroupItem.cs

Lines changed: 85 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,85 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Windows.Forms;
5-
using System.Drawing;
6-
7-
namespace QuickLaunch.Controls
8-
{
9-
public class ToolStripGroupItem : ToolStripMenuItem
10-
{
11-
string _name = string.Empty;
12-
string _details = string.Empty;
13-
14-
public ToolStripGroupItem(string name)
15-
: this(name, null, null, null)
16-
{
17-
18-
}
19-
20-
public ToolStripGroupItem(string name, string details)
21-
: this(name, details, null, null)
22-
{
23-
24-
}
25-
26-
public ToolStripGroupItem(string name, string details, Image image)
27-
: this(name, details, image, null)
28-
{
29-
30-
}
31-
32-
public ToolStripGroupItem(string name, string details, Image image, EventHandler onClick)
33-
: base(string.Format("{0} ({1})WWWWWW", name, details), image, onClick)
34-
{
35-
_name = name;
36-
_details = string.IsNullOrEmpty(details) ? string.Empty : "(" + details + ")";
37-
}
38-
39-
protected bool IsVertical
40-
{
41-
get { return !IsOnOverflow && Owner.Orientation != Orientation.Horizontal; }
42-
}
43-
44-
protected override void OnPaint(PaintEventArgs e)
45-
{
46-
if (!IsVertical)
47-
{
48-
// Draw the background
49-
Owner.Renderer.DrawMenuItemBackground(new ToolStripItemRenderEventArgs(e.Graphics, this));
50-
51-
int padding = this.Owner.Padding.Left;
52-
53-
// Draw the image
54-
padding += 4;
55-
if (Image != null)
56-
e.Graphics.DrawImage(Image, padding, (e.ClipRectangle.Height - Image.Height) / 2);
57-
58-
// Draw the name text
59-
padding += 23;
60-
Size textSize = TextRenderer.MeasureText(_name, Owner.Font);
61-
Rectangle textRectangle = new Rectangle(padding, 0, textSize.Width, this.Height);
62-
Owner.Renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(e.Graphics, this, _name, textRectangle, Owner.ForeColor, Owner.Font, ContentAlignment.MiddleLeft));
63-
64-
// Draw the details text
65-
if (!string.IsNullOrEmpty(_details))
66-
{
67-
padding += textSize.Width;
68-
textSize = TextRenderer.MeasureText(_details, Owner.Font);
69-
textRectangle = new Rectangle(padding, 0, textSize.Width, this.Height);
70-
Owner.Renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(e.Graphics, this, _details, textRectangle, Color.Gray, Owner.Font, ContentAlignment.MiddleLeft));
71-
}
72-
}
73-
else
74-
{
75-
base.OnPaint(e);
76-
}
77-
}
78-
}
79-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Windows.Forms;
5+
using System.Drawing;
6+
using PluginCore.Helpers;
7+
8+
namespace QuickLaunch.Controls
9+
{
10+
public class ToolStripGroupItem : ToolStripMenuItem
11+
{
12+
string _name = string.Empty;
13+
string _details = string.Empty;
14+
15+
public ToolStripGroupItem(string name)
16+
: this(name, null, null, null)
17+
{
18+
19+
}
20+
21+
public ToolStripGroupItem(string name, string details)
22+
: this(name, details, null, null)
23+
{
24+
25+
}
26+
27+
public ToolStripGroupItem(string name, string details, Image image)
28+
: this(name, details, image, null)
29+
{
30+
31+
}
32+
33+
public ToolStripGroupItem(string name, string details, Image image, EventHandler onClick)
34+
: base(string.Format("{0} ({1})WWWWWW", name, details), image, onClick)
35+
{
36+
_name = name;
37+
_details = string.IsNullOrEmpty(details) ? string.Empty : "(" + details + ")";
38+
}
39+
40+
protected bool IsVertical
41+
{
42+
get { return !IsOnOverflow && Owner.Orientation != Orientation.Horizontal; }
43+
}
44+
45+
protected override void OnPaint(PaintEventArgs e)
46+
{
47+
if (!IsVertical)
48+
{
49+
// Draw the background
50+
Owner.Renderer.DrawMenuItemBackground(new ToolStripItemRenderEventArgs(e.Graphics, this));
51+
52+
int padding = this.Owner.Padding.Left;
53+
54+
// Draw the image
55+
padding += ScaleHelper.Scale(4);
56+
if (Image != null)
57+
{
58+
Rectangle source = new Rectangle(0, 0, Image.Width, Image.Height);
59+
Rectangle dest = new Rectangle(new Point(padding, 0), ScaleHelper.Scale(new Size(16, 16)));
60+
dest.Offset(0, (e.ClipRectangle.Height - dest.Height) / 2);
61+
e.Graphics.DrawImage(Image, dest, source, GraphicsUnit.Pixel);
62+
}
63+
64+
// Draw the name text
65+
padding += ScaleHelper.Scale(23);
66+
Size textSize = TextRenderer.MeasureText(_name, Owner.Font);
67+
Rectangle textRectangle = new Rectangle(padding, 0, textSize.Width, this.Height);
68+
Owner.Renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(e.Graphics, this, _name, textRectangle, Owner.ForeColor, Owner.Font, ContentAlignment.MiddleLeft));
69+
70+
// Draw the details text
71+
if (!string.IsNullOrEmpty(_details))
72+
{
73+
padding += textSize.Width;
74+
textSize = TextRenderer.MeasureText(_details, Owner.Font);
75+
textRectangle = new Rectangle(padding, 0, textSize.Width, this.Height);
76+
Owner.Renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(e.Graphics, this, _details, textRectangle, Color.Gray, Owner.Font, ContentAlignment.MiddleLeft));
77+
}
78+
}
79+
else
80+
{
81+
base.OnPaint(e);
82+
}
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)