コード例 #1
0
ファイル: ModernDialog.cs プロジェクト: yangdaichun/ZHXY.ZSXT
 private static IEnumerable<Button> GetButtons(ModernDialog owner, MessageBoxButton button)
 {
     if (button == MessageBoxButton.OK) {
         yield return owner.OkButton;
     }
     else if (button == MessageBoxButton.OKCancel) {
         yield return owner.OkButton;
         yield return owner.CancelButton;
     }
     else if (button == MessageBoxButton.YesNo) {
         yield return owner.YesButton;
         yield return owner.NoButton;
     }
     else if (button == MessageBoxButton.YesNoCancel) {
         yield return owner.YesButton;
         yield return owner.NoButton;
         yield return owner.CancelButton;
     }
 }
コード例 #2
0
        protected override void Save(object model)
        {
            if (_XiaoQu != null)
            {
                if (_XiaoQu.XueYuanId == 0)
                {
                    ModernDialog dialog = new ModernDialog() { Content = "学院名称不能为空" };
                    dialog.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(_XiaoQu.Name))
                {
                    ModernDialog dialog = new ModernDialog() { Content = "校区名称不能为空" };
                    dialog.ShowDialog();
                    return;
                }
                Services.XiaoQuServicesClient service = new Services.XiaoQuServicesClient();
                //新增
                if (_XiaoQu.Id == 0)
                {
                    int i = service.XiaoQuAdd(_XiaoQu);
                }
                //修改
                else
                {
                    int i = service.XiaoQuUpdate(_XiaoQu);
                }
                BorderVisibility = Visibility.Collapsed;
                service.Close();
            }
        }
コード例 #3
0
ファイル: ModernDialog.cs プロジェクト: yangdaichun/ZHXY.ZSXT
        /// <summary>
        /// Displays a messagebox.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="title">The title.</param>
        /// <param name="button">The button.</param>
        /// <param name="owner">The window owning the messagebox. The messagebox will be located at the center of the owner.</param>
        /// <returns></returns>
        public static MessageBoxResult ShowMessage(string text, string title, MessageBoxButton button, Window owner = null)
        {
            var dlg = new ModernDialog {
                Title = title,
                Content = new BBCodeBlock { BBCode = text, Margin = new Thickness(0, 0, 0, 8) },
                MinHeight = 0,
                MinWidth = 0,
                MaxHeight = 480,
                MaxWidth = 640,
            };
            if (owner != null) {
                dlg.Owner = owner;
            }

            dlg.Buttons = GetButtons(dlg, button);
            dlg.ShowDialog();
            return dlg.messageBoxResult;
        }