利用C#画视频录制及播放的界面(一)

最近因网站需要,必须写一个视频录制及播放的界面,原来考虑使用图片来解决问题。但最后还是放弃了这种想法,因为使用图片不够灵活,而且将来无法订制软件皮肤。所以,决定直接画图的方式来解决。
首先看一下要实现的界面:(本届面使用普通设计软件画出)
/*声明:BrawDraw.com, ZPXP.com版权所有:a3news(AT)hotmail.com,仅供学习,参考之用,切勿用于商业用途!*/
 

其实也是够复杂的。
每个细微处都得做好它,需要细致和耐心哟。

这两天写出一个框架性的代码出来了:
//VideoInterface.cs
/*
BrawDraw.com, ZPXP.com版权所有:a3news(AT)hotmail.com,仅供学习,参考之用,切勿用于商业用途!
*/
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;

namespace BrawDraw.Com.Video
{
 /// <summary>
 /// 视频录制入回放界面(VideoInterFace)
 /// </summary>
 public class VideoInterFace : System.ComponentModel.Component
 {
  private SolidBrush brush1 = new SolidBrush(Color.FromArgb(0, 0, 0, 0));
  private SolidBrush brush2 = new SolidBrush(Color.FromArgb(255, 0, 0, 0));
  private Pen stroke1 = new Pen(Color.FromArgb(255, 255, 25, 14), 1F);
  private Font font1 = new Font("Times New Roman", 10F, ((FontStyle)(0)), GraphicsUnit.Point, 1);
  private StringFormat stringformat1 = new StringFormat(StringFormat.GenericTypographic);   
  private RectangleF Image1Rectangle = new RectangleF(2, 573, 852, 550);       
  protected GraphicsPath outer_RoundRect = new GraphicsPath(
   new PointF[] {
        new PointF(10F, 24F),
        new PointF(10F, 13F),
        new PointF(19F, 7F),
        new PointF(26F, 7F),
        new PointF(825F, 7F),
        new PointF(834F, 7F),
        new PointF(841F, 14F),
        new PointF(841F, 23F),
        new PointF(841F, 525F),
        new PointF(841F, 535F),
        new PointF(836F, 542F),
        new PointF(824F, 542F),
        new PointF(30F, 542F),
        new PointF(16F, 542F),
        new PointF(10F, 535F),
        new PointF(10F, 524F)},
   new System.Byte[] {
          0,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          131});
   
  protected GraphicsPath top_RoundRect_Outer = new GraphicsPath(
   new PointF[] {
        new PointF(10F, 63F),
        new PointF(10F, 22F),
        new PointF(11F, 15F),
        new PointF(16F, 8F),
        new PointF(25F, 7F),
        new PointF(826F, 7F),
        new PointF(833F, 7F),
        new PointF(841F, 14F),
        new PointF(841F, 22F),
        new PointF(841F, 63F)},
   new System.Byte[] {
          0,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          129});
   
  private Pen top_RoundRect_OuterPen = new Pen(Color.FromArgb(255, 255, 25, 14), 0.1F);
   
  protected GraphicsPath ClosedPath2 = new GraphicsPath(
   new PointF[] {
        new PointF(10F, 63F),
        new PointF(10F, 24F),
        new PointF(10F, 17F),
        new PointF(15F, 8F),
        new PointF(25F, 7F),
        new PointF(189F, 7F),
        new PointF(199F, 9F),
        new PointF(207F, 19F),
        new PointF(211F, 35F),
        new PointF(214F, 49F),
        new PointF(222F, 59F),
        new PointF(229F, 63F)},
   new System.Byte[] {
          0,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          3,
          3,
          131});
   
  protected Rectangle topRight_MinButton_Outer = new Rectangle(711, 19, 33, 33);   
  protected Rectangle topRight_MaxButton_Outer = new Rectangle(753, 19, 33, 33);   
  protected Rectangle topRight_CloseButton_Outer = new Rectangle(794, 19, 33, 33);   
  protected Rectangle Rect1 = new Rectangle(717, 34, 22, 3);   
  protected Rectangle Rect2 = new Rectangle(759, 26, 20, 19);   
  protected PointF Line1PointStart = new PointF(822F, 24F);   
  protected PointF Line1PointEnd = new PointF(798F, 46F);   
  protected PointF Line2PointStart = new PointF(799F, 24F);   
  protected PointF Line2PointEnd = new PointF(823F, 46F);   
  protected Rectangle rect_WordLuo_BgOuter = new Rectangle(248, 18, 38, 37);   
  protected Rectangle rect_WordBo_BgOuter = new Rectangle(290, 18, 38, 37);   
  protected Rectangle rect_WordSu_BgOuter = new Rectangle(332, 18, 38, 37);   
  protected Rectangle rect_WordSmall_BgOuter1 = new Rectangle(380, 27, 28, 28);   
  protected Rectangle Rect7 = new Rectangle(413, 27, 28, 28);   
  protected Rectangle Rect8 = new Rectangle(445, 27, 28, 28);   
  protected Rectangle Rect9 = new Rectangle(478, 27, 28, 28);   
  protected Rectangle Rect10 = new Rectangle(510, 27, 28, 28);   
  protected Rectangle Rect11 = new Rectangle(542, 27, 28, 28);   
  protected GraphicsPath centerRight_RoundRect_NotesZone = new GraphicsPath(
   new PointF[] {
        new PointF(588F, 94F),
        new PointF(588F, 88F),
        new PointF(592F, 82F),
        new PointF(599F, 82F),
        new PointF(809F, 82F),
        new PointF(816F, 82F),
        new PointF(819F, 88F),
        new PointF(819F, 95F),
        new PointF(819F, 451F),
        new PointF(819F, 462F),
        new PointF(814F, 465F),
        new PointF(807F, 465F),
        new PointF(597F, 465F),
        new PointF(593F, 465F),
        new PointF(588F, 461F),
        new PointF(588F, 454F)},
   new System.Byte[] {
          0,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          131});
   
  protected GraphicsPath ClosedPath8 = new GraphicsPath(new PointF[] {
                      new PointF(710F, 503F),
                      new PointF(710F, 501F),
                      new PointF(712F, 498F),
                      new PointF(715F, 498F),
                      new PointF(784F, 498F),
                      new PointF(787F, 498F),
                      new PointF(789F, 501F),
                      new PointF(789F, 504F),
                      new PointF(789F, 524F),
                      new PointF(789F, 527F),
                      new PointF(787F, 530F),
                      new PointF(782F, 530F),
                      new PointF(716F, 530F),
                      new PointF(712F, 530F),
                      new PointF(710F, 528F),
                      new PointF(710F, 526F)},
   new System.Byte[] {
          0,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          131});
   
  protected GraphicsPath bottom_RoundRect_Outer = new GraphicsPath(
   new PointF[] {
        new PointF(10F, 487F),
        new PointF(10F, 526F),
        new PointF(11F, 536F),
        new PointF(17F, 542F),
        new PointF(30F, 542F),
        new PointF(826F, 542F),
        new PointF(834F, 542F),
        new PointF(841F, 536F),
        new PointF(841F, 527F),
        new PointF(841F, 487F)},
   new System.Byte[] {
          0,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          129});
   
  protected GraphicsPath bottomLeft_Outer = new GraphicsPath(
   new PointF[] {
        new PointF(10F, 487F),
        new PointF(10F, 526F),
        new PointF(11F, 536F),
        new PointF(17F, 542F),
        new PointF(30F, 542F),
        new PointF(671F, 542F),
        new PointF(649F, 527F),
        new PointF(657F, 498F),
        new PointF(634F, 487F),
        new PointF(620F, 487F)},
   new System.Byte[] {
          0,
          1,
          3,
          3,
          3,
          1,
          3,
          3,
          3,
          129});
   
  protected Rectangle playButton_Outer = new Rectangle(34, 497, 33, 33);   
  protected Rectangle Ellipse5 = new Rectangle(74, 497, 33, 33);   
  protected Rectangle Ellipse6 = new Rectangle(113, 497, 33, 33);   
  protected Rectangle Ellipse7 = new Rectangle(152, 497, 33, 33);   
  protected Rectangle backwardPlayButton_Outer = new Rectangle(191, 497, 33, 33);   
  protected GraphicsPath progressBarOuter = new GraphicsPath(
   new PointF[] {
        new PointF(243F, 528F),
        new PointF(238F, 527F),
        new PointF(238F, 519F),
        new PointF(243F, 518F),
        new PointF(470F, 518F),
        new PointF(475F, 519F),
        new PointF(475F, 528F),
        new PointF(470F, 528F)},
   new System.Byte[] {
          0,
          3,
          3,
          3,
          1,
          3,
          3,
          131});
   
  protected Rectangle progressBarNotifier = new Rectangle(279, 517, 12, 12);
   
  protected GraphicsPath soundVolumnOuter = new GraphicsPath(
   new PointF[] {
        new PointF(494F, 527F),
        new PointF(632F, 510F),
        new PointF(625F, 527F)},
   new System.Byte[] {
          0,
          1,
          129});
   
  protected Rectangle soundVolumnNotifier = new Rectangle(499, 507, 21, 21);
   
  protected GraphicsPath playButton_innerTriangle = new GraphicsPath(
   new PointF[] {
        new PointF(47F, 520F),
        new PointF(47F, 507F),
        new PointF(58F, 514F)},
   new System.Byte[] {
          0,
          1,
          129});
   
  protected Rectangle Rect12 = new Rectangle(85, 507, 5, 14);   
  protected Rectangle Rect13 = new Rectangle(123, 507, 14, 14);   
  protected Rectangle Rect14 = new Rectangle(172, 507, 2, 14);   
  protected GraphicsPath ClosedPath14 = new GraphicsPath(
   new PointF[] {
        new PointF(162F, 508F),
        new PointF(162F, 521F),
        new PointF(172F, 514F)},
   new System.Byte[] {
          0,
          1,
          129});
   
  protected GraphicsPath ClosedPath15 = new GraphicsPath(
   new PointF[] {
        new PointF(206F, 520F),
        new PointF(206F, 507F),
        new PointF(216F, 514F)},
   new System.Byte[] {
          0,
          1,
          129});
   
  protected Rectangle Rect15 = new Rectangle(201, 507, 2, 14);   
  protected string Text3 = "视频回放";   
  private System.Single Text3PointX = 240;   
  private System.Single Text3PointY = 498;   
  protected string Text4 = "00:56    /   02:12";   
  private RectangleF Text4Rect = new RectangleF(367, 499, 104, 15);   
  protected Rectangle centerLeftRect_VideoZone = new Rectangle(33, 84, 534, 380);
   
  public VideoInterFace()
  {
   this.InitializeGraphics();
  }
   
  private void InitializeGraphics()
  {
   this.stringformat1.Alignment = StringAlignment.Near;
  }
   
  public virtual void RenderGraphics(Graphics g)
  {
   g.SmoothingMode = SmoothingMode.AntiAlias;
   g.TextRenderingHint = TextRenderingHint.AntiAlias;
   g.FillPath(this.brush1, this.outer_RoundRect);
   g.DrawPath(this.stroke1, this.outer_RoundRect);
   g.FillPath(this.brush1, this.top_RoundRect_Outer);
   g.DrawPath(this.top_RoundRect_OuterPen, this.top_RoundRect_Outer);
   g.FillPath(this.brush1, this.ClosedPath2);
   g.DrawPath(this.stroke1, this.ClosedPath2);
   g.FillEllipse(this.brush1, this.topRight_MinButton_Outer);
   g.DrawEllipse(this.stroke1, this.topRight_MinButton_Outer);
   g.FillEllipse(this.brush1, this.topRight_MaxButton_Outer);
   g.DrawEllipse(this.stroke1, this.topRight_MaxButton_Outer);
   g.FillEllipse(this.brush1, this.topRight_CloseButton_Outer);
   g.DrawEllipse(this.stroke1, this.topRight_CloseButton_Outer);
   g.FillRectangle(this.brush1, this.Rect1);
   g.DrawRectangle(this.stroke1, this.Rect1);
   g.FillRectangle(this.brush1, this.Rect2);
   g.DrawRectangle(this.stroke1, this.Rect2);
   g.DrawLine(this.stroke1, this.Line1PointStart, this.Line1PointEnd);
   g.DrawLine(this.stroke1, this.Line2PointStart, this.Line2PointEnd);
   g.FillRectangle(this.brush1, this.rect_WordLuo_BgOuter);
   g.DrawRectangle(this.stroke1, this.rect_WordLuo_BgOuter);
   g.FillRectangle(this.brush1, this.rect_WordBo_BgOuter);
   g.DrawRectangle(this.stroke1, this.rect_WordBo_BgOuter);
   g.FillRectangle(this.brush1, this.rect_WordSu_BgOuter);
   g.DrawRectangle(this.stroke1, this.rect_WordSu_BgOuter);
   g.FillRectangle(this.brush1, this.rect_WordSmall_BgOuter1);
   g.DrawRectangle(this.stroke1, this.rect_WordSmall_BgOuter1);
   g.FillRectangle(this.brush1, this.Rect7);
   g.DrawRectangle(this.stroke1, this.Rect7);
   g.FillRectangle(this.brush1, this.Rect8);
   g.DrawRectangle(this.stroke1, this.Rect8);
   g.FillRectangle(this.brush1, this.Rect9);
   g.DrawRectangle(this.stroke1, this.Rect9);
   g.FillRectangle(this.brush1, this.Rect10);
   g.DrawRectangle(this.stroke1, this.Rect10);
   g.FillRectangle(this.brush1, this.Rect11);
   g.DrawRectangle(this.stroke1, this.Rect11);
   g.FillPath(this.brush1, this.centerRight_RoundRect_NotesZone);
   g.DrawPath(this.stroke1, this.centerRight_RoundRect_NotesZone);
   g.FillPath(this.brush1, this.ClosedPath8);
   g.DrawPath(this.stroke1, this.ClosedPath8);
   g.FillPath(this.brush1, this.bottom_RoundRect_Outer);
   g.DrawPath(this.stroke1, this.bottom_RoundRect_Outer);
   g.FillPath(this.brush1, this.bottomLeft_Outer);
   g.DrawPath(this.stroke1, this.bottomLeft_Outer);
   g.FillEllipse(this.brush1, this.playButton_Outer);
   g.DrawEllipse(this.stroke1, this.playButton_Outer);
   g.FillEllipse(this.brush1, this.Ellipse5);
   g.DrawEllipse(this.stroke1, this.Ellipse5);
   g.FillEllipse(this.brush1, this.Ellipse6);
   g.DrawEllipse(this.stroke1, this.Ellipse6);
   g.FillEllipse(this.brush1, this.Ellipse7);
   g.DrawEllipse(this.stroke1, this.Ellipse7);
   g.FillEllipse(this.brush1, this.backwardPlayButton_Outer);
   g.DrawEllipse(this.stroke1, this.backwardPlayButton_Outer);
   g.FillPath(this.brush1, this.progressBarOuter);
   g.DrawPath(this.stroke1, this.progressBarOuter);
   g.FillEllipse(this.brush1, this.progressBarNotifier);
   g.DrawEllipse(this.stroke1, this.progressBarNotifier);
   g.FillPath(this.brush1, this.soundVolumnOuter);
   g.DrawPath(this.stroke1, this.soundVolumnOuter);
   g.FillEllipse(this.brush1, this.soundVolumnNotifier);
   g.DrawEllipse(this.stroke1, this.soundVolumnNotifier);
   g.FillPath(this.brush1, this.playButton_innerTriangle);
   g.DrawPath(this.stroke1, this.playButton_innerTriangle);
   g.FillRectangle(this.brush1, this.Rect12);
   g.DrawRectangle(this.stroke1, this.Rect12);
   g.FillRectangle(this.brush1, this.Rect13);
   g.DrawRectangle(this.stroke1, this.Rect13);
   g.FillRectangle(this.brush1, this.Rect14);
   g.DrawRectangle(this.stroke1, this.Rect14);
   g.FillPath(this.brush1, this.ClosedPath14);
   g.DrawPath(this.stroke1, this.ClosedPath14);
   g.FillPath(this.brush1, this.ClosedPath15);
   g.DrawPath(this.stroke1, this.ClosedPath15);
   g.FillRectangle(this.brush1, this.Rect15);
   g.DrawRectangle(this.stroke1, this.Rect15);
   g.DrawString(this.Text3, this.font1, this.brush2, this.Text3PointX, this.Text3PointY);
   g.DrawString(this.Text4, this.font1, this.brush2, this.Text4Rect, this.stringformat1);
   g.FillRectangle(this.brush1, this.centerLeftRect_VideoZone);
   g.DrawRectangle(this.stroke1, this.centerLeftRect_VideoZone);
  }
   
  // Required to dispose of created resources
  private void DisposeGraphics()
  {
   this.brush1.Dispose();
   this.brush2.Dispose();
   this.stroke1.Dispose();
   this.font1.Dispose();
   this.stringformat1.Dispose();
   this.outer_RoundRect.Dispose();
   this.top_RoundRect_Outer.Dispose();
   this.top_RoundRect_OuterPen.Dispose();
   this.ClosedPath2.Dispose();
   this.centerRight_RoundRect_NotesZone.Dispose();
   this.ClosedPath8.Dispose();
   this.bottom_RoundRect_Outer.Dispose();
   this.bottomLeft_Outer.Dispose();
   this.progressBarOuter.Dispose();
   this.soundVolumnOuter.Dispose();
   this.playButton_innerTriangle.Dispose();
   this.ClosedPath14.Dispose();
   this.ClosedPath15.Dispose();
  }
   
  protected override void Dispose(bool disposing)
  {
   if (disposing)
   {
    this.DisposeGraphics();
   }
  }
 }
}
在winform中运行的结果截屏:(注:BrawDraw Logo及萝卜鼠图标等文字尚未加上)

(未完待续),详见:利用C#画视频录制及播放的界面(二)[过两天制作出来之后再贴上)

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值