diff --git a/MemcardRex/Extras/glassSupport.cs b/MemcardRex/Extras/glassSupport.cs deleted file mode 100644 index d4baba1..0000000 --- a/MemcardRex/Extras/glassSupport.cs +++ /dev/null @@ -1,213 +0,0 @@ -//Aero glass support for Windows Vista and up -//Based on the free examples provided by Graham O’Neale (http://goneale.com/) -//Shendo 2009 - 2011 - -using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.InteropServices; -using System.Drawing; - -namespace MemcardRex -{ - class glassSupport - { - [DllImport("dwmapi.dll")]public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref margins pMarInset); - [DllImport("dwmapi.dll")]static extern void DwmIsCompositionEnabled(ref bool pfEnabled); - - [DllImport("uxtheme.dll", CharSet = CharSet.Unicode)] - public extern static int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); - - [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)] - private static extern IntPtr GetDC(IntPtr hdc); - [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)] - private static extern int SaveDC(IntPtr hdc); - [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)] - private static extern int ReleaseDC(IntPtr hdc, int state); - [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)] - private static extern IntPtr CreateCompatibleDC(IntPtr hDC); - [DllImport("gdi32.dll", ExactSpelling = true)] - private static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); - [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)] - private static extern bool DeleteObject(IntPtr hObject); - [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)] - private static extern bool DeleteDC(IntPtr hdc); - [DllImport("gdi32.dll")] - private static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop); - [DllImport("UxTheme.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] - private static extern int DrawThemeTextEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, string text, int iCharCount, int dwFlags, ref RECT pRect, ref DTTOPTS pOptions); - [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)] - private static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO pbmi, uint iUsage, int ppvBits, IntPtr hSection, uint dwOffset); - - private const int DTT_COMPOSITED = (int)(1UL << 13); - private const int DTT_GLOWSIZE = (int)(1UL << 11); - - private const int DT_SINGLELINE = 0x00000020; - private const int DT_CENTER = 0x00000001; - private const int DT_VCENTER = 0x00000004; - private const int DT_NOPREFIX = 0x00000800; - - private const int SRCCOPY = 0x00CC0020; - - private const int BI_RGB = 0; - private const int DIB_RGB_COLORS = 0; - - public const int HTCLIENT = 0x1; - public const int HTCAPTION = 0x2; - public const int WM_NCHITTEST = 0x84; - public const int WM_DWMCOMPOSITIONCHANGED = 0x031E; - - public struct margins - { - public int left; - public int right; - public int top; - public int bottom; - } - - private struct POINTAPI - { - public int x; - public int y; - }; - - private struct DTTOPTS - { - public uint dwSize; - public uint dwFlags; - public uint crText; - public uint crBorder; - public uint crShadow; - public int iTextShadowType; - public POINTAPI ptShadowOffset; - public int iBorderSize; - public int iFontPropId; - public int iColorPropId; - public int iStateId; - public int fApplyOverlay; - public int iGlowSize; - public IntPtr pfnDrawTextCallback; - public int lParam; - }; - - private struct RECT - { - public int left; - public int top; - public int right; - public int bottom; - }; - - private struct BITMAPINFOHEADER - { - public int biSize; - public int biWidth; - public int biHeight; - public short biPlanes; - public short biBitCount; - public int biCompression; - public int biSizeImage; - public int biXPelsPerMeter; - public int biYPelsPerMeter; - public int biClrUsed; - public int biClrImportant; - }; - - private struct RGBQUAD - { - public byte rgbBlue; - public byte rgbGreen; - public byte rgbRed; - public byte rgbReserved; - }; - - private struct BITMAPINFO - { - public BITMAPINFOHEADER bmiHeader; - public RGBQUAD bmiColors; - }; - - //Check if the Aero glass is available and enabled - public bool isGlassSupported() - { - bool glassSupported = false; - - //Check if the OS supports DWM (only Windows Vista and 7) - if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor <= 1) - { - //Check if the DWM is enabled - DwmIsCompositionEnabled(ref glassSupported); - } - - return glassSupported; - } - - //Draw text on the glass surface - public void DrawTextOnGlass(IntPtr hwnd, String text, Font font, Rectangle ctlrct, int iglowSize) - { - if (isGlassSupported()) - { - RECT rc = new RECT(); - RECT rc2 = new RECT(); - - rc.left = ctlrct.Left; - rc.right = ctlrct.Right; - rc.top = ctlrct.Top; - rc.bottom = ctlrct.Bottom; - - rc2.left = 6; - rc2.top = 5; - rc2.right = rc.right - rc.left; - rc2.bottom = rc.bottom - rc.top; - - IntPtr destdc = GetDC(hwnd); - IntPtr Memdc = CreateCompatibleDC(destdc); - IntPtr bitmap; - IntPtr bitmapOld = IntPtr.Zero; - IntPtr logfnotOld; - - int uFormat = DT_SINGLELINE | DT_NOPREFIX; - - BITMAPINFO dib = new BITMAPINFO(); - dib.bmiHeader.biHeight = -(rc.bottom - rc.top); - dib.bmiHeader.biWidth = rc.right - rc.left; - dib.bmiHeader.biPlanes = 1; - dib.bmiHeader.biSize = Marshal.SizeOf(typeof(BITMAPINFOHEADER)); - dib.bmiHeader.biBitCount = 32; - dib.bmiHeader.biCompression = BI_RGB; - if (!(SaveDC(Memdc) == 0)) - { - bitmap = CreateDIBSection(Memdc, ref dib, DIB_RGB_COLORS, 0, IntPtr.Zero, 0); - if (!(bitmap == IntPtr.Zero)) - { - bitmapOld = SelectObject(Memdc, bitmap); - IntPtr hFont = font.ToHfont(); - logfnotOld = SelectObject(Memdc, hFont); - try - { - System.Windows.Forms.VisualStyles.VisualStyleRenderer renderer = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.Window.Caption.Active); - DTTOPTS dttOpts = new DTTOPTS(); - dttOpts.dwSize = (uint)Marshal.SizeOf(typeof(DTTOPTS)); - dttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE; - dttOpts.iGlowSize = iglowSize; - DrawThemeTextEx(renderer.Handle, Memdc, 0, 0, text, -1, uFormat, ref rc2, ref dttOpts); - BitBlt(destdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, Memdc, 0, 0, SRCCOPY); - } - catch (Exception e) - { - Console.WriteLine(e.Message); - } - - SelectObject(Memdc, bitmapOld); - SelectObject(Memdc, logfnotOld); - DeleteObject(bitmap); - DeleteObject(hFont); - - ReleaseDC(Memdc, -1); - DeleteDC(Memdc); - } - } - } - } - } -} diff --git a/MemcardRex/GUI/mainWindow.Designer.cs b/MemcardRex/GUI/mainWindow.Designer.cs index f18b63a..5af8328 100644 --- a/MemcardRex/GUI/mainWindow.Designer.cs +++ b/MemcardRex/GUI/mainWindow.Designer.cs @@ -1028,7 +1028,6 @@ private void InitializeComponent() this.Text = "mainWindow"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.mainWindow_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); - this.Paint += new System.Windows.Forms.PaintEventHandler(this.mainWindow_Paint); this.mainMenu.ResumeLayout(false); this.mainMenu.PerformLayout(); this.mainToolbar.ResumeLayout(false); diff --git a/MemcardRex/GUI/mainWindow.cs b/MemcardRex/GUI/mainWindow.cs index 77cf90b..f187045 100644 --- a/MemcardRex/GUI/mainWindow.cs +++ b/MemcardRex/GUI/mainWindow.cs @@ -43,15 +43,6 @@ public partial class mainWindow : Form //Location of the application string appPath = Application.StartupPath; - //API for the Aero glass effect - glassSupport windowGlass = new glassSupport(); - - //Margins for the Aero glass - glassSupport.margins windowMargins = new glassSupport.margins(); - - //Rectangle for the Aero glass - Rectangle windowRectangle = new Rectangle(); - //Plugin system (public because plugin dialog has to access it) public rexPluginSystem pluginSystem = new rexPluginSystem(); @@ -76,7 +67,6 @@ public struct programSettings public int warningMessage; //Warning message settings public int restoreWindowPosition; //Restore window position public int fixCorruptedCards; //Try to fix corrupted memory cards - public int glassStatusBar; //Vista glass status bar public int formatType; //Type of formatting for hardware interfaces public string listFont; //List font public string communicationPort; //Communication port for Hardware interfaces @@ -96,8 +86,7 @@ public programSettings(int i = 0) backupMemcards = 0; warningMessage = 0; restoreWindowPosition = 0; - fixCorruptedCards = 0; - glassStatusBar = 0; + fixCorruptedCards = 0; formatType = 0; listFont = ""; communicationPort = ""; @@ -145,55 +134,12 @@ public mainWindow() } } - //Apply glass effect on the client area - private void applyGlass() - { - //Reset margins to zero - windowMargins.top = 0; - windowMargins.bottom = 0; - windowMargins.left = 0; - windowMargins.right = 0; - - //Check if the requirements for the Aero glass are met - if (windowGlass.isGlassSupported() && mainSettings.glassStatusBar == 1) - { - //Hide status strip - this.mainStatusStrip.Visible = false; - - windowMargins.bottom = (int)(xScale * 22); - windowRectangle = new Rectangle(0, this.ClientSize.Height - windowMargins.bottom, this.ClientSize.Width, windowMargins.bottom + 5); - glassSupport.DwmExtendFrameIntoClientArea(this.Handle, ref windowMargins); - - //Repaint the form - this.Refresh(); - } - else - { - //Check if effect of aero needs to be supressed - if (Environment.OSVersion.Version.Major >= 6) - { - windowMargins.bottom = 0; - windowRectangle = new Rectangle(0, this.ClientSize.Height - windowMargins.bottom, this.ClientSize.Width, windowMargins.bottom + 5); - glassSupport.DwmExtendFrameIntoClientArea(this.Handle, ref windowMargins); - - //Repaint the form - this.Refresh(); - } - - //Show status strip - this.mainStatusStrip.Visible = true; - } - } - //Apply program settings private void applySettings() { //Refresh all active lists for (int i = 0; i < cardList.Count; i++) refreshListView(i, cardList[i].SelectedIndices[0]); - - //Refresh status of Aero glass - applyGlass(); } //Apply program settings from given values @@ -234,9 +180,6 @@ private void loadProgramSettings() //Load List Grid settings mainSettings.showListGrid = xmlAppSettings.readXmlEntryInt("ShowGrid", 0, 1); - //Load glass option switch - mainSettings.glassStatusBar = xmlAppSettings.readXmlEntryInt("GlassStatusBar", 0, 1); - //Load icon interpolation settings mainSettings.iconInterpolationMode = xmlAppSettings.readXmlEntryInt("IconInterpolationMode", 0, 1); @@ -314,9 +257,6 @@ private void saveProgramSettings() //Set List Grid settings xmlAppSettings.writeXmlEntry("ShowGrid", mainSettings.showListGrid.ToString()); - //Set glass option switch - xmlAppSettings.writeXmlEntry("GlassStatusBar", mainSettings.glassStatusBar.ToString()); - //Set icon interpolation settings xmlAppSettings.writeXmlEntry("IconInterpolationMode", mainSettings.iconInterpolationMode.ToString()); @@ -1399,9 +1339,6 @@ private void refreshStatusStrip() toolString.Text = PScard[mainTabControl.SelectedIndex].cardLocation + " "; else toolString.Text = " "; - - //If glass is enabled repaint the form - if(windowGlass.isGlassSupported() && mainSettings.glassStatusBar == 1)this.Refresh(); } //Save work and close the application @@ -1486,7 +1423,6 @@ private void Form1_Load(object sender, EventArgs e) mainSettings.restoreWindowPosition = 0; mainSettings.communicationPort = "COM1"; mainSettings.formatType = 0; - mainSettings.glassStatusBar = 1; //Load settings from Settings.ini loadProgramSettings(); @@ -1496,9 +1432,6 @@ private void Form1_Load(object sender, EventArgs e) //Create an empty card upon startup or load one given by the command line if(loadCommandLine() == false)openCard(null); - - //Apply Aero glass effect to the window - applyGlass(); } private void managePluginsToolStripMenuItem_Click(object sender, EventArgs e) @@ -2181,47 +2114,6 @@ private void mainTabControl_DragDrop(object sender, DragEventArgs e) } } - private void mainWindow_Paint(object sender, PaintEventArgs e) - { - if (windowGlass.isGlassSupported() && mainSettings.glassStatusBar == 1) - { - Brush blackBrush = new SolidBrush(Color.Black); - Graphics windowGraphics = e.Graphics; - - //Create a black rectangle for Aero glass - windowGraphics.FillRectangle(blackBrush, windowRectangle); - - //Show path of the currently active card - windowGlass.DrawTextOnGlass(this.Handle, toolString.Text, new Font("Segoe UI", 9f, FontStyle.Regular), windowRectangle, 10); - } - } - - protected override void WndProc(ref Message message) - { - base.WndProc(ref message); - - //DWM composition is changed and glass support should be revaluated - if (message.Msg == glassSupport.WM_DWMCOMPOSITIONCHANGED) - { - applyGlass(); - } - - //Move the window if user clicked on the glass area - if (message.Msg == glassSupport.WM_NCHITTEST && message.Result.ToInt32() == glassSupport.HTCLIENT) - { - //Check if DWM composition is enabled - if (windowGlass.isGlassSupported() && mainSettings.glassStatusBar == 1) - { - int mouseX = (message.LParam.ToInt32() & 0xFFFF); - int mouseY = (message.LParam.ToInt32() >> 16); - Point windowPoint = this.PointToClient(new Point(mouseX,mouseY)); - - //Check if the clicked area is on glass - if(windowRectangle.Contains(windowPoint)) message.Result = new IntPtr(glassSupport.HTCAPTION); - } - } - } - private void dexDriveMenuRead_Click(object sender, EventArgs e) { //Read a Memory Card from DexDrive diff --git a/MemcardRex/GUI/preferencesWindow.Designer.cs b/MemcardRex/GUI/preferencesWindow.Designer.cs index bb6b4d9..36b6c7b 100644 --- a/MemcardRex/GUI/preferencesWindow.Designer.cs +++ b/MemcardRex/GUI/preferencesWindow.Designer.cs @@ -39,7 +39,6 @@ private void InitializeComponent() this.interpolationCombo = new System.Windows.Forms.ComboBox(); this.interpolationLabel = new System.Windows.Forms.Label(); this.backupWarningCheckBox = new System.Windows.Forms.CheckBox(); - this.glassCheckbox = new System.Windows.Forms.CheckBox(); this.backupCheckbox = new System.Windows.Forms.CheckBox(); this.dexDriveCombo = new System.Windows.Forms.ComboBox(); this.hardwarePortLabel = new System.Windows.Forms.Label(); @@ -172,16 +171,6 @@ private void InitializeComponent() this.backupWarningCheckBox.Text = "Show warning messages (save editing)."; this.backupWarningCheckBox.UseVisualStyleBackColor = true; // - // glassCheckbox - // - this.glassCheckbox.AutoSize = true; - this.glassCheckbox.Location = new System.Drawing.Point(248, 84); - this.glassCheckbox.Name = "glassCheckbox"; - this.glassCheckbox.Size = new System.Drawing.Size(101, 17); - this.glassCheckbox.TabIndex = 12; - this.glassCheckbox.Text = "Glass status bar"; - this.glassCheckbox.UseVisualStyleBackColor = true; - // // backupCheckbox // this.backupCheckbox.AutoSize = true; @@ -222,7 +211,7 @@ private void InitializeComponent() // restorePositionCheckbox // this.restorePositionCheckbox.AutoSize = true; - this.restorePositionCheckbox.Location = new System.Drawing.Point(248, 108); + this.restorePositionCheckbox.Location = new System.Drawing.Point(248, 84); this.restorePositionCheckbox.Name = "restorePositionCheckbox"; this.restorePositionCheckbox.Size = new System.Drawing.Size(191, 17); this.restorePositionCheckbox.TabIndex = 13; @@ -276,7 +265,7 @@ private void InitializeComponent() // fixCorruptedCardsCheckbox // this.fixCorruptedCardsCheckbox.AutoSize = true; - this.fixCorruptedCardsCheckbox.Location = new System.Drawing.Point(248, 132); + this.fixCorruptedCardsCheckbox.Location = new System.Drawing.Point(248, 108); this.fixCorruptedCardsCheckbox.Name = "fixCorruptedCardsCheckbox"; this.fixCorruptedCardsCheckbox.Size = new System.Drawing.Size(184, 17); this.fixCorruptedCardsCheckbox.TabIndex = 103; @@ -355,7 +344,6 @@ private void InitializeComponent() this.Controls.Add(this.restorePositionCheckbox); this.Controls.Add(this.spacerLabel); this.Controls.Add(this.gridCheckbox); - this.Controls.Add(this.glassCheckbox); this.Controls.Add(this.backupWarningCheckBox); this.Controls.Add(this.iconSizeLabel); this.Controls.Add(this.backupCheckbox); @@ -393,7 +381,6 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox interpolationCombo; private System.Windows.Forms.Label interpolationLabel; private System.Windows.Forms.CheckBox backupCheckbox; - private System.Windows.Forms.CheckBox glassCheckbox; private System.Windows.Forms.CheckBox backupWarningCheckBox; private System.Windows.Forms.Label iconSizeLabel; private System.Windows.Forms.ComboBox iconSizeCombo; diff --git a/MemcardRex/GUI/preferencesWindow.cs b/MemcardRex/GUI/preferencesWindow.cs index 105dc34..d25f68d 100644 --- a/MemcardRex/GUI/preferencesWindow.cs +++ b/MemcardRex/GUI/preferencesWindow.cs @@ -32,10 +32,6 @@ public void initializeDialog(mainWindow.programSettings progSettings) SavedComPort = progSettings.communicationPort; if (progSettings.showListGrid == 1) gridCheckbox.Checked = true; else gridCheckbox.Checked = false; if (progSettings.backupMemcards == 1) backupCheckbox.Checked = true; else backupCheckbox.Checked = false; - if (progSettings.glassStatusBar == 1) glassCheckbox.Checked = true; else glassCheckbox.Checked = false; - glassSupport glass = new glassSupport(); - if (!glass.isGlassSupported()) - glassCheckbox.Enabled = false; if (progSettings.warningMessage == 1) backupWarningCheckBox.Checked = true; else backupWarningCheckBox.Checked = false; if (progSettings.restoreWindowPosition == 1) restorePositionCheckbox.Checked = true; else restorePositionCheckbox.Checked = false; if (progSettings.fixCorruptedCards == 1) fixCorruptedCardsCheckbox.Checked = true; else fixCorruptedCardsCheckbox.Checked = false; @@ -83,7 +79,6 @@ private void applySettings() if (gridCheckbox.Checked == true) progSettings.showListGrid = 1; else progSettings.showListGrid = 0; if (backupCheckbox.Checked == true) progSettings.backupMemcards = 1; else progSettings.backupMemcards = 0; - if (glassCheckbox.Checked == true) progSettings.glassStatusBar = 1; else progSettings.glassStatusBar = 0; if (backupWarningCheckBox.Checked == true) progSettings.warningMessage = 1; else progSettings.warningMessage = 0; if (restorePositionCheckbox.Checked == true) progSettings.restoreWindowPosition = 1; else progSettings.restoreWindowPosition = 0; if (fixCorruptedCardsCheckbox.Checked == true) progSettings.fixCorruptedCards = 1; else progSettings.fixCorruptedCards = 0; diff --git a/MemcardRex/MemcardRex.csproj b/MemcardRex/MemcardRex.csproj index 9becf81..0463bf7 100644 --- a/MemcardRex/MemcardRex.csproj +++ b/MemcardRex/MemcardRex.csproj @@ -115,7 +115,6 @@ cardReaderWindow.cs - Form