private void OpenSystemContextMenu(MouseButtonEventArgs e) { System.Windows.Point position = e.GetPosition(this); System.Windows.Point screen = this.PointToScreen(position); int num = 36; if (position.Y < (double)num) { IntPtr handle = (new WindowInteropHelper(this)).Handle; IntPtr systemMenu = NativeUtils.GetSystemMenu(handle, false); if (base.WindowState != WindowState.Maximized) { NativeUtils.EnableMenuItem(systemMenu, 61488, 0); } else { NativeUtils.EnableMenuItem(systemMenu, 61488, 1); } int num1 = NativeUtils.TrackPopupMenuEx(systemMenu, NativeUtils.TPM_LEFTALIGN | NativeUtils.TPM_RETURNCMD, Convert.ToInt32(screen.X + 2), Convert.ToInt32(screen.Y + 2), handle, IntPtr.Zero); if (num1 == 0) { return; } NativeUtils.PostMessage(handle, 274, new IntPtr(num1), IntPtr.Zero); } }