|
thanks..
but i want select the border and then resize that image
|
|
|
|
|
use a panel(base panel for the size you feel max for your streching)
in it put three panels and two splitter controls as following
p s p
s
p
dock them accordingly and you have it
p=> panel
s=> splitter
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
Hi,
I tried encrypting and decrypting a string using the following Java code and key. And was successful.
Then, I used the following C# to encrypt and decrypt a string using the following C# code and key. And was successful.
But when i tried to encrypted using java and decrypted using C#, but it was not successful.
Can someone please help? THanks in advanced.
[JAVA code]
private static String algorithm = "DESede";
private static Key key = null;
private static Cipher cipher = null;
private static void setUp() throws Exception {
key = new SecretKeySpec("123456789012345678901234".getBytes(), algorithm);
cipher = Cipher.getInstance(algorithm);
}
public static void main(String[] args) throws Exception {
setUp();
byte[] encryptionBytes = null;
encryptionBytes = encrypt("This is a testing");
System.out.println("Recovered: " + decrypt(encryptionBytes));
}
private static byte[] encrypt(String input) throws InvalidKeyException,
BadPaddingException, IllegalBlockSizeException {
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] inputBytes = input.getBytes();
return cipher.doFinal(inputBytes);
}
private static String decrypt(byte[] encryptionBytes) throws
InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] recoveredBytes = cipher.doFinal(encryptionBytes);
String recovered = new String(recoveredBytes);
return recovered;
}
[C# Code]
static void Main()
{
try
{
TripleDESCryptoServiceProvider tDESalg = new
TripleDESCryptoServiceProvider();
// Create a string to encrypt.
string sData = "This is a testing";
// Encrypt the string to an in-memory buffer.
byte[] key = Encoding.UTF8.GetBytes("123456789012345678901234");
byte[] Data = EncryptTextToMemory(sData, key, key);
string Final = DecryptTextFromMemory(Data, key, key);
// Display the decrypted string to the console.
Console.WriteLine(Final);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
public static byte[] EncryptTextToMemory(string Data, byte[] Key, byte[] IV)
{
try
{
// Create a MemoryStream.
MemoryStream mStream = new MemoryStream();
// Create a CryptoStream using the MemoryStream
// and the passed key and initialization vector (IV).
CryptoStream cStream = new CryptoStream(mStream,
new TripleDESCryptoServiceProvider().CreateEncryptor(Key, IV),
CryptoStreamMode.Write);
// Convert the passed string to a byte array.
byte[] toEncrypt = Encoding.UTF8.GetBytes(Data);
// Write the byte array to the crypto stream and flush it.
cStream.Write(toEncrypt, 0, toEncrypt.Length);
cStream.FlushFinalBlock();
// Get an array of bytes from the
// MemoryStream that holds the
// encrypted data.
byte[] ret = mStream.ToArray();
// Close the streams.
cStream.Close();
mStream.Close();
// Return the encrypted buffer.
return ret;
}
catch (CryptographicException e)
{
Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
return null;
}
}
public static string DecryptTextFromMemory(byte[] Data, byte[] Key, byte[] IV)
{
try
{
// Create a new MemoryStream using the passed
// array of encrypted data.
MemoryStream msDecrypt = new MemoryStream(Data);
// Create a CryptoStream using the MemoryStream
// and the passed key and initialization vector (IV).
CryptoStream csDecrypt = new CryptoStream(msDecrypt,
new TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV),
CryptoStreamMode.Read);
// Create buffer to hold the decrypted data.
byte[] fromEncrypt = new byte[Data.Length];
// Read the decrypted data out of the crypto stream
// and place it into the temporary buffer.
csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length);
//Convert the buffer into a string and return it.
return new ASCIIEncoding().GetString(fromEncrypt);
}
catch (CryptographicException e)
{
Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
return null;
}
}
|
|
|
|
|
VS 2003
C#: Windows Application - DataForm Wizard
3 records, Add 1 record
-----------------
Hi, I have a DataGrid and Textboxes link to the objCustomerDataset. When I add new record, after I click update button, the record is updated (Seen in Datagrid). The problem here is when I closed my form and relaunch, the pointer in the datagrid always point to the new record and the textboxes record (using DtatForm Wizard) to create is also at the new record. How do I reload the pointer to point at first record??
Note: I placed this.LoadDataset() at the form initialize.
|
|
|
|
|
hi, hope this will help
dataGrid1.CurrentCell = new DataGridCell(0,0);
Tamimi - Code
|
|
|
|
|
Hi, where do I insert this code?
|
|
|
|
|
hi
whereever you want !!!!!!!!
like when load the data, on button pressed
Tamimi - Code
|
|
|
|
|
I have an XmlNodeList and I just want to reverse the order of it. I have to keep it as an XmlNodeList because my repeater control (which I bind to it) depends on that.
/\ |_ E X E GG
|
|
|
|
|
Since the XPath function reverse is only for XPath 2.0, I can think of only two ways to do this:
1. Put your XML into a DataSet and use a DataView to tell it to sort in reverse order.
2. Use an XPathNodeIterator .
Option 2 is kind of difficult. Basically, instead of using an XmlDocument , you use an XPathDocument object to represent your XML. Then, you create an XPathNavigator from the document or from the node in the document that you want to start from. Use the navigator to Compile an XPathExpression object. Call AddSort on the XPathExpression to tell it to sort the nodes in reverse order (this is similar to how you would sort in an XSLT document). Then you can call the Evaluate method on the XPathNavigator to get an XPathNodeIterator , which you can bind to. The code really isn't that long, it just takes a while to figure out.
|
|
|
|
|
how can i made me application to have an intercactive interface like nero interfce ?
|
|
|
|
|
be creative
Tamimi - Code
|
|
|
|
|
Sir, i need help to make a chat room in C#.net. Kindly can you provide me any chat application source code.
|
|
|
|
|
|
All,
Are there any conditional defines for the /unsafe compiler switch? I have some code that I've written two versions for, one usafe (and much faster) and the other all "safe" code.
I now want to wrap the code in #if / #else / #endif blocks but need a "internal" conditional define that will select based on the presence of the /unsafe compiler switch.
Or... where can I get a list of "all" the VS.2005 C# "internal" conditional defines?
Thanks,
-Vino Rodrigues
|
|
|
|
|
Directives:
http://msdn2.microsoft.com/en-us/library/ed8yd1ha.aspx
You can create your own DEFINE and set it accordingly.
example: csc CondMethod.cs tracetest.cs /d:DEBUG
|
|
|
|
|
Thanks mate.
Know that one already.
I was hoping for a pre-defined (like MS code used "WINNT" or "WINCE") or an alternative method to "know" when /unsafe switch is on.
-Vino
|
|
|
|
|
Wouldn't that just be placed in the MSBUILD? There are several sections for each development target.
|
|
|
|
|
You might be able to work something out with this:
Conditional Attribute in C# compared to #if #endif
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=420
|
|
|
|
|
Hi All,
I have the following:
public struct sFileListStruct
{
public String sFileName;
public DateTime dFileTime;
}
I am developing an application that backs newly modified files up to the server. I want to save bandwidth, and the route that I have chosen is when the application copies a file onto the server, it will add an entry into an arraylist. At the end of the operation the arraylist is written to a file. (Serialized).
When the application starts, it reads the file and populates the arraylist with sFileListStruct. These are the files that have been backed up already. Next, I perform a file search and populate another ArrayList. This second ArrayList contains all the current files.
I want to compare the filename's and then look at the modification time for each file. I basically have something such as
foreach (sFileListStruct sCurrentFile in aAllFilesArrayList)
{
// Do some code in here
}
Now, what I have tried inside of the foreach is to do this:
if (aFilesCopiedArrayList.IndexOf(sCurrentFile) != -1)
{
// It's a new file, or the modification date has changed, do something here
}
I have also tried using sFilesCopiedArrayList.Contains(). They are incredibly slow. There are around 1,000 files that it is comparing, and it takes 60 seconds or more to do a comparison of them using either of those methods (This is a 2.6GHZ dual core machine). What I have winded up doing, which cuts that time down to about 10 seconds is actually putting a foreach within a foreach
foreach (sFileListStruct sCurrentFile in aAllFilesArrayList)
{
foreach (sFileListStruct sOldFile in aOldFilesArrayList)
{
if ((sOldFile.sFileName == sCurrentFile.sFileName) && (sCurrentFile.dFileTime > sOldFile.dFileTime)
{
// copy and update...
}
}
}
That appears to be a lot quicker than using IndexOf or Contains. I am wondering if anyone knows why, or is there some other way that I can check one ArrayList's contents against another ArrayList's contents quicker? I am just trying to do it the proper way and the way that will allow it to run the quickest.
TIA
|
|
|
|
|
Use a Hashtable with the filename as key. That should make it considerably faster to locate the items.
---
b { font-weight: normal; }
|
|
|
|
|
What Guffa said. If you still want to continue with your approach, you could try
1. Does sFileListStruct have to be a struct/code>? Things would be much faster if it's a <code>class instead.
2. converting the ArrayList to List<sFileListStruct>. This will work only if you're using .NET 2.0. This saves the unboxing cost when you read the struct out of the list.
3. Overriding Equals in your struct should help things too. I've read that the default implementation of Equals, which is what IndexOf uses, uses reflection to compare field values.
|
|
|
|
|
Hi i am stumped on how to insert characters into a string so it can display correctly. for instance i am wanting to format a string (ex "19999"). To be displayed as 199.99 (to show a price of $199.99 instead of $19,999). Also to go a bit further i would if the price did reach in the thousands (ex 121499) i would need it to show as 1,214.99. I've looked for some format property but i couldn't find anything
Thanks in advance
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Since you constantly want to change 123456 into 1,234.56 then I suggest converting the string into a decimal first, then divide it by 100 and display it.
You can use the {0:c} currency formatting to display the '$', the ',' and '.'
Here's[^] a good article on string formatting in C# just in case you need it.
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin
Edbert
Sydney, Australia
|
|
|
|
|
Try this:
string output = (value / 100.0).ToString('N');
the 'N' style gives your number to two decimal places and comma seperates the thousands.
Regards,
Rob Philpott.
|
|
|
|
|
hi this is my code for get CPU ID :
string cpuInfo = String.Empty;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == String.Empty)
{ // only return cpuInfo from first CPU
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
}
}
return cpuInfo;
but in my system, it is not working correctly(and why in another computer it worked correctly ?)
the error that was shown me : Object reference not set to an instance of an object.
How to solve problem ?
thanks .
|
|
|
|