-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bb50f7
commit 4c4724c
Showing
11 changed files
with
477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Ched/UI/Windows/Behaviors/HideWindowCloseButtonBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Interop; | ||
using Microsoft.Xaml.Behaviors; | ||
|
||
namespace Ched.UI.Windows.Behaviors | ||
{ | ||
public class HideWindowCloseButtonBehavior : Behavior<Window> | ||
{ | ||
#region NativeMethods | ||
private const int GWL_STYLE = -16; | ||
private const int WS_SYSMENU = 0x80000; | ||
|
||
[DllImport("user32.dll", SetLastError = true)] | ||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex); | ||
|
||
[DllImport("user32.dll")] | ||
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); | ||
#endregion | ||
|
||
protected override void OnAttached() | ||
{ | ||
base.OnAttached(); | ||
AssociatedObject.Loaded += OnLoaded; | ||
} | ||
|
||
protected override void OnDetaching() | ||
{ | ||
AssociatedObject.Loaded -= OnLoaded; | ||
base.OnDetaching(); | ||
} | ||
|
||
private void OnLoaded(object sender, RoutedEventArgs e) | ||
{ | ||
var hwnd = new WindowInteropHelper(AssociatedObject).Handle; | ||
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
using Ched.UI.Shortcuts; | ||
|
||
namespace Ched.UI.Windows.Converters | ||
{ | ||
public class ShortcutKeyTextConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value == null) return ""; | ||
var key = (System.Windows.Forms.Keys)value; | ||
return key.ToShortcutChar(); | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Oops, something went wrong.