/// ------------------------------------------------------------------------------------ static StandardAudioButtons() { PlayButtonImage = CreateMediaControlImage(ResourceImageCache.PlaySegment); StopButtonImage = CreateMediaControlImage(ResourceImageCache.StopSegment); HotPlayButtonImage = PaintingHelper.MakeHotImage(PlayButtonImage); HotStopButtonImage = PaintingHelper.MakeHotImage(StopButtonImage); }
/// ------------------------------------------------------------------------------------ protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); m_borderColor = (PaintingHelper.CanPaintVisualStyle() ? VisualStyleInformation.TextControlBorder : SystemColors.ControlDark); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Draws the button with an image. /// </summary> /// ------------------------------------------------------------------------------------ private void DrawArrow(PaintEventArgs e) { Rectangle rc = ClientRectangle; // If possible, render the button with visual styles. Otherwise, // paint the plain Windows 2000 push button. VisualStyleElement element = GetCorrectVisualStyleArrowElement(); if (PaintingHelper.CanPaintVisualStyle(element)) { VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawParentBackground(e.Graphics, rc, this); renderer.DrawBackground(e.Graphics, rc); return; } if (Font.SizeInPoints != 12) { Font = new Font(Font.FontFamily, 12, GraphicsUnit.Point); } ControlPaint.DrawButton(e.Graphics, rc, (m_state == PaintState.HotDown ? ButtonState.Pushed : ButtonState.Normal)); var arrowGlyph = Platform.IsWindows // In the Marlett font, '3' is the left arrow and '4' is the right. ? (m_drawLeftArrowButton ? "3" : "4") // Linux doesn't have the Marlett font, so use standard Unicode dingbats here. : (m_drawLeftArrowButton ? "\u25C4" : "\u25BA"); Color clr = (Enabled ? SystemColors.ControlText : SystemColors.GrayText); TextRenderer.DrawText(e.Graphics, arrowGlyph, Font, rc, clr, m_txtFmtflags); }
/// ------------------------------------------------------------------------------------ /// <summary> /// When the mouse is over the tab, draw a line across the top to hightlight the tab /// the mouse is over. /// </summary> /// ------------------------------------------------------------------------------------ private void DrawHoverIndicator(Graphics g) { if (!_mouseOver) { return; } var rc = ClientRectangle; var clr = (PaintingHelper.CanPaintVisualStyle() ? VisualStyleInformation.ControlHighlightHot : SystemColors.Highlight); // Draw the lines that only show when the mouse is over the tab. using (Pen pen = new Pen(clr)) { if (_selected) { g.DrawLine(pen, 3, 1, rc.Right - 4, 1); g.DrawLine(pen, 2, 2, rc.Right - 3, 2); } else { g.DrawLine(pen, 0, 0, rc.Right - 3, 0); g.DrawLine(pen, 0, 1, rc.Right - 3, 1); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Draws the button with an image. /// </summary> /// ------------------------------------------------------------------------------------ public void DrawArrow(PaintEventArgs e) { Rectangle rc = ClientRectangle; // If possible, render the button with visual styles. Otherwise, // paint the plain Windows 2000 push button. var element = GetCorrectVisualStyleArrowElement(); if (PaintingHelper.CanPaintVisualStyle(element)) { VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawParentBackground(e.Graphics, rc, this); renderer.DrawBackground(e.Graphics, rc); return; } if (Font.SizeInPoints != 12) { Font = new Font(Font.FontFamily, 12, GraphicsUnit.Point); } ControlPaint.DrawButton(e.Graphics, rc, (m_state == PaintState.HotDown ? ButtonState.Pushed : ButtonState.Normal)); // In the Marlette font, '3' is the left arrow and '4' is the right. string arrowGlyph = (m_drawLeftArrowButton ? "3" : "4"); Color clr = (Enabled ? SystemColors.ControlText : SystemColors.GrayText); // The 'r' in the Marlette font is the close button symbol 'X' TextRenderer.DrawText(e.Graphics, arrowGlyph, Font, rc, clr, FormatFlags); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnPaintBackground(PaintEventArgs e) { base.OnPaintBackground(e); if (m_mouseOver || Checked) { m_state = (m_mouseDown ? PaintState.HotDown : PaintState.Hot); } else { m_state = PaintState.Normal; } if (DrawBackground != null && DrawBackground(this, e, m_state)) { return; } Rectangle rc = ClientRectangle; using (SolidBrush br = new SolidBrush(BackColor)) e.Graphics.FillRectangle(br, rc); if (m_state != PaintState.Normal) { PaintingHelper.DrawHotBackground(e.Graphics, rc, m_state); } }
/// ------------------------------------------------------------------------------------ private void DrawHighlightedGridOrListViewItemBackground(Graphics g, Rectangle rc, bool selected) { var clrTop = (selected ? _selectedItemTopColor : _overrideHighlightTopColor); var clrBottom = (selected ? _selectedItemBottomColor : _overrideHighlightBottomColor); PaintingHelper.DrawGradientBackground(g, rc, clrTop, clrBottom, true); }
/// ------------------------------------------------------------------------------------ protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (_moreReliableDesignMode) { return; } _tableLayoutOuter.RowStyles.Clear(); _tableLayoutOuter.RowCount = 4; _tableLayoutOuter.RowStyles.Add(new RowStyle()); _tableLayoutOuter.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); _tableLayoutOuter.RowStyles.Add(new RowStyle(SizeType.Absolute, HeightOfTableLayoutButtonRow)); _tableLayoutOuter.RowStyles.Add(new RowStyle()); _normalPlayInSegmentButton = ResourceImageCache.ListenToSegment; _hotPlayInSegmentButton = PaintingHelper.MakeHotImage(_normalPlayInSegmentButton); _waveControl = CreateWaveControl(); InitializeZoomCombo(); // For efficiency, do this before initializing the wave control. InitializeWaveControl(); _waveControl.Dock = DockStyle.Fill; _panelWaveControl.Controls.Add(_waveControl); _waveControl.BringToFront(); _waveControl.FormatNotSupportedMessageProvider = waveFormat => { if (waveFormat.Channels > 2) { return(string.Format(LocalizationManager.GetString( "DialogBoxes.Transcription.SegmenterDlgBase.Segmenting3ChannelAudioFilesNotSupportedMsg", "Segmenting {0} channel audio files is not supported."), waveFormat.Channels)); } return(string.Format(LocalizationManager.GetString( "DialogBoxes.Transcription.SegmenterDlgBase.SegmentingAudioFormatNotSupportedMsg", "Segmenting {0} bit, {1} audio files is not supported."), waveFormat.BitsPerSample, waveFormat.Encoding)); }; _labelZoom.Font = Program.DialogFont; _labelSegmentXofY.Font = Program.DialogFont; _labelSegmentNumber.Font = Program.DialogFont; _labelTimeDisplay.Font = Program.DialogFont; _labelSourceRecording.Font = _undoToolStripMenuItem.Font = _ignoreToolStripMenuItem.Font = FontHelper.MakeFont(Program.DialogFont, FontStyle.Bold); _undoToolStripMenuItem.AutoSize = false; _ignoreToolStripMenuItem.AutoSize = false; _undoToolStripMenuItem.Width = _ignoreToolStripMenuItem.Width = Math.Max(_ignoreToolStripMenuItem.Width, _undoToolStripMenuItem.Width); _undoToolStripMenuItem.Height *= 2; _ignoreToolStripMenuItem.Height = _undoToolStripMenuItem.Height; HandleStringsLocalized(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle rc = ClientRectangle; if (m_insertMode || Capture) { PaintingHelper.DrawHotBackground(e.Graphics, rc, PaintState.Hot); if (m_labels.Count > 0 && m_insertMode) { DrawInsertionMarker(e.Graphics); } } else { m_insertPoint = new Point(0, rc.Bottom - 3); if (m_labels.Count > 0) { e.Graphics.FillRectangle(SystemBrushes.Control, rc); } else { // At this point, we know the panel is empty and the mouse isn't over it. // Therefore, fill in the background so the user can see there is something // here. Otherwise the panel would be invisible. Color clr1 = SystemColors.ControlDark; Color clr2 = ColorHelper.CalculateColor(Color.White, clr1, 30); using (LinearGradientBrush br = new LinearGradientBrush(rc, Color.White, clr2, 60)) e.Graphics.FillRectangle(br, rc); // Draw a border around the label. ControlPaint.DrawBorder(e.Graphics, rc, SystemColors.ButtonShadow, ButtonBorderStyle.Solid); } } // Put the word "Empty" (or localized equivalent) in the panel when // it doesn't yet contain a search pattern. if (m_labels.Count == 0) { using (Font fnt = new Font(FontHelper.UIFont.Name, 8, GraphicsUnit.Point)) using (StringFormat sf = STUtils.GetStringFormat(true)) { e.Graphics.DrawString(Properties.Resources.kstidEmptySearchPatternText, fnt, SystemBrushes.ControlText, rc, sf); } if (!m_insertMode && m_tooltip.GetToolTip(this) != m_emptyPatternTooltip) { m_tooltip.SetToolTip(this, m_emptyPatternTooltip); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="HoverCueTextBox"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public HoverCueTextBox() { DynamicBorder = true; HoverBorderColor = (PaintingHelper.CanPaintVisualStyle() ? VisualStyleInformation.TextControlBorder : SystemColors.ControlDarkDark); InitializeComponent(); _txtBox.BackColor = BackColor; SetStyle(ControlStyles.UseTextForAccessibility, true); SizeChanged += HandleSizeChanged; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Catch the non client area paint message so we can paint a border that isn't black. /// </summary> /// ------------------------------------------------------------------------------------ protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == PaintingHelper.WM_NCPAINT && m_overrideBorderDrawing) { PaintingHelper.DrawCustomBorder(this, m_borderColor); m.Result = IntPtr.Zero; m.Msg = 0; } }
/// ------------------------------------------------------------------------------------ protected override void OnPaintBackground(PaintEventArgs e) { if (m_colorTop == Color.Empty && m_colorBottom == Color.Empty) { PaintingHelper.DrawGradientBackground(e.Graphics, ClientRectangle, m_dark); } else { PaintingHelper.DrawGradientBackground(e.Graphics, ClientRectangle, m_colorTop, m_colorBottom); } DrawBottomBorder(e); }
/// ------------------------------------------------------------------------------------ protected override void OnPaintBackground(PaintEventArgs e) { base.OnPaintBackground(e); if (!PaintingHelper.CanPaintVisualStyle()) { ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle); } else { var renderer = new VisualStyleRenderer(GetVisualStyleTextBox()); renderer.DrawBackground(e.Graphics, ClientRectangle); } }
/// ------------------------------------------------------------------------------------ protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var rc = ClientRectangle; rc.Height--; rc.Width--; var clr = (PaintingHelper.CanPaintVisualStyle() ? VisualStyleInformation.TextControlBorder : Color.Gray); using (var pen = new Pen(clr)) e.Graphics.DrawRectangle(pen, rc); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnPaintBackground(PaintEventArgs e) { if (!DesignMode && m_paintExplorerBarBackground) { VisualStyleElement element = VisualStyleElement.ExplorerBar.NormalGroupBackground.Normal; if (PaintingHelper.CanPaintVisualStyle(element)) { VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawBackground(e.Graphics, ClientRectangle); return; } } base.OnPaintBackground(e); }
/// ------------------------------------------------------------------------------------ public EnhancedPanel() { ClipTextForChildControls = true; DoubleBuffered = true; SetStyle(ControlStyles.UseTextForAccessibility, true); base.Font = FontHelper.UIFont; m_rcText = ClientRectangle; ForeColor = SystemColors.ControlText; BorderStyle = (Application.VisualStyleState == VisualStyleState.NoneEnabled ? BorderStyle.Fixed3D : BorderStyle.FixedSingle); m_borderColor = (PaintingHelper.CanPaintVisualStyle() ? VisualStyleInformation.TextControlBorder : SystemColors.ControlDark); }
/// ------------------------------------------------------------------------------------ private void DrawButtonBackground(Graphics g) { var rc = Button.ClientRectangle; if (!_gradientButton || ButtonBackColor == Color.Empty || ButtonBackColor == Color.Transparent) { using (var br = new SolidBrush(BackColor)) g.FillRectangle(br, rc); } else { PaintingHelper.DrawGradientBackground(g, rc); //using (var br = new LinearGradientBrush(rc, BackColor, ButtonBackColor, 91f)) // g.FillRectangle(br, rc); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Draws the expand or collapse glyph. The glyph drawn depends on the visible state /// of the hosted control. /// </summary> /// ------------------------------------------------------------------------------------ private void DrawExpandCollapseGlyph(Graphics g) { // Determine the rectangle in which the expanding/collapsing button will be drawn. Rectangle rc = new Rectangle(0, 0, m_glyphButtonWidth, m_button.Height); if (RightToLeft == RightToLeft.No) { rc.X = (m_button.ClientRectangle.Right - rc.Width); } VisualStyleElement element; if (m_drawHot) { element = (m_control.Visible ? VisualStyleElement.ExplorerBar.NormalGroupCollapse.Hot : VisualStyleElement.ExplorerBar.NormalGroupExpand.Hot); } else { element = (m_control.Visible ? VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal : VisualStyleElement.ExplorerBar.NormalGroupExpand.Normal); } if (PaintingHelper.CanPaintVisualStyle(element)) { VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawBackground(g, rc); } else { Image glyph = (m_expanded ? Properties.Resources.kimidExplorerBarCollapseGlyph : Properties.Resources.kimidExplorerBarEpandGlyph); if (RightToLeft == RightToLeft.No) { rc.X = rc.Right - (glyph.Width + 1); } rc.Y += (m_button.Height - glyph.Height) / 2; rc.Width = glyph.Width; rc.Height = glyph.Height; g.DrawImage(glyph, rc); } }
/// ------------------------------------------------------------------------------------ public AmbiguousSequencesDlg() { InitializeComponent(); if (!PaintingHelper.CanPaintVisualStyle()) { pnlGrid.BorderStyle = BorderStyle.Fixed3D; } BuildGrid(); _grid.Columns["seq"].DefaultCellStyle.Font = App.PhoneticFont; _grid.Columns["seq"].CellTemplate.Style.Font = App.PhoneticFont; _grid.Columns["base"].DefaultCellStyle.Font = App.PhoneticFont; _grid.Columns["base"].CellTemplate.Style.Font = App.PhoneticFont; _grid.Columns["cvpattern"].DefaultCellStyle.Font = App.PhoneticFont; _grid.Columns["cvpattern"].CellTemplate.Style.Font = App.PhoneticFont; }
/// ------------------------------------------------------------------------------------ public TranscriptionChangesDlg() { InitializeComponent(); if (!PaintingHelper.CanPaintVisualStyle()) { pnlGrid.BorderStyle = BorderStyle.Fixed3D; } m_transChangeCtrl = new TranscriptionChangesControl(); m_transChangeCtrl.BorderStyle = BorderStyle.None; m_transChangeCtrl.Dock = DockStyle.Fill; m_transChangeCtrl.TabIndex = 0; m_transChangeCtrl.Grid.RowsAdded += HandleExperimentalTransCtrlRowsAdded; pnlGrid.Controls.Add(m_transChangeCtrl); m_transChangeCtrl.Grid.AdjustGridRows( Properties.Settings.Default.TranscriptionChangesDlgGridExtraRowHeight); App.AddMediatorColleague(this); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Draw a background that looks like a list view header. /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnPaintBackground(PaintEventArgs e) { Rectangle rc = ClientRectangle; e.Graphics.FillRectangle(SystemBrushes.Window, rc); VisualStyleElement element = VisualStyleElement.Header.Item.Normal; // Draw the background, preferrably using visual styles. if (!PaintingHelper.CanPaintVisualStyle(element)) { ControlPaint.DrawButton(e.Graphics, rc, ButtonState.Normal); } else { // Add 2 so the separator that's drawn at the right // side of normal list resultView header isn't visible. rc.Width += 2; if (m_showWindowBackgroudOnTopAndRightEdge) { // Shrink the rectangle so the top and left // edge window background don't get clobbered. rc.Height--; rc.Y++; rc.X++; } VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawBackground(e.Graphics, rc); if (m_showWindowBackgroudOnTopAndRightEdge) { // Draw a window background color line down the right edge. rc = ClientRectangle; e.Graphics.DrawLine(SystemPens.Window, new Point(rc.Width - 1, 0), new Point(rc.Width - 1, rc.Bottom)); } } }
/// ------------------------------------------------------------------------------------ private void HandleButtonPaint(object sender, PaintEventArgs e) { var rc = _panelButton.ClientRectangle; var element = GetVisualStyleComboButton(); if (!PaintingHelper.CanPaintVisualStyle()) { var state = ButtonState.Normal; if (element == VisualStyleElement.ComboBox.DropDownButton.Pressed) { state = ButtonState.Pushed; } if (!Enabled) { state |= ButtonState.Inactive; } ControlPaint.DrawComboButton(e.Graphics, rc, state); return; } if (element != VisualStyleElement.ComboBox.DropDownButton.Normal) { var renderer = new VisualStyleRenderer(element); renderer.DrawBackground(e.Graphics, rc); } else { var x = (int)Math.Round((rc.Width - 7) / 2f, MidpointRounding.AwayFromZero); var y = (int)Math.Round((rc.Height - 4) / 2f, MidpointRounding.AwayFromZero); e.Graphics.DrawLine(SystemPens.WindowText, x, y, x + 6, y++); e.Graphics.DrawLine(SystemPens.WindowText, x + 1, y, x + 5, y++); e.Graphics.DrawLine(SystemPens.WindowText, x + 2, y, x + 4, y); e.Graphics.DrawLine(SystemPens.WindowText, x + 3, y, x + 3, y + 1); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Draws the button in the cell. /// </summary> /// ------------------------------------------------------------------------------------ private void DrawButton(Graphics g, Rectangle rcbtn, int rowIndex) { if (!InternalShowButton(rowIndex)) { return; } bool paintComboButton = (OwningButtonColumn == null ? false : OwningButtonColumn.UseComboButtonStyle); VisualStyleElement element = (paintComboButton ? GetVisualStyleComboButton() : GetVisualStylePushButton()); if (PaintingHelper.CanPaintVisualStyle(element)) { VisualStyleRenderer renderer = new VisualStyleRenderer(element); if (!OwningButtonColumn.DrawDefaultComboButtonWidth) { renderer.DrawBackground(g, rcbtn); } else { Rectangle rc = rcbtn; Size sz = renderer.GetPartSize(g, rc, ThemeSizeType.True); rc.Width = sz.Width + 2; rc.X = (rcbtn.Right - rc.Width); renderer.DrawBackground(g, rc); } } else { ButtonState state = (m_mouseDownOnButton && m_mouseOverButton && m_enabled ? ButtonState.Pushed : ButtonState.Normal); if (!m_enabled) { state |= ButtonState.Inactive; } if (paintComboButton) { ControlPaint.DrawComboButton(g, rcbtn, state); } else { ControlPaint.DrawButton(g, rcbtn, state); } } string buttonText = (OwningButtonColumn == null ? null : OwningButtonColumn.ButtonText); if (string.IsNullOrEmpty(buttonText)) { return; } Font buttonFont = (OwningButtonColumn == null ? SystemInformation.MenuFont : OwningButtonColumn.ButtonFont); // Draw text TextFormatFlags flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.NoPrefix | TextFormatFlags.EndEllipsis | TextFormatFlags.NoPadding | TextFormatFlags.PreserveGraphicsClipping; Color clrText = (m_enabled ? SystemColors.ControlText : SystemColors.GrayText); TextRenderer.DrawText(g, buttonText, buttonFont, rcbtn, clrText, flags); }