private void AddObject(Element thisElement) { FileExplorerObject element = thisElement.feobject; double tempWidth = Field.RenderSize.Width; if (savedWidth != tempWidth) { RepaintGrid(); savedWidth = tempWidth; // rendered width of Grid we use to display elements } int amount = elements.Count(); // count all elements displayed int column = ((amount + 1) % amountInRow) - 1; // calculate number of column of element if (column < 0) { column = 0; } int row = (int)Math.Truncate((double)((amount + 1) / amountInRow)); // calculate number of row of element //element.Margin = new Thickness((objectWidth + margin) * column, (objectHeight + margin) * row, 0, 0); elements.Add(new Element(amount + 1, row, column, element)); Grid.SetColumn(element, column); Grid.SetRow(element, row); Field.Children.Add(element); }
public Element(int number, int row, int column, FileExplorerObject feobject) { this.number = number; this.row = row; this.column = column; this.feobject = feobject; }