protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (Enabled) { if (_TxBackColor != ButtonColor) { using (GraphicsPath path = BtnRenderer.GetRoundedRect(_TxRect, _BtnInfo.CornerRadius)) using (Brush brush = new SolidBrush(Color.FromArgb(VisualStyle.UseModernStyle ? 175 : 255, _TxBackColor))) { e.Graphics.FillPath(brush, path); } //BtnRenderer.DrawString(e.Graphics, ClientRectangle, _TxBackColor, BtnState, Text, Font, ContentAlignment.TopCenter, ForeColor); } if (_RxBackColor != ButtonColor) { using (GraphicsPath path = BtnRenderer.GetRoundedRect(_RxRect, _BtnInfo.CornerRadius)) using (Brush brush = new SolidBrush(Color.FromArgb(VisualStyle.UseModernStyle ? 175 : 255, _RxBackColor))) { e.Graphics.FillPath(brush, path); } } } using (Pen linePen = new Pen(Enabled ? _BtnInfo.GetBorderColor(BtnState.Normal) : _BtnInfo.GetBorderColor(BtnState.Inactive), 2)) { e.Graphics.DrawLine(linePen, 1, _RxRect.Top - 2, Width - 3, _RxRect.Top - 2); } if (_DrawX) { using (Pen p = new Pen(Color.Red, 5)) { e.Graphics.DrawLine(p, 6, 6, Width - 6, Height - 6); e.Graphics.DrawLine(p, Width - 6, 6, 6, Height - 6); } } BtnRenderer.DrawString(e.Graphics, ClientRectangle, _TxBackColor, BtnState, Text, Font, ContentAlignment.TopCenter, ForeColor); }
protected override void OnPaint(PaintEventArgs e) { // base.OnPaint(e); BtnState st = !Enabled ? BtnState.Inactive : (_State == BtnState.Pushed) && _AllAsOneBt ? BtnState.Pushed : BtnState.Normal; BtnState stBT1 = !Enabled || _StateBT1 == BtnState.Inactive ? BtnState.Inactive : (_StateBT1 == BtnState.Pushed) || (st == BtnState.Pushed) ? BtnState.Pushed : (_StateBT1 == BtnState.MouseOver) && !_AllAsOneBt ? BtnState.MouseOver : BtnState.Normal; BtnState stBT2 = !Enabled ? BtnState.Inactive : (_StateBT2 == BtnState.Pushed) || (st == BtnState.Pushed) ? BtnState.Pushed : (_StateBT2 == BtnState.MouseOver) && !_AllAsOneBt ? BtnState.MouseOver : BtnState.Normal; BtnRenderer.Draw(e.Graphics, _BtnInfo[st]); //Pintar PTT if (_PttImage != null) { e.Graphics.DrawImage(_PttImage, _PttRect.X, _PttRect.Y); } //Pintar Squlech if (_SquelchImage != null) { e.Graphics.DrawImage(_SquelchImage, _SquelchRect.X, _SquelchRect.Y); if (_QidxValue >= 0) { Rectangle txtRect = ClientRectangle; txtRect.Offset(32, 2); BtnRenderer.DrawString(e.Graphics, txtRect, Color.Transparent, st, _QidxValue.ToString(), _SmallFontBold, ContentAlignment.TopCenter, Color.Black); } } BtnRenderer.Draw(e.Graphics, _TxBtnInfo[stBT1]); BtnRenderer.Draw(e.Graphics, _RxBtnInfo[stBT2]); //Para pintar los fuera de servicio if (_DrawX) { using (Pen p = new Pen(Color.Red, 3)) { e.Graphics.DrawLine(p, 6, 38, Width - 6, Height - 6); e.Graphics.DrawLine(p, Width - 6, 38, 6, Height - 6); } } Rectangle textRect = ClientRectangle; textRect.Offset(0, -5); BtnRenderer.DrawString(e.Graphics, textRect, _BtnInfo.GetBackColor(st), st, _Frecuency, _SmallFontBold, ContentAlignment.TopCenter, ForeColor); textRect.Offset(0, 13); BtnRenderer.DrawString(e.Graphics, textRect, _BtnInfo.GetBackColor(st), st, _Alias, _SmallFont, ContentAlignment.TopCenter, ForeColor); if (_RtxGroup > 0) { string rtxGroup = ((char)('G' + _RtxGroup - 1)).ToString(); e.Graphics.DrawString(rtxGroup, _SmallFontBold, Brushes.Black, 3, _TxBtnInfo.Rect.Top - 15); } else if (_RtxGroup == -1) { e.Graphics.DrawString("R", _SmallFontBold, Brushes.Black, Width - 15, _TxBtnInfo.Rect.Top - 15); } using (Pen linePen = new Pen(Enabled ? _BtnInfo.GetBorderColor(BtnState.Normal) : _BtnInfo.GetBorderColor(BtnState.Inactive), 2)) { e.Graphics.DrawLine(linePen, 1, _TxBtnInfo.Rect.Top, Width - 1, _TxBtnInfo.Rect.Top); } }
protected override void OnPaint(PaintEventArgs e) { // base.OnPaint(e); BtnState st = !Enabled ? BtnState.Inactive : (_State == BtnState.Pushed) && _AllAsOneBt ? BtnState.Pushed : BtnState.Normal; BtnState stBT1 = !Enabled || _StateBT1 == BtnState.Inactive ? BtnState.Inactive : (_StateBT1 == BtnState.Pushed) || (st == BtnState.Pushed) ? BtnState.Pushed : (_StateBT1 == BtnState.MouseOver) && !_AllAsOneBt? BtnState.MouseOver : BtnState.Normal; BtnState stBT2 = !Enabled ? BtnState.Inactive : (_StateBT2 == BtnState.Pushed) || (st == BtnState.Pushed) ? BtnState.Pushed : (_StateBT2 == BtnState.MouseOver) && !_AllAsOneBt ? BtnState.MouseOver : BtnState.Normal; BtnRenderer.Draw(e.Graphics, _BtnInfo[st]); if (_PttImage != null) { #if DEBUG1 e.Graphics.DrawImage(_PttImage, _PttRect); #else e.Graphics.DrawImage(_PttImage, _PttRect.X, _PttRect.Y); #endif } if (_SquelchImage != null) { #if DEBUG1 e.Graphics.DrawImage(_SquelchImage, _SquelchRect); #else e.Graphics.DrawImage(_SquelchImage, _SquelchRect.X, _SquelchRect.Y); #endif if (_QidxValue >= 0) { Rectangle txtRect = ClientRectangle; txtRect.Offset(32, 2); BtnRenderer.DrawString(e.Graphics, txtRect, Color.Transparent, st, _QidxValue.ToString(), _MediumFontBold, ContentAlignment.TopCenter, Color.Black); } } BtnRenderer.Draw(e.Graphics, _TxBtnInfo[stBT1]); BtnRenderer.Draw(e.Graphics, _RxBtnInfo[stBT2]); if (_DrawX) { using (Pen p = new Pen(Color.Red, 5)) { e.Graphics.DrawLine(p, 6, 6, Width - 6, Height - 6); e.Graphics.DrawLine(p, Width - 6, 6, 6, Height - 6); } } Rectangle textRect = ClientRectangle; /** 20180608. Las frecuencias con ID de mas de 7 Caracteres utilizan un FONT ligeramente inferior */ #if DEBUG1 textRect.Offset(0, -5); //_Frecuency = _Frecuency=="125.200" ? "EMERGENCIA" : _Frecuency; Font fontToUse = _Frecuency.Length > 7 ? _SmallFontBold1 : _MediumFontBold; BtnRenderer.DrawString(e.Graphics, textRect, _BtnInfo.GetBackColor(st), st, _Frecuency, fontToUse, ContentAlignment.TopCenter, ForeColor); #else textRect.Offset(0, -5); Font fontToUse = _Frecuency.Length > 7 ? _SmallFontBold1 : _MediumFontBold; if (global::HMI.Model.Module.Properties.Settings.Default.BigFonts) { fontToUse = _BigFont; } BtnRenderer.DrawString(e.Graphics, textRect, _BtnInfo.GetBackColor(st), st, _Frecuency, fontToUse, ContentAlignment.TopCenter, ForeColor); #endif if (global::HMI.Model.Module.Properties.Settings.Default.BigFonts) { fontToUse = _MediumFontBold2; textRect.Offset(0, 20); } else { textRect.Offset(0, 13); fontToUse = _SmallFont; } BtnRenderer.DrawString(e.Graphics, textRect, _BtnInfo.GetBackColor(st), st, _Alias, fontToUse, ContentAlignment.TopCenter, ForeColor); if (_RtxGroup > 0) { string rtxGroup = ((char)('G' + _RtxGroup - 1)).ToString(); e.Graphics.DrawString(rtxGroup, _MediumFontBold, Brushes.Black, 3, _TxBtnInfo.Rect.Top - 15); } else if (_RtxGroup == -1) { e.Graphics.DrawString("R", _MediumFontBold, Brushes.Black, Width - 15, _TxBtnInfo.Rect.Top - 15); } using (Pen linePen = new Pen(Enabled ? _BtnInfo.GetBorderColor(BtnState.Normal) : _BtnInfo.GetBorderColor(BtnState.Inactive), 2)) { e.Graphics.DrawLine(linePen, 1, _TxBtnInfo.Rect.Top, Width - 1, _TxBtnInfo.Rect.Top); } }