Skip to content

Commit

Permalink
Remove deprecated API
Browse files Browse the repository at this point in the history
Fixes #2091

- Remove the following API because they have been obsolete since .NET 2.0:
	* `Menu`
	* `MainMenu`
	* `ContextMenu`
	* `MenuItem`
	* `IMenuEditorService`
	* `ToolBar`
	* `ToolBarAppearance`
	* `ToolBarButton`
	* `ToolBarButtonClickEventArgs`
	* `ToolBarButtonClickEventHandler`
	* `ToolBarButtonStyle`
	* `ToolBarTextAlign`
	* `DataGrid`
	* `DataGridAddNewRow`
	* `DataGridBoolColumn`
	* `DataGridCaption`
	* `DataGridCell`
	* `DataGridColumnCollection`
	* `DataGridColumnStyle`
	* `DataGridDefaultColumnWidthTypeConverter`
	* `DataGridLineStyle`
	* `DataGridParentRows`
	* `DataGridParentRowsLabel`
	* `DataGridRelationshipRow`
	* `DataGridRow`
	* `DataGridState`
	* `DataGridTableCollection`
	* `DataGridTableStyle`
	* `DataGridTextBox`
	* `DataGridTextBoxColumn`
	* `DataGridToolTip`
	* `GridTablesFactory`
	* `IDataGridEditingService`
- Remove the following members in `AxHost` type:
	* `ContextMenu ContextMenu { get; set; }`
	* `event EventHandler ContextMenuChanged`
- Remove the following members in `Control` type:
	* `ContextMenu ContextMenu { get; set; }`
	* `event EventHandler ContextMenuChanged`
	* `void OnContextMenuChanged(EventArgs e)`
- Remove the following members in `Form` type:
	* `MainMenu Menu { get; set; }`
	* `MainMenu MergedMenu { get; }`
	* `void Control.OnContextMenuChanged(EventArgs e)`
- Remove the following members in `NotifyIcon` type:
	* `ContextMenu ContextMenu { get; set; }`
- Remove the following members in `PrintPreviewDialog` type:
	* `MainMenu Menu { get; set; }`
	* `ContextMenu ContextMenu { get; set; }`
	* `event EventHandler ContextMenuChanged`
- Remove the following members in `ToolStripDropDown` type:
	* `ContextMenu ContextMenu { get; set; }`
	* `event EventHandler ContextMenuChanged`
- Remove the following members in `TreeNode` type:
	* `ContextMenu ContextMenu { get; set; }`
- Remove the following members in `UpDownBase` type:
	* `ContextMenu ContextMenu { get; set; }`
  • Loading branch information
RussKie committed Nov 6, 2019
1 parent 0a1879f commit c25937a
Show file tree
Hide file tree
Showing 86 changed files with 286 additions and 50,589 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using Microsoft.Win32;

using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
using static Interop;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;

namespace System.ComponentModel.Design
{
Expand Down Expand Up @@ -478,7 +475,7 @@ internal OleCallback(RichTextBox owner)
public HRESULT GetNewStorage(out Ole32.IStorage storage)
{
Debug.WriteLineIf(RichTextDbg.TraceVerbose, "IRichTextBoxOleCallback::GetNewStorage");

Ole32.ILockBytes pLockBytes = Ole32.CreateILockBytesOnHGlobal(IntPtr.Zero, true);
Debug.Assert(pLockBytes != null, "pLockBytes is NULL!");

Expand Down Expand Up @@ -560,7 +557,7 @@ public HRESULT QueryAcceptData(IComDataObject lpdataobj, IntPtr lpcfFormat, uint

return HRESULT.E_FAIL;
}

return HRESULT.E_NOTIMPL;
}

Expand All @@ -584,20 +581,10 @@ public HRESULT GetDragDropEffect(BOOL fDrag, int grfKeyState, ref int pdwEffect)

public HRESULT GetContextMenu(short seltype, IntPtr lpoleobj, ref Richedit.CHARRANGE lpchrg, out IntPtr hmenu)
{
TextBox tb = new TextBox
{
Visible = true
};
ContextMenu cm = tb.ContextMenu;
if (cm == null || _owner.ShortcutsEnabled == false)
{
hmenu = IntPtr.Zero;
}
else
{
hmenu = cm.Handle;
}
Debug.WriteLineIf(RichTextDbg.TraceVerbose, "IRichTextBoxOleCallback::GetContextMenu");

// do nothing, we don't have ContextMenu any longer
hmenu = IntPtr.Zero;
return HRESULT.S_OK;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,6 @@ protected override void Dispose(bool disposing)
UnhookChildControls(Control);
}

if (ContextMenu != null)
{
ContextMenu.Disposed -= new EventHandler(DetachContextMenu);
}

if (_designerTarget != null)
{
_designerTarget.Dispose();
Expand Down Expand Up @@ -514,38 +509,6 @@ private interface IDesignerTarget : IDisposable
void DefWndProc(ref Message m);
}

private void DetachContextMenu(object sender, EventArgs e)
{
ContextMenu = null;
}

private ContextMenu ContextMenu
{
get => (ContextMenu)ShadowProperties["ContextMenu"];
set
{
ContextMenu oldValue = (ContextMenu)ShadowProperties["ContextMenu"];

if (oldValue != value)
{
EventHandler disposedHandler = new EventHandler(DetachContextMenu);

if (oldValue != null)
{
oldValue.Disposed -= disposedHandler;
}

ShadowProperties["ContextMenu"] = value;

if (value != null)
{
value.Disposed += disposedHandler;
}
}

}
}

private void DataSource_ComponentRemoved(object sender, ComponentEventArgs e)
{
// It is possible to use the control designer with NON CONTROl types.
Expand Down Expand Up @@ -1598,7 +1561,7 @@ protected override void PreFilterProperties(IDictionary properties)
base.PreFilterProperties(properties);
PropertyDescriptor prop;
// Handle shadowed properties
string[] shadowProps = new string[] { "Visible", "Enabled", "ContextMenu", "AllowDrop", "Location", "Name" };
string[] shadowProps = new string[] { "Visible", "Enabled", "AllowDrop", "Location", "Name" };

Attribute[] empty = Array.Empty<Attribute>();
for (int i = 0; i < shadowProps.Length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public class DocumentDesigner : ScrollableControlDesigner, IRootDesigner, IToolb
{
static internal IDesignerSerializationManager manager;

//our menu editor service
protected IMenuEditorService menuEditorService = null;

/// <summary>
/// We override our selectino rules to make the document non-sizeable.
/// </summary>
Expand Down Expand Up @@ -106,45 +103,6 @@ protected override void OnCreateHandle()
throw new NotImplementedException(SR.NotImplementedByDesign);
}

internal virtual void DoProperMenuSelection(ICollection selComponents)
{
foreach (object obj in selComponents)
{
if (obj is ContextMenu cm)
{
menuEditorService.SetMenu((Menu)obj);
}
else
{
if (obj is MenuItem item)
{
//before we set the selection, we need to check if the item belongs the current menu, if not, we need to set the menu editor to the appropiate menu, then set selection
MenuItem parent = item;
while (parent.Parent is MenuItem)
{
parent = (MenuItem)parent.Parent;
}

if (menuEditorService.GetMenu() != parent.Parent)
{
menuEditorService.SetMenu(parent.Parent);
}

//ok, here we have the correct editor selected for this item. Now, if there's only one item selected, then let the editor service know, if there is more than one - then the selection was done through themenu editor and we don't need to tell it
if (selComponents.Count == 1)
{
menuEditorService.SetSelection(item);
}
}
//Here, something is selected, but the menuservice isn't interested so, we'll collapse our active menu accordingly
else
{
menuEditorService.SetMenu(null);
}
}
}
}

/// <summary>
/// Determines if a MenuEditorService has already been started. If not,
/// this method will create a new instance of the service.
Expand Down
Loading

0 comments on commit c25937a

Please sign in to comment.