Skip to content
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
@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Collections;

namespace System.ComponentModel.Design
{
/// <summary>
/// Provides additional information for the Loaded event.
/// </summary>
public sealed class LoadedEventArgs : EventArgs
{
/// <summary>
/// Creates a new LoadedEventArgs object.
/// </summary>
public LoadedEventArgs(bool succeeded, ICollection errors)
{
HasSucceeded = succeeded;
Errors = errors ?? Array.Empty<object>();
}

/// <summary>
/// True to indicate the designer load was successful. Even successful loads can have errors, if the errors were not too servere to prevent the designer from loading.
/// </summary>
public bool HasSucceeded { get; }

/// <summary>
/// A collection of errors that occurred while the designer was loading.
/// </summary>
public ICollection Errors { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,10 @@
// 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.Collections;

namespace System.ComponentModel.Design
{
/// <summary>
/// Represents the method that will handle a Loaded event.
/// </summary>
public delegate void LoadedEventHandler(object sender, LoadedEventArgs e);

/// <summary>
/// Provides additional information for the Loaded event.
/// </summary>
public sealed class LoadedEventArgs : EventArgs
{
private readonly bool _succeeded;
private readonly ICollection _errors;
/// <summary>
/// Creates a new LoadedEventArgs object.
/// </summary>
public LoadedEventArgs(bool succeeded, ICollection errors)
{
_succeeded = succeeded;
_errors = errors;
if (_errors == null)
{
_errors = new object[0];
}
}

/// <summary>
/// A collection of errors that occurred while the designer was loading.
/// </summary>
public ICollection Errors
{
get => _errors;
}

/// <summary>
/// True to indicate the designer load was successful. Even successful loads can have errors, if the errors were not too servere to prevent the designer from loading.
/// </summary>
public bool HasSucceeded
{
get => _succeeded;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ namespace System.Drawing.Design
/// <summary>
/// Provides access to the toolbox in the development environment.
/// </summary>
[ComImport(), Guid("4BACD258-DE64-4048-BC4E-FEDBEF9ACB76"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
[Guid("4BACD258-DE64-4048-BC4E-FEDBEF9ACB76")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IToolboxService
{
/// <summary>
Expand Down Expand Up @@ -167,4 +169,3 @@ public interface IToolboxService
void SetSelectedToolboxItem(ToolboxItem toolboxItem);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ public interface IToolboxUser
void ToolPicked(ToolboxItem tool);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ namespace System.Drawing.Design
/// </summary>
public class ToolboxComponentsCreatedEventArgs : EventArgs
{
private IComponent[] _components;

/// <summary>
/// Initializes a new instance of the <see cref='System.Drawing.Design.ToolboxComponentsCreatedEventArgs'
/// </summary>
public ToolboxComponentsCreatedEventArgs(IComponent[] components) => throw new NotImplementedException(SR.NotImplementedByDesign);
public ToolboxComponentsCreatedEventArgs(IComponent[] components)
{
_components = components;
}

/// <summary>
/// An array storing the toolbox components.
/// </summary>
public IComponent[] Components => throw new NotImplementedException(SR.NotImplementedByDesign);
public IComponent[] Components => (IComponent[])_components?.Clone();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ public class ToolboxComponentsCreatingEventArgs : EventArgs
/// <summary>
/// Initializes a new instance of the <see cref='System.Drawing.Design.ToolboxComponentsCreatingEventArgs'/> object.
/// </summary>
public ToolboxComponentsCreatingEventArgs(IDesignerHost host) => throw new NotImplementedException(SR.NotImplementedByDesign);
public ToolboxComponentsCreatingEventArgs(IDesignerHost host)
{
DesignerHost = host;
}

/// <summary>
/// An instance of IDesignerHost that has made the creat request. This can be null if no designer host
/// was provided to the toolbox item.
/// An instance of IDesignerHost that has made the creat request.
/// This can be null if no designer host was provided to the toolbox item.
/// </summary>
public IDesignerHost DesignerHost => throw new NotImplementedException(SR.NotImplementedByDesign);
public IDesignerHost DesignerHost { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@
namespace System.Windows.Forms.Design.Behavior
{
/// <summary>
/// This class represents the arguments describing a BehaviorDragDrop event
/// fired by the BehaviorService.
/// This class represents the arguments describing a BehaviorDragDrop event
/// fired by the BehaviorService.
/// </summary>
public class BehaviorDragDropEventArgs : EventArgs
{
/// <summary>
/// Constructor. This class is created by the BehaviorService directly
/// before a drag operation begins.
/// </summary>
public BehaviorDragDropEventArgs(ICollection dragComponents)
{
throw new NotImplementedException(SR.NotImplementedByDesign);
DragComponents = dragComponents;
}

/// <summary>
/// Returns the list of IComponents currently being dragged.
/// Returns the list of IComponents currently being dragged.
/// </summary>
public ICollection DragComponents => throw new NotImplementedException(SR.NotImplementedByDesign);
public ICollection DragComponents { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,29 @@ namespace System.ComponentModel.Design
/// </summary>
public class DesignerActionListsChangedEventArgs : EventArgs
{

private readonly object _relatedObject;
private readonly DesignerActionListCollection _actionLists;
private readonly DesignerActionListsChangedType _changeType;

/// <summary>
/// Constructor that requires the object in question, the type of change and the remaining actionlists left for the object. on the related object.
/// </summary>
/// </summary>
public DesignerActionListsChangedEventArgs(object relatedObject, DesignerActionListsChangedType changeType, DesignerActionListCollection actionLists)
{
_relatedObject = relatedObject;
_changeType = changeType;
_actionLists = actionLists;
RelatedObject = relatedObject;
ChangeType = changeType;
ActionLists = actionLists;
}

/// <summary>
/// The type of changed that caused the related event to be thrown.
/// </summary>
public DesignerActionListsChangedType ChangeType => _changeType;
/// The object this change is related to.
/// </summary>
public object RelatedObject { get; }

/// <summary>
/// The object this change is related to.
/// </summary>
public object RelatedObject => _relatedObject;
/// The type of changed that caused the related event to be thrown.
/// </summary>
public DesignerActionListsChangedType ChangeType { get; }

/// <summary>
/// The remaining actionlists left for the related object.
/// </summary>
public DesignerActionListCollection ActionLists => _actionLists;
/// </summary>
public DesignerActionListCollection ActionLists { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// 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.Runtime.InteropServices;

namespace System.ComponentModel.Design
{
/// <summary>
/// This event is thown by the DesignerActionListservice when a shortcut is either added or removed to/from the related object.
/// </summary>
[System.Runtime.InteropServices.ComVisible(true)]
[ComVisible(true)]
public delegate void DesignerActionListsChangedEventHandler(object sender, DesignerActionListsChangedEventArgs e);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
// 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.Runtime.InteropServices;

namespace System.ComponentModel.Design
{
/// <summary>
/// An enum that defines what time of action happend to the related object's DesignerActionLists collection.
/// </summary>
[System.Runtime.InteropServices.ComVisible(true)]
[ComVisible(true)]
public enum DesignerActionListsChangedType
{
/// <summary>
Expand All @@ -19,6 +21,5 @@ public enum DesignerActionListsChangedType
/// Signifies that one or more DesignerActionList was removed.
/// </summary>
ActionListsRemoved

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,23 @@ namespace System.ComponentModel.Design
/// </summary>
public class DesignerActionUIStateChangeEventArgs : EventArgs
{
private readonly object _relatedObject;
private readonly DesignerActionUIStateChangeType _changeType;

/// <summary>
/// Constructor that requires the object in question, the type of change and the remaining actionlists left for the object on the related object.
/// </summary>
public DesignerActionUIStateChangeEventArgs(object relatedObject, DesignerActionUIStateChangeType changeType)
{
_relatedObject = relatedObject;
_changeType = changeType;
RelatedObject = relatedObject;
ChangeType = changeType;
}

/// <summary>
/// The type of changed that caused the related event to be thrown.
/// </summary>
public DesignerActionUIStateChangeType ChangeType => _changeType;

/// <summary>
/// The object this change is related to.
/// </summary>
public object RelatedObject => _relatedObject;
public object RelatedObject { get; }

/// <summary>
/// The type of changed that caused the related event to be thrown.
/// </summary>
public DesignerActionUIStateChangeType ChangeType { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace System.ComponentModel.Design
{
public enum DesignerActionUIStateChangeType
{
Show, Hide, Refresh
Show,
Hide,
Refresh
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Collections;
using System.Collections.Generic;
using Xunit;

namespace System.ComponentModel.Design.Tests
{
public class DesignerActionListsChangedEventArgsTests
{
public static IEnumerable<object[]> Ctor_Object_DesignerActionListsChangedType_DesignerActionListCollection_TestData()
{
yield return new object[] { null, DesignerActionListsChangedType.ActionListsAdded - 1, null };
yield return new object[] { new object(), DesignerActionListsChangedType.ActionListsAdded, new DesignerActionListCollection() };
}

[Theory]
[MemberData(nameof(Ctor_Object_DesignerActionListsChangedType_DesignerActionListCollection_TestData))]
public void Ctor_Object_DesignerActionListsChangedType_DesignerActionListCollection(object relatedObject, DesignerActionListsChangedType changeType, DesignerActionListCollection actionLists)
{
var e = new DesignerActionListsChangedEventArgs(relatedObject, changeType, actionLists);
Assert.Same(relatedObject, e.RelatedObject);
Assert.Equal(changeType, e.ChangeType);
Assert.Same(actionLists, e.ActionLists);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Collections;
using System.Collections.Generic;
using Xunit;

namespace System.ComponentModel.Design.Tests
{
public class DesignerActionUIStateChangeEventArgsTests
{
public static IEnumerable<object[]> Ctor_Object_DesignerActionUIStateChangeType_TestData()
{
yield return new object[] { null, DesignerActionUIStateChangeType.Show - 1 };
yield return new object[] { new object(), DesignerActionUIStateChangeType.Show };
}

[Theory]
[MemberData(nameof(Ctor_Object_DesignerActionUIStateChangeType_TestData))]
public void Ctor_Object_DesignerActionUIStateChangeType(object relatedObject, DesignerActionUIStateChangeType changeType)
{
var e = new DesignerActionUIStateChangeEventArgs(relatedObject, changeType);
Assert.Same(relatedObject, e.RelatedObject);
Assert.Equal(changeType, e.ChangeType);
}
}
}
Loading