|
I assume you are using GDI+ to draw. try using double buffer.
this.SetStyle(ControlStyles.DoubleBuffer, true);
Instead to draw every command to screen, it draws to memory and when all completed, it draws already completed drawing from memory. Always use .Flush to clean graphic controls after usage.
also you can use this.Invalidate(Rectange) to force update of specific region.
Here are some articles about tetris:
A .Net Tetris game in c# using GDI+[^]
Falling Blocks Game[^]
|
|
|
|
|
As the other guy said, I assume you're using GDI+. This is bad. GDI+ was not meant for games. Call of Duty certainly does not use GDI+. You need to go to microsoft's download site and download the XNA 3.1 game libraries. Don't worry about all the xbox stuff, you can write all the code in C# and it'll run on windows.
You'll have to rewrite some of your drawing code, but if you organized it properly the game logic should all copy over as is. This will be 10x faster than using windows forms gdi stuff.
FYI, this ALSO isn't what the call of duty folks are using, but it's a lot closer.
|
|
|
|
|
Ah, thanks to both of you that answered. That makes sence And alright, I'll try the invalidate(Rectangle) thing, I hope that works. And also, I'll download XNA and I'll play around with it. Thanks again guys.
|
|
|
|
|
If you want alternative to XNA, you can look at SlimDX. This framework was developed after microsoft decidec to stop developing Managed Direct X. I noticed of its exsistence, when I needed to install after i installed comercial game. Yes it is very popular and I wont say the name, because I do not want to advertise
|
|
|
|
|
I see a lot of people on here making new libraries and tools for things that we could already do, but it's not as easy as it ought to be and I think that's great. You know what I'd love to see? A really robust library for .NET aimed at windows automation. I'm frequently having to automate things in windows(and ubuntu but lets not get into that), and I'll use either AutoHotKey, AutoIT, or VBScript, and I have to say, compared to statically typed, compiled, object-oriented C#, those languages blow.
So if anyone's looking for a good article subject or community project, I'd love to see a good library in C# code that had SendKey, MouseClick, ActivateWindow, etc. but now the user could leverage all the power of C# along with it.
Just a thought.
|
|
|
|
|
Witch attribute I need to set, so that designer can resize control only vertical or horizontal Simular to Textbox. It can be resized only by width as long as it doesn't have Multiline property to true.
Is there an if statement, so that code executing code is excluded, while the control is being rendered by Design view.
Currently I am at work, so I don't have much time to google around.
I have Read a Book "GDI+ Application Custom Controls with Visual C# 2005", This book is nearly an introduction to custom controls. Is there any book with more advance topics?
|
|
|
|
|
Saksida Bojan wrote: Witch attribute I need to set, so that designer can resize control only vertical or horizontal Simular to Textbox. It can be resized only by width as long as it doesn't have Multiline property to true.
That's probably not done using an attribute, but by setting some maximum and minimum widths. Perhaps even guarding those, in the Resize-event.
Saksida Bojan wrote: Currently I am at work, so I don't have much time to google around.
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: That's probably not done using an attribute, but by setting some maximum and minimum widths. Perhaps even guarding those, in the Resize-event.
Does not help. Even if I set Minimum and maximum width, designer still shows that can be resized in any direction. Look at Textbox and notice you can't change height, because simply you can't grab on resize rectangle when control is selceted
|
|
|
|
|
Saksida Bojan wrote: Does not help. Even if I set Minimum and maximum width, designer still shows that can be resized in any direction. Look at Textbox and notice you can't change height, because simply you can't grab on resize rectangle when control is selceted
I found this solution on SO[^], which you probably already tried;
protected override void SetBoundsCore(int x, int y,
int width, int height, BoundsSpecified specified)
{
if (this.DesignMode)
base.SetBoundsCore(x, y, 500, 490, specified);
else
base.SetBoundsCore(x, y, width, height, specified);
}
I are Troll
|
|
|
|
|
I am sorry for late reply, but this code does exactly as i would use resize event or setting min and max size. this.DesignMode is part of an answer and i thank you for it. I have just found a book with more advance topics. I am sure it will be there. Thank you for your time
|
|
|
|
|
I Found the way to use what i wanted.
I added a dll reference: system.Design.dll
I added using System.Windows.Form.Design
[ToolboxItem(true)]
[Designer(typeof(testDesigner))]
public class test : Button
{
[Browsable(true)]
public bool MultiLine
{
get
{
return testDesigner.m;
}
set
{
testDesigner.m = value;
}
}
}
public class testDesigner : ControlDesigner
{
public static bool m;
public override SelectionRules SelectionRules
{
get
{
if (!m)
return SelectionRules.LeftSizeable | SelectionRules.RightSizeable | SelectionRules.Visible | SelectionRules.Moveable;
else
return SelectionRules.BottomSizeable | SelectionRules.TopSizeable | SelectionRules.Visible | SelectionRules.Moveable;
}
}
}
|
|
|
|
|
|
Hi anyone, good day for you...
i have a problem of using an ICMP class at SharpPcap-2.1.1, i need example showing the implementation of that class.........
thank u, i hope u will help me .............. Is that OK ???
|
|
|
|
|
Maybe this question is better off at a forum at the providers of SharpPcap?
|
|
|
|
|
Whatever SharpPcap-2.1.1 is, doesn't comes with some documentation or help file or a website or a forum? You should be searching them since they are the dedicated source to understand SharpPcap-2.1.1.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
3bood.ghzawi wrote: ICMP
No clue what that is.
3bood.ghzawi wrote: SharpPcap-2.1.1
No clue what that is.
You definitely need some help.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
This forum is only for the c# using the standard framework elements. If you are using a 3rd party API/ Framework you should try their forum. Few (if any) people here will have any experience of SharpPcap.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Hi
I have a tabcontrol in my form that this tabcontrol has 7 tabpages ;
I want to know how can i hide or unvisible or disable some tabpages of this tabcontrol?
|
|
|
|
|
I found this:
You can dynamically remove and inseret TabPages into the TabControl.TabPages collection to hide and show tabs at runtime.
TabPage tabPageSave = null;
private void button1_Click(object sender, EventArgs e)
{
this.tabPageSave = tabControl1.SelectedTab;
this.tabControl1.TabPages.Remove(this.tabPageSave);
}
private void button2_Click(object sender, EventArgs e)
{
if (this.tabPageSave != null)
{
int loc = tabControl1.SelectedIndex;
this.tabControl1.TabPages.Insert(loc, this.tabPageSave);
}
}
using this google search phrase:
c# winforms tabcontrol hide tabs
Personally, I create TabItems manually instead of adding them in the designer, and then instantiate them in a List so I can manipulate them more logically, but it's essentially the same as what's happening in the code above.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi,
I am creating query editor as in sql server. I have to use blue color for reserved words and black for others. I have inserted the color table in "RTF" of richtextbox , but the modifications in the "RTF" cause the index of richtextbox remains at zero.
Please tell me the reason of this.
Thanks,
Sonia
|
|
|
|
|
Index? What index of RichTextBox?? Your question doesn't make any sense.
|
|
|
|
|
Dave I think what is meant by index is the index of a thing in the table or perhaps the index of paragraph etc being enumerated in the RTF.
|
|
|
|
|
Cursor remains on the start of richtextbox.
|
|
|
|
|
Adding text to the RTB, or any TextBox for that matter, does not move the Caret. The property that controls the Caret position is SelectionStart. If you want to add text and move the Caret at the same time, use AppendText, or just set the SelectionStart property yourself.
|
|
|
|
|
I originally created a project in VS2008, converted it to VS2010. Last night, I decided I didn't want to continue using VS2010.
I then created a new project in VS2008, and copied all of the code from the original project into it. Everything compiles just fine, but the app didn't work like it did before the latest conversion, so I started up a debug session, and immediately found the problem.
When the app starts up, it fires off a BackgroundWorker object. The worker processes as normal, but when it jumps into the ReportProgress event handler,the first line of code is an if statement. It appears as if the if statement isn't being evaluated at all (I put an else clause in to see, and it's not being stepped into at all), and control is immediately returned to the RunWorker event handler.
What could I have done to the code that could possibly cause this?
Of course, I've tried the obvious remedy (clean/rebuild), but it didn't work.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|