Skip to content

Commit 0242f5b

Browse files
committed
- Avoid unnecessary border in QuickFind
- Dispose reused IEventHandler controls correctly - Custom ScrollBar improvements, more like VS (needs still work when disabled) - Draw AutoHideWindowControl border better - Removed unused image from SurroundMenu - Added disabled arrow system colors
1 parent 8efab05 commit 0242f5b

7 files changed

Lines changed: 63 additions & 42 deletions

File tree

‎External/Plugins/CodeRefactor/Controls/SurroundMenu.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace CodeRefactor.Controls
1212
{
1313
public class SurroundMenu : ToolStripMenuItem
1414
{
15-
private Image image;
1615
private List<String> items;
1716

1817
public SurroundMenu()
@@ -23,7 +22,7 @@ public SurroundMenu()
2322
/// <summary>
2423
///
2524
/// </summary>
26-
override public bool Enabled
25+
public override bool Enabled
2726
{
2827
set
2928
{
@@ -75,7 +74,7 @@ public void GenerateSnippets(ScintillaNet.ScintillaControl sci)
7574
content = File.ReadAllText(itm);
7675
if (content.IndexOf("{0}") > -1)
7776
{
78-
this.DropDownItems.Insert(this.DropDownItems.Count, new ToolStripMenuItem(Path.GetFileNameWithoutExtension(itm), image));
77+
this.DropDownItems.Insert(this.DropDownItems.Count, new ToolStripMenuItem(Path.GetFileNameWithoutExtension(itm)));
7978
}
8079
}
8180
}

‎FlashDevelop/Controls/QuickFind.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public void ApplyFixedDocumentPadding()
531531
{
532532
Rectangle find = this.RectangleToScreen(this.ClientRectangle);
533533
Rectangle doc = document.RectangleToScreen(document.ClientRectangle);
534-
if (this.Visible && doc.IntersectsWith(find)) document.Padding = new Padding(0, 0, 0, this.Height);
534+
if (this.Visible && doc.IntersectsWith(find)) document.Padding = new Padding(0, 0, 0, this.Height - 1);
535535
else document.Padding = new Padding(0);
536536
}
537537
}

‎FlashDevelop/Docking/TabbedDocument.cs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,16 @@ private void DocumentControlAdded(Object sender, ControlEventArgs e)
570570
this.UpdateDocumentIcon(this.FileName);
571571
}
572572

573-
public void Close()
573+
/// <summary>
574+
/// Close the document and update buttons
575+
/// </summary>
576+
public new void Close()
574577
{
575578
base.Close();
576579
ButtonManager.UpdateFlaggedButtons();
577580
}
581+
578582
}
583+
579584
}
585+

‎PluginCore/DockPanelSuite/Customization/DockPanelStripRenderer.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
472472
Graphics g = e.Graphics;
473473
Rectangle dropDownRect = e.ArrowRectangle;
474474
Color color = GetThemeColor("ToolStripItem.ArrowColor");
475-
if (color != Color.Empty) e.ArrowColor = color;
475+
if (!e.Item.Enabled) e.ArrowColor = SystemColors.GrayText;
476+
else if (color != Color.Empty) e.ArrowColor = color;
476477
else e.ArrowColor = SystemColors.MenuText;
477478
using (Brush brush = new SolidBrush(e.ArrowColor))
478479
{

‎PluginCore/DockPanelSuite/Docking/DockPanel.AutoHideWindow.cs‎

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -307,22 +307,23 @@ protected virtual Rectangle DisplayingRectangle
307307
get
308308
{
309309
Rectangle rect = ClientRectangle;
310+
Boolean flat = PluginCore.PluginBase.MainForm.GetThemeColor("AutoHideWindowControl.BackColor") != Color.Empty;
310311

311312
// exclude the border and the splitter
312313
if (DockState == DockState.DockBottomAutoHide)
313314
{
314-
rect.Y += 2 + Measures.SplitterSize;
315-
rect.Height -= 2 + Measures.SplitterSize;
315+
rect.Y += flat ? 1 : 2 + Measures.SplitterSize;
316+
rect.Height -= flat ? 1 : 2 + Measures.SplitterSize;
316317
}
317318
else if (DockState == DockState.DockRightAutoHide)
318319
{
319-
rect.X += 2 + Measures.SplitterSize;
320-
rect.Width -= 2 + Measures.SplitterSize;
320+
rect.X += flat ? 1 : 2 + Measures.SplitterSize;
321+
rect.Width -= flat ? 1 : 2 + Measures.SplitterSize;
321322
}
322323
else if (DockState == DockState.DockTopAutoHide)
323-
rect.Height -= 2 + Measures.SplitterSize;
324+
rect.Height -= flat ? 1 : 2 + Measures.SplitterSize;
324325
else if (DockState == DockState.DockLeftAutoHide)
325-
rect.Width -= 2 + Measures.SplitterSize;
326+
rect.Width -= flat ? 1 : 2 + Measures.SplitterSize;
326327

327328
return rect;
328329
}
@@ -331,24 +332,25 @@ protected virtual Rectangle DisplayingRectangle
331332
protected override void OnLayout(LayoutEventArgs levent)
332333
{
333334
DockPadding.All = 0;
335+
Boolean flat = PluginCore.PluginBase.MainForm.GetThemeColor("AutoHideWindowControl.BackColor") != Color.Empty;
334336
if (DockState == DockState.DockLeftAutoHide)
335337
{
336-
DockPadding.Right = 2;
338+
DockPadding.Right = flat ? 1 : 2;
337339
m_splitter.Dock = DockStyle.Right;
338340
}
339341
else if (DockState == DockState.DockRightAutoHide)
340342
{
341-
DockPadding.Left = 2;
343+
DockPadding.Left = flat ? 1 : 2;
342344
m_splitter.Dock = DockStyle.Left;
343345
}
344346
else if (DockState == DockState.DockTopAutoHide)
345347
{
346-
DockPadding.Bottom = 2;
348+
DockPadding.Bottom = flat ? 1 : 2;
347349
m_splitter.Dock = DockStyle.Bottom;
348350
}
349351
else if (DockState == DockState.DockBottomAutoHide)
350352
{
351-
DockPadding.Top = 2;
353+
DockPadding.Top = flat ? 1 : 2;
352354
m_splitter.Dock = DockStyle.Top;
353355
}
354356

@@ -374,22 +376,35 @@ protected override void OnPaint(PaintEventArgs e)
374376
{
375377
// Draw the border
376378
Graphics g = e.Graphics;
377-
379+
Color border = PluginCore.PluginBase.MainForm.GetThemeColor("AutoHideWindowControl.BackColor");
378380
if (DockState == DockState.DockBottomAutoHide)
379-
g.DrawLine(SystemPens.ControlLightLight, 0, 1, ClientRectangle.Right, 1);
381+
{
382+
if (border != Color.Empty) g.DrawLine(new Pen(border), 0, 1, ClientRectangle.Right, 1);
383+
else g.DrawLine(SystemPens.ControlLightLight, 0, 1, ClientRectangle.Right, 1);
384+
}
380385
else if (DockState == DockState.DockRightAutoHide)
381-
g.DrawLine(SystemPens.ControlLightLight, 1, 0, 1, ClientRectangle.Bottom);
386+
{
387+
if (border != Color.Empty) g.DrawLine(new Pen(border), 1, 0, 1, ClientRectangle.Bottom);
388+
else g.DrawLine(SystemPens.ControlLightLight, 1, 0, 1, ClientRectangle.Bottom);
389+
}
382390
else if (DockState == DockState.DockTopAutoHide)
383391
{
384-
g.DrawLine(SystemPens.ControlDark, 0, ClientRectangle.Height - 2, ClientRectangle.Right, ClientRectangle.Height - 2);
385-
g.DrawLine(SystemPens.ControlDarkDark, 0, ClientRectangle.Height - 1, ClientRectangle.Right, ClientRectangle.Height - 1);
392+
if (border != Color.Empty) g.DrawLine(new Pen(border), 0, ClientRectangle.Height - 1, ClientRectangle.Right, ClientRectangle.Height - 1);
393+
else
394+
{
395+
g.DrawLine(SystemPens.ControlDark, 0, ClientRectangle.Height - 2, ClientRectangle.Right, ClientRectangle.Height - 2);
396+
g.DrawLine(SystemPens.ControlDarkDark, 0, ClientRectangle.Height - 1, ClientRectangle.Right, ClientRectangle.Height - 1);
397+
}
386398
}
387399
else if (DockState == DockState.DockLeftAutoHide)
388400
{
389-
g.DrawLine(SystemPens.ControlDark, ClientRectangle.Width - 2, 0, ClientRectangle.Width - 2, ClientRectangle.Bottom);
390-
g.DrawLine(SystemPens.ControlDarkDark, ClientRectangle.Width - 1, 0, ClientRectangle.Width - 1, ClientRectangle.Bottom);
401+
if (border != Color.Empty) g.DrawLine(new Pen(border), 0, ClientRectangle.Height - 1, ClientRectangle.Right, ClientRectangle.Height - 1);
402+
else
403+
{
404+
g.DrawLine(SystemPens.ControlDark, ClientRectangle.Width - 2, 0, ClientRectangle.Width - 2, ClientRectangle.Bottom);
405+
g.DrawLine(SystemPens.ControlDarkDark, ClientRectangle.Width - 1, 0, ClientRectangle.Width - 1, ClientRectangle.Bottom);
406+
}
391407
}
392-
393408
base.OnPaint(e);
394409
}
395410

@@ -610,4 +625,5 @@ internal void RefreshAutoHideStrip()
610625
}
611626

612627
}
628+
613629
}

‎PluginCore/PluginCore/Controls/Common.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ public DataGridViewEx()
162162
EventManager.AddEventHandler(this, EventType.ApplyTheme);
163163
}
164164

165+
protected override void Dispose(bool disposing)
166+
{
167+
EventManager.RemoveEventHandler(this);
168+
base.Dispose(disposing);
169+
}
170+
165171
public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
166172
{
167173
if (e.Type == EventType.ApplyTheme)
@@ -329,6 +335,12 @@ public FlatCombo()
329335
EventManager.AddEventHandler(this, EventType.ApplyTheme);
330336
}
331337

338+
protected override void Dispose(bool disposing)
339+
{
340+
EventManager.RemoveEventHandler(this);
341+
base.Dispose(disposing);
342+
}
343+
332344
public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
333345
{
334346
if (e.Type == EventType.ApplyTheme)

‎PluginCore/ScintillaNet/ScintillaControl.cs‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,15 @@ private void OnScrollUpdate(ScintillaControl sender)
100100
sender.vScrollBar.Maximum = vMax;
101101
sender.vScrollBar.LargeChange = vPage;
102102
sender.vScrollBar.Value = sender.FirstVisibleLine;
103-
sender.vScrollBar.CurrentPosition = sender.VisibleFromDocLine(sender.CurrentLine);
103+
sender.vScrollBar.CurrentPosition = vMax > 1 ? sender.VisibleFromDocLine(sender.CurrentLine) : -1;
104104
sender.vScrollBar.Scroll += sender.OnScrollBarScroll;
105105
sender.hScrollBar.Scroll -= sender.OnScrollBarScroll;
106106
sender.hScrollBar.Minimum = 0;
107107
sender.hScrollBar.Maximum = sender.ScrollWidth;
108108
sender.hScrollBar.LargeChange = sender.Width;
109109
sender.hScrollBar.Value = sender.XOffset;
110110
sender.hScrollBar.Scroll += sender.OnScrollBarScroll;
111-
sender.vScrollBar.Visible = vMax > 1;
112-
if (sender.vScrollBar.Visible == vMax > 1)
113-
{
114-
sender.OnResize(null, null);
115-
}
111+
sender.vScrollBar.Enabled = vMax > 1;
116112
}
117113

118114
/// <summary>
@@ -132,11 +128,6 @@ private void OnScrollBarScroll(Object sender, ScrollEventArgs e)
132128
/// </summary>
133129
private void AddScrollBars(ScintillaControl sender)
134130
{
135-
if (this.InvokeRequired)
136-
{
137-
this.BeginInvoke((MethodInvoker)delegate { this.AddScrollBars(sender); });
138-
return;
139-
}
140131
sender.IsVScrollBar = false;
141132
sender.IsHScrollBar = false;
142133
sender.vScrollBar.Scroll += sender.OnScrollBarScroll;
@@ -152,11 +143,6 @@ private void AddScrollBars(ScintillaControl sender)
152143
/// </summary>
153144
private void RemoveScrollBars(ScintillaControl sender)
154145
{
155-
if (this.InvokeRequired)
156-
{
157-
this.BeginInvoke((MethodInvoker)delegate { this.RemoveScrollBars(sender); });
158-
return;
159-
}
160146
sender.IsVScrollBar = true;
161147
sender.IsHScrollBar = true;
162148
sender.vScrollBar.Scroll -= sender.OnScrollBarScroll;
@@ -203,14 +189,15 @@ public ScintillaControl(string fullpath)
203189

204190
protected override void Dispose(bool disposing)
205191
{
192+
EventManager.RemoveEventHandler(this);
206193
if (highlightDelay != null) highlightDelay.Stop();
207194
base.Dispose(disposing);
208195
}
209196

210197
public void OnResize(object sender, EventArgs e)
211198
{
212-
Int32 vsbWidth = this.vScrollBar.Visible && this.Controls.Contains(this.vScrollBar) ? this.vScrollBar.Width : 0;
213-
Int32 hsbHeight = this.hScrollBar.Visible && this.Controls.Contains(this.hScrollBar) ? this.hScrollBar.Height : 0;
199+
Int32 vsbWidth = this.Controls.Contains(this.vScrollBar) ? this.vScrollBar.Width : 0;
200+
Int32 hsbHeight = this.Controls.Contains(this.hScrollBar) ? this.hScrollBar.Height : 0;
214201
if (Win32.ShouldUseWin32()) SetWindowPos(this.hwndScintilla, 0, ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - vsbWidth, ClientRectangle.Height - hsbHeight, 0);
215202
}
216203

0 commit comments

Comments
 (0)