473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

convert code written without editor to editor compatible?

I have an application in C# that was written as a bunch of individual CS
files. I would like to combine these all into single solution that can be
editied with the Visual Studio 2003 editor. Does anyone have any tips on
how to quickly bring this code into the VS2003 environment? Below is a
sample of the code for an about box: For this example, it wouldn't be all
that difficult to just create a new form and set all the properties to match
this code through the designer, but there are 20 other much more complex
forms I would need to do the same thing for.

using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace ActiveNotes
{
public class AboutBox: Form
{

private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnOK;
/*
*
public static void Main()
{
AboutBox dlg = new AboutBox();
DialogResult dr = dlg.ShowDialog();
Console.WriteLine("Dialog box terminated with " + dr);
}
*/
public AboutBox()
{
Text = "About ActiveNotes";
StartPosition = FormStartPosition.CenterScreen;

pictureBox1 = new System.Windows.Forms.PictureBox();
label1 = new System.Windows.Forms.Label();
labelVersion = new System.Windows.Forms.Label();
btnOK = new System.Windows.Forms.Button();

//Standard style for dialog boxes
FormBorderStyle = FormBorderStyle.FixedDialog;
//To allow cancel without buttons.
//ControlBox = false;
MaximizeBox = false;
MinimizeBox = false;
ShowInTaskbar = false;
//
// pictureBox1
//
this.pictureBox1.Image =
Image.FromFile(Path.GetDirectoryName(Application.E xecutablePath)+"\\art\\splash2.jpg");
this.pictureBox1.Location = new System.Drawing.Point(8, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(376, 296);
this.pictureBox1.TabIndex = 7;
this.pictureBox1.TabStop = false;

//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(8, 312);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(376, 23);
this.label1.TabIndex = 1;
this.label1.Text = "ActiveNotes 3.0 - Copyright 2003 ActiveGroup
Ventures, Inc.";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;


//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(296, 360);
this.btnOK.Name = "btnOK";
this.btnOK.TabIndex = 0;
this.btnOK.Text = "OK";
this.btnOK.Click += new System.EventHandler(this.OnOKClick);

this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.labelVersion,
this.btnOK,
this.linkLabel1,
this.label1,
this.pictureBox1});

ClientSize = new Size(392, 397);
this.Load += new System.EventHandler(this.AboutBox_Load);

}

void OnOKClick(object obj, EventArgs ea)
{
DialogResult = DialogResult.OK;
}

protected override void OnPaint(PaintEventArgs pea)
{
Graphics g = pea.Graphics;

}
private void AboutBox_Load(object sender, System.EventArgs e)
{
this.ActiveControl = this.btnOK;
}
}

Nov 16 '05 #1
2 1481
Assuming you want the properties that you're setting during construction to
be reflected in the design-time experience and have design-time changes
automatically round-tripped, it's quite difficult to migrate this code
without manually creating a form in Visual Studio. The reason is that the
form designer serializes its state into your source code in a specific
format, and it's unlikely that you'll accidently stumble across it.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com/blogs/mickey

"Billy Greening" <bi***@activegroup.net> wrote in message
news:uL**************@TK2MSFTNGP11.phx.gbl...
I have an application in C# that was written as a bunch of individual CS
files. I would like to combine these all into single solution that can be
editied with the Visual Studio 2003 editor. Does anyone have any tips on
how to quickly bring this code into the VS2003 environment? Below is a
sample of the code for an about box: For this example, it wouldn't be all
that difficult to just create a new form and set all the properties to match this code through the designer, but there are 20 other much more complex
forms I would need to do the same thing for.

using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace ActiveNotes
{
public class AboutBox: Form
{

private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnOK;
/*
*
public static void Main()
{
AboutBox dlg = new AboutBox();
DialogResult dr = dlg.ShowDialog();
Console.WriteLine("Dialog box terminated with " + dr);
}
*/
public AboutBox()
{
Text = "About ActiveNotes";
StartPosition = FormStartPosition.CenterScreen;

pictureBox1 = new System.Windows.Forms.PictureBox();
label1 = new System.Windows.Forms.Label();
labelVersion = new System.Windows.Forms.Label();
btnOK = new System.Windows.Forms.Button();

//Standard style for dialog boxes
FormBorderStyle = FormBorderStyle.FixedDialog;
//To allow cancel without buttons.
//ControlBox = false;
MaximizeBox = false;
MinimizeBox = false;
ShowInTaskbar = false;
//
// pictureBox1
//
this.pictureBox1.Image =
Image.FromFile(Path.GetDirectoryName(Application.E xecutablePath)+"\\art\\spl
ash2.jpg"); this.pictureBox1.Location = new System.Drawing.Point(8, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(376, 296);
this.pictureBox1.TabIndex = 7;
this.pictureBox1.TabStop = false;

//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(8, 312);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(376, 23);
this.label1.TabIndex = 1;
this.label1.Text = "ActiveNotes 3.0 - Copyright 2003 ActiveGroup
Ventures, Inc.";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;


//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(296, 360);
this.btnOK.Name = "btnOK";
this.btnOK.TabIndex = 0;
this.btnOK.Text = "OK";
this.btnOK.Click += new System.EventHandler(this.OnOKClick);

this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.labelVersion,
this.btnOK,
this.linkLabel1,
this.label1,
this.pictureBox1});

ClientSize = new Size(392, 397);
this.Load += new System.EventHandler(this.AboutBox_Load);

}

void OnOKClick(object obj, EventArgs ea)
{
DialogResult = DialogResult.OK;
}

protected override void OnPaint(PaintEventArgs pea)
{
Graphics g = pea.Graphics;

}
private void AboutBox_Load(object sender, System.EventArgs e)
{
this.ActiveControl = this.btnOK;
}
}

Nov 16 '05 #2
On Mon, 7 Jun 2004 12:25:38 -0400, "Billy Greening"
<bi***@activegroup.net> wrote:
I have an application in C# that was written as a bunch of individual CS
files. I would like to combine these all into single solution that can be
editied with the Visual Studio 2003 editor. Does anyone have any tips on
how to quickly bring this code into the VS2003 environment? Below is a
sample of the code for an about box: For this example, it wouldn't be all
that difficult to just create a new form and set all the properties to match
this code through the designer, but there are 20 other much more complex
forms I would need to do the same thing for.


That's a drawback of Microsoft's designers, you either have to
always use them, or never use them. There's very little latitude for
switching back and forth.
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
7
by: Dave | last post by:
Does anyone know of a Windows compatible command line tool that capable of parsing Microsoft's VC++ workspace/project (e.g., .dsw, .dsp, .sln, ..vcproj, etc.) files and generating an...
5
by: Robin Johnson | last post by:
Hi, I've written an engine in Javascript for running text adventure games on a web page: http://www.robinjohnson.f9.co.uk/adventure/hamlet.html (That's the only game I've written with it so...
35
by: Michel Sanner | last post by:
Hello, One of the greatest feature of Python in my opinion is the way the interpreter can be used to integrate a wide variety of software packages by dynamically linking them. This approach has...
8
by: goldtech | last post by:
Newbie esp about html validation - seems like something to strive for. Yet many pages even "enterprise" corporate type pages do not validate, yet seem to display well on most browsers. Two...
47
by: mister catering | last post by:
I have a doubt... why is so dificult to reuse software developed under the same language (not only c of course) and under the same compiler?. It seems the language itself is not enough to build a...
16
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project...
4
by: csgraham74 | last post by:
Hi, Ive posted on this previously but had no response. Basically i need to build some html using a rich text editor. Then i want to actually create an html document from this and save it to my...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.