Exemplo n.º 1
0
        public MultiMessageBox(string title, string message, MBoxType mBoxType = MBoxType.Confirm)
        {
            InitializeComponent();
            // 准备Binding
            Binding binding = new Binding()
            {
                Source = title,
                //Path = new PropertyPath("Name"),// 需绑定的数据源属性名
                Mode = BindingMode.OneWay,// 绑定模式
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            // 连接数据源与绑定目标
            BindingOperations.SetBinding(
                titlelb,               // 需绑定的控件  ,

                Label.ContentProperty, // 需绑定的控件属性
                binding);

            Binding binding1 = new Binding()
            {
                Source = message,
                Mode   = BindingMode.OneWay,// 绑定模式
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            BindingOperations.SetBinding(
                tipMessage,
                Label.ContentProperty,// 需绑定的控件属性
                binding1);

            switch (mBoxType)
            {
            case MBoxType.Confirm:
                this.tipico.Source      = new BitmapImage(new Uri("/Image/question.png", UriKind.Relative));
                this.CanCel.Visibility  = Visibility.Visible;
                this.Confirm.Visibility = Visibility.Visible;
                this.Confirm.Margin     = new Thickness(0, 0, 10, 20);
                break;

            case MBoxType.Warning:
                this.tipico.Source     = new BitmapImage(new Uri("/Image/warning.png", UriKind.Relative));
                this.CanCel.Visibility = Visibility.Collapsed;
                this.Confirm.Margin    = new Thickness(30, 0, 0, 20);

                break;

            case MBoxType.Info:
                this.tipico.Source     = new BitmapImage(new Uri("/Image/info.png", UriKind.Relative));
                this.CanCel.Visibility = Visibility.Collapsed;
                this.Confirm.Margin    = new Thickness(30, 0, 0, 20);

                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        static public MBoxResult Show(string title, string content, MBoxType type)
        {
            string strOk = "确定";

            if (Lang == Lang.ZH_TW)
            {
                strOk = "確定";
            }
            else if (Lang == Lang.EN_US)
            {
                strOk = "OK";
            }
            return(doShow(title, new Run[] { new Run(content) }, new string[] { strOk }, type, 0));
        }
Exemplo n.º 3
0
 static public MBoxResult Show(string title, string content, string[] operators, MBoxType type)
 {
     return(doShow(title, new Run[] { new Run(content) }, operators, type, 0));
 }
Exemplo n.º 4
0
        private void setType(MBox mBox, MBoxType type)
        {
            if (type == MBoxType.Normal)
            {
                /* icon */
                mBox.image_1.Source = new BitmapImage(new Uri("./Resources/MessageBoxLight.png", UriKind.RelativeOrAbsolute));
                mBox.image_2.Source = new BitmapImage(new Uri("./Resources/MessageBoxLight.png", UriKind.RelativeOrAbsolute));

                /* color up */
                LinearGradientBrush lgb = new LinearGradientBrush();
                lgb.StartPoint        = new Point(0, 0);
                lgb.EndPoint          = new Point(0, 1);
                lgb.RelativeTransform = new RotateTransform(270);
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF5DC2EC"), 0.0));
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF16AAE8"), 0.261));
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FEECF5FE"), 0.884));
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFFBFDFF"), 1.0));
                grid_up.Background = lgb;

                /* color mid */
                lgb            = new LinearGradientBrush();
                lgb.StartPoint = new Point(0, 0);
                lgb.EndPoint   = new Point(0, 1);
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFEEECD3"), 0.0));
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFFFE89C"), 1.0));
                grid_mid.Background = lgb;

                /* color down */
                lgb                   = new LinearGradientBrush();
                lgb.StartPoint        = new Point(0, 0);
                lgb.EndPoint          = new Point(0, 1);
                lgb.RelativeTransform = new RotateTransform(270);
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFFCFCFC"), 0.0));
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF42B4E4"), 0.421));
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF72CBF0"), 0.642));
                lgb.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFF0F0F0"), 1.0));
                grid_down.Background = lgb;

                /* color others*/
                shadow.Color        = (Color)ColorConverter.ConvertFromString("#FF181819");
                tbk_head.Foreground = Brushes.White;

                /* animation */
                if (PlayAnimation)
                {
                    /* icon span */
                    DoubleAnimation da = new DoubleAnimation();
                    da.Duration          = new Duration(TimeSpan.FromSeconds(1.2));
                    da.From              = 0.0;
                    da.To                = 1260;
                    da.DecelerationRatio = 0.75;
                    da.Completed        += da_Completed;
                    this.aar.BeginAnimation(AxisAngleRotation3D.AngleProperty, da, HandoffBehavior.SnapshotAndReplace);
                }
            }
            else if (type == MBoxType.Alarm)
            {
                mBox.image_1.Source = new BitmapImage(new Uri("./Resources/alarm170619.png", UriKind.RelativeOrAbsolute));
                mBox.image_2.Source = new BitmapImage(new Uri("./Resources/alarm170619.png", UriKind.RelativeOrAbsolute));

                /* color */
                grid_up.Background   = convertStrToSolidColor("#FFFFE538");
                grid_down.Background = convertStrToSolidColor("#FFFFE538");
                grid_mid.Background  = convertStrToSolidColor("#FFFFFEF7");
                tbk_head.Foreground  = convertStrToSolidColor("#FFFF001D");
                shadow.Color         = (Color)ColorConverter.ConvertFromString("#FFFF4B00");

                if (PlayAnimation)
                {
                    /* background shadow */
                    DoubleAnimation dAnimation = new DoubleAnimation();
                    dAnimation.From           = 20.0;
                    dAnimation.To             = 100.0;
                    dAnimation.AutoReverse    = true;
                    dAnimation.RepeatBehavior = RepeatBehavior.Forever;
                    dAnimation.Duration       = new Duration(TimeSpan.FromSeconds(1.5));
                    shadow.BeginAnimation(System.Windows.Media.Effects.DropShadowEffect.BlurRadiusProperty, dAnimation, HandoffBehavior.SnapshotAndReplace);

                    /* icon span */
                    DoubleAnimation da = new DoubleAnimation();
                    da.Duration          = new Duration(TimeSpan.FromSeconds(1.2));
                    da.From              = 0.0;
                    da.To                = 1260;
                    da.DecelerationRatio = 0.75;
                    da.Completed        += da_Completed;
                    this.aar.BeginAnimation(AxisAngleRotation3D.AngleProperty, da, HandoffBehavior.SnapshotAndReplace);
                }
            }
        }
Exemplo n.º 5
0
        static private MBoxResult doShow(string title, Run[] contents, string[] operators, MBoxType type, int limitSec)
        {
            MBoxResult ret = MBoxResult.Yes;
            List <ContentDescription> lsContents = new List <ContentDescription>();

            foreach (var run in contents)
            {
                ContentDescription cd = new ContentDescription(run);
                lsContents.Add(cd);
            }

            Application.Current.Dispatcher.Invoke(new Action(delegate
            {
                MBox mbox = new MBox();
                mbox.setType(mbox, type);
                mbox.tbk_content.Text = "";
                mbox.tbk_head.Text    = "";

                if (title == null || contents == null || operators == null)
                {
                    mbox.ShowDialog();
                }

                if (operators.Length == 1)
                {
                    mbox.grid_ret2.Visibility = mbox.grid_ret3.Visibility = Visibility.Hidden;
                    mbox.grid_ret1.Visibility = Visibility.Visible;
                    mbox.btn_ret1_yes.Content = operators[0];
                }
                else if (operators.Length == 2)
                {
                    mbox.grid_ret1.Visibility = mbox.grid_ret3.Visibility = Visibility.Hidden;
                    mbox.grid_ret2.Visibility = Visibility.Visible;
                    mbox.btn_ret2_yes.Content = operators[0];
                    mbox.btn_ret2_no.Content  = operators[1];
                }
                else if (operators.Length == 3)
                {
                    mbox.grid_ret1.Visibility    = mbox.grid_ret2.Visibility = Visibility.Hidden;
                    mbox.grid_ret3.Visibility    = Visibility.Visible;
                    mbox.btn_ret3_yes.Content    = operators[0];
                    mbox.btn_ret3_no.Content     = operators[1];
                    mbox.btn_ret3_cancel.Content = operators[2];
                }

                mbox.tbk_head.Text = title;
                foreach (var r in lsContents)
                {
                    mbox.tbk_content.Inlines.Add(r.convertToRun());
                }

                if (limitSec > 0)
                {
                    mbox._limitSec        = limitSec;
                    WaitCallback workItem = new WaitCallback(td_timer);
                    ThreadPool.QueueUserWorkItem(workItem, mbox);
                }

                mbox.ShowDialog();
                ret = _result;
            }));

            return(ret);
        }
Exemplo n.º 6
0
 static public MBoxResult Show(string title, Run[] contents, string[] operators, MBoxType type, int limitSec)
 {
     return(doShow(title, contents, operators, type, limitSec));
 }