Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueMystical committed Sep 17, 2024
2 parents 73a11a5 + 558e20c commit f53d513
Showing 1 changed file with 62 additions and 15 deletions.
77 changes: 62 additions & 15 deletions SourceFiles/Messenger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static DialogResult MessageBox(Exception ex, bool ShowTrace = true) =>
/// <returns>It is a modal window, blocking other actions in the application until the user closes it.</returns>
public static DialogResult MessageBox(
string Message, string title, MessageBoxButtons buttons = MessageBoxButtons.OK,
MessageBoxIcon icon = MessageBoxIcon.Information)
MessageBoxIcon icon = MessageBoxIcon.Information, bool pIsDarkMode = true)
{
Debug.WriteLine(icon.ToString());

Expand All @@ -74,7 +74,7 @@ public static DialogResult MessageBox(
break;
}

return MessageBox(Message, title, Icon, buttons);
return MessageBox(Message, title, Icon, buttons, pIsDarkMode);
}

/// <summary>Displays a message window, also known as a dialog box, which presents a message to the user.</summary>
Expand All @@ -85,7 +85,7 @@ public static DialogResult MessageBox(
/// <returns>It is a modal window, blocking other actions in the application until the user closes it.</returns>
public static DialogResult MessageBox(
string Message, string title, MsgIcon Icon,
MessageBoxButtons buttons = MessageBoxButtons.OK)
MessageBoxButtons buttons = MessageBoxButtons.OK, bool pIsDarkMode = true)
{
Form form = new Form
{
Expand All @@ -99,6 +99,8 @@ public static DialogResult MessageBox(
};

DarkModeCS DMode = new DarkModeCS(form);
DMode.ApplyTheme(pIsDarkMode);

Base64Icons _Icons = new Base64Icons();

#region Bottom Panel & Buttons
Expand Down Expand Up @@ -320,7 +322,7 @@ public static DialogResult MessageBox(
/// <returns>OK si el usuario acepta. By BlueMystic @2024</returns>
public static DialogResult InputBox(
string title, string promptText, ref List<KeyValue> Fields,
MsgIcon Icon = 0, MessageBoxButtons buttons = MessageBoxButtons.OK)
MsgIcon Icon = 0, MessageBoxButtons buttons = MessageBoxButtons.OK, bool pIsDarkMode = true)
{
Form form = new Form
{
Expand All @@ -334,6 +336,7 @@ public static DialogResult InputBox(
};

DarkModeCS DMode = new DarkModeCS(form);
DMode.ApplyTheme(pIsDarkMode);

// Error Management & Icon Library:
ErrorProvider Err = new ErrorProvider();
Expand Down Expand Up @@ -521,16 +524,22 @@ public static DialogResult InputBox(
#endregion Buttons

#region Prompt Text

Label lblPrompt = new Label

Label lblPrompt = new Label();
if (!string.IsNullOrWhiteSpace(promptText))
{
Dock = DockStyle.Top,
Text = promptText,
//Font = new Font(form.Font, FontStyle.Bold),
AutoSize = false,
Height = 24,
TextAlign = ContentAlignment.MiddleCenter
};
lblPrompt.Dock = DockStyle.Top;
lblPrompt.Text = promptText; //Font = new Font(form.Font, FontStyle.Bold),
lblPrompt.AutoSize = false;
lblPrompt.Height = 24;
lblPrompt.TextAlign = ContentAlignment.MiddleCenter;
}
else
{
lblPrompt.Location = new Point(0, 0);
lblPrompt.Width = 0;
lblPrompt.Height = 0;
}
form.Controls.Add(lblPrompt);

#endregion Prompt Text
Expand Down Expand Up @@ -589,6 +598,28 @@ public static DialogResult InputBox(
});
};
}
if (field.ValueType == ValueTypes.Multiline)
{
field_Control = new TextBox
{
Text = field.Value,
Dock = DockStyle.Fill,
TextAlign = HorizontalAlignment.Left,
Multiline = true,
ScrollBars = ScrollBars.Vertical
};
((TextBox)field_Control).TextChanged += (sender, args) =>
{
AddTextChangedDelay((TextBox)field_Control, ChangeDelayMS, text =>
{
field.Value = ((TextBox)sender).Text;

//aqui 'KeyValue' valida el nuevo valor y puede cancelarlo
((TextBox)sender).Text = Convert.ToString(field.Value);
Err.SetError(field_Control, field.ErrorText);
});
};
}
if (field.ValueType == ValueTypes.Password)
{
field_Control = new TextBox
Expand Down Expand Up @@ -742,7 +773,22 @@ public static DialogResult InputBox(

// Add controls to appropriate cells:
Contenedor.Controls.Add(field_label, 0, currentRow); // Column 0 for labels
Contenedor.Controls.Add(field_Control, 1, currentRow); // Column 1 for text boxes
if (field.ValueType == ValueTypes.Multiline)
{
Contenedor.Controls.Add(field_Control, 1, currentRow);
const int spanRow = 6;
for (int i = 0; i < spanRow; i++)
{
currentRow++;
Contenedor.RowCount++;
Contenedor.RowStyles.Add(new RowStyle(SizeType.Absolute, field_Control.Height));
}
Contenedor.SetRowSpan(field_Control, spanRow);
}
else
{
Contenedor.Controls.Add(field_Control, 1, currentRow); // Column 1 for text boxes
}

Err.SetIconAlignment(field_Control, ErrorIconAlignment.MiddleLeft);

Expand Down Expand Up @@ -973,7 +1019,8 @@ public enum ValueTypes
Time,
Boolean,
Dynamic,
Password
Password,
Multiline
}

public string Key { get; set; }
Expand Down

0 comments on commit f53d513

Please sign in to comment.