|
I often have trouble with class names because I am very pedantic in nature. Two days before deadline I should not be worrying about this at all, but I am. I often get uncertain naming classes that perform only one task, such as one I have now that submits a document to a web service. I don’t favour the clumsy sounding “DocumentSubmitter”, and “DocumentSubmit” sounds much better, but now my class name is no longer a noun. Are there any guidelines on this?
|
|
|
|
|
|
DocumentSumissionHandler?
Isn't there a Document class? Couldn't the document submit itself, removing the need for a special class for it?
---
single minded; short sighted; long gone;
|
|
|
|
|
No, I am of the design school that doesn't permit the document knowledge of the submission process[1]. This allows diverse submission channels without impacting the document. In this I could use your name or DocumentSubmissionEngine, to stick to the noun guideline, but these seem overly verbose, and the Handler suffix may incorrectly hint at a callback method.
[1] On something of a tangent, my favourite example of this debunks the popular OO example where a Customer knows how to Save itself. A real world customer is not aware of how the bank stores his details, nor of how the library stores his details. He is only aware of his details and how to derive certain facts from them.
|
|
|
|
|
Hi All
I have an application which requires me to use the PC com port to communicate with a PIC (16f877) micro-controller. I am planning to use the PC to fill a serial EEPROM with data which constitutes a digitized waveform of 100 samples. In other words the program on the PC needs to take in a text file which holds the values for 100 samples (in hex string/decimal string?) and transmit them on command to the PIC. The pic then takes the data and fills each address in the attached serial EEPROM with a sample value. So for instance, each sample can be between 0x00 and 0xFF (0 to 255) and I need to transmit it as a single byte so the PIC can deal with it.
In the past I have used outportb quite successfully. However, I am now using C# in Visual Studio 2005 and I was wondering if anyone has any suggestions how I can do the same/equivalent? I am having some trouble converting from a string to a byte... What I mean by this is that if the string is 255, I can only convert to a byte array which gives me a byte for 2, then 5 then 5..... What I really want is the byte equivalent to 255 (ie 1111 1111)... I hope this makes sense...
Any help would be gratefully appreciated.
Jamie
|
|
|
|
|
Try the Byte.TryParse method.
"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
|
|
|
|
|
Thanks for that.... On first look it does seem to do what I want. It's amazing how the simple things can cause so much trouble..... Now I just need to re-visit some assembly language to get my graphical display working correctly......
Cheers
Jamie
|
|
|
|
|
Hi,
you need SerialPort.Write Method (Byte[], Int32, Int32) to output arbitrary bytes,
and if your source is a text file with decimal numbers, then a loop containing
byte.TryParse() is the way to go.
If your string input is using hex, then you need NumberStyles.AllowHexSpecifier in
byte.TryParse()
|
|
|
|
|
Hi,
Heres a sample XML document:
<?xml version="1.0" encoding="utf-8"?>
<Sample>
<Name>
<!--Indicates the first name-->
<FName>A</FName>
<!--Indicates the Middle name-->
<MName>M</MName>
<!--Indicates the last name-->
<LName>B</LName>
</Name>
<ID>1</ID>
</Sample>
If i get the count of childnodes of the node <name>, using the following statement: xmlNamenode.Childnodes.count, it returns 6 (i.e) it also includes the comments as a child node. Is there any way to directly get the count of number of elemets (excluding comment nodes) instead of alll the childnodes?
Thanks in advance
Regards
Madhu
|
|
|
|
|
Xml naming convention is camelCase element names.
...
Use XPath. I believe there are several sample queries on the web that will give you the exact results you are looking for.
File Not Found
|
|
|
|
|
hi i want to acces a textbox text in the class file
wat i have to to do to get the values from forms in class
thanks
with regards
Balagurunathan.B
|
|
|
|
|
Please Help!
I have created a class:
using System;
using System.Data.SqlTypes;
using System.IO;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Server;
namespace mySQL
{
public class SQLCLRIO
{
public static void WriteToFile(String content, String filename)
{
SqlPipe sqlP = SqlContext.Pipe();
try
{
File.WriteAllText(filename, content + "\n");
}
catch (Exception ex)
{
sqlP.Send("Error writing to file : " + ex.Message);
}
}
}
}
The problem is when I try to compile it into a dll I get the following.
"Microsoft.SqlServer.Server.SqlContext.Pipe' is a 'property' but is used like a 'method"
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
remove the () at the end of the Pipe. You only have those if you are calling a method.
Ben
|
|
|
|
|
Remove ()
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello everybody.
I am working with MVS2005.My project is C# project
How can I make e table with 10 raws and 10 columns and draw a moving ellipse over table.
Thanks for all.
|
|
|
|
|
Hi,
I am not sure what you mean by table. If its just a visual thing, you might consider
using a Panel, and drawing in it:
- 9 or 11 horizontal lines
- 9 or 11 vertical lines
- your ellipse (redrawn based on a Forms.Timer for animation)
|
|
|
|
|
Now I do this.
private void timer1_Tick(object sender, EventArgs e)
{
X1 += 5;
Y1 += 5;
Invalidate();
SolidBrush myBrush = new SolidBrush(Color.Green);
dataGridView1.Refresh();
Graphics grfx = dataGridView1.CreateGraphics();
grfx.FillEllipse(myBrush, X1, Y1, 15, 15);
}
But I ask is there any other way to do this
|
|
|
|
|
Hi,
some remarks:
1. you should call Dispose() on all objects you create from classes that offer a public
Dispose() method as soon as you dont need the objects any more. It applies to both
myBrush and grfx.
2. you could keep myBrush alive and reuse it over and over.
you should not do that with grfx
3. I would do the painting in a paint handler, not the timer tick (but of course the
x1/y1 update and the Invalidate() belong inside the tick handler). AS a result the
ellipse gets redrawn also every time it got damaged (e.g. when moving another window
over it without having to wait for the next timer tick (dont know what its period is).
BTW The PaintEventArgs offer you a free graphics, so you then dont need CreateGraphics
anymore, and dont have to Dispose() it.
|
|
|
|
|
Hi
Can you send me a sample code how can I do this in paint handler
X and Y is updated in timer tick at 100ms.
|
|
|
|
|
Hi,
create and wire a paint handler for your dataGridView1 or add the relevant lines to an
existing one:
private SolidBrush myBrush = new SolidBrush(Color.Green);
private void dataGridView1_Paint(object sender, PaintEventArgs e) {
Graphics g=e.Graphics;
g.FillEllipse(myBrush, X1, Y1, 15, 15);
}
That should do it.
|
|
|
|
|
I'm so sorry but something wrong.
I try this any times today.
Is there something else in timer tick except to update X and Y value and to Invalidate().Because my dataGridView is repainted only when over it move another window.
Sorry but I'm beginer.
|
|
|
|
|
Hi,
if dataGridView1 is the only thing changed by your timer, then it also is the only
thing that needs to be invalidated, so try dataGridView1.Invalidate() there.
Dont be afraid to try a couple of things, you learn more by having a good balance
between doing some experiments and asking some questions...
|
|
|
|
|
It's my last question.
The effect is the same when in timer tick I make dataGridView1.Refresh();
Byt my dataGridView1 blink every timer tick
|
|
|
|
|
Hi,
that is no surprise, each control that gets redrawn by default starts of with clearing
the background, then painting the foreground.
There is an easy way to make this invisible, it is known as "double buffering" (which
means the drawing is made first in an off-screen buffer, then that one is copied over
the relevant part of the screen). There is Control.DoubleBuffered starting .NET 2.0;
for .NET 1.x you can achieve the same effect using SetStyles on an inherited Control.
Lots of articles on CP use these techniques.
|
|
|
|
|
I have a popup form which comes up on change of combo item, I am not able to see the images on the form every time.Even the operations on the form are also not happening every time.
Can i get some ideas for this?
Thanks in advance,
Sireesha.
|
|
|
|