using System.Drawing; using System.Windows; using InABox.WPF; using Syncfusion.Windows.Controls.Cells; using Syncfusion.Windows.Controls.Grid; using Image = System.Windows.Controls.Image; namespace PRSDesktop.Utils { internal class GridUtils { public static void SetButtonImage(GridStyleInfo style, Bitmap bitmap, GridModel model, int column) { if (bitmap == null) return; style.Image = new Image { Source = bitmap.AsBitmapImage() }; style.ImageContentStretch = ImageContentStretch.Absolute; var MaxHeight = model.RowHeights.DefaultLineSize; var MaxWidth = model.ColumnWidths[column]; var size = (MaxHeight > MaxWidth ? MaxWidth : MaxHeight) * 0.66; style.ImageHeight = new GridLength(size); style.ImageWidth = new GridLength(size); var VMargin = (MaxHeight - size) / 40; var HMargin = (MaxWidth - size) / 2; style.ImageMargins = new CellMarginsInfo(HMargin, VMargin, MaxWidth - HMargin, MaxHeight - VMargin); style.ReadOnly = true; //style.HorizontalAlignment = HorizontalAlignment.Center; //style.VerticalAlignment = VerticalAlignment.Center; } } }