|
When you say C# project, is this a project you're working on in Visual Studio?
|
|
|
|
|
Can someone pls help me with this project
(bouncing ball)Write a program that bounces a blue ball inside a panel.The ball should start moving with a mouseClick event.When the ball hits the edge of the panel it should bounce off the edge and continue to the opposite direction.The ball's position should be updated using a thread and redrawn periodically using another thread.Use the float variable to mantain the ball's position, radius and velocity.Draw the ball using the FillEllipse Method of class Graphics.
Remember to terminate the thread when the user closes the application.
pls help
for(tipzen= theMan;tipzen=superman;tipzen+++)
|
|
|
|
|
Tipzen wrote: Can someone pls help me with this project
Sure, post the code you've already written, and we'd love to help. otherwise, we'd not be helping, we'd be doing your homework.
Is this C# 2.0 ? If so, the backgroundthread class is the one to use. Beyond that, your course materials should tell you all you need to get started, at least. Ask questions when you've tried doing your own homework.
To be honest, these instructions are very explicit. I don't see how you could have trouble starting at least.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
actually i have the same problem and i'll show you what i got so far.
class DrawBall
{
private float initialX;
private float initialY;
private Random generator;
private int direction;
private Panel drawPanel;
private float radius;
private float velocity;
public DrawBall( Panel panel )
{
drawPanel = panel;
generator = new Random();
radius = (float)generator.Next( 10, 30 );
float temp = drawPanel.Size.Width - ( radius * 2 );
initialX = 100;
initialY = 100;
direction = generator.Next( 8 );
velocity = 10;
}
private delegate void DrawBallDelegate( float x, float y );
private void DrawBallInPanel( float x, float y )
{
Graphics myGraphics = drawPanel.CreateGraphics();
myGraphics.FillEllipse( new SolidBrush( Color.Red ),
x, y, radius * 2, radius * 2 );
}
private delegate void ClearPanel();
private void ClearBallsPanel()
{
Graphics myGraphics = drawPanel.CreateGraphics();
myGraphics.Clear( Color.White );
}
public void BallGenerator()
{
while ( true )
{
drawPanel.Invoke( new DrawBallDelegate( DrawBallInPanel ),
new object[] { initialX, initialY } );
Thread.Sleep( 50 );
if ( ( initialX <= drawPanel.Size.Width ) ||
( initialX > 0 ) || ( initialY > 0 ) ||
( initialY <= drawPanel.Size.Height ) )
{
switch ( direction )
{
case 0:
initialY -= velocity;
break;
case 1:
initialX += velocity;
initialY -= velocity;
break;
case 2:
initialX += velocity;
break;
case 3:
initialX += velocity;
initialY += velocity;
break;
case 4:
initialY += velocity;
break;
case 5:
initialX -= velocity;
initialY += velocity;
break;
case 6:
initialX -= velocity;
break;
case 7:
initialX -= velocity;
initialY -= velocity;
break;
}
}
else
{
if ( direction == 0 )
direction = 4;
if ( direction == 1 )
direction = 5;
if ( direction == 2 )
direction = 6;
if ( direction == 3 )
direction = 7;
if ( direction == 4 )
direction = 0;
if ( direction == 5 )
direction = 1;
if ( direction == 6 )
direction = 2;
if ( direction == 7 )
direction = 3;
velocity = (float)generator.Next( 10, 20 );
switch ( direction )
{
case 0:
initialY -= velocity;
break;
case 1:
initialX += velocity;
initialY -= velocity;
break;
case 2:
initialX += velocity;
break;
case 3:
initialX += velocity;
initialY += velocity;
break;
case 4:
initialY += velocity;
break;
case 5:
initialX -= velocity;
initialY += velocity;
break;
case 6:
initialX -= velocity;
break;
case 7:
initialX -= velocity;
initialY -= velocity;
break;
}
}
drawPanel.Invoke( new ClearPanel( ClearBallsPanel ) );
}
}
}
the problem now is that the ball wont stop at the panel borders and just keep moving. i have already tried to remove that bug by putting a if condition.
if ( ( initialX <= drawPanel.Size.Width ) ||
( initialX > 0 ) || ( initialY > 0 ) ||
( initialY <= drawPanel.Size.Height ) )
but it just doesn't work. i have done all the rest of the code including add a thread and mouse event handler.
the only problem now with this condition and the ball that doesn't stop.
Thanks
|
|
|
|
|
Hi All
I'm newbe to OleDb classes.
I'm developing an application that writes on an Excel file using OleDb classes.
To do this there should be a Named Range present in the Excel file.
If I try to use the "Print_Area" name I receive an Exception.
Do you know if it is really possible to use Print_Area and how to do that?
I use the following code for example
"SELECT *.* From Print_Area"
Do I have to tell also what worksheet to use? If it so how to do that?
Regards
ManuStone
|
|
|
|
|
I have a DataGrid in a Windows application form. I have set a button column aside to the data bound from a database.
How do I create a callback function to the clicking of a speciffic button in the DataGrid?
I know that in asp.net I've got the CommandName property of the button, called from the event of the clicking on the DataGrid. I want to do the exact same thing in my Windows application.
|
|
|
|
|
Hi All,
How do I render code of child control (Button,LinkLabel) in parent control (UserControl). Just like Visual studio renders code when Adding DataColumn in DataGridView.
|
|
|
|
|
I don't understand what your saying. Are you asking how to get the child controls of your UserControl to redraw themselves??
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks for reply, No That can be done throuth Overriding OnPaint Event.
I am working on XPander Control for windows application. It has two part XPanderControl Itself and XPanderList Control to host XPanderControl. I don't want User to drag and drop sub controls (eg button,LinkLabel) in XPanderControl. for this I have created a Propery to add sub Control, just like DataGridView (we adds Columns and type of column(textbox,button) using 'Column Collection' Propery). this all working fine in design mode but on Running program all sub controls losts because there is no static code for subcontrols in page where XPanderControl used. I don't know how to add code for newly added subcontrols in this Page.
Ashok Bansal
|
|
|
|
|
Ashok Bansal wrote: this all working fine in design mode but on Running program all sub controls losts because there is no static code for subcontrols in page where XPanderControl used.
It sounds like you're looking for the DesignerSerialzationVisibility[^] attribute class. Without attaching this to the properties of your controls, the Designer can't generate the "static code" you're looking for.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
HI all,
i am dynamically desplaying checkboxes depending upon my count,in CHECKEDLISTBOX CONTROL
BUt now i have to desplay a label and checkbox, in a single control
hope u got the point<wanna desplay="" a="" label="" and="" checkbox="" sidebyside="">
can i do with CHECKEDLISTBOX or should i need to take any other CONTROL
bye byes
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Why can't you just show all your text in the checkbox ? You can use Environment.NewLine in your string.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thnx for ur response,
but what i mean he is,
now in my application i am desplaying 10properties[from my XmlFile] in my CHECKELISTBOX as CheckBoxes
And now i need to add a label[control] foreach[10]properties PLEASE TELL ME HOW?
finally plz tell me is it possible to desply two controls in CHECKEDLISTBOX?
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
pashitech wrote: And now i need to add a label[control] foreach[10]properties PLEASE TELL ME HOW?
Again, why do you need to add a label, why can't you just set the text of the checkbox ?
pashitech wrote: finally plz tell me is it possible to desply two controls in CHECKEDLISTBOX?
I doubt it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
finally plz tell me is it possible to desply two controls in CHECKEDLISTBOX?
here what i mean is,
see i'm desplaying TemparatureProperty and now i need to add description abt TemparatureProperty, Which is another attribute of my backend xml file
so my old output is
checkbox---TemparatureProperty
and my new expected output is
checkbox---TemparatureProperty + (label)TemparatureProperty'sDescription
Hope u got me now.
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
pashitech wrote: finally plz tell me is it possible to desply two controls in CHECKEDLISTBOX?
How often do I need to answer this ? No.
pashitech wrote: checkbox---TemparatureProperty + (label)TemparatureProperty'sDescription
I reiterate. Why on EARTH can't you just append the string to show both values ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I've been working on a plugin for Office, using .NET 2.0 - not using VSTO (Visual Studio Tools for Office). I'm almost finished, and I'm working on the deployment issues.
Appparently, there are a number of issues that one must avoid. First, you should always shim such plugins (see http://blogs.msdn.com/eric_carter/archive/2004/09/28/235500.aspx[^]), and fortunately there is a wizard to help you with that (http://blogs.msdn.com/eric_carter/archive/2006/06/23/641963.aspx[^]).
"Obviously", you should download the Primary Interop Assemblies (PIA) for Office and install them, and they can be found here[^].
Then, there is an KB article which describes a bug in Office that can be taken care of by downloading this[^] hotfix.
Finally, when all this has been taken care of, you can still run into trouble. Which is precisely what I've been experiencing. The thing is, my plugin has a reference to the Office applications it supports (Word,Excel,Outlook), or actually their PIA. But if the user doesn't have one of this application installed (I have an installation where Outlook isn't installed), it's PIA will not be installed either, and my plugin will try to reference a PIA which is not present. Which also means that when my plugin is being loaded from other Office applications, the load fails because the PIA cannot be found, even though that particular PIA will of course not be used. Needless to say, these PIA must be installed in the GAC and I have no control over them (other than shipping the install from Microsoft).
So, what are my options? Is there any way to "delay" the reference to an assembly? Or should I split my plugin into different assemblies, and load only the relevant assembly programmatically? I guess I could do that, but I would rather not if there is another way.
Hope someone will provide some insight into this - and I hope someone understood a word that I said!
Regards,
Daníel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hi,
I creating a SplitContainer inside a Panel thru code.
I have set the Dock property to fill, but when the splitContainer gets draw, it doesnt appear filled until i move the splitter.
Then it gets filled.
Can someone tell me why?
This is a resume of my code:
<br />
SplitContainer region = new SplitContainer();<br />
<br />
region.SuspendLayout();<br />
this.SuspendLayout();<br />
<br />
region.BorderStyle = BorderStyle.Fixed3D;<br />
region.SplitterDistance = d;<br />
region.TabIndex = regions.Count;<br />
region.Dock = System.Windows.Forms.DockStyle.Fill;<br />
regions[regions.Count-1].Panel1.Controls.Add(region);<br />
<br />
region.ResumeLayout(false);<br />
regions.Add(region);<br />
<br />
Any tips?
Thx,
Nuno
|
|
|
|
|
this.ResumeLayout ?
Or perhaps just Invalidate(); ?
I also don't see you adding the control to the Controls collection, does that happen below ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes, it does.
It really is a question of layout resume.
Just to give it a try, i took of all the Suspend and Resume Layout() calls.
It worked, straight out of the box!
But this is not a very good pratice, right?
So.. how should i do this kind of operation?
In which order?
This is how i done it:
this.SuspendLayout();
mainPanel.SuspendLayout();
region.SuspendLayout();
...
region.ResumeLayout(false);
this.mainPanel.ResumeLayout(false);
this.ResumeLayout(false);
?
Nuno
|
|
|
|
|
I've never bothered with suspend/resume layout.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Its just a formality?
Can i ignore just like you, without serious implications? :P
Thx,
Nuno
|
|
|
|
|
I have to admit, I didn't even know it was expected. I write a pretty big winforms app, although I'm not sure how often it uses dynamic controls, I know it does, without issue.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have developed a windows service application in .net 2.0
It all works find and can install it successfully.
How do I transfer the executed file(s) for this program to the server so that it can be run from the services on the server?
What is the process related to this area please?
Thanks
|
|
|
|
|
You can install the service with
InstallUtil -i C:\somewhere\myService.exe
Alternatively you could build an installer project.
____________________________________
There is no proof for this sentence.
|
|
|
|