protected override void OnPaint(PaintEventArgs pevent) { if (this.TipButon != EnumTipButon.MeniuStanga) { Graphics g = pevent.Graphics; Rectangle newRect = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height); Rectangle rectUtil = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1); if (this.Parent != null) { using (Brush fundal = new SolidBrush(this.Parent.BackColor)) { g.FillRectangle(fundal, ClientRectangle); } } using (GraphicsPath path = DreptunghiRotunjit.Create(rectUtil, 3, DreptunghiRotunjit.RectangleCorners.All)) { SizeF textSize = g.MeasureString(this.Text, base.Font); int textX = (int)(base.Size.Width / 2) - (int)(textSize.Width / 2); int textY = (int)(base.Size.Height / 2) - (int)(textSize.Height / 2); g.SmoothingMode = SmoothingMode.HighQuality; //Coloram dreptunghiul vizibil la ecran - fol culoarea de fundal a parintelui if (this.Parent != null) { using (Brush pensulaParinte = new SolidBrush(this.Parent.BackColor)) { g.FillRectangle(pensulaParinte, newRect); } } //Coloram interiorul using (Brush Pensula = new LinearGradientBrush(newRect, getCuloareInchisa(), getCuloareDeschisa(), LinearGradientMode.Vertical)) { if (this.lButtonType == EnumTipButon.InchidereEcran || this.lButtonType == EnumTipButon.Minimizare) { g.FillRectangle(Pensula, newRect); } else { g.FillPath(Pensula, path); } } //Desenam marginile if (this.lButtonType == EnumTipButon.InchidereEcran || this.lButtonType == EnumTipButon.Minimizare) { g.DrawRectangle((this.lButonActiv ? Pens.DarkGray : Pens.Black), newRect.X, newRect.Y, newRect.Width - 1, newRect.Height - 1); } else { if (IHMUtile.PENSULA_CHENAR_SELECTAT != null && IHMUtile.PENSULA_CHENAR != null) { g.DrawPath((this.lButonActiv ? IHMUtile.PENSULA_CHENAR_SELECTAT : IHMUtile.PENSULA_CHENAR), path); } } //Pentru a redesena doar zona asta g.SetClip(path); if (base.Image != null || base.BackgroundImage != null) { bool disposeImage = false; Image lImagineDesen = getImage(ref disposeImage); if (lImagineDesen != null) { g.DrawImage(lImagineDesen, getPunctDesenareImagine(lImagineDesen)); } if (disposeImage) { lImagineDesen.Dispose(); lImagineDesen = null; } } Color culoareText = base.ForeColor; if (!this.Enabled) { culoareText = getCuloareInchisa(); } if (this.lButtonType == EnumTipButon.InchidereEcran || this.lButtonType == EnumTipButon.Minimizare) { culoareText = Color.White; } if (!string.IsNullOrEmpty(this.Text)) { using (Brush pensulaC = new SolidBrush(culoareText)) { g.DrawString(this.Text, base.Font, pensulaC, textX, textY); } } //Daca avem tooltip activ atunci desenam butonul de info if (this.AfiseazaImagineSemnalizareToolTip && this.UtilizeazaToolTip) { g.DrawImage(Imagini.getImagineInformatii(), new Rectangle(newRect.X + (newRect.Width - 18), newRect.Y + (newRect.Height - 16) / 2, 16, 16)); } g.ResetClip(); } } else { base.OnPaint(pevent); } }
/// <summary> /// Formatam butonul in concordanta cu tipul si modul acestuia /// </summary> private void FormateazaButon() { switch (this.lButtonType) { case EnumTipButon.InchidereEcran: this.Image = null; this.Text = "X"; break; case EnumTipButon.Minimizare: this.Image = null; this.Text = "_"; break; case EnumTipButon.Istoric: this.Image = null; this.Text = "H"; this.Size = new Size(23, 23); break; case EnumTipButon.Ajutor: this.Image = CCL.UI.Imagini.getImagineHelp(); this.Text = ""; break; case EnumTipButon.Zoom: this.Image = CCL.UI.Properties.Resources.zoomIn; this.ForeColor = System.Drawing.SystemColors.ControlText; this.Text = ""; break; case EnumTipButon.Standard: //Momentan nu avem nicio actiune pentru acest tip de buton this.ForeColor = System.Drawing.SystemColors.ControlText; break; case EnumTipButon.Editare: this.Image = CCL.UI.Properties.Resources.edit16x16; this.ForeColor = System.Drawing.SystemColors.ControlText; this.Text = ""; break; case EnumTipButon.Parametraj: //Butonul de parametraj nu are niciodata imagine this.Image = null; this.ForeColor = System.Drawing.SystemColors.ControlText; this.Text = ""; break; case EnumTipButon.Bascula: this.Image = null; this.ForeColor = System.Drawing.SystemColors.ControlText; break; case EnumTipButon.Guma: this.Image = CCL.UI.Properties.Resources.eraser; this.ForeColor = System.Drawing.SystemColors.ControlText; this.Text = ""; break; case EnumTipButon.Refresh: this.Image = CCL.UI.Properties.Resources.refresh; this.ForeColor = System.Drawing.SystemColors.ControlText; this.Text = ""; break; case EnumTipButon.Calendar: this.Image = CCL.UI.Properties.Resources.calendarIcon;// calendar_plus; this.ForeColor = System.Drawing.SystemColors.ControlText; this.Text = ""; break; case EnumTipButon.Cautare: //Un buton de cautare are textul "..." dar niciodata imagine this.Text = "..."; this.Image = null; this.ForeColor = System.Drawing.SystemColors.ControlText; break; case EnumTipButon.CautareGoogle: //Un buton de cautare pe google nu are text ci doar imagine this.Text = null; this.Image = CCL.UI.Properties.Resources.google16; this.ForeColor = System.Drawing.SystemColors.ControlText; break; case EnumTipButon.CautareWikipedia: //Un buton de cautare pe google nu are text ci doar imagine this.Text = null; this.Image = CCL.UI.Properties.Resources.WikipediaLogo; this.ForeColor = System.Drawing.SystemColors.ControlText; break; case EnumTipButon.ActiviDezactivati: // In acest caz butonul are doua stari Activi/Dezactivati // Starea initiala este: "Activi" si va corespunde valorii false a proprietatii // Selectat. Cand aceasta este true vom avea starea "Dezactivati" this.ForeColor = System.Drawing.Color.Black; this.Text = ""; setImagineStatutActiviDezactivati(); break; case EnumTipButon.MeniuStanga: this.UseVisualStyleBackColor = false; this.lIsSelectat = false; this.FlatAppearance.BorderSize = 0; this.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.ForeColor = System.Drawing.Color.Transparent; this.BackColor = System.Drawing.Color.Transparent; this.Margin = new System.Windows.Forms.Padding(0); break; case EnumTipButon.LecturaModificare: // In acest caz butonul are doua stari Lectura si Modificare // Lectura <=> Selectat = false; // Modificare <=> Selectat = true; (Util pentru AllowModification) this.Text = ""; if (this.lIsSelectat) { this.Image = CCL.UI.Properties.Resources.ModModificare24; } else { this.Image = CCL.UI.Properties.Resources.ModCitire24; } break; case EnumTipButon.LansareCautare: this.Text = ""; this.FlatStyle = System.Windows.Forms.FlatStyle.Standard; this.Image = CCL.UI.Properties.Resources.Cauta25; break; case EnumTipButon.GestiuneFiltreVerticala: this.Text = ""; setImagineStatutFiltreVerticala(); break; case EnumTipButon.GestiuneFiltreOrizontala: this.Text = ""; setImagineStatutFiltreOrizontala(); break; case EnumTipButon.Sus: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Sus24; break; case EnumTipButon.Jos: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Jos24; break; case EnumTipButon.Stanga: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Stanga24; break; case EnumTipButon.Dreapta: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Dreapta24; break; case EnumTipButon.Documente: base.Image = CCL.UI.Properties.Resources.MyDocuments16; break; case EnumTipButon.Adaugare: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Adauga; break; case EnumTipButon.Email: this.Text = ""; this.Image = CCL.UI.Properties.Resources.email; break; case EnumTipButon.Validare: this.Image = CCL.UI.Properties.Resources.Validare; break; case EnumTipButon.Salvare: this.Image = CCL.UI.Properties.Resources.Text_save; break; case EnumTipButon.Anulare: this.Image = CCL.UI.Properties.Resources.Anulare; break; case EnumTipButon.SortareAlfabetica: this.Image = CCL.UI.Properties.Resources.btn_asc_sort; break; case EnumTipButon.Stergere: this.Image = CCL.UI.Properties.Resources.deleteGri2; break; case EnumTipButon.DetaliiPopUp: this.Text = ""; this.Image = CCL.UI.Properties.Resources.ToolTip16; break; case EnumTipButon.Deschide: this.Image = Imagini.getImagineDeschideDocument(); break; case EnumTipButon.NavigarePrimul: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Primul; break; case EnumTipButon.NavigareInapoi: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Inapoi; break; case EnumTipButon.NavigareInainte: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Inainte; break; case EnumTipButon.NavigareUltimul: this.Text = ""; this.Image = CCL.UI.Properties.Resources.Ultimul; break; case EnumTipButon.AfisareLista: this.Text = ""; this.Image = CCL.UI.Properties.Resources.AfisareLista; break; case EnumTipButon.Print: this.Image = CCL.UI.Properties.Resources.printer; break; case EnumTipButon.Export: this.Image = CCL.UI.Properties.Resources.Text_table; break; case EnumTipButon.Copiere: this.Image = CCL.UI.Properties.Resources.Text_copy; break; case EnumTipButon.MaiMulte: this.Text = string.Empty; this.Image = Imagini.GetImagineMaiMulte(); break; case EnumTipButon.Calculator: this.Text = string.Empty; this.Image = Imagini.GetImagineCalculator(); break; } }