Skip to content

Commit

Permalink
Windows 10 1511 enhancements + maximized windows bug fix trying
Browse files Browse the repository at this point in the history
  • Loading branch information
Cocotteseb committed Dec 5, 2015
1 parent 71e5f32 commit 621ab7c
Show file tree
Hide file tree
Showing 14 changed files with 993 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk
*.bak
*.suo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,28 @@ public class AccurateText : GlobalId
try
{
if (composition && glowing)
DrawCompositionGlowingText(g, memento.Text, memento.Font, rect, state,
SystemColors.ActiveCaptionText, true);
//DrawCompositionGlowingText(g, memento.Text, memento.Font, rect, state,
// SystemColors.ActiveCaptionText, true);
if (Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= 10586)
{
DrawCompositionGlowingText(g, memento.Text, memento.Font, rect, state, (state == PaletteState.Disabled) ? Color.FromArgb(170,170,170) : ContrastColor(AccentColorService.GetColorByTypeName("ImmersiveSystemAccent")), true);
}
else
{
DrawCompositionGlowingText(g, memento.Text, memento.Font, rect, state, SystemColors.ActiveCaptionText, true);
}
else if (composition)
{
//Check if correct in all cases
SolidBrush tmpBrush = brush as SolidBrush;
Color tmpColor;
if ( tmpBrush.Color == null)
if (tmpBrush.Color == null)
tmpColor = SystemColors.ActiveCaptionText;
else
tmpColor = tmpBrush.Color;
DrawCompositionText(g, memento.Text, memento.Font, rect, state,
tmpColor , true, memento.Format);

DrawCompositionText(g, memento.Text, memento.Font, rect, state,
tmpColor, true, memento.Format);
}
else
g.DrawString(memento.Text, memento.Font, brush, rect, memento.Format);
Expand All @@ -291,6 +299,28 @@ public class AccurateText : GlobalId

return ret;
}

private static Color ContrastColor(Color color)
{
int d = 0;
// Counting the perceptive luminance - human eye favors green color...
double a = (1
- (((0.299 * color.R)
+ ((0.587 * color.G) + (0.114 * color.B)))
/ 255));
if ((a < 0.5))
{
d = 0;
}
else
{
// bright colors - black font
d = 255;
}

// dark colors - white font
return Color.FromArgb(d, d, d);
}
#endregion

#region Implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@
<Compile Include="Palette Controls\PaletteDataGridViewTripleCommon.cs" />
<Compile Include="Palette Controls\PaletteDataGridViewTripleRedirect.cs" />
<Compile Include="Palette Controls\PaletteColorButtonStrings.cs" />
<Compile Include="Rendering\RenderOffice2013.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Rendering\Win10Glass\AccentColorService.cs" />
<Compile Include="Rendering\Win10Glass\BlurWindowExtensions.cs" />
<Compile Include="Rendering\KryptonOffice2013Renderer.cs" />
<Compile Include="Rendering\RenderExpertHelpers.cs" />
<Compile Include="Rendering\RenderOffice2007.cs">
Expand All @@ -432,6 +437,8 @@
<Compile Include="Rendering\RenderSparkle.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Rendering\Win10Glass\ThemeService.cs" />
<Compile Include="Rendering\Win10Glass\UserSystemPreferencesService.cs" />
<Compile Include="Values\CheckBoxImages.cs">
</Compile>
<Compile Include="Palette Controls\PaletteHeaderButtonRedirect.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,9 +991,23 @@ protected override void WndProc(ref Message m)

// We do not process the message if on an MDI child, because doing so prevents the
// LayoutMdi call on the parent from working and cascading/tiling the children
if ((m.Msg == (int)PI.WM_NCCALCSIZE) && _themedApp &&
((MdiParent == null) || ApplyCustomChrome))
processed = OnWM_NCCALCSIZE(ref m);
//if ((m.Msg == (int)PI.WM_NCCALCSIZE) && _themedApp &&
// ((MdiParent == null) || ApplyCustomChrome))
if (_themedApp && ((MdiParent == null) || ApplyCustomChrome))
{
switch (m.Msg)
{
case PI.WM_NCCALCSIZE:
processed = OnWM_NCCALCSIZE(ref m);
break;
case PI.WM_GETMINMAXINFO:
OnWM_GETMINMAXINFO(ref m);
/* Setting handled to false enables the application to process it's own Min/Max requirements,
* as mentioned by jason.bullard (comment from September 22, 2011) on http://gallery.expression.microsoft.com/ZuneWindowBehavior/ */
processed = false;
break;
}
}

// Do we need to override message processing?
if (ApplyCustomChrome && !IsDisposed && !Disposing)
Expand Down Expand Up @@ -1085,10 +1099,43 @@ protected override void WndProc(ref Message m)
}

// If the message has not been handled, let base class process it
if (!processed)
if (!processed && m.Msg != PI.WM_GETMINMAXINFO)
base.WndProc(ref m);
}

/// <summary>
/// Creates and populates the MINMAXINFO structure for a maximized window.
/// Puts the structure into memory address given by lParam.
/// Only used to process a WM_GETMINMAXINFO message.
/// </summary>
/// <param name="m">A Windows-based message.</param>
/// <returns>True if the message was processed; otherwise false.</returns>
[SecuritySafeCritical]
protected virtual void OnWM_GETMINMAXINFO(ref Message m)
{

PI.MINMAXINFO mmi = (PI.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(PI.MINMAXINFO));

// Adjust the maximized size and position to fit the work area of the correct monitor
int MONITOR_DEFAULTTONEAREST = 0x00000002;
System.IntPtr monitor = PI.MonitorFromWindow(m.HWnd, MONITOR_DEFAULTTONEAREST);

if (monitor != System.IntPtr.Zero)
{

PI.MONITORINFO monitorInfo = new PI.MONITORINFO();
PI.GetMonitorInfo(monitor, monitorInfo);
PI.RECT rcWorkArea = monitorInfo.rcWork;
PI.RECT rcMonitorArea = monitorInfo.rcMonitor;
mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
}

Marshal.StructureToPtr(mmi, m.LParam, true);
}

/// <summary>
/// Process the WM_NCCALCSIZE message when overriding window chrome.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ public static bool IsCompositionEnabled
// Desktop composition is only available on Vista upwards
if (Environment.OSVersion.Version.Major < 6)
return false;
else
else if (Environment.OSVersion.Version.Major < 10)
{
// Ask the desktop window manager is composition is currently enabled
bool compositionEnabled = false;
PI.DwmIsCompositionEnabled(ref compositionEnabled);
return compositionEnabled;
}
else //Win 10
{
return UserSystemPreferencesService.IsTransparencyEnabled;
}
}
}

Expand Down
Loading

0 comments on commit 621ab7c

Please sign in to comment.