private void Extent_Click(object sender, EventArgs e) { VisualDiskExtent selectedExtent = (VisualDiskExtent)((CheckBox)sender).Tag; ApplyExtentSelection(selectedExtent); UncheckUnselectedDisks(null); }
private void Extent_Paint(object sender, PaintEventArgs e) { CheckBox chkExtent = (CheckBox)sender; VisualDiskExtent extent = (VisualDiskExtent)chkExtent.Tag; Brush brush = DiskStyling.GetVolumeBrush(extent.Volume); int bannerLocationX = 1; int bannerLocationY = 2; int bannerWidth = chkExtent.Width - bannerLocationX - 2; int bannerTextLocationX = 2; int bannerTextLocationY = 0; if (chkExtent.Checked) { bannerLocationX++; bannerLocationY++; bannerTextLocationX++; bannerTextLocationY++; } e.Graphics.FillRectangle(brush, bannerLocationX, bannerLocationY, bannerWidth, ExtentBannerHeight); string typeString = VolumeHelper.GetVolumeTypeString(extent.Volume); if (extent.Volume == null) { typeString = "Free"; } Font font = new Font(chkExtent.Font.FontFamily, 7); Brush bannerTextBrush = Brushes.White; if (extent.Volume is Raid5Volume) { bannerTextBrush = Brushes.Black; } e.Graphics.DrawString(typeString, font, bannerTextBrush, bannerTextLocationX, bannerTextLocationY); }
private void ApplyExtentSelection(VisualDiskExtent selectedExtent) { foreach (CheckBox extentCheckbox in m_extentCheckboxes) { VisualDiskExtent extent = (VisualDiskExtent)extentCheckbox.Tag; extentCheckbox.Checked = (selectedExtent != null) && (extent == selectedExtent || (extent.Volume != null && extent.Volume == selectedExtent.Volume)); } }
private void Extent_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { VisualDiskExtent selectedExtent = (VisualDiskExtent)((CheckBox)sender).Tag; ApplyExtentSelection(selectedExtent); UncheckUnselectedDisks(null); if (ExtentRightClick != null) { Point checkBoxLocation = ((CheckBox)sender).Location; Point location = new Point(checkBoxLocation.X + e.X, checkBoxLocation.Y + e.Y); ExtentRightClick(this, new ExtentRightClickEventArgs(selectedExtent.Extent, selectedExtent.Volume, location)); } } }
public void PopulateView(List <Disk> disks) { CleanView(); long largestDiskSize = 0; for (int diskIndex = 0; diskIndex < disks.Count; diskIndex++) { Disk disk = disks[diskIndex]; CheckBox chkDisk = new CheckBox(); chkDisk.Appearance = Appearance.Button; chkDisk.Text = DiskLabelHelper.GetDiskLabel(disk, diskIndex); int locationY = diskIndex * (DiskHeight + 2); chkDisk.Location = new Point(0, locationY); chkDisk.Width = DiskButtonWidth; chkDisk.Height = DiskHeight; chkDisk.Padding = new Padding(0, ExtentBannerHeight + ExtentPaddingTop, 0, 0); chkDisk.TextAlign = ContentAlignment.TopLeft; chkDisk.Tag = disk; chkDisk.Click += new EventHandler(Disk_Click); chkDisk.MouseUp += new MouseEventHandler(Disk_MouseUp); this.Controls.Add(chkDisk); m_diskCheckboxes.Add(chkDisk); if (disk.Size > largestDiskSize) { largestDiskSize = disk.Size; } } List <VisualDiskExtent> extents = VisualDiskHelper.GetVisualExtents(disks); for (int diskIndex = 0; diskIndex < disks.Count; diskIndex++) { Disk disk = disks[diskIndex]; int diskWidth = (int)VisualDiskHelper.Scale(disk.Size, largestDiskSize, LargestDiskWidth); List <VisualDiskExtent> diskExtents = VisualDiskExtentHelper.GetFiltered(extents, diskIndex); VisualDiskExtentHelper.SortExtentsByFirstSector(diskExtents); List <int> widthEntries = VisualDiskExtentHelper.DistributeWidth(diskExtents, diskWidth); int locationX = DiskButtonWidth + 2; for (int extentIndex = 0; extentIndex < diskExtents.Count; extentIndex++) { VisualDiskExtent extent = diskExtents[extentIndex]; CheckBox chkExtent = new CheckBox(); chkExtent.Appearance = Appearance.Button; int extentWidth = widthEntries[extentIndex]; if (extentWidth > 20) { chkExtent.Text = DiskLabelHelper.GetExtentLabel(extent.Volume, extent.Extent, extentWidth); } if (extentWidth < 50) { chkExtent.Font = new Font(chkExtent.Font.FontFamily, 6.5f); } int locationY = extent.VisualDiskIndex * (DiskHeight + 2); Rectangle extentRect = new Rectangle(locationX, locationY, extentWidth, DiskHeight); locationX += extentWidth; if (extent.Volume == null) { //chkExtent.BackColor = Color.FromArgb(214, 211, 208); } chkExtent.Location = extentRect.Location; chkExtent.Width = extentRect.Width; chkExtent.Height = extentRect.Height; chkExtent.Padding = new Padding(0, ExtentBannerHeight + ExtentPaddingTop, 0, 0); chkExtent.TextAlign = ContentAlignment.TopLeft; chkExtent.Tag = extent; chkExtent.Click += new EventHandler(Extent_Click); chkExtent.MouseUp += new MouseEventHandler(Extent_MouseUp); chkExtent.Paint += new PaintEventHandler(Extent_Paint); this.Controls.Add(chkExtent); m_extentCheckboxes.Add(chkExtent); } } }