Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void SetIconPosition(IEnumerable<DesctopIcon> icons, Action<DesctopIcon, float, float> positionSetter, float l)
- {
- //int maxIconsInLayer = (int)(MathHelper.TwoPi * l / Math.Pow(200000,0.5));
- //int n = (int)Math.Round((MathHelper.TwoPi * Math.Sqrt(files.Length + folders.Length) / Math.Sqrt(MathHelper.Pi)));
- int n = files.Length + folders.Length; //общее кол-во иконок
- int Layers = (int)(1 + Math.Sqrt(12 * n - 5) / 6); //кол-во слоев на пол шара
- float spaceX = MathHelper.PiOver2 / Layers; //шаг угла поворота вокруг оси х
- var unsortedIcons = icons;//хуйня
- float x = MathHelper.PiOver2; //изначальный угол поворота вокруг х
- int iconCount = 1; //иконок в 1м слое
- while (unsortedIcons.Any()) //пока есть хотябы 1 иконка в списке иконок
- {
- //int iconCount = (int)(Math.Abs(2 * maxIconsInLayer * Math.Abs(x) / MathHelper.Pi - maxIconsInLayer) + 1);
- float spaceY = MathHelper.TwoPi / iconCount; //шаг поворота вокруг оси у
- float y = 0; //изначальный поворов вокруг оси у
- int i = 0; //счетчик
- while (i < iconCount) //пока в слое остались иконки
- {
- var icon = unsortedIcons.ElementAtOrDefault(i);
- if (icon == null)
- break;
- positionSetter(icon, x, y); //установка иконки (полярные координаты (поворот вокруг х, поворот вокруг у, блина радиус-вектора))
- y += spaceY; //прибавляем к углу поворота его изменение
- i++; //изменяем счетчик
- }
- unsortedIcons = unsortedIcons.Skip(iconCount); //убираем из списка расставленные иконки
- if (x > 0) //если в верхней половинке шара
- {
- iconCount += 3; //кол-во иконок в след. слое на 3 больше
- }
- else
- {
- iconCount -= 3;
- }
- x -= spaceX; //изменяем угол поворота вокруг х
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement