您的位置:首页 > 其它

Windows Phone开发之Coding4Fun对话框操作类

2012-05-07 17:50 381 查看
去年把windows phone手机的自带弹出框和Coding4Fun做了一个对比【/article/1359314.html】。今天就把操作类全部贴出来。
1.自己先下载一个Coding4Fun的dll文件,然后引用到项目里面,你懂的!
下载地址http://coding4fun.codeplex.com/
2.直接上代码。

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Coding4Fun.Phone;
using Coding4Fun.Phone.Controls;

//@yr.feng
namespace MicroBlogForWP7.Classes.Util
{
    /// <summary>
    /// 对话框
    /// </summary>
    public class Msg
    {
        /// <summary>
        /// 带有"确定"和"取消"按钮消息提示框。返回值为bool类型
        /// </summary>
        /// <param name="content">提示的信息内容</param>
        /// <param name="title">提示的标题</param>
        /// <returns>ture or false</returns>
        public bool ReturnConfirfMsg(string content, string title)
        {
            MessageBoxResult m = MessageBox.Show(content, title, MessageBoxButton.OKCancel);

            if (m == MessageBoxResult.OK)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 带有"确定"按钮消息提示框。返回值为bool类型
        /// </summary>
        /// <param name="content">提示的信息内容</param>
        /// <param name="title">提示的标题</param>
        /// <returns>ture or false</returns>
        public bool ReturnConfirfMsgByOk(string content, string title)
        {
            MessageBoxResult m = MessageBox.Show(content, title, MessageBoxButton.OK);

            if (m == MessageBoxResult.OK)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 带"确定"按钮的消息提示框。不具有返回值
        /// </summary>
        /// <param name="content">提示的信息内容</param>
        /// <param name="title">提示的标题</param>
        public void ConfirfMsgForOK(string content, string title)
        {
            MessageBox.Show(content, title, MessageBoxButton.OK);
        }

        /// <summary>
        /// 带"确定"和"取消"按钮的消息提示框。不具有返回值
        /// </summary>
        /// <param name="content">提示的信息内容</param>
        /// <param name="title">提示的标题</param>
        public void ConfirfMsgForOKCancel(string content, string title)
        {
            MessageBox.Show(content, title, MessageBoxButton.OKCancel);
        }

        /// <summary>
        /// 使用Coding4Fun组件的淡入淡出对话框。不具有返回值
        /// </summary>
        /// <param name="content">提示的信息内容</param>
        /// <param name="title">提示的标题</param>
        /// <param name="timeout">提示消息的显示过期时间。单位毫秒</param>
        public void Coding4FunForMsg(string content, string title, int timeout)
        {
            SolidColorBrush White = new SolidColorBrush(Colors.White);

            SolidColorBrush Red = new SolidColorBrush(Colors.Brown);

            ToastPrompt toast = new ToastPrompt
            {
                Background = Red,
                IsTimerEnabled = true,
                IsAppBarVisible = true, 
                MillisecondsUntilHidden = timeout,
                Foreground = White,
            };

            toast.Title = title;

            toast.Message = content;

            toast.TextOrientation = System.Windows.Controls.Orientation.Horizontal;

            toast.Show();
        }
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: