<commit_before>﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;

namespace MaterialWinforms.Controls
{
    public class MaterialDialog : MaterialForm
    {
        private const int CS_DROPSHADOW = 0x00020000;
        private FontManager _FontManager;
        private static MaterialDialog _msgBox;
        private FlowLayoutPanel _flpButtons = new FlowLayoutPanel();
        private List<MaterialFlatButton> _buttonCollection = new List<MaterialFlatButton>();
        private static DialogResult _buttonResult = new DialogResult();
        private Panel pnl_Top;
        private MaterialLabel lbl_Message;
        private Label lbl_Title;
        private Panel pnl_Footer;
        private Panel pnl_Message;
        private static Timer _timer;
        

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern bool MessageBeep(uint type);

        private MaterialDialog(MaterialSkinManager pColor)
        {
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.BackColor = pColor.GetCardsColor();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Padding = new System.Windows.Forms.Padding(0);
            this.Width = 400;
            this.SkinManager.ColorScheme = pColor.ColorScheme;
            this.SkinManager.Theme = pColor.Theme;
            _FontManager = new FontManager();
         

            InitializeComponent();

            

            _flpButtons.FlowDirection = FlowDirection.RightToLeft;
            _flpButtons.Dock = DockStyle.Fill;
            pnl_Footer.Controls.Add(_flpButtons);
            lbl_Title.ForeColor = SkinManager.ColorScheme.AccentColor;
        }

        public static void Show(MaterialForm pForm,string message)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.lbl_Message.Text = message;
            _msgBox.ShowDialog();
            MaterialDialog.InitButtons(MaterialDialog.Buttons.OK);
        }

        public static void Show(MaterialForm pForm, string title,UserControl pContent)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.Controls.Remove(_msgBox.pnl_Top);
            pContent.Location = new Point(0,0);
            _msgBox.Controls.Add(pContent);
            _msgBox.Width = pContent.Width;
            _msgBox.Height = _msgBox.pnl_Footer.Height +5 + pContent.Height;
            _msgBox.lbl_Title.Text = title;
            MaterialDialog.InitButtons(MaterialDialog.Buttons.OK);
            _msgBox.ShowDialog();
        }

        public static void Show(MaterialForm pForm, string message, string title)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.SkinManager.ColorScheme = pForm.SkinManager.ColorScheme;
            _msgBox.lbl_Message.Text = message;
            _msgBox.lbl_Title.Text = title;
            _msgBox.ShowDialog();
        }

        public static DialogResult Show(MaterialForm pForm, string message, string title, Buttons buttons)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.lbl_Message.Text = message;
            _msgBox.lbl_Title.Text = title;

            MaterialDialog.InitButtons(buttons);

            _msgBox.ShowDialog();
            MessageBeep(0);
            return _buttonResult;
        }

        public static void Show(MaterialForm pForm, string title, UserControl pContent, Buttons buttons)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.Controls.Remove(_msgBox.pnl_Top);
            pContent.Location = new Point(0, 0);
            _msgBox.Controls.Add(pContent);
            _msgBox.Width = pContent.Width;
            _msgBox.Height = _msgBox.pnl_Footer.Height + 5 + pContent.Height;
            _msgBox.lbl_Title.Text = title;
            MaterialDialog.InitButtons(buttons);
            _msgBox.ShowDialog();
        }

        public static DialogResult Show(MaterialForm pForm, string message, string title, Buttons buttons, Icon icon)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.lbl_Message.Text = message;
            _msgBox.lbl_Title.Text = title;

            MaterialDialog.InitButtons(buttons);
            MaterialDialog.InitIcon(icon);
            _msgBox.ShowDialog();
            MessageBeep(0);
            return _buttonResult;
        }

        public static DialogResult Show(MaterialForm pForm, string message, string title, Buttons buttons, Icon icon, AnimateStyle style)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.lbl_Message.Text = message;
            _msgBox.lbl_Title.Text = title;
            _msgBox.Height = 0;

            MaterialDialog.InitButtons(buttons);
            MaterialDialog.InitIcon(icon);

            _timer = new Timer();
            Size formSize = _msgBox.Size;

            switch (style)
            {
                case MaterialDialog.AnimateStyle.SlideDown:<commit_msg>Dialog result auch bei Custom Content zurrückgeben<commit_after>﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;

namespace MaterialWinforms.Controls
{
    public class MaterialDialog : MaterialForm
    {
        private const int CS_DROPSHADOW = 0x00020000;
        private FontManager _FontManager;
        private static MaterialDialog _msgBox;
        private FlowLayoutPanel _flpButtons = new FlowLayoutPanel();
        private List<MaterialFlatButton> _buttonCollection = new List<MaterialFlatButton>();
        private static DialogResult _buttonResult = new DialogResult();
        private Panel pnl_Top;
        private MaterialLabel lbl_Message;
        private Label lbl_Title;
        private Panel pnl_Footer;
        private Panel pnl_Message;
        private static Timer _timer;
        

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern bool MessageBeep(uint type);

        private MaterialDialog(MaterialSkinManager pColor)
        {
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.BackColor = pColor.GetCardsColor();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Padding = new System.Windows.Forms.Padding(0);
            this.Width = 400;
            this.SkinManager.ColorScheme = pColor.ColorScheme;
            this.SkinManager.Theme = pColor.Theme;
            _FontManager = new FontManager();
         

            InitializeComponent();

            

            _flpButtons.FlowDirection = FlowDirection.RightToLeft;
            _flpButtons.Dock = DockStyle.Fill;
            pnl_Footer.Controls.Add(_flpButtons);
            lbl_Title.ForeColor = SkinManager.ColorScheme.AccentColor;
        }

        public static void Show(MaterialForm pForm,string message)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.lbl_Message.Text = message;
            _msgBox.ShowDialog();
            MaterialDialog.InitButtons(MaterialDialog.Buttons.OK);
        }

        public static DialogResult Show(MaterialForm pForm, string title,UserControl pContent)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            pContent.Location = new Point(0, 0);
            _msgBox.pnl_Message.Controls.Add(pContent);
            _msgBox.Width = pContent.Width;
            _msgBox.pnl_Message.Location = new Point(0, _msgBox.pnl_Message.Location.Y);
            _msgBox.Height = _msgBox.pnl_Footer.Height +5 + pContent.Height;
            _msgBox.lbl_Title.Text = title;
            MaterialDialog.InitButtons(MaterialDialog.Buttons.OK);
            return _buttonResult;
        }

        public static void Show(MaterialForm pForm, string message, string title)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.SkinManager.ColorScheme = pForm.SkinManager.ColorScheme;
            _msgBox.lbl_Message.Text = message;
            _msgBox.lbl_Title.Text = title;
            _msgBox.ShowDialog();
        }

        public static DialogResult Show(MaterialForm pForm, string message, string title, Buttons buttons)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.lbl_Message.Text = message;
            _msgBox.lbl_Title.Text = title;

            MaterialDialog.InitButtons(buttons);

            _msgBox.ShowDialog();
            MessageBeep(0);
            return _buttonResult;
        }

        public static DialogResult Show(MaterialForm pForm, string title, UserControl pContent, Buttons buttons)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            pContent.Location = new Point(0, 0);
            _msgBox.pnl_Message.Controls.Add(pContent);
            _msgBox.Width = pContent.Width;
            _msgBox.pnl_Message.Location = new Point(0, _msgBox.pnl_Message.Location.Y);
            _msgBox.Height = _msgBox.pnl_Footer.Height +5 + pContent.Height;
            _msgBox.lbl_Title.Text = title;
            MaterialDialog.InitButtons(buttons);
            _msgBox.ShowDialog();
            return _buttonResult;
        }

        public static DialogResult Show(MaterialForm pForm, string message, string title, Buttons buttons, Icon icon)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.lbl_Message.Text = message;
            _msgBox.lbl_Title.Text = title;

            MaterialDialog.InitButtons(buttons);
            MaterialDialog.InitIcon(icon);
            _msgBox.ShowDialog();
            MessageBeep(0);
            return _buttonResult;
        }

        public static DialogResult Show(MaterialForm pForm, string message, string title, Buttons buttons, Icon icon, AnimateStyle style)
        {
            _msgBox = new MaterialDialog(pForm.SkinManager);
            _msgBox.lbl_Message.Text = message;
            _msgBox.lbl_Title.Text = title;
            _msgBox.Height = 0;

            MaterialDialog.InitButtons(buttons);
            MaterialDialog.InitIcon(icon);

            _timer = new Timer();
            Size formSize = _msgBox.Size;

            switch (style)
            {
                case MaterialDialog.AnimateStyle.SlideDown:
{'fraction_non_alphanumeric': 0.07732299839304282, 'fraction_numerical': 0.004726344645051517, 'mean_word_length': 2.2404287901990814, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6975939', 'n_tokens_mistral': 2857, 'n_tokens_neox': 2827, 'n_words': 571}