Example #1
0
        public void PlaceWidget(WidgetControl widget)
        {
            var     colSpan = Grid.GetColumnSpan(widget);
            AppCell cell    = App.WindowManager.Matrix.GetFreeCell(colSpan);

            Grid.SetColumn(widget, (int)cell.Column);
            Grid.SetRow(widget, (int)cell.Row);
            widget.HorizontalAlignment = HorizontalAlignment.Right;
            App.WindowManager.Matrix.ReserveSpace(cell.Column, cell.Row, colSpan);
            widget.Width  = colSpan * Envi.MinTileWidth - Envi.TileSpacing * 2;
            widget.Height = Envi.MinTileHeight - Envi.TileSpacing * 2;
        }
 /// <summary>
 /// Finds free cell with enough horizontal space
 /// </summary>
 /// <param name="length">Required horizontal space</param>
 /// <returns>Index of cell where widget can be placed. If there is no free cell, returns -1.</returns>
 public AppCell GetFreeCell(int length)
 {
     for (var i = 0; i < maxCols; i++) //looks up in columns
     {
         var index = GetFreeRow(i, length);
         if (index != -1)
         {
             var cell = new AppCell(i, index);
             return cell;
         }
     }
     return new AppCell(-1, -1);
 }