|
no offence taken. i learn by answering as well
you made some good points
|
|
|
|
|
i'm trying to draw a rectangle with in a panel and move it with in the panel,though i draw it i can't move it, i found the method ControlPaint.DrawReversibleFrame
but it draws in the screen not in the pannel
any idea hw to handle this
thanx in advance
|
|
|
|
|
Firstly, you need to handle the Panel Paint event. That way, each time the panel needs to draw, you will get told to do so. In the handler:
private Rectangle myRect = new Rectangle(0, 0, 40, 30);
private void myPanel_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawRectangle(Pens.Azure, myRect);
}
If you then change the position or size of myRect, just call myPanel.Invalidate() to force the panel to redraw. There is more complex stuff you may want, but that'll get you started on the basics.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
Well, i'm sure decorator pattern works in c#, but trying to post this from jave to c#,
no luck so far.
http://java-x.blogspot.com/2007/01/implementing-decorator-pattern-in-java.html
basically this line always gives me trouble, "Decorator decorator = new ConcreteDecorator(comp);"
------------------------------------------------------
import decorator.*;
public class Client {
public static void main(String[] args) {
IComponent comp = new Component();
Decorator decorator = new ConcreteDecorator(comp);
decorator.doStuff();
}
-------------------------------------------------------
BTW, i'm using abstract classes only, no interfaces.
Anyone knows a working example in c# ?
wow
|
|
|
|
|
5883 wrote: Anyone knows a working example in c# ?
Try here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Yes[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
The decorator pattern is used extensively in the Stream abstract class
and all it's sub classes. Read Here[^]
|
|
|
|
|
I want to know how can I prevent the form resizing when the user double clicks on the titlebar
|
|
|
|
|
You can't prevent it, but you can handle the event and cancel it or resize back the original.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
|
No that is not what I suggested! It is ludicrous to override WndProc when there are perfectly good and valid events for this.
ResizeBegin[^]
Resize[^]
SizeChanged[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
As I said, it's one way - not the way - to implement your suggestion.
In my haste, I was looking for events prefixed with "On ". Given that the events you mentioned exist, subscribing to them would undoubtedly be the way to go.
/ravi
|
|
|
|
|
jrahma wrote: How?
HANDLE THE EVENT !!!
If you still don't understand then give up.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have a combobox1 and I want to move to another combobox2 (in a different panel).
I tried to put the KeyCode Tab in the KeyDown but it didn't work and when I tried the same in KeyUp it will move immediately to combobox2 when combobox1 gets focused
What can I do if I just need a simple (move to combobox2) when user uses Tab on combobox1
|
|
|
|
|
I don't recall the details, the solution must be in one of the properties TabStop, TabIndex; and/or one of the methods IsInputChar(), IsInputKey().
|
|
|
|
|
Luc is right - it is the tab order you want.
Stop trying to handle the Tab key yourself - Windows handles it quite well for you. Assuming that the two comboboxes are on the same form: (If they aren't then you definitely want to change the whole design because that would be horrible and confusing for the user)
Make sure each combobox has it's TabStop property set to true - this is the default.
Since they are in different panels, set the TabOrder for each Panel so they are consecutive. I.e. panel with combobox 1 has taborder 0, panel with combobox 2 has taborder 1. Make sure that no other controls has those Tab Order values. (There is a toolbar button for view / set of taborder on the Layout toolbar - normally at the far right end.)
That's it. Windows now takes care of it.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I have a method that takes a SendOrPostCallback delegate as a parameter.
public void Post(SendOrPostCallback sendOrPostCallback)
{
}
I want to overload this method and instead take a MethodInvoker delegate.
public void Post(MethodInvoker methodInvoker)
{
}
The problem is this second method needs to convert the MethodInvoker to a SendOrPostCallback using null for the state parameter so it can call the original method.
I can't figure out how to do this
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Do you mean something like this?
void Post(MethodInvoker methodInvoker)
{
Post(new SendOrPostCallback((object useless) => { methodInvoker(); }));
}
Ok it isn't really a conversion.. but afaik that isn't possible anyway
edit: nevermind, if this was what you meant you wouldn't have asked..
|
|
|
|
|
harold aptroot wrote: if this was what you meant you wouldn't have asked
Well it does what I asked so I guess it was! Not being a Linqy kind of guy I have nor really used lambda expressions so I'm off to work out how/why this works and to see if can be done without the lambda
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Well, you could easily do it with a normal anonymous method:
void Post(MethodInvoker methodInvoker)
{
Post(delegate (object useless) { methodInvoker(); });
}
Or you could go for Pain and do it the manual way:
class HolderThingy
{
public MethodInvoker methodInvoker;
public void Invoke(object useless)
{
methodInvoker();
}
}
void Post(MethodInvoker methodInvoker)
{
HolderThingy holder = new HolderThingy();
holder.methodInvoker = methodInvoker;
Post(new SendOrPostCallback(holder.Invoke));
}
|
|
|
|
|
Cool
Is there anyway to do it using the null keyword instead of
object useless ?
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Not that I know of.. it has to match the method signature of SendOrPostCallback , so you need an argument of type object .
Why do you want to use null ?
|
|
|
|
|
no particular reason, useless is null anyway so it's no overhead.
Many thanks, credits are in the code pointing here
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|