![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2006
Posts: 3
Rep Power: 0
![]() |
C# n00b needs LOTS of help....
the situation as it stands. Am in a work study program so I go to work 3 weeks and school 1 week a month at my vocational school to "learn programming" and become an IT whiz. Well what they dont give you there is any form of syntax or "modern" languages...my boss has had me working on a data base language that is very pascal oriented for the last 3 years. So that is what I know better, the basic concepts of OOP are clear to me. I just have NO idea whatsoever even how to initialize the variables here in the program I am trying to write. Our CompSci teacher has given us until Friday(due date) to write something in C#. Has to be a simulation with a least six different variables that can be manually entered and animated.
So my idea was to show the effectiveness of an M82A1 barrett rifle against several (3) different targets depending on range,ammo type,engagement duration and maybe a little wind. This whole business is timed, there is a progress bar that when it reaches completion the sniper bites it. Otherwise there is an image of the ammo types to be chosen before starting the simulation, the enemy, (I havent figured out how to fill in the Combo boxes yet), the idea is to show only the picture of the chosen target and show a small jpg when the target is hit and when the rifle fires. what I am using as tools: net framework 1.1 and Antechinus C# Editor here is what I have so far: the current errors are in lines 292 and 304 having to do with "Cannot implicitly convert type 'System.Drawing.ContentAlignment' to 'System.Windows.Forms.HorizontalAlignment' " using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace MyNamespace { /// <summary> /// Summary for MyNamespace /// </summary> public class MyForm : System.Windows.Forms.Form { //{{OBJ_DECLARATION(MyNamespace.MyForm) protected System.Windows.Forms.PictureBox gunbox; protected System.Windows.Forms.PictureBox blastbox; protected System.Windows.Forms.PictureBox practicebox; protected System.Windows.Forms.PictureBox slapbox; protected System.Windows.Forms.PictureBox Raufossbox; protected System.Windows.Forms.PictureBox HEbox; protected System.Windows.Forms.RadioButton hebutton; protected System.Windows.Forms.RadioButton slapbutton; protected System.Windows.Forms.RadioButton practicebutton; protected System.Windows.Forms.RadioButton raufossbutton; protected System.Windows.Forms.PictureBox bmpdbox; protected System.Windows.Forms.PictureBox t62box; protected System.Windows.Forms.PictureBox gazbox; protected System.Windows.Forms.Button FIRE; protected System.Windows.Forms.Button RESET; protected System.Windows.Forms.Button CEASEFIRE; protected System.Windows.Forms.ProgressBar ArtilleryZerobar; protected System.Windows.Forms.ComboBox ComboBox1; protected System.Windows.Forms.PictureBox impactbox; protected System.Windows.Forms.TextBox artillerybox; protected System.Windows.Forms.TextBox targetbox; protected System.Windows.Forms.TextBox sniperbox; //}}OBJ_DECLARATION public MyForm() { // Required for Visual Forms support InitializeComponent(); // TODO: Add any constructor code after InitializeComponent call } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { base.Dispose( disposing ); } /// <summary> /// Required method for Visual Forms support - do not modify /// the contents between the //{{ ... //}} tags. /// </summary> private void InitializeComponent() { //{{OBJ_INSTANTIATION(MyNamespace.MyForm) this.gunbox = new System.Windows.Forms.PictureBox(); this.blastbox = new System.Windows.Forms.PictureBox(); this.practicebox = new System.Windows.Forms.PictureBox(); this.slapbox = new System.Windows.Forms.PictureBox(); this.Raufossbox = new System.Windows.Forms.PictureBox(); this.HEbox = new System.Windows.Forms.PictureBox(); this.hebutton = new System.Windows.Forms.RadioButton(); this.slapbutton = new System.Windows.Forms.RadioButton(); this.practicebutton = new System.Windows.Forms.RadioButton(); this.raufossbutton = new System.Windows.Forms.RadioButton(); this.bmpdbox = new System.Windows.Forms.PictureBox(); this.t62box = new System.Windows.Forms.PictureBox(); this.gazbox = new System.Windows.Forms.PictureBox(); this.FIRE = new System.Windows.Forms.Button(); this.RESET = new System.Windows.Forms.Button(); this.CEASEFIRE = new System.Windows.Forms.Button(); this.ArtilleryZerobar = new System.Windows.Forms.ProgressBar(); this.ComboBox1 = new System.Windows.Forms.ComboBox(); this.impactbox = new System.Windows.Forms.PictureBox(); this.artillerybox = new System.Windows.Forms.TextBox(); this.targetbox = new System.Windows.Forms.TextBox(); this.sniperbox = new System.Windows.Forms.TextBox(); //}}OBJ_INSTANTIATION this.SuspendLayout(); this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.gunbox) this.gunbox.Location = new System.Drawing.Point(20, 110); this.gunbox.Size = new System.Drawing.Size(230, 70); this.gunbox.TabIndex = 0; this.gunbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\m82a1_2.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.blastbox) this.blastbox.Location = new System.Drawing.Point(250, 110); this.blastbox.Size = new System.Drawing.Size(60, 40); this.blastbox.TabIndex = 1; this.blastbox.Visible = false; this.blastbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\muzzle.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.practicebox) this.practicebox.Location = new System.Drawing.Point(480, 320); this.practicebox.Size = new System.Drawing.Size(190, 70); this.practicebox.TabIndex = 2; this.practicebox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\dum_dum.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.slapbox) this.slapbox.Location = new System.Drawing.Point(480, 230); this.slapbox.Size = new System.Drawing.Size(190, 70); this.slapbox.TabIndex = 3; this.slapbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\body_armor.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.Raufossbox) this.Raufossbox.Location = new System.Drawing.Point(710, 320); this.Raufossbox.Size = new System.Drawing.Size(190, 70); this.Raufossbox.TabIndex = 4; this.Raufossbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\raufoss.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.HEbox) this.HEbox.Location = new System.Drawing.Point(710, 240); this.HEbox.Size = new System.Drawing.Size(190, 60); this.HEbox.TabIndex = 5; this.HEbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\high_ex.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.hebutton) this.hebutton.Location = new System.Drawing.Point(680, 250); this.hebutton.Size = new System.Drawing.Size(20, 20); this.hebutton.TabIndex = 6; this.hebutton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.slapbutton) this.slapbutton.Location = new System.Drawing.Point(450, 260); this.slapbutton.Size = new System.Drawing.Size(20, 20); this.slapbutton.TabIndex = 7; this.slapbutton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.practicebutton) this.practicebutton.Location = new System.Drawing.Point(450, 350); this.practicebutton.Size = new System.Drawing.Size(20, 20); this.practicebutton.TabIndex = 8; this.practicebutton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.raufossbutton) this.raufossbutton.Location = new System.Drawing.Point(680, 340); this.raufossbutton.Size = new System.Drawing.Size(20, 20); this.raufossbutton.TabIndex = 9; this.raufossbutton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.bmpdbox) this.bmpdbox.Location = new System.Drawing.Point(840, 30); this.bmpdbox.Size = new System.Drawing.Size(340, 260); this.bmpdbox.TabIndex = 10; this.bmpdbox.Enabled = false; this.bmpdbox.Visible = false; this.bmpdbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\bmpd.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.t62box) this.t62box.Location = new System.Drawing.Point(840, 30); this.t62box.Size = new System.Drawing.Size(340, 280); this.t62box.TabIndex = 11; this.t62box.Visible = false; this.t62box.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\t62.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.gazbox) this.gazbox.Location = new System.Drawing.Point(850, 30); this.gazbox.Size = new System.Drawing.Size(340, 280); this.gazbox.TabIndex = 12; this.gazbox.Visible = false; this.gazbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\uazjeep.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.FIRE) this.FIRE.Location = new System.Drawing.Point(20, 340); this.FIRE.Size = new System.Drawing.Size(80, 40); this.FIRE.Text = "Engage"; this.FIRE.TabIndex = 13; this.FIRE.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(0)), ((System.Byte)(0))); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.RESET) this.RESET.Location = new System.Drawing.Point(200, 340); this.RESET.Size = new System.Drawing.Size(80, 40); this.RESET.Text = "Reset"; this.RESET.TabIndex = 14; this.RESET.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(255)), ((System.Byte)(255))); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.CEASEFIRE) this.CEASEFIRE.Location = new System.Drawing.Point(110, 340); this.CEASEFIRE.Size = new System.Drawing.Size(80, 40); this.CEASEFIRE.Text = "Break off"; this.CEASEFIRE.TabIndex = 15; this.CEASEFIRE.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(0))); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.ProgressBar1) this.ArtilleryZerobar.Location = new System.Drawing.Point(30, 270); this.ArtilleryZerobar.Size = new System.Drawing.Size(250, 40); this.ArtilleryZerobar.TabIndex = 16; this.ArtilleryZerobar.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(0)), ((System.Byte)(0))); this.ArtilleryZerobar.Maximum = 100; this.ArtilleryZerobar.Minimum = 0; this.ArtilleryZerobar.Value = 0; //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.ComboBox1) this.ComboBox1.Location = new System.Drawing.Point(340, 270); this.ComboBox1.Size = new System.Drawing.Size(100, 110); this.ComboBox1.Text = "Opponent"; this.ComboBox1.TabIndex = 17; this.ComboBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(0))); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.PictureBox2) this.impactbox.Location = new System.Drawing.Point(790, 90); this.impactbox.Size = new System.Drawing.Size(40, 70); this.impactbox.TabIndex = 18; this.impactbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\impact.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.ArtilleryZerobar) this.ArtilleryZerobar.Location = new System.Drawing.Point(30, 270); this.ArtilleryZerobar.Size = new System.Drawing.Size(250, 40); this.ArtilleryZerobar.TabIndex = 16; this.ArtilleryZerobar.Maximum = 100; this.ArtilleryZerobar.Minimum = 0; this.ArtilleryZerobar.Value = 0; //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.impactbox) this.impactbox.Location = new System.Drawing.Point(790, 90); this.impactbox.Size = new System.Drawing.Size(40, 70); this.impactbox.TabIndex = 18; this.impactbox.Visible = false; this.impactbox.Image = new Bitmap("C:\\Documents and Settings\\us\\My Documents\\My Pictures\\impact.jpg"); //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.targetbox) this.targetbox.Location = new System.Drawing.Point(880, 80); this.targetbox.Size = new System.Drawing.Size(280, 90); this.targetbox.Text = "TARGET DESTROYED"; this.targetbox.TabIndex = 20; this.targetbox.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(0)), ((System.Byte)(0))); this.targetbox.Visible = false; this.targetbox.Font = new System.Drawing.Font("Franklin Gothic Medium", 10F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); --->>> PROBLEM 1 <<<<------------------------------------------------- this.targetbox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.sniperbox) this.sniperbox.Location = new System.Drawing.Point(20, 100); this.sniperbox.Size = new System.Drawing.Size(230, 70); this.sniperbox.Text = "YOU ARE DEAD!!"; this.sniperbox.TabIndex = 21; this.sniperbox.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(0))); this.sniperbox.Visible = false; this.sniperbox.Font = new System.Drawing.Font("Arial", 10F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); ---->>>> PROBLEM2<<<<<<<<<<<<<<<<<------------------------------- this.sniperbox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; //}}OBJ_PROPERTIES //{{OBJ_PROPERTIES(MyNamespace.MyForm.artillerybox) this.artillerybox.Location = new System.Drawing.Point(30, 230); this.artillerybox.Size = new System.Drawing.Size(140, 30); this.artillerybox.Text = "Artillery zeroing in on Sniper:"; this.artillerybox.TabIndex = 19; this.artillerybox.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255))); //}}OBJ_PROPERTIES //{{FORM_PROPERTIES(MyNamespace.MyForm) this.ClientSize = new System.Drawing.Size(1200, 400); this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0))); this.Font = new System.Drawing.Font("MS Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Controls.Add(this.gunbox); this.Controls.Add(this.blastbox); this.Controls.Add(this.practicebox); this.Controls.Add(this.slapbox); this.Controls.Add(this.Raufossbox); this.Controls.Add(this.HEbox); this.Controls.Add(this.hebutton); this.Controls.Add(this.slapbutton); this.Controls.Add(this.practicebutton); this.Controls.Add(this.raufossbutton); this.Controls.Add(this.bmpdbox); this.Controls.Add(this.t62box); this.Controls.Add(this.gazbox); this.Controls.Add(this.FIRE); this.Controls.Add(this.RESET); this.Controls.Add(this.CEASEFIRE); this.Controls.Add(this.ArtilleryZerobar); this.Controls.Add(this.ComboBox1); this.Controls.Add(this.impactbox); this.Controls.Add(this.artillerybox); this.Controls.Add(this.targetbox); this.Controls.Add(this.sniperbox); //}}FORM_PROPERTIES this.Name = "MyForm"; this.Text = "MyForm"; // Form caption this.ResumeLayout(false); } /// <summary> /// The main entry point for the application. /// </summary> static void Main() { Application.Run(new MyForm()); } } } I have to say this is worlds apart from anything I have seen or done and I am having a hell of a time with it. Especially since we are left to our own devices and 4 days to come up with a solution. (There arent really enough tutorials to do what I want to do in this short a time.) Another question I do have is the .jpgs that I have specified are the dragged into the .exe when this thing is compiled and rund or have I just put several hard links in my code which I know is a rather stupid thing to do. Two things that the teacher said we werent allowed to do anymore are 1.the game of life or 2. a racing sim because they exist all over the net. All help is appreciated. Last edited by rojar; Feb 1st, 2006 at 11:12 AM. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Please read the post for new users please; use code tags and a proper title for the thread. Please post the code you think the error as well... I'm not putting 6000+ lines of code for 2 lines of code with mistakes? Do this, and you'll probably get some more help.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2006
Posts: 3
Rep Power: 0
![]() |
well since I can no longer edit the first one
sorry about that...
heres the short version: error: m82a1.cs(292,31): error CS0029: Cannot implicitly convert type 'System.Drawing.ContentAlignment' to 'System.Windows.Forms.HorizontalAlignment' //{{OBJ_PROPERTIES(MyNamespace.MyForm.targetbox)
this.targetbox.Font = new System.Drawing.Font("Franklin Gothic Medium", 10F, ((System.Drawing.FontStyle)(System.Drawing.FontSty le.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
--->>> PROBLEM 1 <<<<-------------------------------------------------
this.targetbox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//}}OBJ_PROPERTIES
//{{OBJ_PROPERTIES(MyNamespace.MyForm.sniperbox)
this.sniperbox.Font = new System.Drawing.Font("Arial", 10F, ((System.Drawing.FontStyle)(System.Drawing.FontSty le.Bold | System.Drawing.FontStyle.Italic)), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
---->>>> PROBLEM2<<<<<<<<<<<<<<<<<-------------------------------
this.sniperbox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//}}OBJ_PROPERTIES |
|
|
|
|
|
#4 | |
|
Programmer
Join Date: Dec 2005
Posts: 53
Rep Power: 3
![]() |
Quote:
Unless of course there is something in HorizontalAlignment.* that doesn't meet your needs? |
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Feb 2006
Posts: 3
Rep Power: 0
![]() |
thanks
that seemed to work fine, just I dont have any idea why. I see that the calls are to different processes is one more protected than the other?
|
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
C# is strongly typed. HorizontalAlignment != ContentAlignment, therefore it complains. They're not the same thing, otherwise one of them wouldn't exist.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|