MagicBuzz | Code qui marche pas sur PocketPC, mais pas compliqué à refaire proprement (virer les Brush et mettre Color à la place, et remplacer le FillPie par un truc qui marche sur PocketPC... j'imagine un FillEllipse par dessus lequel on dessine un polygone effaçant tout de dont on n'a pas besoin
Code :
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Text;
- using System.Windows.Forms;
- namespace MagicProgressBar
- {
- public partial class Circular : UserControl
- {
- private ulong min = 0;
- private ulong max = 100;
- private ulong value = 0;
- public ulong Min
- {
- get
- {
- return this.min;
- }
- set
- {
- if (value > this.max) throw new OverflowException("Min value can't be bigger than Max value" );
- if (value > this.value) throw new OverflowException("Min value can't be bigger than current value" );
- this.min = value;
- }
- }
- public ulong Max
- {
- get
- {
- return this.max;
- }
- set
- {
- if (value < this.max) throw new OverflowException("Max value can't be lower than Min value" );
- if (value < this.value) throw new OverflowException("Max value can't be lower than current value" );
- this.max = value;
- }
- }
- public ulong Value
- {
- get
- {
- return this.value;
- }
- set
- {
- if (value > this.max) throw new OverflowException("Current value can't be bigger than Max value" );
- if (value < this.min) throw new OverflowException("Current value can't be lower than Min value" );
- this.value = value;
- }
- }
- public Circular()
- {
- InitializeComponent();
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- base.OnPaint(e);
- Pen p = new Pen(Brushes.Black, 1f);
- e.Graphics.FillPie(Brushes.Red, new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientSize.Width - 1, this.ClientSize.Height - 1), 0f, (this.min < this.max) ? (360 * (this.value - this.min) / (this.max - this.min)) : 0);
- e.Graphics.FillEllipse((new Pen(this.BackColor)).Brush, new Rectangle(this.ClientRectangle.X + 30, this.ClientRectangle.Y + 30, this.ClientSize.Width - 59, this.ClientSize.Height - 59));
- e.Graphics.DrawEllipse(p, new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientSize.Width - 1, this.ClientSize.Height - 1));
- e.Graphics.DrawEllipse(p, new Rectangle(this.ClientRectangle.X + 30, this.ClientRectangle.Y + 30, this.ClientSize.Width - 59, this.ClientSize.Height - 59));
- }
- }
- }
|
|