def on_paint(self, sender, e): if self.snip_enabled and self.snip_rectangle is not None: br = SolidBrush(Color.FromArgb(120, Color.White)) rc = self.snip_rectangle pen = Pen(Color.Red, 3.0) x1 = rc.X x2 = rc.X + rc.Width y1 = rc.Y y2 = rc.Y + rc.Height e.Graphics.FillRectangle(br, Rectangle(0, 0, x1, self.Height)) e.Graphics.FillRectangle( br, Rectangle(x2, 0, self.Width - x2, self.Height)) e.Graphics.FillRectangle(br, Rectangle(x1, 0, x2 - x1, y1)) e.Graphics.FillRectangle( br, Rectangle(x1, y2, x2 - x1, self.Height - y2)) e.Graphics.DrawRectangle(pen, rc)
def __init__(self, moduleManager, contents): ListBox.__init__(self) self.moduleManager = moduleManager # behaviour self.LabelEdit = False self.MultiSelect = False # appearance self.Dock = DockStyle.Fill self.ScrollAlwaysVisible = True self.TabIndex = 0 self.HideSelection = False # Keep selected item grey when lost focus self.textBrush = SolidBrush(SystemColors.WindowText) self.icon = Bitmap(UIGlobal.ModuleIcon) self.DrawMode = DrawMode.OwnerDrawVariable self.DrawItem += self.OnDrawItem self.MeasureItem += self.OnMeasureItem self.UpdateAllItems(contents)
def OnPaint(self, event): g = event.Graphics self.LocateRect() brush = SolidBrush(self.color) g.FillRectangle(brush, self.r)