Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

Guffa

@Guffa
About
Posts
9.0k
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • mark as unsaved if the user changes ANYTHING?
    G Guffa

    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.

    C# question

  • load a lot of Images to memory
    G Guffa

    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.

    C# graphics question data-structures performance help

  • about BitVector32
    G Guffa

    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.

    C# question

  • load a lot of Images to memory
    G Guffa

    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.

    C# graphics question data-structures performance help

  • load a lot of Images to memory
    G Guffa

    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.

    C# graphics question data-structures performance help

  • How to cancel the adobe reader opening when You click a link on IE?
    G Guffa

    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.

    C# question csharp adobe tutorial

  • Download Speed
    G Guffa

    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.

    C# performance tutorial code-review

  • Parse out all the "{" + string + "}" occurences?
    G Guffa

    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.

    C# question

  • want to allow the user to enter ' but shows error
    G Guffa

    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.

    C# database help

  • want to allow the user to enter ' but shows error
    G Guffa

    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.

    C# database help

  • How do i learn c# programming fast
    G Guffa

    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.

    C# csharp c++ question

  • how can i find number of days in a given year and month
    G Guffa

    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.

    C# question

  • how can i find number of days in a given year and month
    G Guffa

    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.

    C# question

  • how can i find number of days in a given year and month
    G Guffa

    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.

    C# question

  • Regular expression for 0 to 1000
    G Guffa

    0|[1-9]\d{0,2}|1000

    Despite everything, the person most likely to be fooling you next is yourself.

    C# csharp regex

  • Please help a newbie that is totally confused....
    G Guffa

    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.

    Visual Basic help database design game-dev

  • To Henry Minute, Original Griff, fly904, stancrm, Computafreak, Guffa, DaveyM69, J4amieC, Tom Deketelaere and Dave Kreskowiak
    G Guffa

    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.

    C# csharp question dotnet algorithms tools

  • Help me with formatted int32 strings. [modified]
    G Guffa

    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.

    C# help

  • Complex Question
    G Guffa

    ... or the File.WriteAllText[^] method.

    Despite everything, the person most likely to be fooling you next is yourself.

    C# csharp tools help tutorial question

  • how to make a part of string as Bold??
    G Guffa

    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.

    C# tutorial help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups