-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completed support for Win32 Menu and Win32 Toolbar integration.
- Loading branch information
1 parent
c248e5e
commit 13ee0fd
Showing
50 changed files
with
5,138 additions
and
687 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* COPYRIGHT NOTICE | ||
MIT License | ||
Copyright (c) 2022 SharpVNC Limited | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
using System.ComponentModel; | ||
using System.Drawing; | ||
|
||
namespace BetterControls | ||
{ | ||
/// <summary> | ||
/// Represents a context menu. | ||
/// </summary> | ||
[ToolboxItem(true)] | ||
[DesignTimeVisible(true)] | ||
[ToolboxBitmap(typeof(BetterToolbar), "BetterContextMenuIcon.bmp")] | ||
public class BetterContextMenu : BetterMenuRoot | ||
{ | ||
/// <summary> | ||
/// Initialize a new instance of <see cref="BetterContextMenu"/>. | ||
/// </summary> | ||
public BetterContextMenu() { } | ||
} | ||
} |
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,93 @@ | ||
/* COPYRIGHT NOTICE | ||
MIT License | ||
Copyright (c) 2022 SharpVNC Limited | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace BetterControls | ||
{ | ||
/// <summary> | ||
/// Wrapper of the Windows Menu classes. | ||
/// </summary> | ||
partial class BetterMenu | ||
{ | ||
/// <summary> | ||
/// This method is raised when <see cref="AutoSizeItems"/> has been changed. | ||
/// </summary> | ||
/// <param name="e">The event arguments as an instance of <see cref="EventArgs"/>.</param> | ||
protected virtual void OnAutoSizeItemsChanged(EventArgs e) | ||
{ | ||
if (e is null) | ||
{ | ||
throw new ArgumentNullException(nameof(e)); | ||
} | ||
|
||
AutoSizeItemsChanged?.Invoke(this, e); | ||
} | ||
|
||
/// <summary> | ||
/// This method is raised when <see cref="CustomStatusWidth"/> has been changed. | ||
/// </summary> | ||
/// <param name="e">The event arguments as an instance of <see cref="EventArgs"/>.</param> | ||
protected virtual void OnCustomStatusWidthChanged(EventArgs e) | ||
{ | ||
if (e is null) | ||
{ | ||
throw new ArgumentNullException(nameof(e)); | ||
} | ||
|
||
CustomStatusWidthChanged?.Invoke(this, e); | ||
} | ||
|
||
/// <summary> | ||
/// This method is raised when <see cref="DefaultButton"/> has been changed. | ||
/// </summary> | ||
/// <param name="e">The event arguments as an instance of <see cref="EventArgs"/>.</param> | ||
protected virtual void OnDefaultButtonChanged(EventArgs e) | ||
{ | ||
if (e is null) | ||
{ | ||
throw new ArgumentNullException(nameof(e)); | ||
} | ||
|
||
DefaultButtonChanged?.Invoke(this, e); | ||
} | ||
|
||
/// <summary> | ||
/// This event is raised <see cref="AutoSizeItems"/> has been changed. | ||
/// </summary> | ||
public event EventHandler<EventArgs> AutoSizeItemsChanged; | ||
|
||
/// <summary> | ||
/// This event is raised <see cref="CustomStatusWidth"/> has been changed. | ||
/// </summary> | ||
public event EventHandler<EventArgs> CustomStatusWidthChanged; | ||
|
||
/// <summary> | ||
/// This event is raised <see cref="DefaultButton"/> has been changed. | ||
/// </summary> | ||
public event EventHandler<EventArgs> DefaultButtonChanged; | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/BetterControls/BetterMenu/BetterMenu.Initialization.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,91 @@ | ||
/* COPYRIGHT NOTICE | ||
MIT License | ||
Copyright (c) 2022 SharpVNC Limited | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace BetterControls | ||
{ | ||
/// <summary> | ||
/// Wrapper of the Windows Menu classes. | ||
/// </summary> | ||
partial class BetterMenu | ||
{ | ||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
protected override void CreateHandle() | ||
{ | ||
if (!IsHandleCreated) | ||
_handle = UnsafeNativeMethods.CreatePopupMenu(); | ||
|
||
base.CreateHandle(); | ||
} | ||
|
||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
protected override void DestroyHandle() | ||
{ | ||
if (IsHandleCreated) | ||
{ | ||
UnsafeNativeMethods.DestroyMenu(GetHandleRef()); | ||
_handle = IntPtr.Zero; | ||
|
||
foreach (BetterMenuItem item in Items) | ||
item.DestroyHandle(); | ||
} | ||
|
||
base.DestroyHandle(); | ||
} | ||
|
||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
/// <param name="e"><inheritdoc/></param> | ||
protected override void OnHandleCreated(EventArgs e) | ||
{ | ||
base.OnHandleCreated(e); | ||
|
||
InitializeItems(); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes items in the menu. | ||
/// </summary> | ||
private void InitializeItems() | ||
{ | ||
foreach (BetterMenuItem item in Items) | ||
{ | ||
if (!item.Visible) | ||
continue; | ||
|
||
NativeMethods.MENUITEMINFO_T structure = item.ComputeMenuItemInfoT(); | ||
|
||
UnsafeNativeMethods.InsertMenuItem(GetHandleRef(), -1, true, structure); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.