Using MetroFramework 1.3.5 and .NET Transitions, in Windows Forms, I have written the code for a live MetroTile. Here is the Timer Tick method used to update the tile:
private void updateTiles_timer_Tick(object sender, EventArgs e)
{
metroPanel1.BackColor = Color.Transparent;
Bitmap bm = new Bitmap(metroPanel1.Width, metroPanel1.Height);
metroTile_startStop.DrawToBitmap(bm, new Rectangle(metroTile_startStop.Location.X, metroTile_startStop.Location.Y, metroTile_startStop.Width, metroTile_startStop.Height));
metroPanel1.BackgroundImage = bm;
if (animationFlag)
{
metroTile_startStop.Text = Properties.Resources.startStopTile_alternateText;
animationFlag = false;
}
else
{
metroTile_startStop.Text = "Start";
animationFlag = true;
}
Transition.run(metroTile_startStop, "Top", metroTile_startStop.Height - 16, 4, new TransitionType_Linear(500));
}
private void metroPanel1_Click(object sender, EventArgs e)
{
metroTile_startStop.PerformClick();
}
The tile is placed inside a MetroPanel with the Size(tile.Width + 10, tile.Height + 8). metroPanel1_Click() is necessary if, during a transition, the user clicks the background bitmap.
I don't have sufficient experience and I need help in writing a custom control so I can easily reuse it in future projects. The control should have a property which sets the timer interval and the possibility to set the tile texts. If I have a working code, then I can extend it to set the tile image, customize animations etc.
Thank you!