Ejemplo n.º 1
0
 public void BuildSweetAlert(Page page)
 {
     if (Timer != null)
     {
         ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "alertMessage", "Swal.fire({" +
                                                 "background:'" + HexaBackgroundColor +
                                                 "',title:'" + Title + "'," +
                                                 "text:'" + Message + "'," +
                                                 "showCloseButton:'" + ShowCloseButton + "'," +
                                                 "footer:'" + FooterMessage + "'," +
                                                 "timer:'" + Timer + "'," +
                                                 "position:'" + AlertPositions + "'," +
                                                 "icon:'" + AlertIcons.ToString() +
                                                 "'})", true);
     }
     else
     {
         ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "alertMessage", "Swal.fire({" +
                                                 "background:'" + HexaBackgroundColor +
                                                 "',title:'" + Title + "'," +
                                                 "showCloseButton:'" + ShowCloseButton + "'," +
                                                 "text:'" + Message + "'," +
                                                 "position:'" + AlertPositions + "'," +
                                                 "footer:'" + FooterMessage + "'," +
                                                 "icon:'" + AlertIcons.ToString() +
                                                 "'})", true);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// アラートウィンドウを表示する
        /// </summary>
        /// <param name="message">アラートウィンドウに表示するテキスト</param>
        /// <param name="title">アラートウィンドウのタイトルバーに表示するテキスト</param>
        /// <param name="icon">アラートウィンドウに表示するアイコン</param>
        public void Show(string message, string title, AlertIcons icon)
        {
            awf = new AlertWindowForm();
            isClosed = false;

            // アニメーション
            awf.Animation = this.Animation;
            awf.Time = this.Time;

            // 余白
            awf.MinimumSize = this.MinimumSize;
            awf.Margin = this.Margin;

            // 外観
            awf.ShowCloseButton = this.ShowCloseButton;
            awf.BackColor = this.BackColor;
            awf.BackColor2 = this.BackColor2;
            awf.GradientMode = this.GradientMode;
            awf.AlertWindowBackgroundImage = this.BackgroundImage;
            awf.AlertWindowBackgroundImageLayout = this.BackgroundImageLayout;
            awf.AlertCursor = this.Cursor;
            this.AddHandlerClick(awf);
            awf.btnClose.Click -= AlertWindow_Click;

            // アイコン設定
            switch (icon)
            {
                case AlertIcons.None:
                    break;
                case AlertIcons.Information:
                    awf.AlertIcon = SystemIcons.Information.ToBitmap();
                    break;
                case AlertIcons.Question:
                    awf.AlertIcon = SystemIcons.Question.ToBitmap();
                    break;
                case AlertIcons.Warning:
                    awf.AlertIcon = SystemIcons.Warning.ToBitmap();
                    break;
                case AlertIcons.Error:
                    awf.AlertIcon = SystemIcons.Error.ToBitmap();
                    break;
                case AlertIcons.Custom:
                    awf.AlertIcon = this.CustomIcon;
                    break;
            }
            // アイコンサイズを調整
            if (awf.AlertIcon != null)
            {
                Bitmap b = new Bitmap(this.IconSize.Width, this.IconSize.Height);
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.DrawImage(awf.AlertIcon, 0, 0, this.IconSize.Width, this.IconSize.Height);
                }
                awf.AlertIcon = b;
            }

            // タイトル設定
            awf.Title = title;
            awf.TitleFont = this.TitleFont;
            awf.TitleForeColor = this.TitleForeColor;

            // メッセージ設定
            awf.Message = message;
            awf.MessageFont = this.MessageFont;
            awf.MessageForeColor = this.MessageForeColor;
            // リンク設定
            foreach (LinkLabel.Link l in this.MessageLiks)
            {
                awf.MessageLiks.Add(l);
            }
            awf.lblLinkMessage.LinkClicked += lblLinkMessage_LinkClicked;

            // アラートウィンドウを表示
            awf.Show();
        }