public MaterialExpansionPanel()
        {
            ShowValidationButtons  = true;
            ValidationButtonEnable = false;
            ValidationButtonText   = "SAVE";
            CancelButtonText       = "CANCEL";
            ShowCollapseExpand     = true;
            Collapse     = false;
            Title        = "Title";
            Description  = "Description";
            DrawShadows  = true;
            ExpandHeight = 240;
            AutoScroll   = false;

            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
            BackColor = SkinManager.BackgroundColor;
            ForeColor = SkinManager.TextHighEmphasisColor;

            Padding = new Padding(24, 64, 24, 16);
            Margin  = new Padding(3, 16, 3, 16);
            Size    = new Size(480, ExpandHeight);

            //CollapseOrExpand();

            _validationButton = new MaterialButton
            {
                DrawShadows    = false,
                Type           = MaterialButton.MaterialButtonType.Text,
                UseAccentColor = _useAccentColor,
                Enabled        = ValidationButtonEnable,
                Visible        = _showValidationButtons,
                Text           = "SAVE"
            };
            _cancelButton = new MaterialButton
            {
                DrawShadows    = false,
                Type           = MaterialButton.MaterialButtonType.Text,
                UseAccentColor = _useAccentColor,
                Visible        = _showValidationButtons,
                Text           = "CANCEL"
            };

            if (!Controls.Contains(_validationButton))
            {
                Controls.Add(_validationButton);
            }
            if (!Controls.Contains(_cancelButton))
            {
                Controls.Add(_cancelButton);
            }

            _validationButton.Click += _validationButton_Click;
            _cancelButton.Click     += _cancelButton_Click;

            UpdateRects();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructer Setting up the Layout
        /// </summary>
        public MaterialSnackBar(string Text, int Duration, bool ShowActionButton, string ActionButtonText, bool UseAccentColor)
        {
            this.Text     = Text;
            this.Duration = Duration;
            TopMost       = true;
            ShowInTaskbar = false;
            Sizable       = false;

            BackColor = SkinManager.SnackBarBackgroundColor;
            FormStyle = FormStyles.StatusAndActionBar_None;

            this.ActionButtonText = ActionButtonText;
            this.UseAccentColor   = UseAccentColor;
            Height      = 48;
            MinimumSize = new System.Drawing.Size(344, 48);
            MaximumSize = new System.Drawing.Size(568, 48);

            this.ShowActionButton = ShowActionButton;

            Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 6, 6));

            _AnimationManager = new AnimationManager();
            _AnimationManager.AnimationType        = AnimationType.EaseOut;
            _AnimationManager.Increment            = 0.03;
            _AnimationManager.OnAnimationProgress += _AnimationManager_OnAnimationProgress;

            _duration.Tick += new EventHandler(duration_Tick);

            _actionButton = new MaterialButton
            {
                AutoSize          = false,
                NoAccentTextColor = SkinManager.SnackBarTextButtonNoAccentTextColor,
                DrawShadows       = false,
                Type           = MaterialButton.MaterialButtonType.Text,
                UseAccentColor = _useAccentColor,
                Visible        = _showActionButton,
                Text           = _actionButtonText
            };
            _actionButton.Click += (sender, e) =>
            {
                ActionButtonClick?.Invoke(this, new EventArgs());
                _closingAnimationDone = false;
                Close();
            };

            if (!Controls.Contains(_actionButton))
            {
                Controls.Add(_actionButton);
            }

            UpdateRects();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Erforderliche Methode für die Designerunterstützung.
 /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     this.FlexibleMaterialFormBindingSource = new System.Windows.Forms.BindingSource(this.components);
     this.messageContainer   = new System.Windows.Forms.Panel();
     this.materialLabel1     = new MaterialSkin.Controls.MaterialLabel();
     this.pictureBoxForIcon  = new System.Windows.Forms.PictureBox();
     this.richTextBoxMessage = new MaterialSkin.Controls.MaterialMultiLineTextBox();
     this.leftButton         = new MaterialSkin.Controls.MaterialButton();
     this.middleButton       = new MaterialSkin.Controls.MaterialButton();
     this.rightButton        = new MaterialSkin.Controls.MaterialButton();
     ((System.ComponentModel.ISupportInitialize)(this.FlexibleMaterialFormBindingSource)).BeginInit();
     this.messageContainer.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.pictureBoxForIcon)).BeginInit();
     this.SuspendLayout();
     //
     // messageContainer
     //
     this.messageContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                           | System.Windows.Forms.AnchorStyles.Left)
                                                                          | System.Windows.Forms.AnchorStyles.Right)));
     this.messageContainer.BackColor = System.Drawing.Color.White;
     this.messageContainer.Controls.Add(this.materialLabel1);
     this.messageContainer.Controls.Add(this.pictureBoxForIcon);
     this.messageContainer.Controls.Add(this.richTextBoxMessage);
     this.messageContainer.Location = new System.Drawing.Point(1, 65);
     this.messageContainer.Name     = "messageContainer";
     this.messageContainer.Size     = new System.Drawing.Size(382, 89);
     this.messageContainer.TabIndex = 1;
     //
     // materialLabel1
     //
     this.materialLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                         | System.Windows.Forms.AnchorStyles.Left)
                                                                        | System.Windows.Forms.AnchorStyles.Right)));
     this.materialLabel1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlexibleMaterialFormBindingSource, "MessageText", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
     this.materialLabel1.Depth      = 0;
     this.materialLabel1.Font       = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
     this.materialLabel1.Location   = new System.Drawing.Point(56, 12);
     this.materialLabel1.MouseState = MaterialSkin.MouseState.HOVER;
     this.materialLabel1.Name       = "materialLabel1";
     this.materialLabel1.Size       = new System.Drawing.Size(314, 65);
     this.materialLabel1.TabIndex   = 9;
     this.materialLabel1.Text       = "<Message>";
     this.materialLabel1.Visible    = false;
     //
     // pictureBoxForIcon
     //
     this.pictureBoxForIcon.BackColor = System.Drawing.Color.Transparent;
     this.pictureBoxForIcon.Location  = new System.Drawing.Point(12, 12);
     this.pictureBoxForIcon.Name      = "pictureBoxForIcon";
     this.pictureBoxForIcon.Size      = new System.Drawing.Size(32, 32);
     this.pictureBoxForIcon.TabIndex  = 8;
     this.pictureBoxForIcon.TabStop   = false;
     //
     // richTextBoxMessage
     //
     this.richTextBoxMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                             | System.Windows.Forms.AnchorStyles.Left)
                                                                            | System.Windows.Forms.AnchorStyles.Right)));
     this.richTextBoxMessage.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
     this.richTextBoxMessage.BorderStyle = System.Windows.Forms.BorderStyle.None;
     this.richTextBoxMessage.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlexibleMaterialFormBindingSource, "MessageText", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
     this.richTextBoxMessage.Depth        = 0;
     this.richTextBoxMessage.Font         = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.richTextBoxMessage.ForeColor    = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
     this.richTextBoxMessage.Location     = new System.Drawing.Point(56, 12);
     this.richTextBoxMessage.Margin       = new System.Windows.Forms.Padding(0);
     this.richTextBoxMessage.MouseState   = MaterialSkin.MouseState.HOVER;
     this.richTextBoxMessage.Name         = "richTextBoxMessage";
     this.richTextBoxMessage.ReadOnly     = true;
     this.richTextBoxMessage.ScrollBars   = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
     this.richTextBoxMessage.Size         = new System.Drawing.Size(314, 65);
     this.richTextBoxMessage.TabIndex     = 0;
     this.richTextBoxMessage.TabStop      = false;
     this.richTextBoxMessage.Text         = "<Message>";
     this.richTextBoxMessage.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBoxMessage_LinkClicked);
     //
     // leftButton
     //
     this.leftButton.Anchor                  = System.Windows.Forms.AnchorStyles.Bottom;
     this.leftButton.AutoSize                = false;
     this.leftButton.AutoSizeMode            = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     this.leftButton.Density                 = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default;
     this.leftButton.Depth                   = 0;
     this.leftButton.DialogResult            = System.Windows.Forms.DialogResult.OK;
     this.leftButton.HighEmphasis            = false;
     this.leftButton.Icon                    = null;
     this.leftButton.Location                = new System.Drawing.Point(32, 163);
     this.leftButton.Margin                  = new System.Windows.Forms.Padding(4, 6, 4, 6);
     this.leftButton.MinimumSize             = new System.Drawing.Size(0, 24);
     this.leftButton.MouseState              = MaterialSkin.MouseState.HOVER;
     this.leftButton.Name                    = "leftButton";
     this.leftButton.Size                    = new System.Drawing.Size(108, 36);
     this.leftButton.TabIndex                = 14;
     this.leftButton.Text                    = "OK";
     this.leftButton.Type                    = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Text;
     this.leftButton.UseAccentColor          = false;
     this.leftButton.UseVisualStyleBackColor = true;
     this.leftButton.Visible                 = false;
     //
     // middleButton
     //
     this.middleButton.Anchor                  = System.Windows.Forms.AnchorStyles.Bottom;
     this.middleButton.AutoSize                = false;
     this.middleButton.AutoSizeMode            = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     this.middleButton.Density                 = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default;
     this.middleButton.Depth                   = 0;
     this.middleButton.DialogResult            = System.Windows.Forms.DialogResult.OK;
     this.middleButton.HighEmphasis            = true;
     this.middleButton.Icon                    = null;
     this.middleButton.Location                = new System.Drawing.Point(148, 163);
     this.middleButton.Margin                  = new System.Windows.Forms.Padding(4, 6, 4, 6);
     this.middleButton.MinimumSize             = new System.Drawing.Size(0, 24);
     this.middleButton.MouseState              = MaterialSkin.MouseState.HOVER;
     this.middleButton.Name                    = "middleButton";
     this.middleButton.Size                    = new System.Drawing.Size(102, 36);
     this.middleButton.TabIndex                = 15;
     this.middleButton.Text                    = "OK";
     this.middleButton.Type                    = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Text;
     this.middleButton.UseAccentColor          = false;
     this.middleButton.UseVisualStyleBackColor = true;
     this.middleButton.Visible                 = false;
     //
     // rightButton
     //
     this.rightButton.Anchor                  = System.Windows.Forms.AnchorStyles.Bottom;
     this.rightButton.AutoSize                = false;
     this.rightButton.AutoSizeMode            = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     this.rightButton.Density                 = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default;
     this.rightButton.Depth                   = 0;
     this.rightButton.DialogResult            = System.Windows.Forms.DialogResult.OK;
     this.rightButton.HighEmphasis            = true;
     this.rightButton.Icon                    = null;
     this.rightButton.Location                = new System.Drawing.Point(258, 163);
     this.rightButton.Margin                  = new System.Windows.Forms.Padding(4, 6, 4, 6);
     this.rightButton.MinimumSize             = new System.Drawing.Size(0, 24);
     this.rightButton.MouseState              = MaterialSkin.MouseState.HOVER;
     this.rightButton.Name                    = "rightButton";
     this.rightButton.Size                    = new System.Drawing.Size(106, 36);
     this.rightButton.TabIndex                = 13;
     this.rightButton.Text                    = "OK";
     this.rightButton.Type                    = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained;
     this.rightButton.UseAccentColor          = false;
     this.rightButton.UseVisualStyleBackColor = true;
     this.rightButton.Visible                 = false;
     //
     // FlexibleMaterialForm
     //
     this.BackColor  = System.Drawing.Color.White;
     this.ClientSize = new System.Drawing.Size(384, 208);
     this.Controls.Add(this.leftButton);
     this.Controls.Add(this.middleButton);
     this.Controls.Add(this.rightButton);
     this.Controls.Add(this.messageContainer);
     this.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlexibleMaterialFormBindingSource, "CaptionText", true));
     this.MaximizeBox   = false;
     this.MinimizeBox   = false;
     this.MinimumSize   = new System.Drawing.Size(276, 140);
     this.Name          = "FlexibleMaterialForm";
     this.ShowIcon      = false;
     this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
     this.Text          = "<Caption>";
     this.Load         += new System.EventHandler(this.FlexibleMaterialForm_Load);
     this.Shown        += new System.EventHandler(this.FlexibleMaterialForm_Shown);
     ((System.ComponentModel.ISupportInitialize)(this.FlexibleMaterialFormBindingSource)).EndInit();
     this.messageContainer.ResumeLayout(false);
     ((System.ComponentModel.ISupportInitialize)(this.pictureBoxForIcon)).EndInit();
     this.ResumeLayout(false);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructer Setting up the Layout
        /// </summary>
        public MaterialDialog(Form ParentForm, string Title, string Text, string ValidationButtonText, bool ShowCancelButton, string CancelButtonText, bool UseAccentColor)
        {
            _formOverlay = new Form
            {
                BackColor       = Color.Black,
                Opacity         = 0.5,
                MinimizeBox     = false,
                MaximizeBox     = false,
                Text            = "",
                ShowIcon        = false,
                ControlBox      = false,
                FormBorderStyle = FormBorderStyle.None,
                Size            = new Size(ParentForm.Width, ParentForm.Height),
                ShowInTaskbar   = false,
                Owner           = ParentForm,
                Visible         = true,
                Location        = new Point(ParentForm.Location.X, ParentForm.Location.Y),
                Anchor          = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom,
            };

            _title = Title;
            if (Title.Length == 0)
            {
                _header_Height = 0;
            }
            else
            {
                _header_Height = 40;
            }

            _text         = Text;
            ShowInTaskbar = false;
            Sizable       = false;

            BackColor = SkinManager.BackgroundColor;
            FormStyle = FormStyles.StatusAndActionBar_None;

            _AnimationManager = new AnimationManager();
            _AnimationManager.AnimationType        = AnimationType.EaseOut;
            _AnimationManager.Increment            = 0.03;
            _AnimationManager.OnAnimationProgress += _AnimationManager_OnAnimationProgress;

            _validationButton = new MaterialButton
            {
                AutoSize       = false,
                DialogResult   = DialogResult.OK,
                DrawShadows    = false,
                Type           = MaterialButton.MaterialButtonType.Text,
                UseAccentColor = UseAccentColor,
                Text           = ValidationButtonText
            };
            _cancelButton = new MaterialButton
            {
                AutoSize       = false,
                DialogResult   = DialogResult.Cancel,
                DrawShadows    = false,
                Type           = MaterialButton.MaterialButtonType.Text,
                UseAccentColor = UseAccentColor,
                Visible        = ShowCancelButton,
                Text           = CancelButtonText
            };

            this.AcceptButton = _validationButton;
            this.CancelButton = _cancelButton;

            if (!Controls.Contains(_validationButton))
            {
                Controls.Add(_validationButton);
            }
            if (!Controls.Contains(_cancelButton))
            {
                Controls.Add(_cancelButton);
            }

            Width = 560;
            int       TextWidth  = TextRenderer.MeasureText(_text, SkinManager.getFontByType(MaterialSkinManager.fontType.Body1)).Width;
            int       RectWidth  = Width - (2 * LEFT_RIGHT_PADDING) - BUTTON_PADDING;
            int       RectHeight = ((TextWidth / RectWidth) + 1) * 19;
            Rectangle textRect   = new Rectangle(
                LEFT_RIGHT_PADDING,
                _header_Height + TEXT_TOP_PADDING,
                RectWidth,
                RectHeight + 9);

            Height = _header_Height + TEXT_TOP_PADDING + textRect.Height + TEXT_BOTTOM_PADDING + 52; //560;
            Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 6, 6));

            int       _buttonWidth            = ((TextRenderer.MeasureText(ValidationButtonText, SkinManager.getFontByType(MaterialSkinManager.fontType.Button))).Width + 32);
            Rectangle _validationbuttonBounds = new Rectangle((Width) - BUTTON_PADDING - _buttonWidth, Height - BUTTON_PADDING - BUTTON_HEIGHT, _buttonWidth, BUTTON_HEIGHT);

            _validationButton.Width   = _validationbuttonBounds.Width;
            _validationButton.Height  = _validationbuttonBounds.Height;
            _validationButton.Top     = _validationbuttonBounds.Top;
            _validationButton.Left    = _validationbuttonBounds.Left; //Button minimum width management
            _validationButton.Visible = true;

            _buttonWidth = ((TextRenderer.MeasureText(CancelButtonText, SkinManager.getFontByType(MaterialSkinManager.fontType.Button))).Width + 32);
            Rectangle _cancelbuttonBounds = new Rectangle((_validationbuttonBounds.Left) - BUTTON_PADDING - _buttonWidth, Height - BUTTON_PADDING - BUTTON_HEIGHT, _buttonWidth, BUTTON_HEIGHT);

            _cancelButton.Width  = _cancelbuttonBounds.Width;
            _cancelButton.Height = _cancelbuttonBounds.Height;
            _cancelButton.Top    = _cancelbuttonBounds.Top;
            _cancelButton.Left   = _cancelbuttonBounds.Left; //Button minimum width management


            //this.ShowDialog();
            //this Dispose();
            //return materialDialogResult;
        }