Kubernetes client UAP development and client uap

Source: Internet
Author: User

Kubernetes client UAP development and client uap

When using an application, there will always be various interactions, some of which need to interact with users, and some only inform users of some information. For the former, the general solution is to bring up a dialog box with buttons (or other controls), with information that needs to be known to the user, and the user needs to use buttons (or other controls) the response interaction is not described here. For the latter, users who do not need to interact with each other, but only inform users of the information, the implementation methods are different. This article will propose several solutions and hope to communicate with others, get better human-computer interaction solutions.

 

1. pop-up window prompt

This method is simple and crude. The MessageDialog method of the system is called directly. A window is displayed, and you need to confirm the returned result. Shows the effect:

Public static async Task ShowMessage (string message) {var msgbox = new Windows. UI. Popups. MessageDialog (message); var result = await msgbox. ShowAsync ();}

 

This is the simplest way to handle notifications in an application without too much Code. However, the disadvantage is that the interface is monotonous and you need to manually close the response, increase interaction costs. If this happens frequently, users may be bored.

 

2. custom control display

This method is flexible. The idea is to customize a control, which is hidden at ordinary times. When an in-app notification is required, it will pop up in a way similar to the notification bar or another mode. It will automatically disappear in a few seconds, the interface can be completely customized without user intervention.

Example:

First add Templated Control

<Grid x: name = "mainGrid" Width = "1920" Height = "60" verticalignment = "Top" HorizontalAlignment = "Center" Background = "{ThemeResource CNBlogsSummaryColor}" Visibility = "Collapsed"> <grid. renderTransform> <TranslateTransform x: Name = "GridTrans" Y = "-60"> </TranslateTransform> </Grid. renderTransform> <TextBlock HorizontalAlignment = "Center" verticalignment = "Center" Style = "{ThemeResource icationicationbarfont}" x: Name = "tb_Notify"> </TextBlock> </Grid>

 

Add the animation to the pop-up:

<Grid.Resources>                            <Storyboard x:Name="tb_Notify_in">                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="mainGrid" Storyboard.TargetProperty="(UIElement.Visibility)">                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">                                        <DiscreteObjectKeyFrame.Value>                                            <Visibility>Visible</Visibility>                                        </DiscreteObjectKeyFrame.Value>                                    </DiscreteObjectKeyFrame>                                    <DiscreteObjectKeyFrame KeyTime="00:03:00">                                        <DiscreteObjectKeyFrame.Value>                                            <Visibility>Collapsed</Visibility>                                        </DiscreteObjectKeyFrame.Value>                                    </DiscreteObjectKeyFrame>                                </ObjectAnimationUsingKeyFrames>                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="GridTrans"                                Storyboard.TargetProperty="Y"                                BeginTime="0:0:0">                                    <SplineDoubleKeyFrame  KeyTime="00:00:00.00" Value="-60"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:00.10" Value="-38"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:00.20" Value="-22"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:00.30" Value="-10"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:00.40" Value="-3"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:00.50" Value="0"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:02.50" Value="0"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:02.60" Value="-3"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:02.70" Value="-10"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:02.80" Value="-22"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:02.90" Value="-38"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:03.00" Value="-60"/>                                </DoubleAnimationUsingKeyFrames>                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="mainGrid"                                Storyboard.TargetProperty="Opacity"                                BeginTime="0:0:0">                                    <SplineDoubleKeyFrame  KeyTime="00:00:00.00" Value="0"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:00.50" Value="0.9"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:02.50" Value="0.9"/>                                    <SplineDoubleKeyFrame  KeyTime="00:00:03.00" Value="0"/>                                </DoubleAnimationUsingKeyFrames>                            </Storyboard>                        </Grid.Resources>

 

In this way, the front-end is designed and the called interface needs to be provided in the background:

public sealed class NotificationBar : Control    {        private TextBlock notifyBlock;        private Grid mainGrid;        private Storyboard storyBoard;        public NotificationBar()        {            this.DefaultStyleKey = typeof(NotificationBar);        }        private void GetTextBlockControl()        {            if (this.notifyBlock == null)            {                this.notifyBlock = this.GetTemplateChild("tb_Notify") as TextBlock;            }        }        private void GetStoryBoardControl(string name)        {            if (this.storyBoard == null)            {                this.storyBoard = this.GetTemplateChild(name) as Storyboard;            }        }        public void ShowMessage(string message)        {            GetTextBlockControl();            GetStoryBoardControl("tb_Notify_in");            if (notifyBlock != null && storyBoard != null)            {                notifyBlock.Text = message;                storyBoard.Begin();            }        }    }

In this way, you only need to add this control to the top of the page to call the ShowMessage method to bring up a prompt box.

<local:NotificationBar x:Name="notifyBlock" Grid.ColumnSpan="99" Grid.RowSpan="99" />

 

XmlDocument toastXml = ToastNotificationManager. getTemplateContent (ToastTemplateType. toastText01); XmlNodeList toastTextElements = toastXml. getElementsByTagName ("text"); toastTextElements [0]. appendChild (toastXml. createTextNode (content); IXmlNode toastNode = toastXml. selectSingleNode ("/toast ");

Then set the attributes, such as whether to mute or disappear for a long time:

((XmlElement)toastNode).SetAttribute("duration", "short");            XmlElement audio = toastXml.CreateElement("audio");            audio.SetAttribute("silent", "true");            toastNode.AppendChild(audio);

Finally, define a toast:

ToastNotification toast = new ToastNotification(toastXml);            toast.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(1);            toast.Tag = "NOTI";            toast.Dismissed += toast_Dismissed;            ToastNotificationManager.CreateToastNotifier().Show(toast);

After toast is defined, we also define the ExpirationTime attribute. This is because after Windows Phone 8.1, the system adds the Notification Center, and all the information will be integrated. If you do not add this sentence, the user will see the prompt again in the Notification Center, which is redundant. Therefore, you must set it to expire immediately and not display it in the Notification Center.

Another problem is that although toast expires, it will not be displayed, but the system will leave an icon in the notification bar in the upper right corner, which makes it unbearable for patients with obsessive-compulsive disorder.

Void toast_Dismissed (ToastNotification sender, ToastDismissedEventArgs args) {ToastNotificationManager. History. Remove ("NOTI ");}

In this way, the entire effect is perfect. If the user thinks that the default disappears for a long time, he can directly Slide left to close this notification:

If the system settings enable the vibration option, the system will vibrate when the prompt is displayed.

 

Summary

The first method is simple, and the effect is relatively simple. The second method is complicated, but the function is also the most powerful and free. The third method is a compromise, both the amount of code and the effect are acceptable. You can choose different methods based on your needs. You are also welcome to talk about how you implement the reminder function in similar applications?

 

Share code and change the world!

Windows Phone Store App link:

Bytes

Windows Store App link:

Http://apps.microsoft.com/windows/zh-cn/app/c76b99a0-9abd-4a4e-86f0-b29bfcc51059

GitHub open source link:

Https://github.com/MS-UAP/cnblogs-UAP

MSDN Sample Code:

Https://code.msdn.microsoft.com/CNBlogs-Client-Universal-477943ab

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.