• 大小: 55KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-26
  • 语言: C#
  • 标签:

资源简介

c#自定义的进度条和音乐播放器的进度条一样炫,绝对值5分,控件的属性中有个布尔类型的IsPlay,如果为true的话,进度点就会闪烁,有当前点Current,自己看吧

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace ControlProcess
{
    [DefaultEvent(“ProgressClick“)]
    [ToolboxBitmap(typeof(TrackBar))]
    public partial class ProcessBar : UserControl
    {
        public ProcessBar()
        {
            //232进度条
            InitializeComponent();
            //this.Setstyle(Controlstyles.UserPaint true);
            //this.Setstyle(Controlstyles.AllPaintingInWmPaint true);
            //this.Setstyle(Controlstyles.DoubleBuffer true);
        }

        private int locationX=0;
        [Description(“单击时X的坐标“)]
        public int LocationX
        {
            get { return locationX; }
        }
   
        private int current = 0;
        [Description(“当前进度“)]
        public int Current
        {
            get { return current; }
            set
            {
                if (value > 232 || value < 0)
                    return;
                current = value;
                panelCurrent.Size = new Size(value 1);
                picture.Location = new Point(value - 4 -3);
                Invalidate();
            }
        }

        private bool isPlay = false;
        [Description(“是否播放“)]
        public bool IsPlay
        {
            get { return isPlay; }
            set { isPlay = value; tmrCurrent.Enabled = isPlay; Invalidate(); }
        }

        public delegate void MouseHandle(object senderEventArgs e);
        [Description(“点下鼠标“)]
        public event MouseHandle BarMouseDown;

        int picturetype = 0;
        private void tmrCurrent_Tick(object sender EventArgs e)
        {
            if (picturetype == 0)
            { picture.Image = Properties.Resources.play_slider_thumb; picturetype = 1; }
            else
            { picture.Image = Properties.Resources.play_slider_thumb_animate; picturetype = 0; }
            GraphicsPath g = subGraphicsPath(picture.Image);
            if (g == null) return;
            picture.Region = new Region(g);
        }

        private unsafe static GraphicsPath subGraphicsPath(Image img)
        {
            if (img == null) return null;
            // 建立GraphicsPath 给我们的位图路径计算使用   
            GraphicsPath g = new GraphicsPath(FillMode.Alternate);
            Bitmap bitmap = new Bitmap(img);
            int width = bitmap.Width;
            int height = bitmap.Height;
            BitmapData bmData = bitmap.LockBits(new Rectangle(0 0 width height) ImageLockMode.ReadWrite PixelFormat.Format24bppRgb);
            byte* p = (byte*)bmData.Scan0;
            int offset = bmData.Stride - width * 3;
            int p0 p1 p2;         // 记录左上角0,0座标的颜色值  
            p0 = p[0];
            p1 = p[1];
            p2 = p[2];

            int star

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      16384  2014-02-19 22:37  ControlProcess\bin\Debug\ControlProcess.dll

     文件      19968  2014-02-19 22:37  ControlProcess\bin\Debug\ControlProcess.pdb

     文件       3702  2014-02-06 14:30  ControlProcess\ControlProcess.csproj

     文件        671  2014-02-19 22:37  ControlProcess\obj\Debug\ControlProcess.csproj.FileListAbsolute.txt

     文件      16384  2014-02-19 22:37  ControlProcess\obj\Debug\ControlProcess.dll

     文件      19968  2014-02-19 22:37  ControlProcess\obj\Debug\ControlProcess.pdb

     文件        180  2014-02-19 22:37  ControlProcess\obj\Debug\ControlProcess.ProcessBar.resources

     文件       4897  2014-02-19 22:37  ControlProcess\obj\Debug\ControlProcess.Properties.Resources.resources

     文件      15072  2014-02-06 15:26  ControlProcess\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6401  2014-02-19 22:37  ControlProcess\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        290  2014-02-19 22:37  ControlProcess\obj\Debug\GenerateResource.read.1.tlog

     文件        554  2014-02-19 22:37  ControlProcess\obj\Debug\GenerateResource.write.1.tlog

     文件       4608  2014-02-06 15:16  ControlProcess\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       5148  2014-02-12 11:38  ControlProcess\ProcessBar.cs

     文件       4320  2014-02-12 11:35  ControlProcess\ProcessBar.Designer.cs

     文件       6015  2014-02-12 11:35  ControlProcess\ProcessBar.resx

     文件       1380  2014-02-05 17:02  ControlProcess\Properties\AssemblyInfo.cs

     文件       3429  2014-02-06 15:16  ControlProcess\Properties\Resources.Designer.cs

     文件      12589  2014-02-06 15:16  ControlProcess\Properties\Resources.resx

     文件       3020  2014-02-06 10:19  ControlProcess\Resources\play_slider_thumb.png

     文件       1257  2014-02-06 10:19  ControlProcess\Resources\play_slider_thumb_animate.png

     目录          0  2014-02-06 15:16  ControlProcess\obj\Debug\TempPE

     目录          0  2014-02-19 22:37  ControlProcess\bin\Debug

     目录          0  2014-02-05 17:03  ControlProcess\bin\Release

     目录          0  2014-02-19 22:37  ControlProcess\obj\Debug

     目录          0  2014-02-05 17:03  ControlProcess\bin

     目录          0  2014-02-05 17:02  ControlProcess\obj

     目录          0  2014-02-06 10:18  ControlProcess\Properties

     目录          0  2014-02-06 10:19  ControlProcess\Resources

     目录          0  2014-02-06 10:19  ControlProcess

............此处省略3个文件信息

评论

共有 条评论