|
Hi
Someone knows where I could find documentation about how install remote Window Service, like in Dameware (remote administrator) where you can install the dameware service when you are Administrator of the domain, It'll be helpful install a service from my pc to the others, cuz many pcs are in other citys.
Any info will be greatful
Thanks
----
hxxbin
|
|
|
|
|
I have a DataTable (data) that contains 3 rows :
value1 value2
textA 0
textB 1
textC 1
I am placing this DataTable into a DataView and then filtering to get the rows where 'value2' does not equal zero :
DataView dvFiltered = new DataView(this.data, "totalUsed <> 0", "value2", DataViewRowState.CurrentRows);
int filteredCount = dvFiltered.Count;
string summary = string.Format("{0} Item(s)", filteredCount.ToString());
For some reason the count, sometimes returns the correct value but most of the time it doesnt, and I cant see a reason why. I have be stepping through the code to make sure the datatable contains the values it should and all that seems fine, as an example the following is taken from my VS watch list :
this.data.Rows[0]["value2"] - "0"
this.data.Rows[1]["value2"] - "1"
this.data.Rows[2]["value2"] - "2"
dvFiltered.Count - 1
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
In the resources file of Web Matrix, I found that the program is using one long bitmap that contains all the icons for the menu, toolbar, etc.
I would like to do this for my application, but I am not sure how to go about this.
How is the bitmap split into individual images?
Are these individual images added to an imagelist somehow? (if so, how?)
What is the best way for me to duplicate the strategy Web Matrix uses to grab an embedded bitmap (representing many icons) to use for my menu and toolbar?
Thanks in Advance!
|
|
|
|
|
If you want to create an ImageList , you can use ImageList.Images.AddStrip . To do this manually, it really isn't that hard. In most cases, squares are used. If the image is 32 pixels high, bitmaps consisting of 32 pixels wide are copied to individual Bitmap instances. You can use Graphics.DrawImage(Image, Rectangle, Rectangle, GraphicsUnit) or a similar method to assist with this process. Once Rectangle specifies the source bounds (in which case you increment the X coordinate by the height of the strip, if dealing with a horizontal strip) and the other specifies the destination bounds (in which case you use Image.GetBounds or the assumed Size and Point(0, 0) ). Use the same GraphicsUnit , which you'll most likely want to use GraphicsUnit.Pixel .
In most cases, ImageList.Images.AddStrip will do nicely.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am creating a bitmap drawing a pie chart and saving it as a gif in my windows app.
I am then linking and empbedding that gif (in the same process) into another app that generates a pdf on the fly.
However, when I close my windows app, the process does not end and i have to do it manually. Here's the code where i'm creating the gif.
const int width = 500, height = 200;
Bitmap objBitmap = new Bitmap(width, height);
Graphics objGraphics = Graphics.FromImage(objBitmap);
objGraphics = Graphics.FromImage(objBitmap);
objGraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
DrawSpendingPieChart(ref objGraphics, alName, alNumber);
string path = storageFolder + "\\" + clientId + "chart1.gif";
try
{
objBitmap.Save(path, ImageFormat.Gif);
}
catch(Exception ioe)
{
throw ioe;
}
finally
{
// clean up...
objBitmap = null;
objGraphics = null;
}
r.cbChart1 = path;
Without the link to this gif, it works fine. The pdf generator links and embeds other gifs outside my windows app fine.
I have isolated the problem to the gif i'm creating. It seemingly remains in memory(even though i set it to null once saved) and is linked to my windows app process: and if used, it keeps my app open.
Does it have to do with Graphics.FromImage() creating a memory stream and retaining it even after I have set objBitmap to null?
Any help?
Dave
|
|
|
|
|
When a Type implements IDisposable like the Graphics and Bitmap classes, you must call Dispose before nullifying the instance variable (which really isn't necessary):
Bitmap bmp = null;
Graphics g = null;
try
{
bmp = new Bitmap(32, 32);
g = Graphics.FromImage(bmp);
}
finally
{
if (g != null) g.Dispose();
if (bmp != null) bmp.Dispose();
} In C#, you can use the using statement to do the same thing as above:
using (Bitmap bmp = new Bitmap(32, 32))
{
using (Graphics g = Graphics.FromImage(bmp))
{
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the reply.
I rewrote the code and called .Dispose() on both objects. But I continue to get the same problem. The application continues to run until I manually close it. If I remove the reference to the created .gif, it closes fine.
|
|
|
|
|
Heath,
I've isolated the problem and it has to do with the pdf generator. THANKS for your help!!
Dave
|
|
|
|
|
Hi,
Im doing a Firewall in C#,on the Process
"byte[] buffer = new byte[20000]; // Start with 20.000 bytes left for information about tcp table
int pdwSize = 20000;
int BufferSize = 100000;
IntPtr lpTable = Marshal.AllocHGlobal(BufferSize);
IntPtr current = lpTable;
int res = IPHlpAPI32Wrapper.GetTcpTable(buffer, out pdwSize, true);
if (res != NO_ERROR)
{
buffer = new byte[pdwSize];
res = IPHlpAPI32Wrapper.GetTcpTable(buffer, out pdwSize, true);
if (res != 0)
return; // Error. You should handle it
}
TcpConnexion = new IpHlpApidotnet.MIB_TCPTABLE();
int nOffset = 0;
// number of entry in the
TcpConnexion.dwNumEntries = Convert.ToInt32(buffer[nOffset]);
nOffset+=4;
TcpConnexion.table = new MIB_TCPROW[TcpConnexion.dwNumEntries];"
Iam passing the MIB_TCPROW object to SetTcpEntry...
But iam getting the Following Error
"Can not marshal field Local of type IpHlpApidotnet.MIB_TCPROW: The type definition of this field has no layout information."
Can u anybody help me out???
Thanx
venkat
|
|
|
|
|
definition of MIB_TCPROW????
|
|
|
|
|
public struct MIB_TCPTABLE
{
public int dwNumEntries;
public MIB_TCPROW[] table;
}
public struct MIB_TCPROW
{
public string StrgState;
public int iState;
public IPEndPoint Local;
public IPEndPoint Remote;
}
|
|
|
|
|
hi..
im trying to populate my checklistbox with a column that im getting from a database.
well i get the column and store in a datatable my question how do i populate whats in the datatable into the checklistbox...pls help...
|
|
|
|
|
Set the DataSource propoerty of CheckListBox property to your datatable and its DisplayMember , name of your column.
And don't cry , there is always a solution.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
well setting the property is another problem...im using Visual Studio .Net 2003 and it looks like they haved scraped these properties off checklisbox..i wonder why...i tought the more adavanced things got the more easier it got for us...sighhhhh...
... i'll stop once i get this prblem fixed...hehehe
|
|
|
|
|
ASGill wrote:
it looks like they haved scraped these properties off checklisbox
Although I donn't have VS.NET 2003 but how is this possible? I can understand it.
Anyway, can't you set it programiically? Like this:
checklistbox1.DataSource = mytable;
checklistbox1.DisplayMember = columnname;
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Hi Mazy...( yeah i know its kinda shocking.. )
anyways... i got the adding part working, its working alrite, but with a flaw...and i have got no clue of what so ever abt why its happennin
<br />
private void frmPrescription_Load(object sender, System.EventArgs e)<br />
{<br />
try<br />
{<br />
oleDbConnection1.Open();<br />
<br />
oleDbDataAdapter1.SelectCommand.CommandText = "SELECT [Med Name] FROM Pharmacy";<br />
<br />
oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();<br />
<br />
oleDbDataAdapter1.Fill(dataSet1);<br />
<br />
for(int i = 0; i < dataSet1.Tables[0].Rows.Count; i++)<br />
{<br />
this.checkedListBoxName.Items.Add(dataSet1.Tables[0].Rows[i][4], false); <br />
}<br />
}<br />
catch (Exception LoadError)<br />
{<br />
MessageBox.Show(LoadError.ToString());<br />
}<br />
finally<br />
{<br />
oleDbConnection1.Close();<br />
oleDbConnection1.Dispose();<br />
}<br />
well when it adds the item, it adds it twice...i.e i have the value "Aspirin" in the column in the table...its s'pose to display it only once but i get
1. Aspirin //numbers represent checkboxes
2. Aspirin
3. Piriton
4. Piriton
and so on.....all of the values are added twice..whats wrong...
|
|
|
|
|
Hi
I 'm wondering why you :
oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();
oleDbDataAdapter1.Fill(dataSet1);
you olny need to oleDbDataAdapter1.Fill(dataSet1);
why did you write
oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();
first .?
bye.
|
|
|
|
|
As Masud said remove oleDbDataAdapter1.SelectCommand.ExecuteNonQuery();
line then you call fill method set the DataSource and DisplayMemerb ofCheckListBox as I told you.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
aight....got it fixed...
the oleDbDataAdapter.SelectCommand.ExecuteNonQuery(); was a mistake...the code i posted was an earlier version of it...sorry...
thx for the help guys
|
|
|
|
|
I'm reading a YCbCr image byte by byte from the parallel port and all I want
to do is to display the image on the screen using C#. I wonder how I can do
it. Ways that I can think of include:
1. Convert to RGB and construct a Bitmap object (Is there any simple way to
do the conversion?)
2. Construct an Image object with YCbCr pixel format (I should that Image
has a Flags property which includes YCbCr color space. But how can I make
use of this?)
A thousand thanks.
Yawen
|
|
|
|
|
I'd like to use my PC's serial port to communicate with my IC which uses the I2C standard. Is there any class or functions that I can use to do that?
Thanks very much.
Yawen
|
|
|
|
|
You should search CodeProject for a number of articles describing serial communications in .NET. Since the .NET base class library does not provide this functionality, there are many libraries available to help you.
If you download the VB.NET Resource Kit from http://msdn.microsoft.com/vbasic/vbrkit[^], you can use Sax.NET. Don't worry that it's in the VB.NET RK. In the .NET Framework, all source compiles to IL that's placed in modules and into assemblies. Any .NET language can use an assembly written in any other .NET language because they all compile to IL.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Suppose I have Class:
1) class Shape{}
2) class Square : Shape {}
3) class Circle : Shape {}
and Method:
1) void f(Shape s){}
2) void f(Square s){}
3) void f(Circle c){}
Now, I declare 3 variables:
1) Shape a1 = new Shape();
2) Square a2 = new Square();
3) Circle a3 = new Circle();
If I call f(a1), it will go to method 1.
If I call f(a2), it will go to method 2.
If I call f(a3), it will go to method 3.
Right?
But If I call f((Shape)a2), it will go to method 1.
Is there anyway to make if I call f((Shape)a2), and it will go to method 2 directly?
|
|
|
|
|
I'm not sure what you want to do, but here's my two cents:
If your parameter is cast to Shape, and Square is derived from Shape, first the runtime / compiler will look in the class Square if it can find a method with the f(Shape s) signature.
Since it can only find the f(Square s) method, it'll go up on class (which is Shape) and there it WILL find the wanted menthod.
If you want class Square to have it's own f(Shape s) method, you'll have to overload the original one, i.e. recreate the f(Shape s) method in the Square class...
|
|
|
|
|
Actually the method f is not a member method of Shape, Square, Circle.
It is static method of another class, which can takes "Shape" or "Square" or "Circle" as parameter.
Actually, what I am doing now is:
public static f(Shape s){
if (s is Square){
f((Square)s);
}
else if (s is Circle){
f((Circle)s);
}
}
public static f(Square s){
MessageBox.Show("It is a Square"):
}
public static f(Circle s){
MessageBox.Show("It is a Circle"):
}
It works, but the problem is when there is a lot of derived class, the f(Shape c) method will be very bulky.
|
|
|
|