cool hit counter [C#] Component Release: MessageTip, Light and Fast Message Alert Window_Intefrankly

[C#] Component Release: MessageTip, Light and Fast Message Alert Window


-------------201610212046 update-------------

Updated to version 2.0, basically a complete rewrite with emphasis on.

  • Change to render animations based on the native LayeredWindow form and UpdateLayeredWindow API, abandoning the .net Form altogether, the former is perfect for this kind of message box, the latter is too bloated for this scenario
  • Higher, faster, stronger, cooler, cooler, cooler
  • Several message window styles can be freely customized. 1.Version 0 seems to only be able to change the icon

The project has been updated to the open source repository, please pick it up if you need it. See the picture.

-------------201608301610 update-------------

Updated based on feedback from several apes in the comments and suggestions, mainly.

  • ShowXX determines the display position based on the active control if the point parameter is not specified, or the cursor position if the active control is a text input class control
  • If the point parameter is specified, it is determined directly from that point
  • Also added a set of ShowXX overloads, accept Control and ToolStripItem (toolbar buttons, etc., hereinafter called item) object, finished according to the object to determine the display position. Note here that the item is unfocused, so there is no way to know in MessageTip that it is the item that is clicked on, and there is no way to do it automatically near the item, so here is a Best Practices : If you want to display it near the item, you need to use the above overload and pass the item in; the rest of the cases can let MessageTip automatically determine where to display it
  • When the display is too close to the top of the screen, it is displayed below the reference point and the animation is changed from floating up to falling down
  • Positioning error in multi-screen environments, currently limiting the message box to be displayed within the screen where the datum is located
  • For the occasional exception mentioned by one of the apes, since I was never able to reproduce it in my environment, I can only guess that it is due to contention for the TipIcon in both the Load event and OnPaint, so for the time being, I'll add exclusive features to the TipIcon getter and hope that will solve it

Original article and web sitedemo I just don't. update finish, The project has been open sourced to the following locations, For those interested, please follow and feel free to fork/push/pull:.

------------- original -------------

Notes. This component works with .net2.0+ winform projects

Appearance.

The actual result is smoother than this gif, we recommend downloading the Tester at the end of the article to experience it

Presentation.

As you can see in the picture, this kind of alert is used more often on web and mobile phones, and the benefits over a proper message box (like MessageBox), I think, are.

  • No need for the user to respond to the message itself, click [OK] or whatever
  • No blocking, no interfering with the user's subsequent actions, just simply telling you it's done
  • Visually ensure the deliverability of messages through animations to compensate for the "ignored" that may result from lack of intervention

This is what I call a [light and fast message alert window] for.

  • Operations that produce quick results, like running a small statement in a local library or something. If it's a time-consuming operation, it's obviously more appropriate to get a progress alert, like this one
  • Situations where only a small amount of feedback is required should not normally exceed 15 words. If you need to feed a lot of information, you can try this one

Features.

  • Display a message near the mouse. So it's not suitable for time-consuming tasks, because by the time the task is finished, the mouse is gone somewhere
  • 3 icons of message nature are built in.

You can also use custom icons (using the Show method)

  • The floating animation effect can be opened and closed (property AllowFloating, which affects the subsequent pop-up message window)
  • You can show only icons or text, or even no icons or text at all ~ although this is not interesting

Usage.

 //On/Off float animation. Default on
MessageTip.AllowFloating = true|false;

 // Default dwell time (milliseconds). This value is used when a negative delay value is specified in ShowXXX, default 500
MessageTip.DefaultDelay = int;

// copies( can be used fornull perhaps"", the same below)、 icon (computing)( because ofnull Icons are not displayed when)、 dwell time( selectable, the same below, For negative values, useDefaultDelay)
MessageTip.Show(" Stephen.", image | null, [delay]);

 //text, built-in green tick icon, length of stay
MessageTip.ShowOk(" Successful implementation", [delay]);

 //text, built-in yellow exclamation mark icon, length of stay
MessageTip.ShowWarning(" Successful implementation", [delay]);

 //text, built-in red cross icon, length of stay
MessageTip.ShowError(" Successful implementation", [delay]);

Background.

I've been meaning to write this for a long time, because a lot of times a serious MessageBox pop-up can affect the mood, it's supposed to be a matter of informing, you have to go and click OK, annoying, but because there's been all kinds of crap, I didn't get it until today. At first it was implemented using the win32 API AnimateWindow (MSDN ), but it does not have the effect of floating up, so simply implement it yourself, the principle is nothing more than a step-by-step modification of the transparency (Opacity) and position (Location) of the form, just using the asynchronous means. Asynchronous is used in two places, one is to change the Location, in order not to let it fight with the transparency animation, and the second is also asynchronous when Showing the form, in order to be completely isolated from the main UI thread from the thread level and to achieve the effect of quickly Showing multiple messages, as shown in the figure.

Otherwise, you have to wait until one message is completely gone before you can show the next one, and there is a risk of blocking other user actions if the Show is in the main thread.

Finally, please point out the problem or tell us about a better solution already in place, thanks!

The project has been put on the netbook, and there is a Tester in there for you to experience, the one in the first picture.http://pan.baidu.com/s/1dEVjzMD

-Bunbi-


Recommended>>
1、Blockchain travel platform Starbull Travel App to go live next month to provide intelligent services based on sightseeing tours official visits etc
2、Father of Alpha Who is the best Jedi or Alpha Dog
3、Solution to the problem of creating a common project in Idea to connect to a database
4、Education The debut of the latest black technology from Najije Concept cockpit for mass consumption
5、Beijing to build national cybersecurity industrial park

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号