public BeneficioCadastro( ButtonBase botaoSalvar, ButtonBase botaoCancelar, Form tela, DataGridView beneficioGridView ) { this.Botao_Salvar = botaoSalvar; this.Botao_Cancelar = botaoCancelar; this.Tela = tela; Beneficios = TiposBeneficio.ObterListaAssociada(); beneficioGridView.AutoGenerateColumns = false; beneficioGridView.DataSource = Beneficios; Botao_Salvar.Click += new EventHandler(Botao_Salvar_Click); Botao_Cancelar.Click += new EventHandler(Botao_Cancelar_Click); Beneficios.AddingNew += (sender, args) => { if (beneficioGridView.Rows.Count == Beneficios.Count) { Beneficios.RemoveAt(Beneficios.Count - 1); return; } }; AoCancelar += () => { beneficioGridView.DataSource = Beneficios; }; AoSalvar += () => { TiposBeneficio.DispararAtualizacao(); }; }
public TipoAcaoCadastro( ButtonBase botaoSalvar, ButtonBase botaoCancelar, Form tela, DataGridView tipoAcaoGridView ) { this.Botao_Salvar = botaoSalvar; this.Botao_Cancelar = botaoCancelar; this.Tela = tela; Tipos = TiposAcao.ObterListaAssociada(); tipoAcaoGridView.AutoGenerateColumns = false; tipoAcaoGridView.DataSource = Tipos; Tipos.AddingNew += (sender, args) => { if (tipoAcaoGridView.Rows.Count == Tipos.Count) { Tipos.RemoveAt(Tipos.Count - 1); return; } }; Botao_Salvar.Click += new EventHandler(Botao_Salvar_Click); Botao_Cancelar.Click += new EventHandler(Botao_Cancelar_Click); AoCancelar += () => { tipoAcaoGridView.DataSource = Tipos; }; }
public ButtonCommandBinding(ButtonBase button, ICommand command, Func<object> commandParameterCallback) : base(button, command) { this.button = button; this.commandParameterCallback = commandParameterCallback; UpdateEnabledProperty(); this.button.Click += ButtonClick; }
public GrupoDiferencialCadastro( ButtonBase botaoSalvar, ButtonBase botaoCancelar, Form tela, DataGridView grupoGridView ) { this.Botao_Salvar = botaoSalvar; this.Botao_Cancelar = botaoCancelar; this.Tela = tela; Grupos = TiposGrupoDiferencial.ObterListaAssociada(); grupoGridView.AutoGenerateColumns = false; grupoGridView.DataSource = Grupos; Botao_Salvar.Click += new EventHandler(Botao_Salvar_Click); Botao_Cancelar.Click += new EventHandler(Botao_Cancelar_Click); Grupos.AddingNew += (sender, args) => { if (grupoGridView.Rows.Count == Grupos.Count) { Grupos.RemoveAt(Grupos.Count - 1); return; } }; AoCancelar += () => { grupoGridView.DataSource = Grupos; }; }
/// <summary> /// Selects the Button /// </summary> /// <param name="Button">The Button that will change its style</param> /// <param name="select">It determines if the button woll be selected</param> /// <remarks> /// If select is true thebutton will be selected, otherwise not. /// </remarks> public static void setSelected(System.Windows.Forms.ButtonBase Button, bool select) { if (select) { Button.Select(); } }
private void btnAddMetadataOK_Click(object sender, EventArgs e) { MetadataDefinition mdDef = (MetadataDefinition)comboBoxName.SelectedItem; if (mdDef != null && string.IsNullOrEmpty(richTextBoxMetadataData.Text)) { DialogResult dr = MessageBox.Show("Metadata value is empty. Do you like to save it?", "Metadata Value", MessageBoxButtons.OKCancel); if (dr == DialogResult.OK) { } else { return; } //MessageBox.Show("This metadata item requires a value ('Actial value' field)."); } if (string.IsNullOrEmpty(comboBoxName.Text)) { MessageBox.Show("Metadata 'name' must be specified."); return; } _MetadataItem = new Adlib.Director.DirectorWSAWrapper.JobManagementService.Metadata(); _MetadataItem.Name = comboBoxName.Text; _MetadataItem.Value = richTextBoxMetadataData.Text; System.Windows.Forms.ButtonBase bb = (System.Windows.Forms.ButtonBase)sender; _OkPressed = true; this.Close(); }
/// <summary> /// コンストラクタ /// </summary> public ButtonCommandBinding(ButtonBase button, ICommand command, Func<object> commandParameterCallback) : base(button, command, commandParameterCallback) { this.target = button; this.target.Click += event_DoExecute; OnUpdatedEnabled(); }
/// <summary> /// Checks if the Control contains a command, if it does not it sets the default /// </summary> /// <param name="button">The control whose command will be checked</param> public static void CheckCommand(System.Windows.Forms.ButtonBase button) { if (button != null) { if (GetCommand(button).Equals("")) { SetCommand(button, button.Text); } } }
public static void PerformAutoLayout( System.Windows.Forms.ButtonBase button, AutoSizeStrategy autoSizeLayoutStrategy, EdgeSnapOptions edgeSnapOptions) { Control container = button.Parent; // Make sure no extra, not-yet-defined options were snuck in EdgeSnapOptions allEdgeSnapOptions = EdgeSnapOptions.SnapLeftEdgeToContainerLeftEdge | EdgeSnapOptions.SnapRightEdgeToContainerRightEdge; if (0 != (edgeSnapOptions & ~allEdgeSnapOptions)) { throw new InvalidEnumArgumentException("edgeSnapOptions"); } if ((edgeSnapOptions & EdgeSnapOptions.SnapLeftEdgeToContainerLeftEdge) != 0) { int oldLeft = button.Left; button.Left = 0; button.Width += oldLeft; } if (container != null && (edgeSnapOptions & EdgeSnapOptions.SnapRightEdgeToContainerRightEdge) != 0) { button.Width = container.Width - button.Left; } switch (autoSizeLayoutStrategy) { case AutoSizeStrategy.AutoHeightAndExpandWidthToContent: button.Size = button.GetPreferredSize(new Size(0, 0)); break; case AutoSizeStrategy.ExpandHeightToContentAndKeepWidth: if (button.Width != 0) { Size preferredSizeP = button.GetPreferredSize(new Size(button.Width, 1)); Size preferredSize = new Size((preferredSizeP.Width * 11) / 10, preferredSizeP.Height); // add 10% padding int lineHeight = preferredSize.Height; int overageScale = (preferredSize.Width + (button.Width - 1)) / button.Width; button.Height = lineHeight * overageScale; } break; case AutoSizeStrategy.None: break; default: throw new InvalidEnumArgumentException("autoSizeLayoutStrategy"); } }
/// <summary> /// Sets the elevation required state for a specified button or command link to display an elevated icon. /// </summary> /// <param name="button"></param> /// <remarks> /// http://msdn.microsoft.com/en-us/library/bb761865(VS.85).aspx /// /// #define BCM_FIRST 0x1600 // Button control messages /// // Macro to use on a button or command link to display an elevated icon /// #define BCM_SETSHIELD (BCM_FIRST + 0x000C) /// #define Button_SetElevationRequiredState(hwnd, fRequired) \ /// (LRESULT)SNDMSG((hwnd), BCM_SETSHIELD, 0, (LPARAM)fRequired) /// </remarks> public static void Button_SetElevationRequiredState(ButtonBase button, bool show) { if (button == null) throw new ArgumentNullException("button"); button.FlatStyle = FlatStyle.System; var buttonHandle = new HandleRef(button, button.Handle); Trace.WriteLine("handle:" + buttonHandle.Handle); var lParam = new IntPtr(Int32.MaxValue - 1); IntPtr ret = SendMessage(buttonHandle, BCM_SETSHIELD, show ? new IntPtr(1) : IntPtr.Zero, ref lParam); Trace.WriteLine(ret.ToInt64()); }
/// <summary> /// Sets the style of the Button /// </summary> /// <param name="Button">The Button that will change its style</param> /// <param name="style">The new style of the Button</param> /// <remarks> /// If style is 0 then sets a popup style to the Button, otherwise sets a standard style to the Button. /// </remarks> public static void setStyle(System.Windows.Forms.ButtonBase Button, int style) { if ((style == 0) || (style == 67108864) || (style == 33554432)) { Button.FlatStyle = System.Windows.Forms.FlatStyle.Popup; } else if ((style == 2097152) || (style == 1048576) || (style == 16777216)) { Button.FlatStyle = System.Windows.Forms.FlatStyle.Standard; } else { throw new System.ArgumentException("illegal style: " + style); } }
public override void DrawButtonBase (Graphics dc, Rectangle clip_area, ButtonBase button) { if (button.FlatStyle == FlatStyle.System) { ButtonRenderer.DrawButton ( dc, new Rectangle (Point.Empty, button.Size), button.Text, button.Font, button.TextFormatFlags, null, Rectangle.Empty, ShouldPaintFocusRectagle (button), GetPushButtonState (button) ); return; } base.DrawButtonBase (dc, clip_area, button); }
/// <summary> /// Metodo utilizado para lanzar el evento /// ToolBarButtonClick /// </summary> /// <param name="pButtonClicked">Botón presionado</param> private void OnToolBarButtonClick(ButtonBase pButtonClicked) { if (ToolBarButtonClick != null) { ButtonClickArgs<ButtonBase> e = new ButtonClickArgs<ButtonBase>(pButtonClicked); if (pButtonClicked.GetType() == typeof(ButtonBase)) { if (!string.IsNullOrEmpty(((ButtonBase)pButtonClicked).AssemblyInfo)) { XtraForm wFrm = (XtraForm)Fwk.HelperFunctions.ReflectionFunctions.CreateInstance(((ButtonBase)pButtonClicked).AssemblyInfo); e.Form = wFrm; } } ToolBarButtonClick(this, e); } }
public ProcessoCadastro(Form tela, TextBoxBase buscaNumeroReferenciaInterna, ButtonBase botaoBusca, ButtonBase botaoAdicionar, ButtonBase botaoSalvar, ButtonBase botaoPDF, ButtonBase botaoFechar, ButtonBase botaoRemover, ButtonBase botaoCancelar, ButtonBase botaoLimpar) { this.Tela = tela; this.Busca_NumeroReferenciaInterna = buscaNumeroReferenciaInterna; this.Botao_Busca = botaoBusca; this.Botao_Adicionar = botaoAdicionar; this.Botao_Salvar = botaoSalvar; this.Botao_PDF = botaoPDF; this.Botao_Fechar = botaoFechar; this.Botao_Remover = botaoRemover; this.Botao_Cancelar = botaoCancelar; this.Botao_Limpar = botaoLimpar; Botao_Limpar.Enabled = true; Botao_Cancelar.Enabled = false; this.ProcessoAtivo = new Processo(); ProcessoAtivo.IdAlterado += (antigo, novo) => buscaNumeroReferenciaInterna.Text = novo.ToString(); this.AdicionarLink(); ProcessoAtivo.OrigemDadosAlterado += (antigo, novo) => { if (novo == OrigemDados.Local) { Botao_Limpar.Enabled = true; Botao_Cancelar.Enabled = false; } else if (novo == OrigemDados.Banco) { Botao_Limpar.Enabled = false; Botao_Cancelar.Enabled = true; } }; AoSalvar += () => { }; AoAdicionar += () => { }; AoBuscar += () => { }; AoCancelar += () => { }; AoLimpar += () => { }; AoRemover += () => { }; AntesDeSalvar += () => { return true; }; }
public PendenciaCadastro( ButtonBase botaoAdicionar, ButtonBase botaoLimpar, ButtonBase botaoSalvar, ButtonBase botaoCancelar, Form tela, DataGridView pendenciaGridView, TextBoxBase txtPendencia ) { this.Botao_Adicionar = botaoAdicionar; this.Botao_Limpar = botaoLimpar; this.Botao_Cancelar = botaoCancelar; this.Botao_Salvar = botaoSalvar; this.Tela = tela; this.Texto_Pendencia = txtPendencia; this.ListaPendencias = Pendencias.ListarAssociado(); pendenciaGridView.AutoGenerateColumns = false; pendenciaGridView.DataSource = ListaPendencias; ListaPendencias.AddingNew += (sender, args) => { if (pendenciaGridView.Rows.Count == ListaPendencias.Count) { ListaPendencias.RemoveAt(ListaPendencias.Count - 1); return; } }; this.Botao_Adicionar.Click += new EventHandler(Botao_Adicionar_Click); this.Botao_Limpar.Click += new EventHandler(Botao_Limpar_Click); this.Botao_Salvar.Click += new EventHandler(Botao_Salvar_Click); this.Botao_Cancelar.Click += new EventHandler(Botao_Cancelar_Click); AoCancelar += () => { pendenciaGridView.DataSource = ListaPendencias; }; }
void LoadAssembly(string pFileName) { lblEx.Visible = false; ButtonBaseList wButtons = new ButtonBaseList(); ButtonBase wButton = new ButtonBase(); try { Assembly wAssembly = new Assembly(pFileName); lblFileName.Text = pFileName; foreach (AssemblyClass wAssemblyClass in wAssembly.ClassCollections) { string name = wAssemblyClass.Name; if (wAssemblyClass.BaseType != null) { typeof(ButtonBase).IsInstanceOfType(wButton); //if (Fwk.HelperFunctions.TypeFunctions.TypeInheritFrom(wAssemblyClass.Type, _BaseTypesFilter)) if (inheritFromAny(wAssemblyClass.Type)) { wButton = new ButtonBase(); wButton.AssemblyInfo = wAssemblyClass.FullyQualifiedName; wButtons.Add(wButton); } } } listBox1.DataSource = wButtons; } catch (Exception ex) { lblEx.Visible = true; lblEx.Text = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex); } }
/// <summary> /// Sets an specific text and/or image to the Button /// </summary> /// <param name="Button">The button to be set</param> /// <param name="control">The control to be contained analized to get the text and/or image for the Button</param> public static void SetButton(System.Windows.Forms.ButtonBase Button, System.Windows.Forms.Control control) { if (control.GetType().FullName == "System.Windows.Forms.Label") { Button.Image = ((System.Windows.Forms.Label)control).Image; Button.Text = ((System.Windows.Forms.Label)control).Text; Button.ImageAlign = ((System.Windows.Forms.Label)control).ImageAlign; Button.TextAlign = ((System.Windows.Forms.Label)control).TextAlign; } else { if (control.GetType().FullName == "System.Windows.Forms.PictureBox") //Tentative to see maps of UIGraphic { Button.Image = ((System.Windows.Forms.PictureBox)control).Image; Button.ImageAlign = ((System.Windows.Forms.Label)control).ImageAlign; } else { Button.Text = control.Text; } } Button.FlatStyle = System.Windows.Forms.FlatStyle.Standard; }
/// <summary> /// Receives a Button instance and sets the Text and Image properties. /// </summary> /// <param name="buttonInstance">Button instance to be set.</param> /// <param name="buttonText">Value to be set to Text.</param> /// <param name="icon">Value to be set to Image.</param> public static void SetStandardButton(System.Windows.Forms.ButtonBase buttonInstance, System.String buttonText, System.Drawing.Image icon) { buttonInstance.Text = buttonText; buttonInstance.Image = icon; }
private static int get_TextAlign(ButtonBase Instance,IntPtr l) { LuaApi.lua_pushnumber(l,(int)Instance.TextAlign); return 1; }
private static int get_ImageKey(ButtonBase Instance,IntPtr l) { LuaApi.lua_pushstring(l,Instance.ImageKey); return 1; }
private static int get_FlatStyle(ButtonBase Instance,IntPtr l) { LuaApi.lua_pushnumber(l,(int)Instance.FlatStyle); return 1; }
private static int set_TextAlign(ButtonBase Instance,IntPtr l) { Instance.TextAlign = (ContentAlignment)LuaApi.lua_tonumber(l,3); return 0; }
private static int set_ImageKey(ButtonBase Instance,IntPtr l) { Instance.ImageKey = LuaApi.lua_tostring(l,3); return 0; }
public abstract void DrawFlatButton(Graphics g, ButtonBase b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
public override void CalculateCheckBoxTextAndImageLayout (ButtonBase button, Point p, out Rectangle glyphArea, out Rectangle textRectangle, out Rectangle imageRectangle) { int check_size = 13; if (button is CheckBox) check_size = (button as CheckBox).Appearance == Appearance.Normal ? 13 : 0; glyphArea = new Rectangle (0, 2, check_size, check_size); Rectangle content_rect = button.ClientRectangle; ContentAlignment align = ContentAlignment.TopLeft;; if (button is CheckBox) align = (button as CheckBox).CheckAlign; else if (button is RadioButton) align = (button as RadioButton).CheckAlign; switch (align) { case ContentAlignment.BottomCenter: glyphArea.Y = button.Height - check_size; glyphArea.X = (button.Width - check_size) / 2 - 2; break; case ContentAlignment.BottomLeft: glyphArea.Y = button.Height - check_size - 2; content_rect.Width -= check_size; content_rect.Offset (check_size, 0); break; case ContentAlignment.BottomRight: glyphArea.Y = button.Height - check_size - 2; glyphArea.X = button.Width - check_size; content_rect.Width -= check_size; break; case ContentAlignment.MiddleCenter: glyphArea.Y = (button.Height - check_size) / 2; glyphArea.X = (button.Width - check_size) / 2; break; case ContentAlignment.MiddleLeft: glyphArea.Y = (button.Height - check_size) / 2; content_rect.Width -= check_size; content_rect.Offset (check_size, 0); break; case ContentAlignment.MiddleRight: glyphArea.Y = (button.Height - check_size) / 2; glyphArea.X = button.Width - check_size; content_rect.Width -= check_size; break; case ContentAlignment.TopCenter: glyphArea.X = (button.Width - check_size) / 2; break; case ContentAlignment.TopLeft: content_rect.Width -= check_size; content_rect.Offset (check_size, 0); break; case ContentAlignment.TopRight: glyphArea.X = button.Width - check_size; content_rect.Width -= check_size; break; } Image image = button.Image; string text = button.Text; Size proposed = Size.Empty; // Force wrapping if we aren't AutoSize and our text is too long if (!button.AutoSize) proposed.Width = button.Width - glyphArea.Width - 2; Size text_size = TextRenderer.MeasureTextInternal (text, button.Font, proposed, button.TextFormatFlags, button.UseCompatibleTextRendering); // Text can't be bigger than the content rectangle text_size.Height = Math.Min (text_size.Height, content_rect.Height); text_size.Width = Math.Min (text_size.Width, content_rect.Width); Size image_size = image == null ? Size.Empty : image.Size; textRectangle = Rectangle.Empty; imageRectangle = Rectangle.Empty; switch (button.TextImageRelation) { case TextImageRelation.Overlay: // Text is centered vertically, and 2 pixels to the right textRectangle.X = content_rect.Left + 2; textRectangle.Y = ((content_rect.Height - text_size.Height) / 2) - 1; textRectangle.Size = text_size; // Image is dependent on ImageAlign if (image == null) return; int image_x = 0; int image_y = 0; int image_height = image.Height; int image_width = image.Width; switch (button.ImageAlign) { case System.Drawing.ContentAlignment.TopLeft: image_x = 5; image_y = 5; break; case System.Drawing.ContentAlignment.TopCenter: image_x = (content_rect.Width - image_width) / 2; image_y = 5; break; case System.Drawing.ContentAlignment.TopRight: image_x = content_rect.Width - image_width - 5; image_y = 5; break; case System.Drawing.ContentAlignment.MiddleLeft: image_x = 5; image_y = (content_rect.Height - image_height) / 2; break; case System.Drawing.ContentAlignment.MiddleCenter: image_x = (content_rect.Width - image_width) / 2; image_y = (content_rect.Height - image_height) / 2; break; case System.Drawing.ContentAlignment.MiddleRight: image_x = content_rect.Width - image_width - 4; image_y = (content_rect.Height - image_height) / 2; break; case System.Drawing.ContentAlignment.BottomLeft: image_x = 5; image_y = content_rect.Height - image_height - 4; break; case System.Drawing.ContentAlignment.BottomCenter: image_x = (content_rect.Width - image_width) / 2; image_y = content_rect.Height - image_height - 4; break; case System.Drawing.ContentAlignment.BottomRight: image_x = content_rect.Width - image_width - 4; image_y = content_rect.Height - image_height - 4; break; default: image_x = 5; image_y = 5; break; } imageRectangle = new Rectangle (image_x + check_size, image_y, image_width, image_height); break; case TextImageRelation.ImageAboveText: content_rect.Inflate (-4, -4); LayoutTextAboveOrBelowImage (content_rect, false, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle); break; case TextImageRelation.TextAboveImage: content_rect.Inflate (-4, -4); LayoutTextAboveOrBelowImage (content_rect, true, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle); break; case TextImageRelation.ImageBeforeText: content_rect.Inflate (-4, -4); LayoutTextBeforeOrAfterImage (content_rect, false, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle); break; case TextImageRelation.TextBeforeImage: content_rect.Inflate (-4, -4); LayoutTextBeforeOrAfterImage (content_rect, true, text_size, image_size, button.TextAlign, button.ImageAlign, out textRectangle, out imageRectangle); break; } }
/// <summary> /// Sets the an specific text for the Button /// </summary> /// <param name="Button">The button to be set</param> /// <param name="label">The text associated with the Button</param> public static void SetButton(System.Windows.Forms.ButtonBase Button, System.String label) { Button.Text = label; Button.FlatStyle = System.Windows.Forms.FlatStyle.Popup; }
public abstract void CalculateButtonTextAndImageLayout(Graphics g, ButtonBase b, out Rectangle textRectangle, out Rectangle imageRectangle);
internal static Rect GetButtonBaseImageBounds(FragmentControlProvider provider, SWF.ButtonBase buttonBase) { //Implementation highly based in ThemeWin32Classic.ButtonBase_DrawImage method Image image; int imageX; int imageY; int imageWidth; int imageHeight; int width = buttonBase.Width; int height = buttonBase.Height; if (buttonBase.ImageIndex != -1) { image = buttonBase.ImageList.Images [buttonBase.ImageIndex]; } else { image = buttonBase.Image; } if (image == null) { return(Rect.Empty); } imageWidth = image.Width; imageHeight = image.Height; switch (buttonBase.ImageAlign) { case ContentAlignment.TopLeft: { imageX = 5; imageY = 5; break; } case ContentAlignment.TopCenter: { GetXYFromWidthInTopCenterAlignment(width, imageWidth, out imageX, out imageY); break; } case ContentAlignment.TopRight: { imageX = width - imageWidth - 5; imageY = 5; break; } case ContentAlignment.MiddleLeft: { imageX = 5; imageY = (height - imageHeight) / 2; break; } case ContentAlignment.MiddleCenter: { imageX = (width - imageWidth) / 2; imageY = (height - imageHeight) / 2; break; } case ContentAlignment.MiddleRight: { imageX = width - imageWidth - 4; imageY = (height - imageHeight) / 2; break; } case ContentAlignment.BottomLeft: { imageX = 5; imageY = height - imageHeight - 4; break; } case ContentAlignment.BottomCenter: { imageX = (width - imageWidth) / 2; imageY = height - imageHeight - 4; break; } case ContentAlignment.BottomRight: { imageX = width - imageWidth - 4; imageY = height - imageHeight - 4; break; } default: { imageX = 5; imageY = 5; break; } } Rect buttonRect = (Rect)provider.GetPropertyValue(AutomationElementIdentifiers.BoundingRectangleProperty.Id); imageX += (int)buttonRect.X; imageY += (int)buttonRect.Y; Rect imageRect = new Rect(imageX, imageY, imageWidth, imageHeight); buttonRect.Intersect(imageRect); return(buttonRect); }
/// <summary> /// Sets the specific Text and Style for the Button /// </summary> /// <param name="Button">The button to be set</param> /// <param name="label">The text associated with the Button</param> /// <param name="style">The style of the Button</param> public static void SetButton(System.Windows.Forms.ButtonBase Button, System.String label, int style) { Button.Text = label; setStyle(Button, style); }
protected virtual void ButtonBase_DrawFocus(ButtonBase button, Graphics dc) { Color focus_color = button.ForeColor; int inflate_value = -3; if (!(button is CheckBox) && !(button is RadioButton)) { inflate_value = -4; if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) focus_color = ControlPaint.Dark(button.BackColor); dc.DrawRectangle (ResPool.GetPen (focus_color), button.ClientRectangle.X, button.ClientRectangle.Y, button.ClientRectangle.Width - 1, button.ClientRectangle.Height - 1); } if (button.Focused) { Rectangle rect = Rectangle.Inflate (button.ClientRectangle, inflate_value, inflate_value); ControlPaint.DrawFocusRectangle (dc, rect); } }
protected virtual void ButtonBase_DrawText(ButtonBase button, Graphics dc) { Rectangle buttonRectangle = button.ClientRectangle; Rectangle text_rect = Rectangle.Inflate(buttonRectangle, -4, -4); if (button.is_pressed) { text_rect.X++; text_rect.Y++; } // Ensure that at least one line is going to get displayed. // Line limit does not ensure that despite its description. text_rect.Height = Math.Max (button.Font.Height, text_rect.Height); if (button.Enabled) { dc.DrawString(button.Text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format); } else { if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) { dc.DrawString(button.Text, button.Font, ResPool.GetSolidBrush (ColorGrayText), text_rect, button.text_format); } else { CPDrawStringDisabled (dc, button.Text, button.Font, button.BackColor, text_rect, button.text_format); } } }
private static int set_FlatStyle(ButtonBase Instance,IntPtr l) { Instance.FlatStyle = (FlatStyle)LuaApi.lua_tonumber(l,3); return 0; }
private static int set_AutoEllipsis(ButtonBase Instance,IntPtr l) { Instance.AutoEllipsis = LuaApi.lua_tonumber(l,3)!=0; return 0; }
internal FlatButtonAppearance(ButtonBase owner) { this.owner = owner; }
private static int set_ImageIndex(ButtonBase Instance,IntPtr l) { Instance.ImageIndex = (Int32)LuaApi.lua_tonumber(l,3); return 0; }
public abstract void CalculateRadioButtonTextAndImageLayout(ButtonBase b, Point offset, out Rectangle glyphArea, out Rectangle textRectangle, out Rectangle imageRectangle);
private static int set_ImeMode(ButtonBase Instance,IntPtr l) { Instance.ImeMode = (ImeMode)LuaApi.lua_tonumber(l,3); return 0; }
public override void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button) { // Draw the button: Draw border, etc. ButtonBase_DrawButton(button, dc); // Draw the image if (button.FlatStyle != FlatStyle.System && ((button.image != null) || (button.image_list != null))) ButtonBase_DrawImage(button, dc); // Draw the focus rectangle if (ShouldPaintFocusRectagle (button)) ButtonBase_DrawFocus(button, dc); // Now the text if (button.Text != null && button.Text != String.Empty) ButtonBase_DrawText(button, dc); }
private static int get_AutoEllipsis(ButtonBase Instance,IntPtr l) { LuaApi.lua_pushnumber(l,Instance.AutoEllipsis?1:0); return 1; }
protected static bool ShouldPaintFocusRectagle (ButtonBase button) { return (button.Focused || button.paint_as_acceptbutton) && button.Enabled && button.ShowFocusCues; }
private static int get_ImageIndex(ButtonBase Instance,IntPtr l) { LuaApi.lua_pushnumber(l,Instance.ImageIndex); return 1; }
protected virtual void ButtonBase_DrawButton (ButtonBase button, Graphics dc) { Rectangle borderRectangle; bool check_or_radio = false; bool check_or_radio_checked = false; bool is_ColorControl = button.BackColor.ToArgb () == ColorControl.ToArgb () ? true : false; CPColor cpcolor = is_ColorControl ? CPColor.Empty : ResPool.GetCPColor (button.BackColor); if (button is CheckBox) { check_or_radio = true; check_or_radio_checked = ((CheckBox)button).Checked; } else if (button is RadioButton) { check_or_radio = true; check_or_radio_checked = ((RadioButton)button).Checked; } if (button.Focused && button.Enabled && !check_or_radio) { // shrink the rectangle for the normal button drawing inside the focus rectangle borderRectangle = Rectangle.Inflate (button.ClientRectangle, -1, -1); } else { borderRectangle = button.ClientRectangle; } if (button.FlatStyle == FlatStyle.Popup) { if (!button.is_pressed && !button.is_entered && !check_or_radio_checked) Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl, button.BackColor); else if (!button.is_pressed && button.is_entered &&!check_or_radio_checked) Internal_DrawButton (dc, borderRectangle, 2, cpcolor, is_ColorControl, button.BackColor); else if (button.is_pressed || check_or_radio_checked) Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl, button.BackColor); } else if (button.FlatStyle == FlatStyle.Flat) { if (button.is_entered && !button.is_pressed && !check_or_radio_checked) { if ((button.image == null) && (button.image_list == null)) { Brush brush = is_ColorControl ? SystemBrushes.ControlDark : ResPool.GetSolidBrush (cpcolor.Dark); dc.FillRectangle (brush, borderRectangle); } } else if (button.is_pressed || check_or_radio_checked) { if ((button.image == null) && (button.image_list == null)) { Brush brush = is_ColorControl ? SystemBrushes.ControlLightLight : ResPool.GetSolidBrush (cpcolor.LightLight); dc.FillRectangle (brush, borderRectangle); } Pen pen = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark); dc.DrawRectangle (pen, borderRectangle.X + 4, borderRectangle.Y + 4, borderRectangle.Width - 9, borderRectangle.Height - 9); } Internal_DrawButton (dc, borderRectangle, 3, cpcolor, is_ColorControl, button.BackColor); } else { if ((!button.is_pressed || !button.Enabled) && !check_or_radio_checked) Internal_DrawButton (dc, borderRectangle, 0, cpcolor, is_ColorControl, button.BackColor); else Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl, button.BackColor); } }
private static int get_ImeMode(ButtonBase Instance,IntPtr l) { LuaApi.lua_pushnumber(l,(int)Instance.ImeMode); return 1; }
protected virtual void ButtonBase_DrawImage(ButtonBase button, Graphics dc) { // Need to draw a picture Image i; int image_x; int image_y; int image_width; int image_height; int width = button.ClientSize.Width; int height = button.ClientSize.Height; if (button.ImageIndex != -1) { // We use ImageIndex instead of image_index since it will return -1 if image_list is null i = button.image_list.Images[button.ImageIndex]; } else { i = button.image; } image_width = i.Width; image_height = i.Height; switch (button.ImageAlign) { case ContentAlignment.TopLeft: { image_x = 5; image_y = 5; break; } case ContentAlignment.TopCenter: { image_x = (width - image_width) / 2; image_y = 5; break; } case ContentAlignment.TopRight: { image_x = width - image_width - 5; image_y = 5; break; } case ContentAlignment.MiddleLeft: { image_x = 5; image_y = (height - image_height) / 2; break; } case ContentAlignment.MiddleCenter: { image_x = (width - image_width) / 2; image_y = (height - image_height) / 2; break; } case ContentAlignment.MiddleRight: { image_x = width - image_width - 4; image_y = (height - image_height) / 2; break; } case ContentAlignment.BottomLeft: { image_x = 5; image_y = height - image_height - 4; break; } case ContentAlignment.BottomCenter: { image_x = (width - image_width) / 2; image_y = height - image_height - 4; break; } case ContentAlignment.BottomRight: { image_x = width - image_width - 4; image_y = height - image_height - 4; break; } default: { image_x = 5; image_y = 5; break; } } dc.SetClip (new Rectangle(3, 3, width - 5, height - 5)); if (button.Enabled) dc.DrawImage (i, image_x, image_y, image_width, image_height); else CPDrawImageDisabled (dc, i, image_x, image_y, ColorControl); dc.ResetClip (); }
// Drawing public abstract void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button);
/// <summary> /// Sets an specific text and/or image to the Button /// </summary> /// <param name="Button">The button to be set</param> /// <param name="control">The control to be contained by the button</param> /// <param name="style">The style of the button</param> public static void SetButton(System.Windows.Forms.ButtonBase Button, System.Windows.Forms.Control control, int style) { SetButton(Button, control); setStyle(Button, style); }