|
It's actually a bad idea to mix your view and your model. When you have a clear separation, you can change the view or add additional views without having to worry about how they impact the model. If you search the web for the Model View Controller pattern, you will get a clearer understanding of how this works.
This article might help as a starter. Clickety[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I've seen may deployments of System Tray applications that slide a window into view then slide it back off the desktop. If I set a position that is on the desktop and just show it...it works. But if I set it below the taskbar location ( this.Top = Screen.PrimaryScreen.Bounds.Bottom ) and then place a Windows.Forms.Timer to a 100 millisecond loop to move the position and Show() the form again, no animation of the screen move occurs. It looks like I may have to do a Win32 call to send a 'move form' message to the form but that is beyond my knowledge right now. Has anyone done an animation like this that can give me good direction for getting this to work??
Thanks
|
|
|
|
|
|
Hello!
I'm trying to do a program that logs all the key presses of the keyboard. The application runs smooth (VisibleInTaskBar = false, Visible = false), but, by doing that, i lose the focus on my form. So, i would be interested if there is a way to "intercept" the key strokes from code. I've searched www.pinvoke.net -> and found this: GetKeyState, but, unfortunately, i wasn't able to implement this.
I've also searched the articles, still... nothing relevant to this ... GetKeyState method or ways to implement it.
Thanks a lot,
Catalin David.
|
|
|
|
|
why not create a windows service project? I think this should do the trick.
|
|
|
|
|
drc_no1 wrote: I'm trying to do a program that logs all the key presses of the keyboard.
What key presses do you want to log; only those of your application or system-wide?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
System-wide, that's the problem. Because on the application would be quite easy. But i don't know how to implement it system-wide.
Thanks a lot!
|
|
|
|
|
How can the contents of an assembly be viewed?
Thanks...
Vasini
|
|
|
|
|
Try Lutz Roeder's .NET Reflector[^].
Or, programatically, look up "Reflection" on MSDN.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
you can view the assembly contents using the ildasm which will be available in the start menu but if you want to use the contents you should do programatically using the "Reflections"
venu gopal
|
|
|
|
|
I have a XML file and I´d like to show only some collums at DataGrid.
I thought it:
dataGrid1.DataSource = ds.Tables["Aluno"].Columns["nome"];
but it doesn´t work!!
Please help-me!!!
|
|
|
|
|
How can I tell that my system is connected to the Internet??
Please advice
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
|
Thank you Rizawn
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I've seen people create StreamWriter objects a couple ways when looking around for info:
<br />
<br />
StreamWriter sw;<br />
<br />
sw = new StreamWriter(filePath);<br />
sw = File.CreateText(filePath);<br />
<br />
What's the difference between those two? Thanks.
"I took the liberty of fertilizing your caviar." -Zoidberg
|
|
|
|
|
This is the implementation of File.CreateText(string):
public static StreamWriter CreateText(string path) {
if (path == null) {
throw new ArgumentNullException("path");
}
return new StreamWriter(path, false);
}
and this is the implementation of StreamWriter(string, bool) that is uses:
public StreamWriter(string path, bool append) : this(path, append, StreamWriter.UTF8NoBOM, 0x400) { }
and this is the implementation of StreamWriter(string):
public StreamWriter(string path) : this(path, false, StreamWriter.UTF8NoBOM, 0x400) { }
So, they are two different paths to the exact same place.
---
single minded; short sighted; long gone;
|
|
|
|
|
I'm trying to send numbers over the serial port as bytes, not strings.
What I mean is if I want to send a 255, that should be 1 byte, not a 2
followed by a 5 and a 5. I'm trying to convert a borland c++ app.
This is what the c++ app does
int8B = 255;
WriteFile(serialPort,&int8B,1,&bytesWritten,NULL);
int8 = gainSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
int8 = offsetSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
int8 = exposureSlider->Position;
WriteFile(serialPort,&int8,1,&bytesWritten,NULL);
Here is what I'm doing that does not work
int x = 255;
sp.WriteLine(String.Format("{0}", x));
sp.WriteLine(String.Format("{0}", trackBar_Gain.Value));
sp.WriteLine(String.Format("{0}", trackBar_Offset.Value));
sp.WriteLine(String.Format("{0}", trackBar_Exposure.Value));
How do I send the 255? I can't do sp.WriteLine(255) since it wants a
string.
any help will be greatly appreciated.
Ringo
|
|
|
|
|
You could try to build a string that holds the right bytes (using Encodings and stuff),
but then why bother; under NET 2.0 SerialPort class has the method
public void Write (byte[] buffer, int offset, int count);
that AFAIK will do what you need.
Luc Pattyn
|
|
|
|
|
1. casting:
Foo foo=(SomeType)myFooishObject;
vs.
Foo foo=myFooishObject as Foo;
2: type comparing:
if (foo.GetType()=="Foo")
vs.
if (foo is Foo)
Under which situations would you use one or the other options for #1 and #2, and why?
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hello Marc,
Marc Clifton wrote: Foo foo=myFooishObject as Foo;
This is my solution for #1 and #2. (for #2 followed by "if (foo!=null)"
Marc Clifton wrote: and why?
"as" never throught an exception and prevents me of making double Type compares.
All the best,
Martin
|
|
|
|
|
I'd go with option B for each. In case 1 it avoids a possible exception for invalid cast. In case 2 it avoids the string comparison and the fat finger syndrome.
only two letters away from being an asset
|
|
|
|
|
B for the first if I think about it, A if my C++ autopilot is running unchecked.
B for the second, I never even thought of doing the former.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Hi Marc,
For value types:
- I typically do not use is nor as.
- I use casting to document widening, or to steer narrowing the (int) size, or to switch
between signed and unsigned.
- and of course I try not to need casting at all (by selecting the right type to begin with).
For reference types:
- I avoid GetType(), it is too expensive and somewhat clumsy
- I avoid using casting, with two typical exceptions: when getting an "object" either
by cloning something with Clone(), or when retrieving from a non-generic collection.
(I still try to write code that also could run on 1.1)
- If a ref type must be turned into a more specialized one I tend to use "as" and a null test
(unless "is" is all I need); a null test often already is present anyhow.
BTW: I like your FooishObjects !
Regards,
Luc Pattyn
|
|
|
|
|
Marc Clifton wrote: Foo foo=(SomeType)myFooishObject;
This is a regular cast, normally used to tell the compiler as what type it should treat the object, or for converting between simple data types (for example converting a byte to an int ). If the object is not possible to cast to the specified type, you get an exception.
Foo foo=myFooishObject as Foo;
This is used if you are not certain what the actual data type is. If the cast is possible, you get a reference of the given type, otherwise null. To check if the cast was successful, you just check for null.
if (foo.GetType()=="Foo")
I suppose that you mean: if (foo.GetType().Name=="Foo")
This creates a Type object, gets the type name as a string and compares to the literal string. This might be useful if you use a variable instead of a literal string, as that is the situation where you can't use is to check the type.
if (foo is Foo)
This is a more straight forward way of checking the type. It's more efficient than comparing strings.
---
single minded; short sighted; long gone;
|
|
|
|
|
Marc Clifton wrote: Foo foo=(SomeType)myFooishObject;
When I *know* that myFooishObject is convertible to SomeType.
Marc Clifton wrote: Foo foo=myFooishObject as Foo;
When I am *trying* to use myFooishObject as it was Foo, but I am not sure.
Marc Clifton wrote: if (foo.GetType()=="Foo")
When type of foo is not known, or doesn't exist at all at compile time.
Marc Clifton wrote: if (foo is Foo)
When I want to know if foo is of type Foo, but I don't need to work with it as type of Foo later.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|