资源简介
此项目中有两个工程 WpfTest 附加 GifImageLib 即可使用
美化了tabcontrol控件,同时支持gif动画,学习的好资料
代码片段和文件信息
using System;
using System.IO;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
namespace GifImageLib
{
class GifAnimation : Viewbox
{
private class Gifframe : Image
{
public int delayTime;
public int disposalMethod;
public int left;
public int top;
public int width;
public int height;
}
private Canvas canvas = null;
private Listame> frameList = null;
private int frameCounter = 0;
private int numberOfframes = 0;
private int numberOfLoops = -1;
private int currentLoop = 0;
private int logicalWidth = 0;
private int logicalHeight = 0;
private DispatcherTimer frameTimer = null;
private Gifframe currentParseGifframe;
public GifAnimation()
{
canvas = new Canvas();
this.Child = canvas;
}
private void Reset()
{
if (frameList != null)
{
frameList.Clear();
}
frameList = null;
frameCounter = 0;
numberOfframes = 0;
numberOfLoops = -1;
currentLoop = 0;
logicalWidth = 0;
logicalHeight = 0;
if (frameTimer != null)
{
frameTimer.Stop();
frameTimer = null;
}
}
#region PARSE
private void ParseGif(byte[] gifData)
{
frameList = new Listame>();
currentParseGifframe = new Gifframe();
ParseGifDataStream(gifData 0);
}
private int ParseBlock(byte[] gifData int offset)
{
switch (gifData[offset])
{
case 0x21:
if (gifData[offset + 1] == 0xF9)
{
return ParseGraphicControlExtension(gifData offset);
}
else
{
return ParseExtensionBlock(gifData offset);
}
case 0x2C:
offset = ParseGraphicBlock(gifData offset);
frameList.Add(currentParseGifframe);
currentParseGifframe = new Gifframe();
return offset;
case 0x3B:
return -1;
default:
throw new Exception(“GIF format incorrect: missing graphic block or special-purpose block. “);
}
}
private int ParseGraphicControlExtension(byte[] gifData int offset)
{
int return
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-01-15 22:24 GifImageLib\
文件 11103 2007-12-23 15:56 GifImageLib\GifAnimation.cs
文件 14264 2016-01-15 22:24 GifImageLib\GifImage.cs
文件 3870 2016-01-15 21:13 GifImageLib\GifImageLib.csproj
目录 0 2016-01-15 21:16 GifImageLib\Properties\
文件 2290 2007-12-23 12:37 GifImageLib\Properties\AssemblyInfo.cs
文件 2862 2016-01-15 21:13 GifImageLib\Properties\Resources.Designer.cs
文件 5612 2007-12-23 12:37 GifImageLib\Properties\Resources.resx
文件 1111 2016-01-15 21:13 GifImageLib\Properties\Settings.Designer.cs
文件 201 2007-12-23 12:37 GifImageLib\Properties\Settings.settings
目录 0 2016-01-15 21:16 GifImageLib\bin\
目录 0 2016-01-15 21:31 GifImageLib\bin\Debug\
文件 17920 2016-01-15 22:24 GifImageLib\bin\Debug\GifImageLib.dll
文件 38400 2016-01-15 22:24 GifImageLib\bin\Debug\GifImageLib.pdb
目录 0 2016-01-15 21:16 GifImageLib\obj\
目录 0 2016-01-15 22:15 GifImageLib\obj\Debug\
文件 6927 2016-01-15 21:17 GifImageLib\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 180 2016-01-15 21:31 GifImageLib\obj\Debug\GifImageLib.Properties.Resources.resources
文件 1117 2016-01-15 22:15 GifImageLib\obj\Debug\GifImageLib.csproj.FileListAbsolute.txt
文件 789 2016-01-15 21:31 GifImageLib\obj\Debug\GifImageLib.csproj.GenerateResource.Cache
文件 1824 2016-01-15 22:15 GifImageLib\obj\Debug\GifImageLib.csprojResolveAssemblyReference.cache
文件 17920 2016-01-15 22:24 GifImageLib\obj\Debug\GifImageLib.dll
文件 38400 2016-01-15 22:24 GifImageLib\obj\Debug\GifImageLib.pdb
目录 0 2016-01-15 21:16 GifImageLib\obj\Debug\TempPE\
文件 3584 2016-01-15 21:13 GifImageLib\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
目录 0 2016-01-15 22:16 WpfTest\
目录 0 2016-01-15 20:56 WpfTest\Entity\
文件 2314 2016-01-15 20:56 WpfTest\Entity\TabEntity.cs
文件 2218 2016-01-14 21:54 WpfTest\Form1.Designer.cs
文件 357 2016-01-14 21:54 WpfTest\Form1.cs
文件 5817 2016-01-14 21:54 WpfTest\Form1.resx
............此处省略67个文件信息
- 上一篇:WPF操作滚动条
- 下一篇:c#窗体编程显示鼠标位置;菜单程序;时钟程序
评论
共有 条评论