Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 2091 Remove deprecated controls #2157

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
RussKie marked this conversation as resolved.
Show resolved Hide resolved
{
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