private void DevicesDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }
            var grid   = (DataGridView)sender;
            var row    = grid.Rows[e.RowIndex];
            var column = grid.Columns[e.ColumnIndex];
            var item   = (UserDevice)row.DataBoundItem;

            if (column == IsOnlineColumn)
            {
                e.Value = item.IsOnline
                                        ? Properties.Resources.bullet_square_glass_green
                                        : Properties.Resources.bullet_square_glass_grey;
            }
            else if (column == ConnectionClassColumn)
            {
                e.Value = item.ConnectionClass == Guid.Empty
                                        ? new Bitmap(16, 16)
                                        : DeviceDetector.GetClassIcon(item.ConnectionClass, 16)?.ToBitmap();
            }
            else if (column == DeviceIdColumn)
            {
                var d = item.Device;
                if (d != null)
                {
                }
                //e.Value = item.de
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var bm = (Guid)value == Guid.Empty
                                ? new Bitmap(32, 32)
                                : DeviceDetector.GetClassIcon((Guid)value, 32)?.ToBitmap();
            var img = ControlsHelper.GetImageSource(bm);

            return(img);
        }
示例#3
0
        public static ImageSource Convert(Guid value)
        {
            var bm = value == Guid.Empty
                                ? new Bitmap(32, 32)
                                : DeviceDetector.GetClassIcon(value, 32)?.ToBitmap();
            var img = ControlsHelper.GetImageSource(bm);

            return(img);
        }
示例#4
0
        private void DevicesDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            var grid   = (DataGridView)sender;
            var row    = grid.Rows[e.RowIndex];
            var column = grid.Columns[e.ColumnIndex];
            var item   = (UserDevice)row.DataBoundItem;

            if (column == IsOnlineColumn)
            {
                e.Value = item.IsOnline
                                        ? Properties.Resources.bullet_square_glass_green
                                        : Properties.Resources.bullet_square_glass_grey;
            }
            else if (column == ConnectionClassColumn)
            {
                e.Value = item.ConnectionClass == Guid.Empty
                                        ? new Bitmap(16, 16)
                                        : DeviceDetector.GetClassIcon(item.ConnectionClass, 16)?.ToBitmap();
            }
            else if (column == IsHiddenColumn)
            {
                var left = row.Cells[e.ColumnIndex].OwningColumn.Width;
                // Show checkbox.
                if (item.AllowHide && e.CellStyle.Padding.Left >= 0)
                {
                    e.CellStyle.Padding = new Padding();
                }
                // Hide checkbox (move out of the sight).
                if (!item.AllowHide && e.CellStyle.Padding.Left == 0)
                {
                    e.CellStyle.Padding = new Padding(left, 0, 0, 0);
                }
            }
            else if (column == DeviceIdColumn)
            {
                var d = item.Device;
                if (d != null)
                {
                }
                //e.Value = item.de
            }
        }