|
Many thanks! nice article!
|
|
|
|
|
I am working on a project in C# that involves some rather convoluted formulas to calculate values. The resulting code has been very difficult to write and even harder to read/debug. What I want to do is overload some operators to make the math a bit quicker to write and easer to read. (Especially since I know that some of these formulas will change in the future)
For example; I would rather do something like “10^(somevariable* somethingelse)” than “math.pow(10, (somevariable* somethingelse)” since things like this are often buried deeper in a more complicated formula. [I have at least one formula involving 12 operators, 3 of them are raising part of the equation to the power of another part]
I have looked up Operator Overloading and they all refer to using it on user defined classes or UDT’s. There must be an easer way.
David Wilkes
|
|
|
|
|
|
Basic?!?! Wish I had, but far along enough now that I don't want to start over.
Thanks for the link. I will see if it helps.
David Wilkes
|
|
|
|
|
You could abuse the XOR operator ^ by wrapping your numbers in a struct with overloaded operators.
You cannot introduce new operators, but you can do something similar with C# 3.0: you can go from the prefix notation "Math.Pow(b, e)" to the infix notation "b.Pow(e)" by defining an extension method.
static class ExtensionMethods
{
public static double Pow(this double b, double e)
{
return Math.Pow(b, e);
}
}
|
|
|
|
|
I have made a windows. added toolStripContainer and added a Menustrip and toolstrip to the Toppanel and added a statusstrip to bottom panel of StripContainer.
Then I set the Dock property of toolstripContainer to Fill. and set the Anchor property of toolstrip to Top,Right.
Now my problem is Just the toolstrip.
When I resize my form the Statusbar and Menu just work fine but the toolstrip stays in its original place.
Any Ideas?
|
|
|
|
|
HI,
I like to know where i can get a template for
Adding a Control in DataGridView Cell
MS Got DataGridViewButtonColumn etc.
I'm tring to build a one of my own
(I want to Add the Image Property to The DataGridViewButtonColumn)
(i do not want to use the "dataGridView1_CellPainting" Event)
but i do not Know What methods to Override and so..
Can anyone refer me To a Good Guide
THANKS
Have Fun
Never forget it
|
|
|
|
|
Is there a way to draw a new line when something is triggered? Thanks in advance, and I hope that doesn't confuse anyone...
- "Achieving all knowledge does not mean achieving all wisdom."
- "Welcome to the end."
|
|
|
|
|
MasterSharp wrote: and I hope that doesn't confuse anyone...
Didn't confuse me. It's crystal clear that you posted a completely ambiguous and utterly useless message.
Also the answer to your question is, yes.
|
|
|
|
|
Okay, you got me; HOW, please. I've been busy (REALLY), and havn't been reading much of the book (Dummies on C#) lately, so, I know my questions are dumb, but I also just want to know.
- "Achieving all knowledge does not mean achieving all wisdom."
- "Welcome to the end."
|
|
|
|
|
MasterSharp wrote: I know my questions are dumb
We don't, or at least I don't, know your question is dumb because you didn't put any specific information in your post so we/I don't know what your question is. For instance when you said "draw a new line" O'Hanlon is sure you want to draw a graphic line, but I've been in these forums long enough to know you might mean a text new line as in carriage return / line feed, and that might be in a window control like a multi-line text box or a Grid or a ListView or even a console. so I'm not making any such assumption. If you want to specify "what event" and what you mean by "new line" I might have experience that could help.
|
|
|
|
|
True; I never thought about that. Error on me, and I meant graphics.
- "Achieving all knowledge does not mean achieving all wisdom."
- "Welcome to the end."
|
|
|
|
|
led mike wrote: For instance when you said "draw a new line" O'Hanlon is sure you want to draw a graphic line, but I've been in these forums long enough to know you might mean a text new line as in carriage return / line feed, and that might be in a window control like a multi-line text box or a Grid or a ListView or even a console. so I'm not making any such assumption
Ahhh, but I've answered enough of his questions to know that he generally asks about graphics questions.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
led mike wrote: Cheater
That's me.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Have an event and create a new line object when the event is triggered. I say a line object because you really need to create this as an object in its own right. That way, the painting of the line is handled by the line object itself.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Could I please have an example that sort of goes along with the code below?
private bool Triggered = false;<br />
<br />
private void Form1_Paint(object sender, PaintEventArgs e)<br />
{<br />
Graphics A = e.Graphics;<br />
<br />
if (Triggered1 == true)<br />
{<br />
<br />
}<br />
}
- "Achieving all knowledge does not mean achieving all wisdom."
- "Welcome to the end."
|
|
|
|
|
MasterSharp wrote: if (Triggered1 == true)
{
.... paint line
Triggered1 = false;
}
Then in the other event handler you set Triggered1 to true and Invalidate. But this is NOT a "design", it's just showing the mechanics. Anytime I see flags I become suspicious of design flaws.
|
|
|
|
|
Flags?
- "Achieving all knowledge does not mean achieving all wisdom."
- "Welcome to the end."
|
|
|
|
|
The member boolean that you set to draw your line. If you want more than one lines, have a line class, and have a collection of them like List<Line> as a member. Then, your paint event should iterate over this collection and draw the lines. That would be a design.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at
|
|
|
|
|
Hey, thanks, I got it!
- "Achieving all knowledge does not mean achieving all wisdom."
- "Welcome to the end."
|
|
|
|
|
Nice reply! I'm voting it a 5 and I never (well almost never ) do that.
Thanks for having my back on the weekend.
|
|
|
|
|
HI,
i've got an icon that i'm saving as Jpeg
(Beacuse i canot use in a butto for EXMPALE)
i can save it i a format of Jpeg
but then it gets a background Color of black
any IDEAS???
THNKS
Have Fun
Never forget it
|
|
|
|
|
|
Save it to a PNG instead. Trust me - this works, I did it today.
Deja View - the feeling that you've seen this post before.
|
|
|
|