Skip to content

Instantly share code, notes, and snippets.

@NastenaL
Created January 3, 2016 16:32
Show Gist options
  • Save NastenaL/d77d42de312630165137 to your computer and use it in GitHub Desktop.
Save NastenaL/d77d42de312630165137 to your computer and use it in GitHub Desktop.
Анимация боковой панели
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Diploma
{
public partial class Form1 : Form
{
Bitmap RotatingBlocks;
Point DrawHere;
Rectangle InvalidRect;
public Form1()
{
InitializeComponent();
}
//FOR SLIDER----------------------------------------------------------------------------
public static class Util
{
public enum Effect { Roll, Slide, Center, Blend}
public static void Animate(Control ctl, Effect effect, int msec, int angle)
{
int flags = effmap[(int)effect];
if (ctl.Visible)
{ flags |= 0x10000; angle += 180; }
else
{
if (ctl.TopLevelControl == ctl) flags |= 0x20000;
else if (effect == Effect.Blend) throw new ArgumentException();
}
flags |= dirmap[(angle % 360) / 45];
bool ok = AnimateWindow(ctl.Handle, msec, flags);
if (!ok) throw new Exception("Animation failed");
ctl.Visible = !ctl.Visible;
}
private static int[] dirmap = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
private static int[] effmap = { 0, 0x40000, 0x10, 0x80000 };
[DllImport("user32.dll")]
private static extern bool AnimateWindow(IntPtr handle, int msec, int flags);
}
//------------------------------------------------------------------------------------
private void pnOpen_Click(object sender, EventArgs e)
{
// Загрузка анимации для боковой панели
Util.Animate(panel1, Util.Effect.Center, 200, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment