トレイアイコンアニメ
-
05-09-2019 - |
質問
いかにアイコンはWindowsの通知領域(システムトレイ).
何が最善の方法においてアイコンアニメイト?使用できる、アニメーションgif、いなすか?
私C#コンポーネントのラインナップでサポート受け入れます。
解決
Abhinabaバスのブログ アニメーションやテキストシステムトレイを使用C# 説明します。
まり:
- るということで、ついでにアイコンの表示アニメーションフレーム。
- 切り替えのアイコンをトレイにタイマー-イベント
- をビットマップストリップがあります。各フレームは、16x16ピクセル
- 使用 SysTray.cs
例えば
private void button1_Click(object sender, System.EventArgs e)
{
m_sysTray.StopAnimation();
Bitmap bmp = new Bitmap("tick.bmp");
// the color from the left bottom pixel will be made transparent
bmp.MakeTransparent();
m_sysTray.SetAnimationClip(bmp);
m_sysTray.StartAnimation(150, 5);
}
SetAnimationClip
以下のコード作成、アニメーションフレーム
public void SetAnimationClip (Bitmap bitmapStrip)
{
m_animationIcons = new Icon[bitmapStrip.Width / 16];
for (int i = 0; i < m_animationIcons.Length; i++)
{
Rectangle rect = new Rectangle(i*16, 0, 16, 16);
Bitmap bmp = bitmapStrip.Clone(rect, bitmapStrip.PixelFormat);
m_animationIcons[i] = Icon.FromHandle(bmp.GetHicon());
}
}
アニメーションするために、フレーム StartAnimation
開始タイマーのタイマーのアイコンの変更をアニメーションのシーケンスです。
public void StartAnimation(int interval, int loopCount)
{
if(m_animationIcons == null)
throw new ApplicationException("Animation clip not set with
SetAnimationClip");
m_loopCount = loopCount;
m_timer.Interval = interval;
m_timer.Start();
}
private void m_timer_Tick(object sender, EventArgs e)
{
if(m_currIndex < m_animationIcons.Length)
{
m_notifyIcon.Icon = m_animationIcons[m_currIndex];
m_currIndex++;
}
....
}
使用SysTray
の作成およびワイヤーアップメニュー
ContextMenu m_menu = new ContextMenu();
m_menu.MenuItems.Add(0, new MenuItem("Show",new
System.EventHandler(Show_Click)));
取得したいアイコンを静的にセットします。
をSysTrayオブジェクトのすべての必要な情報
m_sysTray = new SysTray("Right click for context menu",
new Icon(GetType(),"TrayIcon.ico"), m_menu);
画像を加工する帯とアニメーションフレームに。6フレームストリップの幅が6*16、高さ16ピクセル
Bitmap bmp = new Bitmap("tick.bmp");
// the color from the left bottom pixel will be made transparent
bmp.MakeTransparent();
m_sysTray.SetAnimationClip(bmp);
インバージョンにどのように行うかを示す多くの時に必要なループのアニメーションのフレーム遅延
m_sysTray.StartAnimation(150, 5);
停止のアニメコ
m_sysTray.StopAnimation();
他のヒント
私はこれを行うための最善の方法は、あなたが速度と時間に基づいて、新たな画像にシステムトレイのオブジェクトを変更し続けることができ、複数の小さなアイコンを持つことだと思います。
所属していません StackOverflow