1. C# / Говнокод #6297

    +127

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    if (accNum > 0 && accNum < accModels.Count){
                switch (accNum)
                {
                    case 1: accModels[0].WorldMatrix = Matrix.CreateScale(0.7f) * Matrix.CreateRotationX(0.3f) * Matrix.CreateRotationY(chrYaw + MathHelper.Pi) * Matrix.CreateTranslation(plPos + Vector3.Up * 9.0f + Vector3.Transform(Vector3.Backward * 2.0f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
                    case 2: accModels[1].WorldMatrix = Matrix.CreateScale(0.5f) * Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 11.0f + Vector3.Transform(Vector3.Backward + Vector3.Right * 3.0f, Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2))); break;
                    case 3: accModels[2].WorldMatrix = Matrix.CreateScale(0.5f) * Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 11.0f + Vector3.Transform(Vector3.Backward + Vector3.Right * 3.0f, Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2))); break;
    
                    case 4: accModels[3].WorldMatrix = Matrix.CreateScale(0.5f) * Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 5.0f + Vector3.Transform(Vector3.Backward * 0.0f + Vector3.Right * 0.7f, Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2))); break;
                    case 5: accModels[4].WorldMatrix = Matrix.CreateScale(0.55f) * Matrix.CreateRotationZ(0.3f) * Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 5.0f + Vector3.Transform(Vector3.Backward * 0.0f + Vector3.Right * 0.7f, Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2))); break;
                    case 6: accModels[5].WorldMatrix = Matrix.CreateScale(0.5f) * Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 18.0f + Vector3.Transform(Vector3.Right * -0.4f, Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2))); break;
                    <...>
                   case 11: accModels[10].WorldMatrix = Matrix.CreateScale(1.2f) * Matrix.CreateRotationX(-0.3f) * Matrix.CreateRotationY(chrYaw) * Matrix.CreateTranslation(plPos + Vector3.Up * 8.5f + Vector3.Transform(Vector3.Backward * 1.4f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
                    case 12: accModels[11].WorldMatrix = Matrix.CreateScale(1.0f) * Matrix.CreateRotationX(0.3f) * Matrix.CreateRotationY(chrYaw + MathHelper.Pi) * Matrix.CreateTranslation(plPos + Vector3.Up * 9.0f + Vector3.Transform(Vector3.Backward * 2.0f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
                    case 13: accModels[12].WorldMatrix = Matrix.CreateScale(1.0f) * Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * -1.0f + Vector3.Transform(Vector3.Backward * 2.0f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
                    case 14: accModels[13].WorldMatrix = Matrix.CreateScale(1.0f) * Matrix.CreateRotationZ(-0.3f) * Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 4.0f + Vector3.Transform(Vector3.Backward * 1.3f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
    
                    case 15: accModels[14].WorldMatrix = Matrix.CreateScale(0.4f) * Matrix.CreateRotationY(chrYaw) * Matrix.CreateTranslation(plPos + Vector3.Up * 22.0f + Vector3.Transform(Vector3.Right * 1.3f + Vector3.Backward * 3.8f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
    
                    default: accModels[accNum - 1].WorldMatrix = Matrix.CreateScale(0.7f) * Matrix.CreateRotationX(0.3f) * Matrix.CreateRotationY(chrYaw + MathHelper.Pi) * Matrix.CreateTranslation(plPos + Vector3.Up * 9.0f + Vector3.Transform(Vector3.Backward * 1.3f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
    
                }
    }

    Ой как мне не хотелось это в XMLку выносить...

    RaZeR, 09 Апреля 2011

    Комментарии (7)
  2. C# / Говнокод #6266

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    delegate(AccountRegisterRecord record)
    {
        bool status = true;
        status = record.Editable ? true : false;
        return status;
    }

    Делегат проверки активности элемента контекстного меню

    Mathematician, 07 Апреля 2011

    Комментарии (31)
  3. C# / Говнокод #6258

    +109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    try
     {
    //тут другой гавнокод связаный с регистрацией
    }
    catch(ApplicationException)
    {
        this.ModelState.AddModelError("DuplicateUser", Strings.DuplicateUser);
        return View(model);
    }

    Вот так, если приложение падает значит юзверь уже существует....

    biff, 07 Апреля 2011

    Комментарии (4)
  4. C# / Говнокод #6250

    +119

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    RegistryKey readKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Webzen\\Mu\\Config\\");
            Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser;
            RegistryKey saveKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Webzen\\Mu\\Config\\");
    
            private void b_exit_Click(object sender, EventArgs e)
            {
                if (checkBox1.Checked == true)
                    saveKey.SetValue("WindowMode", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                else
                    saveKey.SetValue("WindowMode", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
                if (checkBox2.Checked == true)
                    saveKey.SetValue("MusicOnOff", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                else
                    saveKey.SetValue("MusicOnOff", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
                if (checkBox3.Checked == true)
                    saveKey.SetValue("SoundOnOff", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                else
                    saveKey.SetValue("SoundOnOff", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
                if (comboBox1.SelectedItem == "800x600")
                    saveKey.SetValue("Resolution", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                else if (comboBox1.SelectedItem == "1024x768")
                    saveKey.SetValue("Resolution", (int)0x00000002, Microsoft.Win32.RegistryValueKind.DWord);
                else if (comboBox1.SelectedItem == "1280x1024")
                    saveKey.SetValue("Resolution", (int)0x00000003, Microsoft.Win32.RegistryValueKind.DWord);
                saveKey.Close();
                this.Close();
            }
    
            private void Options_Load(object sender, EventArgs e)
            {
                XmlDocument cfg = new XmlDocument();
                cfg.Load("cfg.xml");
                String lang = cfg.GetElementsByTagName("language")[0].InnerText;
                if (lang == "en")
                {
                    checkBox1.Text = "In window";
                    checkBox3.Text = "Music";
                    checkBox2.Text = "Sounds";
                    label1.Text = "Resolution game";
                    b_exit.Text = "Save";
                    b_cancel.Text = "Cancel";
                }
                int loadString = (int)readKey.GetValue("WindowMode");
                if (loadString == 1)
                    checkBox1.Checked = true;
                int loadString2 = (int)readKey.GetValue("MusicOnOff");
                if (loadString2 == 1)
                    checkBox2.Checked = true;
                int loadString3 = (int)readKey.GetValue("SoundOnOff");
                if (loadString3 == 1)
                    checkBox3.Checked = true;
                if (readKey.GetValue("Resolution") == null)
                {
                    regKey.CreateSubKey("SOFTWARE\\Webzen\\Mu\\Config");
                    regKey.SetValue("Resolution", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                }
                else
                {
                    int loadString4 = (int)readKey.GetValue("Resolution");
                    if (loadString4 == (int)0x00000001)
                        comboBox1.Text = "800x600";
                    else if (loadString4 == (int)0x00000002)
                        comboBox1.Text = "1024x768";
                    else if (loadString4 == (int)0x00000003)
                        comboBox1.Text = "1280x1024";
                    else
                        comboBox1.Text = "Выберите разрешение";
                }
                readKey.Close();
            }

    Код годичной давности, по сравнению с моими классами сейчас, это небо и земля.

    daffsik, 06 Апреля 2011

    Комментарии (6)
  5. C# / Говнокод #6248

    +985

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    public void ptsb()      {
                DateTime NW = System.DateTime.Now;
                int gh = NW.Day + 1; 
                int hj = NW.Month;   
                int NG = NW.Year;
                bool vg = System.DateTime.IsLeapYear(NW.Year); 
                if (hj==2)                     {
                    if (vg)                    {
                    if (gh > 29)                {
                        gh = 1;     
                        hj = 3;                    } } 
                    if (gh > 28)                {
                        gh = 1;    
                        hj = 3;     
                    } }
                else{
                    if (hj == 4)                   {
                        if (gh > 30)
                        {
                            gh = 1;
                            hj = 5;                      } }
                    else                {
                        if (hj == 6)                     {
                            if (gh > 30)                        {
                                gh = 1;
                                hj = 7;                        } }
                        else
                        {
                            if (hj == 9)                          {
                                if (gh > 30)                            {
                                    gh = 1;
                                    hj = 10;  
                                } }
                            else    {
                                if (hj == 11)                             {
                                    if (gh > 30)                                {
                                        gh = 1;
                                        hj = 12;                                  } }
                                else  {
                                    if (gh > 31)                                 {
                                        gh = 1;
                                        hj = hj + 1;
                                        if (hj == 13){
                                            hj = 1;
                                            NG = NG + 1;                                    }}}}}}}
         if (NW.Month < 10)         {
             if (NW.Day < 10)            {
                 d = "0" + NW.Month + "-" + "0" + NW.Day + "-" + NW.Year;
                 }
             else           {
                 d = "0" + NW.Month + "-" + NW.Day + "-" + NW.Year;         }     }
         else      {
                                    if (NW.Day < 10)                                 {
                                        d = NW.Month + "-" + "0" + NW.Day + "-" + NW.Year;        }
                                    else     {
                                        d = NW.Month + "-" + NW.Day + "-" + NW.Year;          }     }    
     if (hj < 10)       {
             if (gh < 10)           {
                 b = "0" + hj + "-" + "0" + gh + "-" + NG;         }
             else           {
                 b = "0" + hj + "-" + gh + "-" + NG;         }     }
         else      {
             if (gh < 10)         {
                 b = hj + "-" + "0" + gh + "-" + NG;        }
             else         {
                 b = hj + "-" +gh + "-" + NG;     }}}

    .....

    ded_efsey, 06 Апреля 2011

    Комментарии (18)
  6. C# / Говнокод #6243

    +119

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    try
    {
         selectedDate = Calendar1.SelectedDate.AddMilliseconds(-1);
         selectedDate = Calendar1.SelectedDate;
    }
    catch (Exception)
    {
          selectedDate = DateTime.Now.Date;
    }

    Ну вот как-то так пытался отловить дефолтовое значение календаря.

    partizan, 06 Апреля 2011

    Комментарии (6)
  7. C# / Говнокод #6237

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    /// <summary>
    /// Конвертирование руского текста в английский.
    /// </summary>
    /// <param name="russianText">Русский текст.</param>
    public static string ConvertToEnglish(string russianText)
    {
    	string englishText = russianText.ToLower();
    
    	englishText = englishText.Replace("КПК", "PDA");
    	englishText = englishText.Replace("ПК", "PC");
    	englishText = englishText.Replace("Ач ", "Ah");
    	englishText = englishText.Replace("ПО", "Software");
    	englishText = englishText.Replace("ОС", "OS");
    	.
    	.
    	.
    	//далее еще около 300 подобных замен
    
    	return englishText;
    }

    Изюминка этого говнокода заключается в первой строчке функции.
    Встретил там же где и http://govnokod.ru/6170

    lexx-pnz, 05 Апреля 2011

    Комментарии (19)
  8. C# / Говнокод #6233

    +117

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    int massaotves = 0;
                        var result = db.Vesi500.SingleOrDefault(x => x.Id_vesi500 == 10);
                        massaotves = Convert.ToInt32(result.Value_vesi500);
                        int step500 = 0;
                        //int ost1 = summ500 % massaotves;
                        //if (ost1 == 0)
                        //    step500 = summ500 / massaotves;
                        //else
                        //    step500 = (summ500 / massaotves) + 1;
    
                        int ost1 = summ500 % 450;
                        if (ost1 == 0)
                            step500 = summ500 / 450;
                        else
                            step500 = (summ500 / 450) + 1;
                        #endregion
    
                        #region Отвесы и суммы для 200 весов
                        int massaotves200 = 0;
                        var result1 = db.Vesi200.SingleOrDefault(x => x.Id_vesi200 == 9);
                        massaotves200 = Convert.ToInt32(result1.Value_vesi200);
                        int step200 = 0;
                        //int ost2 = summ200 % massaotves200;
                        //if (ost2 == 0)
                        //    step200 = summ200 / massaotves200;
                        //else
                        //    step200 = (summ200 / massaotves200) + 1;
                        
                        int ost2 = summ200 % 180;
                        if (ost2 == 0)
                            step200 = summ200 / 180;
                        else
                            step200 = (summ200 / 180) + 1;
                        #endregion                   
    
    
                        int itog = 0;
                        //if (step200 > step500)
                        //    itog = step200;
                        //else
                        //    itog = step500;
    
                        int test = (summ200 + summ500) / massaotves200;
                        if (test >= step500 && test >= step200)
                            itog = test;
                        else if (step200 > step500)
                            itog = step200;
                        else   
                            itog = step500;
    
                        textBox3.Text = Convert.ToString(itog);
                        vsegootvesov = itog;

    Выполняет расчет необходимых показателей, для запуска технологического процесса

    fxlancer, 05 Апреля 2011

    Комментарии (2)
  9. C# / Говнокод #6232

    +119

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    string[] otgruzka = new string[11] { "Отгрузка компонент 1 Вес 5дк-500", "Отгрузка компонент 2 Вес 5дк-500", "Отгрузка компонент 3 Вес 5дк-500", "Отгрузка компонент 4 Вес 5дк-500", "Отгрузка компонент 5 Вес 5дк-500", "Отгрузка компонент 6 Вес 5дк-500", "Отгрузка компонент 1 Вес 5дк-200", "Отгрузка компонент 2 Вес 5дк-200", "Отгрузка компонент 3 Вес 5дк-200", "Отгрузка компонент 4 Вес 5дк-200", "Отгрузка компонент 5 Вес 5дк-200", };
                        string[] silos = new string[11] { "Силос 1", "Силос 5", "Силос 6", "Силос 7", "Силос 8", "Силос 31-H", "Силос 9", "Силос 11", "Силос 2", "Силос 3", "Силос 4" };
                                           
                        for (int i = 0; i < dataGridView1.RowCount; i++)
                        {
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 1")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[0]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 5")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[1]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 6")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[2]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 7")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[3]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 8")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[4]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 31-H")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[5]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 9")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[6]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 11")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[7]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 2")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[8]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 3")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[9]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 4")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[10]);
                        }                    
                        textBox12.Text = Convert.ToString(modbus_master.GetValue("Текущий отвес 5дк-200") + 1);
    
                        if (modbus_master.GetValue("Текущий отвес 5дк-200") > WorkWithArchive.currentOtves200)
                        {
                            WorkWithArchive.WriteArchiveOtves200(modbus_master.GetValue("Текущий отвес 5дк-200"));
                            WorkWithArchive.currentOtves200 = modbus_master.GetValue("Текущий отвес 5дк-200");
                            WorkWithArchive.WriteArchiveKomponent200(dataGridView1);
                            WorkWithArchive.ot200 = true;
                        }

    Программа управления на производстве, взаимодействует с контроллером, получает кучу данных и такую же кучу отправляет.

    fxlancer, 05 Апреля 2011

    Комментарии (11)
  10. C# / Говнокод #6224

    +980

    1. 1
    2. 2
    3. 3
    4. 4
    if (ch=='k' && ch!='t')
    {
         something
    }

    Найдено в довольно серьезном проекте.

    timurets, 05 Апреля 2011

    Комментарии (16)