Skip to content

Commit

Permalink
build: migrate sample forms to net8 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul-Siemens committed Jul 12, 2024
1 parent 240bcf3 commit 782333e
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 283 deletions.
2 changes: 1 addition & 1 deletion Src/DevAge.Windows.Forms/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions Src/WindowsFormsSample/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
using System.Reflection;
using System.Runtime.CompilerServices;

//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.0.*")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
Expand Down
27 changes: 17 additions & 10 deletions Src/WindowsFormsSample/GridSamples/frmSample25.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class frmSample25 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panelBottom;
private SourceGrid.Grid grid;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem mnWindow;
// TODO MainMenu is no longer supported. Use MenuStrip instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
private System.Windows.Forms.MenuStrip mainMenu1;
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
private System.Windows.Forms.ToolStripMenuItem mnWindow;
/// <summary>
/// Required designer variable.
/// </summary>
Expand Down Expand Up @@ -53,8 +55,10 @@ private void InitializeComponent()
{
this.panelBottom = new System.Windows.Forms.Panel();
this.grid = new SourceGrid.Grid();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.mnWindow = new System.Windows.Forms.MenuItem();
// TODO MainMenu is no longer supported. Use MenuStrip instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mainMenu1 = new System.Windows.Forms.MenuStrip();
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mnWindow = new System.Windows.Forms.ToolStripMenuItem();
this.panelBottom.SuspendLayout();
this.SuspendLayout();
//
Expand Down Expand Up @@ -87,12 +91,13 @@ private void InitializeComponent()
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mainMenu1.Items.AddRange(new System.Windows.Forms.ToolStripMenuItem[] {
this.mnWindow});
//
// mnWindow
//
this.mnWindow.Index = 0;
//this.mnWindow.Index = 0;
this.mnWindow.Text = "Window";
//
// frmSample25
Expand All @@ -101,7 +106,7 @@ private void InitializeComponent()
this.ClientSize = new System.Drawing.Size(772, 470);
this.Controls.Add(this.panelBottom);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.MainMenuStrip = this.mainMenu1;
this.Name = "frmSample25";
this.Text = "frmSample25";
this.Load += new System.EventHandler(this.frmSample25_Load);
Expand Down Expand Up @@ -157,8 +162,9 @@ private void frmSample25_Load(object sender, System.EventArgs e)

if (assemblyTypes[i] != this.GetType())
{
MenuItem menu = new MenuForm(this, assemblyTypes[i], sampleAttribute.Description + " " + sampleAttribute.SampleNumber.ToString());
mnWindow.MenuItems.Add(menu);
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
ToolStripMenuItem menu = new MenuForm(this, assemblyTypes[i], sampleAttribute.Description + " " + sampleAttribute.SampleNumber.ToString());
mnWindow.DropDownItems.Add(menu);
}
}
}
Expand All @@ -171,7 +177,8 @@ private void frmSample25_Load(object sender, System.EventArgs e)
}


private class MenuForm : MenuItem
private class MenuForm : // TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
ToolStripMenuItem
{
private Type mFrm;
private Form mParent;
Expand Down
7 changes: 4 additions & 3 deletions Src/WindowsFormsSample/GridSamples/frmSample26.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ public CellCursor():base(Cursors.Cross, true)

public class PopupMenu : SourceGrid.Cells.Controllers.ControllerBase
{
ContextMenu menu = new ContextMenu();
// TODO ContextMenu is no longer supported. Use ContextMenuStrip instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
ContextMenuStrip menu = new ContextMenuStrip();
public PopupMenu()
{
menu.MenuItems.Add("Menu 1", new EventHandler(Menu1_Click));
menu.MenuItems.Add("Menu 2", new EventHandler(Menu2_Click));
menu.Items.Add("Menu 1", null, new EventHandler(Menu1_Click));
menu.Items.Add("Menu 2", null, new EventHandler(Menu2_Click));
}

public override void OnMouseUp(SourceGrid.CellContext sender, MouseEventArgs e)
Expand Down
49 changes: 31 additions & 18 deletions Src/WindowsFormsSample/StartForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ namespace WindowsFormsSample
/// </summary>
public class StartForm : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem mnFile;
private System.Windows.Forms.MenuItem mnExit;
private System.Windows.Forms.MenuItem mnHelp;
private System.Windows.Forms.MenuItem mnAbout;
// TODO MainMenu is no longer supported. Use MenuStrip instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
private System.Windows.Forms.MenuStrip mainMenu1;
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
private System.Windows.Forms.ToolStripMenuItem mnFile;
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
private System.Windows.Forms.ToolStripMenuItem mnExit;
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
private System.Windows.Forms.ToolStripMenuItem mnHelp;
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
private System.Windows.Forms.ToolStripMenuItem mnAbout;
private SourceGrid.Grid grid1;
/// <summary>
/// Required designer variable.
Expand Down Expand Up @@ -52,43 +57,51 @@ protected override void Dispose( bool disposing )
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.mnFile = new System.Windows.Forms.MenuItem();
this.mnExit = new System.Windows.Forms.MenuItem();
this.mnHelp = new System.Windows.Forms.MenuItem();
this.mnAbout = new System.Windows.Forms.MenuItem();
// TODO MainMenu is no longer supported. Use MenuStrip instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mainMenu1 = new System.Windows.Forms.MenuStrip();
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mnFile = new System.Windows.Forms.ToolStripMenuItem();
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mnExit = new System.Windows.Forms.ToolStripMenuItem();
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mnHelp = new System.Windows.Forms.ToolStripMenuItem();
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mnAbout = new System.Windows.Forms.ToolStripMenuItem();
this.grid1 = new SourceGrid.Grid();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mainMenu1.Items.AddRange(new System.Windows.Forms.ToolStripMenuItem[] {
this.mnFile,
this.mnHelp});
//
// mnFile
//
this.mnFile.Index = 0;
this.mnFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
// this.mnFile.Index = 0;
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mnFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripMenuItem[] {
this.mnExit});
this.mnFile.Text = "File";
//
// mnExit
//
this.mnExit.Index = 0;
// this.mnExit.Index = 0;
this.mnExit.Text = "Exit";
this.mnExit.Click += new System.EventHandler(this.mnExit_Click);
//
// mnHelp
//
this.mnHelp.Index = 1;
this.mnHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
// this.mnHelp.Index = 1;
// TODO MenuItem is no longer supported. Use ToolStripMenuItem instead. For more details see https://docs.microsoft.com/en-us/dotnet/core/compatibility/winforms#removed-controls
this.mnHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripMenuItem[] {
this.mnAbout});
this.mnHelp.Text = "Help";
//
// mnAbout
//
this.mnAbout.Index = 0;
// this.mnAbout.Index = 0;
this.mnAbout.Text = "About";
//
// grid1
Expand All @@ -113,7 +126,7 @@ private void InitializeComponent()
this.BackColor = System.Drawing.SystemColors.Window;
this.ClientSize = new System.Drawing.Size(624, 305);
this.Controls.Add(this.grid1);
this.Menu = this.mainMenu1;
this.MainMenuStrip = this.mainMenu1;
this.Name = "StartForm";
this.Text = "Examples Explorer";
this.ResumeLayout(false);
Expand Down
Loading

0 comments on commit 782333e

Please sign in to comment.