I have made a custom control using c# and I have it in a project with another custom control. I include the compiled dllinto another project, but the BitmapButton is not visible (it seems it's not compiling). I don't know about the other control, because it wasn't made by me.
Here is the code of BitMapButton:
and here is the code of the other control:Code:/* * Created by SharpDevelop. * User: MateuszJ * Date: 2007-08-07 * Time: 22:36 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace Multitool.Controls { /// <summary> /// Description of BitmapButton. /// </summary> public partial class BitmapButton : UserControl { public BitmapButton() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } Image backgroundImage, pressedImage; bool pressed = false; // Property for the background image to be drawn behind the button text. public Image BackgroundImage { get { return this.backgroundImage; } set { this.backgroundImage = value; } } // Property for the background image to be drawn behind the button text when // the button is pressed. public Image PressedImage { get { return this.pressedImage; } set { this.pressedImage = value; } } // When the mouse button is pressed, set the "pressed" flag to true // and invalidate the form to cause a repaint. The .NET Compact Framework // sets the mouse capture automatically. protected override void OnMouseDown(MouseEventArgs e) { this.pressed = true; this.Invalidate(); base.OnMouseDown (e); } // When the mouse is released, reset the "pressed" flag // and invalidate to redraw the button in the unpressed state. protected override void OnMouseUp(MouseEventArgs e) { this.pressed = false; this.Invalidate(); base.OnMouseUp (e); } // Override the OnPaint method to draw the background image and the text. protected override void OnPaint(PaintEventArgs e) { if(this.pressed && this.pressedImage != null) e.Graphics.DrawImage(this.pressedImage, 0, 0); else e.Graphics.DrawImage(this.backgroundImage, 0, 0); // Draw the text if there is any. if(this.Text.Length > 0) { SizeF size = e.Graphics.MeasureString(this.Text, this.Font); // Center the text inside the client area of the PictureButton. e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), (this.ClientSize.Width - size.Width) / 2, (this.ClientSize.Height - size.Height) / 2); } // Draw a border around the outside of the // control to look like Pocket PC buttons. e.Graphics.DrawRectangle(new Pen(Color.Black), 0, 0, this.ClientSize.Width - 1, this.ClientSize.Height - 1); base.OnPaint(e); } } }
Code:/* * Created by SharpDevelop. * User: MarcinS * Date: 2006-07-13 * Time: 20:49 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace Multitool.Controls { /// <summary> /// Description of ColorProgressBarWithText. /// </summary> public partial class ColorProgressBarWithText { public ColorProgressBarWithText() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } void ColorProgressBarWithTextPaint(object sender, System.Windows.Forms.PaintEventArgs e) { BackColor = this.Parent.BackColor; //brzegi Pen cien = new Pen(SystemColors.ControlDark); Pen swiatlo = new Pen(SystemColors.ControlLightLight); e.Graphics.DrawLine(cien,0,Height-1,0,0); e.Graphics.DrawLine(cien,0,0,Width-1,0); e.Graphics.DrawLine(swiatlo,Width-1,0,Width-1,Height-1); e.Graphics.DrawLine(swiatlo,Width-1,Height-1,0,Height-1); Bitmap bufor = new Bitmap(Width,Height); Graphics g = Graphics.FromImage(bufor); BackColor = this.Parent.BackColor; const int margines = 2; int stepwidth = 2*Height/3; double procenty = 0; if (Maximum>Minimum) procenty = (Value-Minimum)/(double)(Maximum-Minimum); int szerokosc = (int)Math.Round( procenty*(Width-2*margines-1)); for (int i=margines;i<margines+szerokosc;i++) { if (!Smooth && ((i%stepwidth)>0) && (i%stepwidth<margines+1)) continue; g.DrawLine(new Pen(ObliczKolor(i)), i,margines,i,Height-margines-1); } e.Graphics.DrawImage(bufor,0,0); } private Color ObliczKolor(int i) { if (i<0 || i>Width) throw new Exception("Zly parametr i"); return Color.FromArgb( ColorBegin.R+i*(ColorEnd.R-ColorBegin.R)/Width, ColorBegin.G+i*(ColorEnd.G-ColorBegin.G)/Width, ColorBegin.B+i*(ColorEnd.B-ColorBegin.B)/Width); } public void PerformStep() { Value+=Step; } #region Wlasnosci private int _Minimum = 0; private int _Maximum = 100; private int _Value = 0; private int _Step = 10; private Color _ColorBegin = Color.Yellow; private Color _ColorEnd = Color.Red; private bool _Smooth; private string _TextOn; public int Minimum { get { return _Minimum; } set { if (value>_Maximum) value = _Maximum; _Minimum = value; Refresh(); } } public int Maximum { get { return _Maximum; } set { if (value<_Minimum) value = _Minimum; _Maximum = value; Refresh(); } } public int Value { get { return _Value; } set { if (value<_Minimum) value = _Minimum; if (value>_Maximum) value = _Maximum; _Value = value; OnValueChanged(this,new EventArgs(),Value); Refresh(); } } public int Step { get { return _Step; } set { _Step = value; } } public Color ColorBegin { get { return _ColorBegin; } set { _ColorBegin = value; Refresh(); } } public Color ColorEnd { get { return _ColorEnd; } set { _ColorEnd = value; Refresh(); } } public bool Smooth { get { return _Smooth; } set { _Smooth = value; Refresh(); } } public string TextOn { get { return _TextOn; } set { _TextOn = value; Refresh(); } } #endregion #region Zdarzenie ValueChanged public delegate void ValueChangedEventHandler( object sender, System.EventArgs e, int _value); [Category("Behavior"), Description( "Zachodzi, gdy zmienia się własność Value.")] public event ValueChangedEventHandler ValueChanged; protected virtual void OnValueChanged( object sender, System.EventArgs e, int _value) { if (ValueChanged!=null) ValueChanged(this,e,_value); } #endregion void Refr(object sender, System.EventArgs e) { Refresh(); } } }
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks