You don't need an event handler for each field in the form. Just point the Changed event of every relevant control to the same event handler.
Despite everything, the person most likely to be fooling you next is yourself.
You don't need an event handler for each field in the form. Just point the Changed event of every relevant control to the same event handler.
Despite everything, the person most likely to be fooling you next is yourself.
Yes, you would use LockBits to get access to the pixel data. No, there isn't any image format with alpha channel and the compression ratio of JPEG, at least not supported by the .NET framework.
Despite everything, the person most likely to be fooling you next is yourself.
Becuase the signed integer is CLR compliant, and the unsigned integer is not.
Despite everything, the person most likely to be fooling you next is yourself.
No, there is no lossy compression for PNG. The high compression rate of JPEG is simply done by throwing away the data that has least visual impact on the result. It would of course be possible to write your own compression algorithm that does that, but it would be very hard to get the same quality - compression ratio as JPEG compression, as the compression used in a PNG is not at all designed for lossy compression. Another alternative that is a bit more promising would be to extract the color data and alpha channel separately, and compress the color data as a regular JPEG image and the alpha data as a grayscale JPEG image.
Despite everything, the person most likely to be fooling you next is yourself.
nryk wrote:
private byte[] FileToByteArray (string path)
Just use the File.ReadAllBytes
method.
nryk wrote:
of course every bitmap in the memory takes about 10 times more then in the file
nryk wrote:
i get a byte array that is about 10 times bigger
From that I can deduct that you either managed to change the image into an image that is ten times larger (e.g. three times larger in both x and y axis), or you have changed it into something that the Save method could not compress at all. Could you post example image files somewhere for examination?
Despite everything, the person most likely to be fooling you next is yourself.
Generally speaking, you can't. This is a setting in the browser that the user has control over. The user chooses what should happen when a PDF file is opened. If you get the user to run an application on the client computer, it would be possible to change this setting, but that is nothing that you would normally do, and nothing that a user would normally allow.
Despite everything, the person most likely to be fooling you next is yourself.
Also: If you call ToString on the StringBuilder in every iteration in the loop, that will force it to allocate a new buffer and copy the data to it when you continue to add data to it. You lose any benefits of using the StringBuilder, the performance gets as bad as using += on a string. So you will have shuffled around several gigabytes of data before you are done reading the 200 kilobytes.
Despite everything, the person most likely to be fooling you next is yourself.
Given that you have the text in the text
variable and the replacements in the replacements
dictionary:
text = RegEx.Replace(text, @"\{(.+?)\}", m => replacements[m.Value]);
Despite everything, the person most likely to be fooling you next is yourself.
Note: That is the correct way to escape a string for some specific databases, like MS SQL Server and MS Access. For other databases you need to do it differently. It's important to use the correct escaping method for the specific database, otherwise the code is still wide open for SQL injections. If you use a parameterised query instead, there is no need for escaping.
Despite everything, the person most likely to be fooling you next is yourself.
Your application is wide open for SQL injection attacks. Please instruct your users not to enter this in the text field:
','','',8);drop table Users;--
Alternatively, you can correct the code. Use parameterised queries instead of concatenating the data into the query.
Despite everything, the person most likely to be fooling you next is yourself.
There are some specific differences between C++ and C# that you should be aware of, like for example how the memory management differs. I made a search on MSDN for some article about the differences between C++ and C#, and realised that a lot of the articles in the search result would be relevant. MSDN: search for C# C++[^]
Despite everything, the person most likely to be fooling you next is yourself.
Have a look at this:
private void button1_Click(object sender, EventArgs e) {
button1.Enabled = false;
int year = dateTimePicker1.Value.Year;
int month = dateTimePicker1.Value.Month;
DateTime start = new DateTime(year, month, 1);
dateTimePicker1.Value = start;
int days = DateTime.DaysInMonth(year, month);
for (int i = 0; i < days; i++) {
dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells[0].Value = start.AddDays(i).DayOfWeek;
dataGridView1.Rows[i].Cells[1].Value = start.AddDays(i).ToShortDateString();
}
}
Despite everything, the person most likely to be fooling you next is yourself.
Or if you don't want to reinvent the wheel:
if (DateTime.IsLeapYear(year)) {
// is leap year
} else {
// not leap year
}
;)
Despite everything, the person most likely to be fooling you next is yourself.
Then you just use variables in the call to the DaysInMonth method instead of the literal values used in the example.
Despite everything, the person most likely to be fooling you next is yourself.
0|[1-9]\d{0,2}|1000
Despite everything, the person most likely to be fooling you next is yourself.
Here is one problem:
Card1 = Int(51 * Rnd)
This will give you a random number with 51 possible values, i.e. from 0 to 50. That means that you are never touching the last card in the deck. You are doing 100 times as much work as you need to in order to shuffle the deck. You don't have to make more than 51 swaps to completely shuffle the deck, you just have to make sure that each card has an equal chance to be swapped into each position in the deck:
For card1 = 0 To 50
card2 = card1 + Int((52 - card1) * Rnd)
If card1 <> card2 Then
Temp = Image1(card1).Picture
Image1(card1).Picture = Image1(card2).Picture
Image1(card2).Picture = Temp
End If
Next Index
Despite everything, the person most likely to be fooling you next is yourself.
What's your problem? I try to be helpful, and what do I get for that? You call it useless and hurtful. I can understand if you don't find the advice very helpful if it's not exactly what you are looking for, but it's certainly not useless. If you find it hurtful, then it's certainly not my fault, and something that you have to work on yourself. If you can't even read well meaning advice without being hurt, you should definitely not be asking questions in a forum, but rather seek professional help.
Despite everything, the person most likely to be fooling you next is yourself.
I was thinking in the same direction, only without the StringBuilder as intermediate result...
int result = 0;
for (int i = 0; i < formatter.Length; i++) {
if (formatter[i] == '0') {
result = result * 10 + (text[i] - '0');
}
}
Despite everything, the person most likely to be fooling you next is yourself.
... or the File.WriteAllText[^] method.
Despite everything, the person most likely to be fooling you next is yourself.
The label doesn't support different font settings for part of the text. Use the Paint event of the label and draw the text yourself.
Despite everything, the person most likely to be fooling you next is yourself.