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

    +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
    public void прорисовка_точек()
            {
                for (int i = 0; i < лист_точек.Count; i++)
                {
                    //Data0
                    if (((лист_точек[i] as ArrayList)[4] as ArrayList).Count != 0)
                    {
                        уровни определение_уровня = new уровни(s, (лист_точек[i] as ArrayList)[3].ToString(), 4);
                        if (определение_уровня.рисуем == true)
                        {
                            string type = (лист_точек[i] as ArrayList)[1].ToString();                        
                            for (int k = 0; k < ((лист_точек[i] as ArrayList)[4] as ArrayList).Count; k++)
                            {
                                PointF point = (((лист_точек[i] as ArrayList)[4] as ArrayList)[k] as List<PointF>)[0];
                                преобразование_координат координаты_старые = new преобразование_координат(point.X, point.Y, коэф_старый.max_x, коэф_старый.max_y, коэф_старый.K_x, коэф_старый.K_y);
                                point.X = (float)((новый.max_x_new - координаты_старые.xn) * новый.K_x_new * s);
                                point.Y = (float)((новый.max_y_new - координаты_старые.yn) * новый.K_y_new * s);
                                Rectangle rect = new Rectangle(Convert.ToInt32(point.X),Convert.ToInt32(point.Y),1,1);
                                if (проверка(this.Width, this.Height, point.X, point.Y) == true)
                                {
                                    Кисти_точек точки = new Кисти_точек(type);
                                    G.DrawImage(точки.bitm, point.X, point.Y, точки.bitm.Width, точки.bitm.Height);
                                }
                               прорисовка_надписей_точек(point, ((лист_точек[i] as ArrayList)[2].ToString()));
                            }
                        }
                    }
                }
            }

    Взято отсюда http://www.cyberforum.ru/csharp-net/thread330291-page3.html

    vvs, 08 Июля 2011

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

    +962

    1. 1
    2. 2
    3. 3
    bool isVisible = Convert.ToBoolean(Convert.ToBoolean(paramsArr[3]));
    
    чтоб наверняка :)

    wader, 07 Июля 2011

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

    +955

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    static string foo()
            {
                int i = 0;
                //code
                return "some string "+ i++;
            }

    Irdis, 07 Июля 2011

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

    +961

    1. 1
    2. 2
    //МегаДекодер)
       _word = HttpUtility.UrlEncode(HttpUtility.UrlDecode(SearchDataHelper.RemoveSpecialCharacters(word, true)));

    drakoner, 04 Июля 2011

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

    +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
    //чОткая функция которая возвращает количество отображаемых узлов
    //в дереве без скролла
    int GetcountVisibleNodesInList()
    {
        int res = 0;
    
        if (FormGUI.c_MainWorkSpaseTree.Nodes.Count == 0)
        {
            this.FormGUI.c_MainWorkSpaseTree.Nodes.Add(new TreeNode());
            res = this.FormGUI.c_MainWorkSpaseTree.Height / FormGUI.c_MainWorkSpaseTree.getNodeRectangle(this.FormGUI.c_MainWorkSpaseTree.Nodes[0]).Height;
            this.FormGUI.c_MainWorkSpaseTree.Nodes[0].Remove();
        }
        else
        {
            res = this.FormGUI.c_MainWorkSpaseTree.Height / FormGUI.c_MainWorkSpaseTree.getNodeRectangle(this.FormGUI.c_MainWorkSpaseTree.Nodes[0]).Height;
        }
    
        //и незабываем воткнуть вычисленное значение в комбобокс
        this.FormGUI.c_cmb_countRowsInPage.Text = (res - 4).ToString();
        return res;
    }
    
    //пример использования функции
    void FormGUI_Load(object sender, EventArgs e)
    {
        //возвращается интовое значение и ложится в комбобокс
        GetcountVisibleNodesInList();
    
        int CountRows = 0;
        if (int.TryParse(FormGUI.c_cmb_countRowsInPage.Text, out CountRows))
        {
            _LastShowedRowNumber = 0;
            GoToNextPage(); //там же комбобокс опять парсится
        }
    }

    обратите внимание на обработчик загрузки формы.
    Из нужного кода там только вызов GoToNextPage() в котором опять же парсим комбобокс

    UgayNick, 04 Июля 2011

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

    +958

    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
    if (args.Cube == null)
    {
    	args.Cube = null;
    	stringBuilder.AppendLine(Properties.Resources.ErrorCubeEmpty);
    }
    else if(...)
    {
    ...
    }
    else if (...)
    {
    ...
    }
    else
    {
    ...
    }
    int num = args.Cube.NumSamplesIJK.K;

    redrick, 04 Июля 2011

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

    +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
    public string GetNormalImage(int newWidth, int newHeight, string sufix = "normal") {
                String[] tmp = _originalImagePath.Split('.');
                String newImagePath = "";
                for (int i = 0; i < tmp.Length - 1; i++)
                {
                    newImagePath += tmp[i];
                    newImagePath += "_";
                }
                newImagePath += sufix + ".";
                newImagePath += tmp[tmp.Length - 1];
    
                
                Image oldImage = Image.FromFile(_originalImagePath);
                if (oldImage.Height >= oldImage.Width) {
                    Image newImage;
                    newImage = FixedSize(oldImage, newWidth, newHeight);
                    newImage.Save(newImagePath);
                } else {
    
                    float heightRatio = (float)newHeight / (float)oldImage.Height;
                    float widthRatio = (float)newWidth / (float)oldImage.Width;
    
                    float bestRatio = 1;
                    if (heightRatio < widthRatio) {
                        bestRatio = heightRatio;
                    } else {
                        bestRatio = widthRatio;
                    }
    
                    var result = new System.Drawing.Bitmap((int)Math.Round(oldImage.Width * bestRatio), (int)Math.Round(oldImage.Height * bestRatio));
                    using (var graphics = Graphics.FromImage(result))
                    {
                        graphics.CompositingQuality = CompositingQuality.HighQuality;
                        graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                        graphics.SmoothingMode = SmoothingMode.HighQuality;
                        graphics.DrawImage(oldImage, new Rectangle(Point.Empty, new Size((int)Math.Round(oldImage.Width * bestRatio), (int)Math.Round(oldImage.Height * bestRatio))));
                    }
                    result.Save(newImagePath);
                }
    
                return newImagePath;
            }

    ресайз изображения

    tuxcod, 30 Июня 2011

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

    +109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (File.Exists(local)) {
                        if (Connect()) {
                            if (ftpConnection.Exists(remote)) {
    //code
                            }
                        }
                    }

    Irdis, 27 Июня 2011

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

    +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
    26. 26
    27. 27
    28. 28
    static Queue<string> getProxiesFromFile(string filename)
            {
                Queue<string> temp=new Queue<string>();
                System.IO.StreamReader file;
                string line;
                // Read the file and display it line by line.
                if (filename == null)
                {
                    file = new System.IO.StreamReader("proxy.txt");
                }
                else
                {
                    try
                    {
                        file = new System.IO.StreamReader(filename);
                    }
                    catch (FileNotFoundException)
                    {
                        throw;
                    }
                }
                while ((line = file.ReadLine()) != null)
                {
                    temp.Enqueue (line);
                    Console.WriteLine(line);
                }
                return temp;
            }

    Считываем файл построчно и заносим в Queue<string> .

    gg123, 27 Июня 2011

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

    +126

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public static IEnumerable<TItem> GetNextItemFrom<TItem>(IEnumerable<TItem> Collection)
            {
                foreach (var Item in Collection)
                    yield return Item;
            }

    Говногость, 26 Июня 2011

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