Follow along with the video below to see how to install our site as a web app on your home screen.
Nota: This feature currently requires accessing the site using the built-in Safari browser.
Hola george.manson.69 está buenísimo recién lo probé.Bueno subo un control muy sencillo un Medidor Circular.
Saludos.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Probando
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Graphics papel = pictureBox1.CreateGraphics();
// Creamos el lápiz inicial.
// Dibujamos una línea recta.
Pen lápiz2 = new Pen(Color.Green, 10);
lápiz2.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
lápiz2.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
papel.DrawLine(lápiz2, 20, 188, 188, 188);
// Dibujar rectángulo.
Pen lápiz3 = new Pen(Color.Black);
papel.DrawRectangle(lápiz3, 10, 10, 376, 376);
// Dibujar círculo 100 % redondo.
Pen lápiz4 = new Pen(Color.Red, 5);
papel.DrawEllipse(lápiz4, 10, 10, 376, 376);
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D; // No olvidar.
namespace Lavadora
{
public partial class Form1 : Form
{
// Definir un objeto para crear líneas y curvas.
private Pen lápiz2;
private Pen lápiz3;
private Pen lápiz4;
private float ángulo;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Size = new Size(300, 300);
pictureBox1.BackColor = Color.AntiqueWhite;
lápiz2 = new Pen(Color.Green, 10);
lápiz2.StartCap = LineCap.ArrowAnchor;
lápiz2.EndCap = LineCap.RoundAnchor;
lápiz3 = new Pen(Color.Black);
lápiz4 = new Pen(Color.Red, 5);
ángulo = 0;
}
private void button1_Click(object sender, EventArgs e)
{
ángulo += 10F;
pictureBox1.Refresh();
}
private void button2_Click(object sender, EventArgs e)
{
ángulo -= 10F;
pictureBox1.Refresh();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(lápiz3, 10, 10, pictureBox1.ClientSize.Width - 20, pictureBox1.ClientSize.Height - 20);
e.Graphics.DrawEllipse(lápiz4, 10, 10, pictureBox1.ClientSize.Height - 20, pictureBox1.ClientSize.Height - 20);
e.Graphics.TranslateTransform(pictureBox1.ClientSize.Width / 2, pictureBox1.ClientSize.Height / 2);
e.Graphics.RotateTransform(ángulo);
e.Graphics.TranslateTransform(-pictureBox1.ClientSize.Width / 2, -pictureBox1.ClientSize.Height / 2);
e.Graphics.DrawLine(lápiz2, 20, pictureBox1.ClientSize.Height / 2, pictureBox1.ClientSize.Width / 2, pictureBox1.ClientSize.Height / 2);
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
ángulo = (float)trackBar1.Value;
pictureBox1.Refresh();
label_angulo.Text = ángulo.ToString();
}
}
}
public partial class Form1 : Form
{
int x, y, width, height;
private float minValue = 0;
private float maxValue = 50;
private float currentValue;
private float recommendedValue;
float fromAngle = 90F; // 135
float toAngle = 450F; // 405
public Form1()
{
InitializeComponent();
panel1.Paint += panel1_Paint;
x = 5;
y = 5;
minValue = 0;
maxValue = 100;
width = panel1.Width - 10;
height = panel1.Height - 10;
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
width = panel1.Width - x * 2;
height = panel1.Height - y * 2;
DrawPointer(e.Graphics, ((width) / 2) + x, ((height) / 2) + y);
}
private void DrawPointer(Graphics gr, int cx, int cy)
{
float radius = panel1.Width / 2 - (panel1.Width * .12F);
float val = maxValue - minValue;
gr.SmoothingMode = SmoothingMode.AntiAlias;
val = (100 * (currentValue - minValue)) / val;
val = ((toAngle - fromAngle) * val) / 100;
val += fromAngle;
float angle = GetRadian(val);
float gradientAngle = angle;
gr.DrawLine(new Pen(Color.Black, 2),
new PointF(cx, cy),
new PointF((float)(cx + radius * Math.Cos(angle)), (float)(cy + radius * Math.Sin(angle))));
}
public float GetRadian(float theta)
{
return theta * (float)Math.PI / 180F;
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
currentValue = (float)trackBar1.Value;
panel1.Refresh();
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D; // No olvidar.
namespace Lavadora_2
{
public partial class Form1 : Form
{
private Pen lápiz2;
private Pen lápiz3;
private Pen lápiz4;
private float ángulo;
private GraphicsPath m_lavadora;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Size = new Size(300, 300);
pictureBox1.BackColor = Color.AntiqueWhite;
lápiz2 = new Pen(Color.Green, 10);
lápiz2.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
lápiz2.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
lápiz3 = new Pen(Color.Black);
lápiz4 = new Pen(Color.Red, 10);
ángulo = 0;
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(lápiz3, 10, 10, pictureBox1.ClientSize.Width - 20, pictureBox1.ClientSize.Height - 20);
e.Graphics.DrawEllipse(lápiz4, 10, 10, pictureBox1.ClientSize.Height - 20, pictureBox1.ClientSize.Height - 20);
e.Graphics.TranslateTransform(pictureBox1.ClientSize.Width / 2, pictureBox1.ClientSize.Height / 2);
e.Graphics.RotateTransform(ángulo);
e.Graphics.TranslateTransform(-pictureBox1.ClientSize.Width / 2, -pictureBox1.ClientSize.Height / 2);
//e.Graphics.DrawLine(lápiz2, 20, pictureBox1.ClientSize.Height / 2, pictureBox1.ClientSize.Width / 2, pictureBox1.ClientSize.Height / 2);
e.Graphics.DrawPath(lápiz2, m_lavadora);
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
ángulo = (float)trackBar1.Value;
pictureBox1.Refresh();
}
private void pictureBox1_Resize(object sender, EventArgs e)
{
int ancho = pictureBox1.ClientSize.Width;
int alto = pictureBox1.ClientSize.Height;
m_lavadora = new GraphicsPath();
m_lavadora.AddEllipse(20, 20, ancho - 40, alto - 40);
m_lavadora.CloseFigure();
m_lavadora.AddLine(20, (alto / 2), ancho - 20, (alto / 2));
m_lavadora.CloseFigure();
m_lavadora.AddLine(ancho / 2, 20, ancho / 2, alto - 20);
m_lavadora.CloseFigure();
}
}
}
// Foros de electrónica http://www.forosdeelectronica.com
// By Meta.
// Fecha 14-04-2014.
// http://electronica-pic.blogspot.com.es
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D; // No olvidar.
namespace Lavadora_4
{
public partial class Form1 : Form
{
private Pen lápiz2;
private Pen lápiz3;
private Pen lápiz4;
private float ángulo;
private SolidBrush agua;
private GraphicsPath m_lavadora;
private GraphicsPath m_agua;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Size = new Size(300, 300);
pictureBox1.BackColor = Color.AntiqueWhite;
lápiz2 = new Pen(Color.Green, 10);
lápiz2.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
lápiz2.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
lápiz3 = new Pen(Color.Black);
lápiz4 = new Pen(Color.Red, 10);
ángulo = 0;
agua = new SolidBrush(Color.FromArgb(200, 0, 0, 255)); // Transparencia del agua 200.
trackBar2.Value = -90; // Para que empiece sin agua.
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(lápiz3, 10, 10, pictureBox1.ClientSize.Width - 20, pictureBox1.ClientSize.Height - 20);
e.Graphics.DrawEllipse(lápiz4, 10, 10, pictureBox1.ClientSize.Height - 20, pictureBox1.ClientSize.Height - 20);
e.Graphics.TranslateTransform(pictureBox1.ClientSize.Width / 2, pictureBox1.ClientSize.Height / 2);
e.Graphics.RotateTransform(ángulo);
e.Graphics.TranslateTransform(-pictureBox1.ClientSize.Width / 2, -pictureBox1.ClientSize.Height / 2);
//e.Graphics.DrawLine(lápiz2, 20, pictureBox1.ClientSize.Height / 2, pictureBox1.ClientSize.Width / 2, pictureBox1.ClientSize.Height / 2);
e.Graphics.DrawPath(lápiz2, m_lavadora);
e.Graphics.ResetTransform();
e.Graphics.FillPath(agua, m_agua);
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
ángulo = (float)trackBar1.Value;
pictureBox1.Refresh();
}
private void pictureBox1_Resize(object sender, EventArgs e)
{
int ancho = pictureBox1.ClientSize.Width;
int alto = pictureBox1.ClientSize.Height;
m_lavadora = new GraphicsPath();
m_lavadora.AddEllipse(20, 20, ancho - 40, alto - 40);
m_lavadora.CloseFigure();
m_lavadora.AddLine(20, (alto / 2), ancho - 20, (alto / 2));
m_lavadora.CloseFigure();
m_lavadora.AddLine(ancho / 2, 20, ancho / 2, alto - 20);
m_lavadora.CloseFigure();
m_agua = new GraphicsPath();
m_agua.AddArc(20, 20, ancho - 40, alto - 40, trackBar2.Value, 180 - 2 * trackBar2.Value);
m_agua.CloseFigure();
}
private void trackBar2_ValueChanged(object sender, EventArgs e)
{
m_agua = new GraphicsPath();
m_agua.AddArc(20, 20, pictureBox1.ClientSize.Width - 40, pictureBox1.ClientSize.Height - 40, -trackBar2.Value, 180 - 2 * -trackBar2.Value);
m_agua.CloseFigure();
pictureBox1.Refresh();
}
}
}
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Dibujo_Animado_GDI { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button_Activar_Click(object sender, EventArgs e) { timer1.Start(); // Activa el temporizador. Lo que no se si esto es mejor así o como indica abajo. // timer1.Enabled = true; timer2.Start(); timer3.Start(); // Tiempos en cada timer, lo que no me sale como cambiarlo desde el textBox. 1000 milisegundo son 1 segundo. timer1.Interval = 100; // 0.1 segundos. timer1.Interval = 500; // 0.5 segundos o medio segundo. timer1.Interval = 1000; // 1 segundo. } private void button_Detener_Click(object sender, EventArgs e) { // Detener los timer. timer1.Stop(); // También puede ser así: timer1.Enabled = false, lo que no se cual es el más adecuado para estos casos. timer2.Stop(); timer3.Stop(); } } }