zoukankan      html  css  js  c++  java
  • c# winform 类似android toast消息功能

    先看下效果:

    支持动画,支持声音,支持定时自动关闭

    使用方法:

    var notifycation = new Notification(“My Notification”, "My notification message goes here", 2, "Slide", "Right");

    notifycation.show();

    用起来就这么简单,第一个参数是title,第二个是内容,背景红色是可以换的,第三个参数是自动关闭时间,第四个是窗口动作,淡入淡出,或者滑翔,第五个参数是从左边还是右边,上边还是下边出来

    支持多个toast,消失之前会叠加不会盖住,

    核心源码:

    if (duration < 0)
                    duration = int.MaxValue;
                else
                    duration = duration * 1000;
    
                lifeTimer.Interval = duration;
                labelTitle.Text = title;
                labelBody.Text = body;
    
                _animator = new FormAnimator(this, animation, direction, 500);
    
                Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20));
    

      

    [DllImport("user32")]
            internal extern static bool AnimateWindow(IntPtr hWnd, int dwTime, int dwFlags);
    
            [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
            internal static extern IntPtr CreateRoundRectRgn
            (
                int nLeftRect, // x-coordinate of upper-left corner
                int nTopRect, // y-coordinate of upper-left corner
                int nRightRect, // x-coordinate of lower-right corner
                int nBottomRect, // y-coordinate of lower-right corner
                int nWidthEllipse, // width of ellipse
                int nHeightEllipse // height of ellipse
            );
    

      

    源码下载

  • 相关阅读:
    VS2013中设置大小写的快捷键
    cocos3.2版本中的一些新特性
    cocos2dx中的设计分辨率与屏幕适配策略
    cocos3.2中如何创建一个场景
    C++中的虚函数(类的向上转换,和向下转换)
    C++中的冒泡排序,选择排序,插入排序
    C++中的快速排序(使用vector和数组的不同)
    2440addr.h
    2440slib.h
    mmu.h
  • 原文地址:https://www.cnblogs.com/y114113/p/6971937.html
Copyright © 2011-2022 走看看