|
Good luck with that. The only thing that has a chance of that kind of performance is DirectX and a good video card. Treat the graph like an object in a video game and you might get what you want.
|
|
|
|
|
I have also tried using directx. About 2-3 millions points is OK, after that you cannot see the lines anymore, you can only see the background. The lines are gone. I think directx has also a problem with that.
|
|
|
|
|
Everything is going to have a problem like that. You're graphing MANY more points than there are pixels on the screen. All you're EVER going to get is a big indecipherable blob on the screen.
|
|
|
|
|
Could you tell me how I can drag a panel on the form?
Thanks in advance.
|
|
|
|
|
Yes I can.
...
Use the mouse drag event and use it to set the location of the panel. If there is not a mouse drag use mouse down combined with mouse move.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Would you mind explaining the code?
|
|
|
|
|
I have a gridview in which I need to combine two columns in one. One field is an true/false, this column I would like to add the string "Office" if it is true. The other field is a string. The problem I am having is that the field in the grid displays true/false and not the string "Office". I am very new to C# in regards that I am using SQL Server to retieve this data. I am sure that the select statment is correct. But the source on the design page is where my problem is...I think. Can you help?
|
|
|
|
|
I'm assuming your data source for this grid is a DataTable. Perhaps adding a DataColumn with an expression would help.
More Info[^]
|
|
|
|
|
Evening all (depending where you are of course !)
This is going to be tricky to explain but i'll give it my best.
Please bear in mind i am a novice to C#.
I'm going to run a loop to create a 'List' of 10 animals.
I'm using polymorhism to then cast each animal the type i need (cat, dog, etc).
newAnimals[0] = new Cat();
newAnimals[1] = new Cat();
I'm confused as to how i can then give each object a reference name so that i can reference individual object's and invoke methods on them ?
For instance - say i had 5 animas in the list and the first 2 were cats.
I need to be able to say -
cat1.eat();
cat2.play();
Is there a way i can do this ?
Thanks in advance
(loving the forum by the way !!)
|
|
|
|
|
No you can't (I don't think so), except you declare 5 variables like:
cat1 = newAnimals[0];
cat2 = newAnimals[1];
...
Then you can use these variables. However newAnimal[0].eat should work for you...
Life is 5: 3 me, 1 you.
Trying to find the missing part is the meaning of Life.
And sadness is when you find that part!
|
|
|
|
|
If you need to tell which animals are of what type to do something specific with them, then your inheritance tree is probably broken. You can add methods like GetAllCats, tho. Then you can do this:
foreach(Animal animal in newAnimals)
{
Cat c = animal as Cat;
if (c != null)
{
// Add c to a list to return, or do something with c
}
}
The as keyword attempts to cast an object as a derived object, and returns null if it fails.
I would also use a list instead of an array, so you can add as many animals as you like, unless your class requires you to use arrays at this point.
If you just mean accessing the objects, then newAnimals[0], newAnimals[1] is how you reference them.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks Cristian,
Your reply was v-helpful.
I've since tried
newcat1 = zooAnimals[0] as Cat;
but this doesn't seem to work either.
Can i not cast the object in this way ?
|
|
|
|
|
What does 'does not work' mean ? If zooAnimals is an array of Animals, and Cat is a class derived from Animal, then so long as newcat1 is a Cat and zooAnumals[0] is a Cat, it should work fine.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Cristian,
my appologies for not being very specific - still getting used to this 'posting' bit !
Ok - my code goes -
Animal newcat1;
zooAnimals = new List<Animal>();
for (i = 0; i < 2; i++)
{
Animal animal = new Animal();
zooAnimals.Add(animal);
}
newcat1 = zooAnimals[0] as Cat;
newcat2 = zooAnimals[1] as Cat;
the program then throws a 'Null Reference - Object reference not set to an instance of an object.'
When i hover the pointer, the 'newcat1' is still set to null
|
|
|
|
|
Well, you're adding Animal s to the list, not Cat s.
So what you need to do is:
Cat newcat1;
zooAnimals = new List<animal>();
for (i = 0; i < 2; i++)
{
Animal animal = new Cat();
zooAnimals.Add(animal);
}
newcat1 = zooAnimals[0] as Cat;
newcat2 = zooAnimals[1] as Cat;
</animal>
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi there,
I was looking over your post and I think this is a sample of how to accomplish what you are looking for. Look this over:
using System;
using System.Collections.Generic;
public abstract class ZooAnimal
{
public abstract string Speak();
}
public class Cat : ZooAnimal
{
public override string Speak()
{
return "Meow";
}
}
public class Lion : Cat
{
public override string Speak()
{
return "Rowr!";
}
}
public class Program
{
public static void Main(params string[] args)
{
List<ZooAnimal> zooAnimals = new List<ZooAnimal>();
for (int i = 0; i < 2; i++)
zooAnimals.Add(new Cat());
for (int i = 0; i < 3; i++)
zooAnimals.Add(new Lion());
for (int i = 0; i < zooAnimals.Count; i++)
{
Lion lion = zooAnimals[i] as Lion;
if (lion != null)
Console.WriteLine("The lion says: " + lion.Speak());
else
{
Cat cat = zooAnimals[i] as Cat;
Console.WriteLine("The cat says: " + cat.Speak());
}
}
Console.Read();
}
}
See this is all just a matter of inheritance and making sure you instantiate your types correctly. In your code example you are adding two animals to the collection but trying to get out two cats. Remember - all cats are animals but not all animals are cats. To get the code you posted to work correctly, you would need to add cats to the zooAnimals collection instead of just animals. This works just fine in C# by the way - an object declared as a base type can always hold an instance of one of its derived types. To illustrate I created a three tiered inheritance example. Notice that in the above example you have ZooAnimals, Cats, and Lions. ZooAnimals is an abstract type, it exists only to serve as a base class for anything that I might consider a zoo animal. Then you have the Cat class. This is also a pretty general class - there are many types of cats, so I derived another class from Cat called Lion. Notice the hierarchy - All Lions are Cats but not all Cats are Lions (illustrated in the final for loop in the static method Main). All Cats are ZooAnimals (as far as this program is concerned at least) all ZooAnimals are not necessarily Cats. It must also follow then that since all Lions are Cats, and all Cats are ZooAnimals, then all Lions are ZooAnimals as well. Hope that helps!
"We are men of action; lies do not become us."
modified on Friday, November 21, 2008 11:39 PM
|
|
|
|
|
I think perhaps you should do some reading on OO. As others have said, you are trying to turn an animal into a cat. It's not a cat, you didn't ask it to be.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hey again.
I know i'm a pain for asking for help twice within a short period of time, but if I can get this working then it should be all the help I need.
I basically want to constrict the location or where the controls are drawn on a form. Ie, I want controls that are added to a form to only be drawn within a certain rectangle, and if they are placed outside of or hanging out of that rectangle, that section of the controls to not be drawn at all.
All the functions and properties built into the Form that reference to ClientSize are based solely for the entire form, but I want to be able to define a custom region for controls within the form to be drawn.
Here's an image example of what I mean[^]
I'm wondering whether I could control the true region from within the OnPaint function, or by using commands in WndProc to define the area to draw controls within.
If anyone can help, thanks a ton!
|
|
|
|
|
Could you not just put all your controls into a panel then arrange the panel so it defines the client area you need? The alternative is to use WM_NCCALCSIZE win32 message to define the client rectangle offset relative to the non-client bounds, but this is more complicated! (see NCCALCSIZE & NCCALCSIZE_PARAMS in msdn/google for more info).
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Yeh I just realised that there was an NCCALCSIZE windows message so i'm implementing the native methods now, hopefully it should work
Thanks
|
|
|
|
|
I am planning to do the following:
I will create some buttons or pictureboxes in a form, each of them represents one moudlue or function, then they will be connected to
do more functions, somehow like CAD.
Now I want to know what kind of controls (button, picture box and others) are better to be used in considering the displaying efficiency, especially when all these controls are refreshed.
thanks.
|
|
|
|
|
If you are looking for complete efficiency you should use DirectX to draw your own controls instead of GDI+.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Hey!
I have a form that uses some pretty heft painting, it draws a custom caption, close, minimize, maximize buttons and border.
It works really perfectly (lagless) when resizing the form, but when I move the form offscreen slightly and move it back in, it draws the bottom border (or the border that was moved off-screen) repeatedly onto the form's body.
My solution to this was to apply Invalidate() into the Form.Move event, but as you can imagine it lags the form heavily when you move the form now. It doesn't lag it to the point that it's slow as such, but it does apply quite a bit of memory (sometimes up to 11k memory whereas on resize it's only around 5k).
Is there any way that I could possibly prevent the form from drawing the borders repeatedly over the body (which looks ugly) without having to completely invalidate the form everytime the form is moved?
Thanks.
|
|
|
|
|
Invalidate region and create a custom region that is bigger than the form and slightly smaller.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Hm? I don't quite understand what you mean, could you elaborate a bit please?
Thanks
|
|
|
|