예제 #1
0
        /// <summary>
        /// 显示提示对话框
        /// </summary>
        /// <param name="content">内容</param>
        /// <param name="icon">图标</param>
        public static void ShowDialog(string content, AlertIcon icon)
        {
            AlertPopup notifyPopup = new AlertPopup(content, Icon[Convert.ToInt32(icon)]);

            notifyPopup.Show();
        }
예제 #2
0
 /// <summary>
 /// SweetAlert
 /// </summary>
 /// <param name="title"></param>
 /// <param name="message"></param>
 /// <param name="icon"></param>
 public async void Alert(string title, string message, AlertIcon icon)
 {
     await _js.InvokeAsync <object>("Swal.fire", title, message, icon.ToString());
 }
예제 #3
0
        public Alert(string alertTitle, string alertMessage, AlertIcon alertIcon, string destinationPath, List <string> existingDirectoriesPaths)
        {
            try
            {
                InitializeComponent();

                if (alertMessage.Contains("\n"))
                {
                    txtAlertMessage.Location = new Point(58, 23);

                    if (existingDirectoriesPaths == null)
                    {
                        txtAlertMessage.Size = new Size(221, 66);
                    }
                    else
                    {
                        Size = new Size(305, 350);

                        txtAlertMessage.Size = new Size(221, 75);

                        listbox               = new ListBox();
                        listbox.Location      = new Point(58, 100);
                        listbox.Size          = new Size(221, 173);
                        listbox.Anchor        = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                        listbox.SelectionMode = SelectionMode.MultiSimple;
                        listbox.Items.AddRange(existingDirectoriesPaths.Select(d => System.IO.Path.GetFileNameWithoutExtension(d)).ToArray());
                        listbox.SelectedIndexChanged += new EventHandler(listbox_SelectedIndexChanged);
                        Controls.Add(listbox);

                        Size = new Size(450, 350);
                    }
                }

                switch (alertIcon)
                {
                case AlertIcon.Success:
                    pcbAlertIcon.Image = Properties.Resources.Success;

                    if (alertTitle != "No Files to unzip")
                    {
                        btnReturnOk.Visible  = false;
                        btnReturnYes.Visible = true;
                        btnReturnNo.Visible  = true;
                    }
                    break;

                case AlertIcon.Error:
                    pcbAlertIcon.Image = Properties.Resources.Error;
                    break;

                case AlertIcon.Info:
                    pcbAlertIcon.Image = Properties.Resources.Information;
                    break;

                case AlertIcon.Quest:
                    pcbAlertIcon.Image = Properties.Resources.Question;

                    btnReturnOk.Visible  = false;
                    btnReturnYes.Visible = true;
                    btnReturnNo.Visible  = true;
                    break;
                }

                Text = alertTitle;
                txtAlertMessage.Text          = alertMessage;
                this.destinationPath          = destinationPath;
                this.existingDirectoriesPaths = existingDirectoriesPaths;

                OverwritePaths = existingDirectoriesPaths;

                if (destinationPath != null)
                {
                    txtAlertMessage.SelectionStart  = txtAlertMessage.Text.IndexOf(destinationPath);
                    txtAlertMessage.SelectionLength = destinationPath.Length;
                    txtAlertMessage.SelectionColor  = Color.Green;
                }
            }
            catch (Exception ex)
            {
                var alert = new Alert("An Error occurred", ex.Message, AlertIcon.Error, null, null);
                alert.ShowDialog();
            }
        }