Skip to content

Commit

Permalink
1 draft port to new designer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirsan31 committed Jan 15, 2022
1 parent ccb041f commit 17698a2
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 54 deletions.
4 changes: 4 additions & 0 deletions src/System.Windows.Forms.DataVisualization/ChartWin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<Compile Remove="Common\EditorNames.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WinForms.Designer.SDK" Version="1.0.0-prerelease-preview5.21520.4" />
</ItemGroup>

<ItemGroup Label="Embedded Resources">
<EmbeddedResource Update="Common\SR.resx">
<LogicalName>System.Windows.Forms.DataVisualization.Charting.SR.resources</LogicalName>
Expand Down
2 changes: 2 additions & 0 deletions src/System.Windows.Forms.DataVisualization/ChartWinControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
using System.Windows.Forms.DataVisualization.Charting.Utilities;
using System.Windows.Forms.Design.DataVisualization.Charting;

using Microsoft.DotNet.DesignTools.Serialization;

namespace System.Windows.Forms.DataVisualization.Charting
{
using Size = System.Drawing.Size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,29 @@
using System.Reflection;
using System.Windows.Forms.DataVisualization.Charting;

using Microsoft.DotNet.DesignTools.Editors;

namespace System.Windows.Forms.Design.DataVisualization.Charting
{
/// <summary>
/// Designer editor for the chart areas collection.
/// </summary>
internal class AxesArrayEditor : ArrayEditor
{
#region Fields and Constructor
internal class AxesArrayEditor : Microsoft.DotNet.DesignTools.Editors.CollectionEditor
{
#region Fields and Constructor

// Collection form
CollectionForm _form = null;
#warning designer
// Collection form
// CollectionForm _form = null;

// Help topic string
private string _helpTopic = "";
// Help topic string
private string _helpTopic = "";

/// <summary>
/// Object constructor.
/// </summary>
public AxesArrayEditor() : base(typeof(Axis[]))
#warning designer
/// <summary>
/// Object constructor.
/// </summary>
public AxesArrayEditor() : base(null, typeof(Axis[]))
{
}

Expand All @@ -52,6 +56,8 @@ protected override bool CanRemoveInstance(object value)
return false;
}

#warning designer
/*
/// <summary>
/// Ovveride the HelpTopic property to provide different topics,
/// depending on selected property.
Expand All @@ -63,6 +69,7 @@ protected override string HelpTopic
return (_helpTopic.Length == 0) ? base.HelpTopic : _helpTopic;
}
}
*/

/// <summary>
/// Returns the collection form property grid. Added for VS2005 compatibility.
Expand Down Expand Up @@ -110,6 +117,8 @@ private void CollectButtons(ArrayList buttons, System.Windows.Forms.Control.Cont
}
}

#warning designer
/*
/// <summary>
/// Displaying help for the curently selected item in the property grid
/// </summary>
Expand Down Expand Up @@ -169,6 +178,7 @@ protected override CollectionForm CreateCollectionForm()
}
return _form;
}
*/

/// <summary>
/// Flag to prevent stack overflow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ public override void PaintValue(PaintValueEventArgs e)
#endregion
}

#warning designer
/// <summary>
/// This class merely subclasses System.Drawing.Design.ColorEditor and nothing more.
/// This is done so that in the runtime assembly, we refer to this class via an AssemblyQualifiedName
/// instead of the system ColorEditor. This avoids placing version info in the runtime assembly, allowing
/// is to build (theoretically) against any version of the system ColorEditor.
/// </summary>
internal class ChartColorEditor : ColorEditor
internal class ChartColorEditor : UITypeEditor
{
// left empty on purpose, see summary comment.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics.CodeAnalysis;
using System.Drawing.Design;
using System.Windows.Forms.DataVisualization.Charting;
using System.Windows.Forms.DataVisualization.Charting.ChartTypes;

using Microsoft.DotNet.DesignTools.Editors;

namespace System.Windows.Forms.Design.DataVisualization.Charting
{

Expand Down Expand Up @@ -311,6 +312,8 @@ public DataPointCollectionEditor() : base(typeof(DataPointCollection))
{
}

#warning designer
/*
/// <summary>
/// Do not allow to edit if multiple series selected.
/// </summary>
Expand All @@ -330,13 +333,14 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
}
return base.EditValue(context, provider, value);
}
*/

/// <summary>
/// Create instance of data point object
/// </summary>
/// <param name="itemType">Item type.</param>
/// <returns>New item instance.</returns>
protected override object CreateInstance(Type itemType)
/// <summary>
/// Create instance of data point object
/// </summary>
/// <param name="itemType">Item type.</param>
/// <returns>New item instance.</returns>
protected override object CreateInstance(Type itemType)
{
if (Context != null && Context.Instance != null)
{
Expand Down Expand Up @@ -364,23 +368,28 @@ protected override object CreateInstance(Type itemType)
/// </summary>
internal class ChartCollectionEditor : CollectionEditor
{
#region Editor methods and properties
#region Editor methods and properties

// Collection editor form
CollectionForm _form = null;
#warning designer
// Collection editor form
// CollectionForm _form = null;
Chart _chart = null;
ITypeDescriptorContext _context = null;

// Help topic string
string _helpTopic = "";
/// <summary>
/// Object constructor.
/// </summary>
/// <param name="type">AxisName.</param>
public ChartCollectionEditor(Type type) : base(type)

#warning designer
/// <summary>
/// Object constructor.
/// </summary>
/// <param name="type">AxisName.</param>
public ChartCollectionEditor(Type type) : base(null, type)
{
}

#warning designer
/*
/// <summary>
/// Edit object's value.
/// </summary>
Expand Down Expand Up @@ -423,6 +432,7 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
}
}
}
*/

/// <summary>
/// Called when [name reference changing].
Expand Down Expand Up @@ -494,7 +504,8 @@ protected override object SetItems(object editValue, object[] value)
return result;
}


#warning designer
/*
/// <summary>
/// Ovveride the HelpTopic property to provide different topics,
/// depending on selected property.
Expand Down Expand Up @@ -532,6 +543,7 @@ protected override void ShowHelp()
// Re-Init topic name
_helpTopic = "";
}
*/

/// <summary>
/// Returns the collection form property grid. Added for VS2005 compatibility.
Expand Down Expand Up @@ -579,11 +591,15 @@ private void CollectButtons(ArrayList buttons, System.Windows.Forms.Control.Cont
}
}

/// <summary>
/// Cretaes form for collection editing.
/// </summary>
/// <returns>Form object.</returns>
protected override CollectionForm CreateCollectionForm()

#warning designer

/*
/// <summary>
/// Cretaes form for collection editing.
/// </summary>
/// <returns>Form object.</returns>
protected override CollectionForm CreateCollectionForm()
{
_form = base.CreateCollectionForm();
Expand Down Expand Up @@ -617,12 +633,13 @@ protected override CollectionForm CreateCollectionForm()
return _form;
}
*/


/// <summary>
/// Update design-time HTML when OK button is clicked in the collection editor
/// </summary>
private void OnOkClicked(object sender, EventArgs e)
/// <summary>
/// Update design-time HTML when OK button is clicked in the collection editor
/// </summary>
private void OnOkClicked(object sender, EventArgs e)
{
// Clear the help topic
_helpTopic = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
namespace System.Windows.Forms.Design.DataVisualization.Charting
{

#warning designer
/*
/// <summary>
/// Image string editor class.
/// </summary>
Expand Down Expand Up @@ -74,5 +76,57 @@ public override void PaintValue(PaintValueEventArgs e)
}
#endregion
}
*/

/// <summary>
/// Provides an editor for filenames.
/// </summary>
public class ImageValueEditor : UITypeEditor
{
private OpenFileDialog _openFileDialog;

public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (!provider.TryGetService(out IWindowsFormsEditorService _))
{
return value;
}

if (_openFileDialog is null)
{
_openFileDialog = new OpenFileDialog();
InitializeDialog(_openFileDialog);
}

if (value is string stringValue)
{
_openFileDialog.FileName = stringValue;
}

if (_openFileDialog.ShowDialog() == DialogResult.OK)
{
return _openFileDialog.FileName;
}

return value;
}

/// <inheritdoc />
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) => UITypeEditorEditStyle.Modal;

/// <summary>
/// Initializes the open file dialog when it is created. This gives you an opportunity to
/// configure the dialog as you please. The default implementation provides a generic file
/// filter and title.
/// </summary>
protected virtual void InitializeDialog(OpenFileDialog openFileDialog)
{
/*
ArgumentNullException.ThrowIfNull(openFileDialog);
openFileDialog.Filter = SR.GenericFileFilter;
openFileDialog.Title = SR.GenericOpenFile;
*/
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public LegendItemCollectionEditor() : base(typeof(LegendItemsCollection))
{
}

#warning designer
/*
/// <summary>
/// Edit object's value.
/// </summary>
Expand All @@ -38,14 +40,15 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
{
return base.EditValue(context, provider, value);
}
*/

#endregion
}
#endregion
}

/// <summary>
/// Designer editor for the legend collection.
/// </summary>
internal class LegendCollectionEditor : ChartCollectionEditor
/// <summary>
/// Designer editor for the legend collection.
/// </summary>
internal class LegendCollectionEditor : ChartCollectionEditor
{
#region Editor methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms.DataVisualization.Charting;
using Microsoft.DotNet.DesignTools.Designers;

namespace System.Windows.Forms.Design.DataVisualization.Charting
{
Expand Down Expand Up @@ -58,9 +59,9 @@ public override void Initialize(IComponent component)
SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
}

protected override void OnMouseDragBegin(int x, int y)
protected override void OnMouseDragBegin(int x, int y, Keys modifierKeys)
{
base.OnMouseDragBegin(x, y);
base.OnMouseDragBegin(x, y, modifierKeys);
ChartWinDesigner.controlDesigner = this;
}

Expand Down
Loading

0 comments on commit 17698a2

Please sign in to comment.