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

    +114

    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
    private int GetInsertion(byte[] firstArr, byte[] secondArr)
            {
                int result = -1;
                int counter = 0;
                if (firstArr.Count() >= secondArr.Count())
                {
                    for (int i = 0; i < firstArr.Count(); i++)
                    {
                        if (firstArr[i] == secondArr[counter])
                        {
                            counter++;
                            if (counter == secondArr.Count())
                            {
                                result = i - counter + 1;
                                break;
                            }
                        }
                        else
                        {
                            counter = 0;
                        }
                    }
                }
                return result;
            }

    находит индекс вхождения одного массива в другой

    razzil, 23 Марта 2012

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

    +963

    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
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    public partial class Form1 : Form  
        {
            public Form1()
            {
                InitializeComponent();
            }
           
            public void label1_Click(object sender, EventArgs e)
            {
     
            }
     
            public void button1_Click(object sender, EventArgs e)
            {
                label1.Text = "неправильно, вы проиграли";
                button1.Dispose();
                button2.Dispose();
                button3.Dispose();
                button4.Dispose();
                this.BackColor = System.Drawing.Color.Red;
            }
     
            public void button2_Click(object sender, EventArgs e)
            {
               
                label1.Text = "неправильно, вы проиграли";
                button1.Dispose();
                button2.Dispose();
                button3.Dispose();
                button4.Dispose();
                this.BackColor = System.Drawing.Color.Red;
            }
     
            public void button4_Click(object sender, EventArgs e)
            {
                label1.Text = "неправильно, вы проиграли";
                button1.Dispose();
                button2.Dispose();
                button3.Dispose();
                button4.Dispose();
                this.BackColor = System.Drawing.Color.Red;
            }
     
            public void button3_Click(object sender, EventArgs e)
            {
                label1.Text = "правильно";
                button1.Dispose();
                button2.Dispose();
                button3.Dispose();
                button4.Dispose();
                btn.Dispose();
                this.BackColor = System.Drawing.Color.Green;
                btn = new Button();
                btn.Text = "Дальше";
                btn.Top = 200;
                btn.Left = 360;
                btn.Height = 165;
                btn.Width = 269;
                btn.Click += new EventHandler(Press_ok);
                this.Controls.Add(btn);
                
            }
                public void Press_ok (object sender, EventArgs e)
            {
                this.BackColor = System.Drawing.Color.White;
                    btn.Dispose();
                    label1.Text = "сколько должно быть зубов у человека?";
                    button1 = new Button();
                    button1.Text = "16";
                    button1.Height = 23;
                    button1.Width = 142;
                    button1.Left = 272;
                    button1.Top = 414;
                    button1.Click += new EventHandler(Press_1);
                    this.Controls.Add(button1);
              
                    
     
                    button2 = new Button();
                    button2.Text = "32";
                    button2.Height = 23;
                    button2.Width = 142;
                    button2.Left = 711;
                    button2.Top = 414;
                    button2.Click += new EventHandler(Press_2);
                    this.Controls.Add(button2);
     
                    button3 = new Button();
                    button3.Text = "28";
                    button3.Height = 23;
                    button3.Width = 142;
                    button3.Left = 272;
                    button3.Top = 491;
                    button3.Click += new EventHandler(Press_3);
                    this.Controls.Add(button3);
     
                    button4 = new Button();
                    button4.Text = "101";
                    //еще over100500 ГК

    psina-from-ua, 22 Марта 2012

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

    +961

    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
    namespace WindowsFormsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
            {
                switch (keyData)
                {
                    case Keys.Up:
                        if ((pictureBox1.Location.X + pictureBox1.Width >= pictureBox4.Location.X) & (pictureBox1.Location.X <= pictureBox4.Location.X + pictureBox4.Width) & (pictureBox1.Location.Y <= pictureBox4.Location.Y + pictureBox4.Height) & (pictureBox1.Location.Y >= pictureBox4.Location.Y + pictureBox4.Height / 2)) ;
                        else pictureBox1.Top -= 5;
                        if ((pictureBox2.Visible) & (pictureBox3.Visible))
                            if ((pictureBox1.Location.Y >= pictureBox2.Location.Y) & (pictureBox1.Location.Y + pictureBox1.Height <= pictureBox2.Location.Y + pictureBox2.Height) & (pictureBox1.Location.X >= pictureBox2.Location.X) & (pictureBox1.Location.X + pictureBox1.Width <= pictureBox2.Location.X + pictureBox2.Width))
                                pictureBox1.Location = new Point(pictureBox3.Location.X + (pictureBox1.Location.X - pictureBox2.Location.X), pictureBox3.Location.Y - 5);
                        if ((pictureBox2.Visible) & (pictureBox3.Visible))
                            if ((pictureBox1.Location.Y >= pictureBox3.Location.Y) & (pictureBox1.Location.Y + pictureBox1.Height <= pictureBox3.Location.Y + pictureBox3.Height) & (pictureBox1.Location.X >= pictureBox3.Location.X) & (pictureBox1.Location.X + pictureBox1.Width <= pictureBox3.Location.X + pictureBox3.Width))
                                pictureBox1.Location = new Point(pictureBox2.Location.X + (pictureBox1.Location.X - pictureBox3.Location.X), pictureBox2.Location.Y - 5);
                                break;
                    case Keys.Down:
                                if ((pictureBox1.Location.X + pictureBox1.Width >= pictureBox4.Location.X) & (pictureBox1.Location.X <= pictureBox4.Location.X + pictureBox4.Width) & (pictureBox1.Location.Y + pictureBox1.Height <= pictureBox4.Location.Y + pictureBox4.Height / 2) & (pictureBox1.Location.Y + pictureBox1.Height >= pictureBox4.Location.Y)) ;
                        else pictureBox1.Top += 5;
                        if ((pictureBox2.Visible) & (pictureBox3.Visible))
                            if ((pictureBox1.Location.Y >= pictureBox2.Location.Y) & (pictureBox1.Location.Y + pictureBox1.Height <= pictureBox2.Location.Y + pictureBox2.Height) & (pictureBox1.Location.X >= pictureBox2.Location.X) & (pictureBox1.Location.X + pictureBox1.Width <= pictureBox2.Location.X + pictureBox2.Width))
                                pictureBox1.Location = new Point(pictureBox3.Location.X + (pictureBox1.Location.X - pictureBox2.Location.X), (pictureBox3.Location.Y + pictureBox3.Height) - 5);
                        if ((pictureBox2.Visible) & (pictureBox3.Visible))
                            if ((pictureBox1.Location.Y >= pictureBox3.Location.Y) & (pictureBox1.Location.Y + pictureBox1.Height <= pictureBox3.Location.Y + pictureBox3.Height) & (pictureBox1.Location.X >= pictureBox3.Location.X) & (pictureBox1.Location.X + pictureBox1.Width <= pictureBox3.Location.X + pictureBox3.Width))
                                pictureBox1.Location = new Point(pictureBox2.Location.X + (pictureBox1.Location.X - pictureBox3.Location.X), (pictureBox2.Location.Y + pictureBox2.Height) - 5);
                                break;

    Это не поддаётся описанию. Полная версия: http://pastebin.com/97sbSVLa

    P4R4, 22 Марта 2012

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

    +122

    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
    else
                    {
                        if ((textBox1.Text == textBox2.Text) | (textBox1.Text == textBox3.Text) | (textBox1.Text == textBox4.Text) | (textBox1.Text == textBox7.Text)) textBox1.ForeColor = Color.Red; else textBox1.ForeColor = Color.Black;
                        if ((textBox2.Text == textBox1.Text) | (textBox2.Text == textBox3.Text) | (textBox2.Text == textBox5.Text) | (textBox2.Text == textBox8.Text)) textBox2.ForeColor = Color.Red; else textBox2.ForeColor = Color.Black;
                        if ((textBox3.Text == textBox1.Text) | (textBox3.Text == textBox2.Text) | (textBox3.Text == textBox6.Text) | (textBox3.Text == textBox9.Text)) textBox3.ForeColor = Color.Red; else textBox3.ForeColor = Color.Black;
                        if ((textBox4.Text == textBox5.Text) | (textBox4.Text == textBox6.Text) | (textBox4.Text == textBox1.Text) | (textBox4.Text == textBox7.Text)) textBox4.ForeColor = Color.Red; else textBox4.ForeColor = Color.Black;
                        if ((textBox5.Text == textBox4.Text) | (textBox5.Text == textBox6.Text) | (textBox5.Text == textBox2.Text) | (textBox5.Text == textBox8.Text)) textBox5.ForeColor = Color.Red; else textBox5.ForeColor = Color.Black;
                        if ((textBox6.Text == textBox4.Text) | (textBox6.Text == textBox5.Text) | (textBox6.Text == textBox3.Text) | (textBox6.Text == textBox9.Text)) textBox6.ForeColor = Color.Red; else textBox6.ForeColor = Color.Black;
                        if ((textBox7.Text == textBox8.Text) | (textBox7.Text == textBox9.Text) | (textBox7.Text == textBox1.Text) | (textBox7.Text == textBox4.Text)) textBox7.ForeColor = Color.Red; else textBox7.ForeColor = Color.Black;
                        if ((textBox8.Text == textBox7.Text) | (textBox8.Text == textBox9.Text) | (textBox8.Text == textBox2.Text) | (textBox8.Text == textBox5.Text)) textBox8.ForeColor = Color.Red; else textBox8.ForeColor = Color.Black;
                        if ((textBox9.Text == textBox7.Text) | (textBox9.Text == textBox8.Text) | (textBox9.Text == textBox3.Text) | (textBox9.Text == textBox6.Text)) textBox9.ForeColor = Color.Red; else textBox9.ForeColor = Color.Black;
                        if ((textBox1.Text == textBox2.Text) | (textBox1.Text == textBox3.Text) | (textBox1.Text == textBox4.Text) | (textBox1.Text == textBox7.Text) |
                            (textBox2.Text == textBox1.Text) | (textBox2.Text == textBox3.Text) | (textBox2.Text == textBox5.Text) | (textBox2.Text == textBox8.Text) |
                            (textBox3.Text == textBox1.Text) | (textBox3.Text == textBox2.Text) | (textBox3.Text == textBox6.Text) | (textBox3.Text == textBox9.Text) |
                            (textBox4.Text == textBox5.Text) | (textBox4.Text == textBox6.Text) | (textBox4.Text == textBox1.Text) | (textBox4.Text == textBox7.Text) |
                            (textBox5.Text == textBox4.Text) | (textBox5.Text == textBox6.Text) | (textBox5.Text == textBox2.Text) | (textBox5.Text == textBox8.Text) |
                            (textBox6.Text == textBox4.Text) | (textBox6.Text == textBox5.Text) | (textBox6.Text == textBox3.Text) | (textBox6.Text == textBox9.Text) |
                            (textBox7.Text == textBox8.Text) | (textBox7.Text == textBox9.Text) | (textBox7.Text == textBox1.Text) | (textBox7.Text == textBox4.Text) |
                            (textBox8.Text == textBox7.Text) | (textBox8.Text == textBox9.Text) | (textBox8.Text == textBox2.Text) | (textBox8.Text == textBox5.Text) |
                            (textBox9.Text == textBox7.Text) | (textBox9.Text == textBox8.Text) | (textBox9.Text == textBox3.Text) | (textBox9.Text == textBox6.Text)) ;
                        else
                        {
                            label1.Visible = true;
                            label2.Visible = true;
                        }

    Удивлению нет границ! Полная версия: http://pastebin.com/S2getyHn

    P4R4, 22 Марта 2012

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

    +109

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private IEnumerable<CharacteristicValue> GetCharacteristicValues(IQueryable<CharacteristicValue> allCharacteristicValues, int characteristicId)
    {
          var characteristicValues = new CharacteristicValue[userIds.Length];
    
           for (var i = 0; i < userIds.Length; i++)
           {
               characteristicValues[i] = allCharacteristicValues.FirstOrDefault(cv => cv.UserId == userIds[i] && cv.CharacteristicId == characteristicId); // Todo: Try to replace with a single query.
           }
    
           return characteristicValues;
    }

    Драсьте, нашёл в коде такую вот какашку. Как видите параметр allCharacteristicsValues реализует интерфейс IQuarable из EF. То бишь каждый раз, когда будет вызываться метод FirstOrDefault будет делаться запрос к базе. В идеале это должно было бы выглядеть так:

    var characteristicValues = allCharacteristicValues.Where(cv => cv.CharacteristicId == characteristicId && userIds.Contains(cv.UserId));

    Но при такой реализации размер масива пользователей и значение может разниться:

    Values:
    val1
    val2
    val3

    Users:
    1
    2
    3
    4
    5

    Для первого же варианта результат будет выглядеть так:
    Values:
    val1
    val2
    val3
    null
    null

    Users:
    1
    2
    3
    4
    5


    Собственно всё )))) Надеюсь подсоветуете чего-нибудь хорошего ;)

    walash, 20 Марта 2012

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

    +113

    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
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    if ((label1.Text == "O") & (label2.Text == "O") & (label3.Text == "O") | ((label1.Text == "X") & (label2.Text == "X") & (label3.Text == "X")))
                {
                    label1.ForeColor = Color.Red;
                    label2.ForeColor = Color.Red;
                    label3.ForeColor = Color.Red;
                    win = false;
                }
                if ((label4.Text == "O") & (label5.Text == "O") & (label6.Text == "O") | ((label4.Text == "X") & (label5.Text == "X") & (label6.Text == "X")))
                {
                    label4.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label6.ForeColor = Color.Red;
                    win = false;
                }
                if ((label7.Text == "O") & (label8.Text == "O") & (label9.Text == "O") | ((label7.Text == "X") & (label8.Text == "X") & (label9.Text == "X")))
                {
                    label4.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label6.ForeColor = Color.Red;
                    win = false;
                }
                if ((label1.Text == "O") & (label4.Text == "O") & (label7.Text == "O") | ((label1.Text == "X") & (label4.Text == "X") & (label7.Text == "X")))
                {
                    label1.ForeColor = Color.Red;
                    label4.ForeColor = Color.Red;
                    label7.ForeColor = Color.Red;
                    win = false;
                }
                if ((label2.Text == "O") & (label5.Text == "O") & (label8.Text == "O") | ((label2.Text == "X") & (label5.Text == "X") & (label8.Text == "X")))
                {
                    label2.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label8.ForeColor = Color.Red;
                    win = false;
                }
                if ((label3.Text == "O") & (label6.Text == "O") & (label9.Text == "O") | ((label3.Text == "X") & (label6.Text == "X") & (label9.Text == "X")))
                {
                    label3.ForeColor = Color.Red;
                    label6.ForeColor = Color.Red;
                    label9.ForeColor = Color.Red;
                    win = false;
                }
                if ((label1.Text == "O") & (label5.Text == "O") & (label9.Text == "O") | ((label1.Text == "X") & (label5.Text == "X") & (label9.Text == "X")))
                {
                    label1.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label9.ForeColor = Color.Red;
                    win = false;
                }
                if ((label3.Text == "O") & (label5.Text == "O") & (label7.Text == "O") | ((label3.Text == "X") & (label5.Text == "X") & (label7.Text == "X")))
                {
                    label3.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label7.ForeColor = Color.Red;
                    win = false;
                }
            }
    
            private void label7_MouseDown(object sender, MouseEventArgs e)
            {
                if (win)
                    for (int i = 0; i < 1; i++)
                    {
                        if (label7.Text == "")
                        {
                            label7.Text = "X";
    
                            if ((label1.Text == "O") & (label2.Text == "O") & (label3.Text == ""))
                            {
                                label3.Text = "O"; break;
                            }
                            if ((label1.Text == "O") & (label2.Text == "") & (label3.Text == "O"))
                            {
                                label2.Text = "O"; break;
                            }
                            if ((label1.Text == "") & (label2.Text == "O") & (label3.Text == "O"))
                            {
                                label1.Text = "O"; break;
                            }

    Крестики-нолики с одного форума. Полная версия: http://pastebin.com/59W3547n

    P4R4, 19 Марта 2012

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

    +109

    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
    namespace ChemicalLabs
    {
        public partial class MediaViewer : Form
        {
            public static string XPath;
            
            public MediaViewer(string ObjectMediaRef, string ObjectMediaName)
            {
                InitializeComponent();
    
                try
                {
                    this.Text = ObjectMediaName;
                    axWindowsMediaPlayer.settings.volume = 100;
                    ObjectMediaRef = (Convert.ToInt16(ObjectMediaRef) + 1).ToString();
                    XPath = ObjectMediaRef;
    
                    StreamReader DataStream = new StreamReader("c://ChemicalData/" + ObjectMediaRef + "/" + ObjectMediaRef + ".txt", Encoding.GetEncoding(1251));
                    _MEDIA_DATA_AREA.Text = DataStream.ReadToEnd();
    
                    
                    object[] MediaFiles = Directory.GetFiles(
                    @"c://ChemicalData/" + ObjectMediaRef + "/" + "Media", "*.mp4", SearchOption.TopDirectoryOnly);
    
                    for (int i = 0; i < MediaFiles.Length; i++)
                    {FileInfo a = new FileInfo(MediaFiles[i].ToString());MediaFilesList.Items.Add(a.Name.Remove(a.Name.Length - 4));}
                }
                
                catch (Exception Ex)
                {MessageBox.Show(Ex.ToString(),(Ex.Message).ToString(),buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
            }
    
            private void MD_Click(object sender, EventArgs e)
            {
    
                if (MediaFilesList.SelectedItem == null)
                {MessageBox.Show("Вы не выбрали материал! Просмотр невозможен.","Сами не знаете, что хотите...",buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
                else
                {
                    string MediaPath;
                    MediaPath = MediaFilesList.SelectedItem.ToString();
                    MediaPath = "c://ChemicalData/" + XPath + "/" + "Media" + "/" + MediaPath + ".mp4";
                    axWindowsMediaPlayer.close();
                    axWindowsMediaPlayer.URL = MediaPath;
                }
            }
            private void MediaStreamClose_Click(object sender, EventArgs e)
            {this.axWindowsMediaPlayer.close();}
            private void _MediaForm_Close_Click(object sender, EventArgs e)
            {this.axWindowsMediaPlayer.close(); MediaViewer.ActiveForm.Close();}
            private void MediaViewer_FormClosed(object sender, FormClosedEventArgs e)
            {this.axWindowsMediaPlayer.close();MediaViewer.ActiveForm.Close();}
            private void axWindowsMediaPlayer_MouseDownEvent(object sender, AxWMPLib._WMPOCXEvents_MouseDownEvent e)
            {MessageBox.Show("MediaPlayer - ver 0.0.1 for .NET Platform (By Kirill Sancharov)","MediaPlayer for Windows .NET",buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
     }
    }

    Удивляй меня полностью.

    Govnisti_Diavol, 19 Марта 2012

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

    +105

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    //батон ЗАНЕСТИ
            private void btnOk_Click(object sender, EventArgs e)
            {
                if (SaveData())
                {
                    this.Tag = _tParams.Id;
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }

    gcoder, 19 Марта 2012

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

    +115

    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
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    if (DialogResult.OK == openFileDialog.ShowDialog())
                {
                    CleanUp();
    
                    m_objFilterGraph = new FilgraphManager();
                    m_objFilterGraph.RenderFile(openFileDialog.FileName);
    
                    m_objBasicAudio = m_objFilterGraph as IBasicAudio;
                    
                    try
                    {
                        m_objVideoWindow = m_objFilterGraph as IVideoWindow;
                        m_objVideoWindow.Owner = (int) panel1.Handle;
                        m_objVideoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
                        m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
                            panel1.ClientRectangle.Top,
                            panel1.ClientRectangle.Width,
                            panel1.ClientRectangle.Height);
                    }
                    catch (Exception)
                    {
                        m_objVideoWindow = null;
                    }
    
                    m_objMediaEvent = m_objFilterGraph as IMediaEvent;
    
                    m_objMediaEventEx = m_objFilterGraph as IMediaEventEx;
                    m_objMediaEventEx.SetNotifyWindow((int) this.Handle,WM_GRAPHNOTIFY, 0);
    
                    m_objMediaPosition = m_objFilterGraph as IMediaPosition;
    
                    m_objMediaControl = m_objFilterGraph as IMediaControl;
    
                    this.Text = "DirectShow - [" + openFileDialog.FileName + "]";
    
                    m_objMediaControl.Run();
                    m_CurrentStatus = MediaStatus.Running;
    
                    UpdateStatusBar();
                    UpdateToolBar();
                }
            }
    
            private void CleanUp()
            {
                if (m_objMediaControl != null)
                    m_objMediaControl.Stop();
    
                m_CurrentStatus = MediaStatus.Stopped;
    
                if (m_objMediaEventEx != null)
                    m_objMediaEventEx.SetNotifyWindow(0, 0, 0);
    
                if (m_objVideoWindow != null)
                {
                    m_objVideoWindow.Visible = 0;
                    m_objVideoWindow.Owner = 0;
                }
    
                if (m_objMediaControl != null) m_objMediaControl = null;
                if (m_objMediaPosition != null) m_objMediaPosition = null;
                if (m_objMediaEventEx != null) m_objMediaEventEx = null;
                if (m_objMediaEvent != null) m_objMediaEvent = null;
                if (m_objVideoWindow != null) m_objVideoWindow = null;
                if (m_objBasicAudio != null) m_objBasicAudio = null;
                if (m_objFilterGraph != null) m_objFilterGraph = null;
            }
    
            private void menuItem4_Click(object sender, System.EventArgs e)
            {
                this.Close();
            }
    
            private void Form1_SizeChanged(object sender, System.EventArgs e)
            {
                if (m_objVideoWindow != null)
                {
                    m_objVideoWindow.SetWindowPosition(panel1.ClientRectangle.Left,
                        panel1.ClientRectangle.Top,
                        panel1.ClientRectangle.Width,
                        panel1.ClientRectangle.Height);
                }
            }

    Воспроизводим видео.
    Нестандартный путь.

    Govnisti_Diavol, 18 Марта 2012

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

    +108

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public static string RandomWord(int Number)
    {    
    	Random RandomIndex = new Random();
    	string[] ArrayLetter = {"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m"};
    	string OutputValue = null;
    	for (int i = 0; i < Number; i++)
    	{
    	OutputValue += ArrayLetter[RandomIndex.Next(0, 25)];
    	}
    	return OutputValue;
    }

    Метод выводит случайное слово блин.

    KusokGovna, 17 Марта 2012

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