|
Hi,
I want to calculate the negation for the given decimal number.
How can i achieve that in C#.
The following calculation is required in C#.
I am done in converting the IP to binary.
But, how can i calculate the negation for the given Mask? Which need to be used in XOR.
Bin of 172.16.0.0 10101100.00010000.00000000.00000000
~Mask ~255.255.240.0 00000000.00000000.00001111.11111111
-----------------------------------------------------------
^ (XOR) 10101100.00010000.00001111.11111111
Result:dec 172.16.15.255
Thanks in advance.
Subrahmanyam.
|
|
|
|
|
Use the ^ operator for xor:
byte[] ip = {172,16,0,0};<br />
byte[] mask = {255,255,240,0};<br />
byte[] result = new byte[3];<br />
<br />
for (int i=0; i<4; i++) result[i] = ip[i] ^ (~mask[i]);
---
b { font-weight: normal; }
|
|
|
|
|
plz help me!!!!!!!!!!!!!!
I want to display my output form into the internet explorer.....(ex:Like acrobat reader opening in the internet explorer)
Ranjith
|
|
|
|
|
Hi.
Im trying to find a way to hookup to the Window Created, Window Destroyed and Window Activated messages from my C# windows app. NB, id like to hook up to these messages from a system-wide scope and not just my own application (for example, id like to know whenever an internet explorer window is opened or made active.
Is this possible ? Ive managed to hookup to the mouse_ll and keyboard_ll events, but no more !
Can anybody tell me if its possible ? and/or provide an example ?
THanks.~
Roy.
|
|
|
|
|
u can do this with vc there is no hooking with c# on other applications windows messages. even if you used win32 hooking API's implicitly from c#, you will hook only your own Application Messages.
marcoryos
|
|
|
|
|
When I prepare a C# application, is it supposed to work only on a stand-alone machine or it automatically works on a network (intranet) also?
If it automatically works (as a default) on the network also, then is there any way to control the number of computers on the network on which it will work? For example, if I want to allow its operation on only one machine on the network, can I do so, and if yes, then how?
|
|
|
|
|
I want connect to MYSQL database by C# and I want to use storeProcedure to access database but I can't do that. Please help me
|
|
|
|
|
Well to connect to mysql you either need an odbc driver which can be found at mysql's website or microsofts website. afaik mysql doesnt support stored procedures yet - it is only due in version 5 and I think they are far away from that.
|
|
|
|
|
well I dont' know how do you call them .. but certainly MySql does support stored procedures form v.4.1 onwards!
|
|
|
|
|
I call them stored procedures and I beg to differ with you on that statement.
http://dev.mysql.com/doc/mysql/en/roadmap.html[^]
The current production release is 4.1. MySQL 5.0 is available in alpha status. See the table of features and which version they belong to.
|
|
|
|
|
What do you mean when you say that you can't do that? What is it that you need?
---
b { font-weight: normal; }
|
|
|
|
|
I'm trying to resize a gif-image that is transparent. But it looses it's transparesy.
Does someone know how to do this?
My code:
public Bitmap _bitmap = null;
private void getGraphicsFromImageNotStretched(MemoryStream ms, int hight, int width)
{
Image image = Image.FromStream(ms);
double orgHight = (double)image.Height;
double orgWidth = (double)image.Width;
if((orgHight * hight) > (orgWidth * width))
{
double ratio = (orgWidth * width) / (orgHight * hight);
_bitmap = new Bitmap(image, (int)((double)width * ratio), hight);
}
else
{
double ratio = (orgHight * hight) / (orgWidth * width);
_bitmap = new Bitmap(image, width, (int)((double)hight * ratio));
}
image.Dispose();
}
Thanks
Thomas
|
|
|
|
|
I suppose it's because it is a GIF image it has a palette. When you resize it, it has to be converted to a true color image (or the resizing would look awful), and the transparency is lost.
If you convert it to true color before you resize it, it should be possible to keep the transparency.
If you use a true color PNG image with aplha channel transparency instead, it will work, and it will look much better. I use this for water marks on images.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for your replay.
I've tried different things out, but I don't seem to get it right.
The closest I've come is getteing a light-blue background (using PNG).
You don't have a code-snipp that could get me in the right direction.
Thanks
Thomas
|
|
|
|
|
As I said, I have used a transparent PNG, and I had no problem at all with the transparency.
How do you use the resized image? Are you saving it as a file? If so, what file format are you using?
---
b { font-weight: normal; }
|
|
|
|
|
I'm creating small icons of images in an ASP page, so I'm writing the images to the output stream.
First I'm resizing the image, witch data I get from a memory stream (this data is an transparent image):
public Bitmap _bitmap = null;
private void getGraphicsFromImageNotStretched(MemoryStream ms, int hight, int width)
{
Image image = Image.FromStream(ms, true);
double orgHight = (double)image.Height;
double orgWidth = (double)image.Width;
if((orgHight * hight) > (orgWidth * width))
{
double ratio = (orgWidth * width) / (orgHight * hight);
_bitmap = new Bitmap(image, (int)((double)width * ratio), hight);
_bitmap.Palette = image.Palette;
_bitmap.MakeTransparent();
}
else
{
double ratio = (orgHight * hight) / (orgWidth * width);
_bitmap = new Bitmap(image, width, (int)((double)hight * ratio));
_bitmap.Palette = image.Palette;
_bitmap.MakeTransparent();
}
image.Dispose();
}
Then I write the data to the output stream:
public static byte[] GenerateImageBytes(Bitmap theBitmap)
{
byte[] bytes = null;
// save the image to the output stream
System.IO.MemoryStream ms = new System.IO.MemoryStream();
theBitmap.Save(ms, ImageFormat.Png);
bytes = ms.ToArray();
ms.Close();
return bytes;
}
This result in an image that is not treansparent
Thanks
Thomas
|
|
|
|
|
If you call the MakeTransparent method without specifying a color, it will set the default transparent color as transparent. Do you know what color this is, and that it's the correct color to set as transparent?
---
b { font-weight: normal; }
|
|
|
|
|
No I don't know, but won't it be different from image to image?
Theres mabye a way to get it from the Pallete?
Thanks
Thomas
|
|
|
|
|
Hello again! I'm making a web app which generates data from a database and posts it in a datagrid. Now my problem is how could i post data from 2 separate tables in 1 datagrid. Here are the facts:
table1 composes of 14 columns and numerous rows depending on the result (no problem whatsoever)
table2 composes of 4 columns and with only 1 row (clueless)
Now i already have table1 posted on the grid, I was wondering how i could insert table2 on top of table1 creating a few spaces between them in the process. Thanx for all your replies!!
I'm new to programing so the syntax to implement these functions are still quite alien to me. I'd appreciate all your replies thanx in advance!
|
|
|
|
|
|
|
Hi - really if table 1 and table 2 have completely different data, then you should put two datagrids in there. You can't do what you want, because the grid needs consistent column names to display, and at a minimum, the same number of columns.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
oh...coz i was thinking of merging the datas 2gether into 1 main datatable then creating a buffer-like columns and rows as spaces. i mean is that possible? here's the code i tried to use:
public DataTable fMain(string strMonth,string strYear)
{
DataTable dt_emper = new DataTable();
dt_emper = objDS.fGet_employer();
DataTable dt_emp = new DataTable();
dt_emp = objDS.fGet_emp_deduct(strMonth,strYear);
//DataTable dtMain = new DataTable();
DataRow drow;
DataTable dtMain = new DataTable("dtbl");
DataColumn dcolMain = new DataColumn();
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
drow=dtMain.NewRow();
drow[0]=dt_emper.Rows[0][0].ToString();
drow[1]=dt_emper.Rows[0][1].ToString();
drow[2]=dt_emper.Rows[0][2].ToString();
drow[3]="";
drow[4]="";
drow[6]="";
drow[7]="";
drow[8]="";
drow[9]="";
drow[10]="";
drow[11]="";
drow[12]="";
drow[13]="";
drow[14]="";
dtMain.Rows.Add(drow);
for (int ctr=0;ctr<dt_emp.rows.count;ctr++)
{=""
="" drow[0]="dt_emper.Rows[ctr][0];
" drow[1]="dt_emper.Rows[ctr][1];
" drow[2]="dt_emper.Rows[ctr][2];
" drow[3]="dt_emper.Rows[ctr][3];
" drow[4]="dt_emper.Rows[ctr][4];
" drow[5]="dt_emper.Rows[ctr][5];
" drow[6]="dt_emper.Rows[ctr][6];
" drow[7]="dt_emper.Rows[ctr][7];
" drow[8]="dt_emper.Rows[ctr][8];
" drow[9]="dt_emper.Rows[ctr][9];
" drow[10]="dt_emper.Rows[ctr][10];
" drow[11]="dt_emper.Rows[ctr][11];
" drow[12]="dt_emper.Rows[ctr][12];
" drow[13]="dt_emper.Rows[ctr][13];
" drow[14]="dt_emper.Rows[ctr][14];
" drow[15]="dt_emper.Rows[ctr][15];
" dtmain.rows.add(drow);
="" }
="" return="" dtmain;
="" }
i've="" used="" the="" debugging="" technique="" and="" it="" stops="" before="" <code="">dtMain.Rows.Add(drow);. Is it sill possible or do I really need to have 2 grids for the 2 tables?
thanx again!
|
|
|
|
|
What you're thinking of doing is a hack. Do the two tables have data that relate to one another ? If not, then there is no reason to show them in one grid. If so, write a stored procedure that returns the data from both tables in a single dataset. That's what the database is for.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
no they don't have a data that can relate with the other. Darn and i thought i could get away with that. hehe oh well. thanx again Chris! I'l do the 2 grid process
thanx
|
|
|
|