[C#] 콘트롤 애니메이션 효과 > C#/.Net/Blazor/IIS

본문 바로가기
사이트 내 전체검색

C#/.Net/Blazor/IIS

[C#] 콘트롤 애니메이션 효과

페이지 정보

작성자 sbLAB 댓글 0건 조회 5,933회 작성일 18-07-25 18:00

본문


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            comboBox1.Text = "서울";
            Util.Animate(comboBox1, Util.Effect.Slide, 60180);
            Util.Animate(comboBox1, Util.Effect.Slide, 60180);
 
            comboBox2.Text = "전북";
            Util.Animate(comboBox2, Util.Effect.Slide, 70180);
            Util.Animate(comboBox2, Util.Effect.Slide, 70180);
 
            comboBox3.Text = "울산";
            Util.Animate(comboBox3, Util.Effect.Slide, 80180);
            Util.Animate(comboBox3, Util.Effect.Slide, 80180);
 
        }
    }
 
 
    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 = { 15462108};
        private static int[] effmap = { 00x400000x100x80000 };
 
        [DllImport("user32.dll")]
        private static extern bool AnimateWindow(IntPtr handle, int msec, int flags);
    }
 
}
 
 

댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
8
어제
407
최대
1,279
전체
211,778

그누보드5
Copyright © sebom.com All rights reserved.