Add project files.
This commit is contained in:
122
ModVersionChecker/forms/GlobalConfigForm.cs
Normal file
122
ModVersionChecker/forms/GlobalConfigForm.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
|
||||
namespace ModVersionChecker.forms
|
||||
{
|
||||
public class GlobalConfigForm : Form
|
||||
{
|
||||
private IConfigManager _configManager;
|
||||
private GlobalConfig _config;
|
||||
|
||||
private Label _millislabel, _checkStartupLabel;
|
||||
private TrackBar _millisField;
|
||||
private CheckBox _checkStartupField;
|
||||
private Button _saveButton, _cancelButton;
|
||||
private TableLayoutPanel _mainLayout, _configsPanel;
|
||||
private FlowLayoutPanel _buttonPanel;
|
||||
|
||||
public GlobalConfigForm(IConfigManager configManager)
|
||||
{
|
||||
_configManager = configManager;
|
||||
_config = _configManager.GetConfig();
|
||||
InitializeComponent();
|
||||
}
|
||||
private void InitializeComponent()
|
||||
{
|
||||
SuspendLayout();
|
||||
|
||||
ClientSize = new System.Drawing.Size(600, 250);
|
||||
Name = "GlobalConfigForm";
|
||||
Text = "Global Configuration";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Padding = new Padding(10, 20, 10, 20 );
|
||||
_mainLayout = GetMainLayout();
|
||||
_configsPanel = GetConfigsPanel();
|
||||
|
||||
_buttonPanel = GetButtonsPanel();
|
||||
|
||||
_mainLayout.Controls.Add(_configsPanel, 0, 0);
|
||||
_mainLayout.Controls.Add(_buttonPanel, 0, 1);
|
||||
|
||||
Controls.Add(_mainLayout);
|
||||
|
||||
|
||||
ResumeLayout(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private FlowLayoutPanel GetButtonsPanel()
|
||||
{
|
||||
var buttonsPanel = new FlowLayoutPanel { FlowDirection = FlowDirection.RightToLeft, AutoSize = true, Dock = DockStyle.Fill };
|
||||
_saveButton = new Button { Text = "Save", AutoSize = true };
|
||||
_saveButton.Click += (sender, e) =>
|
||||
{
|
||||
_config.IntervalMinutes = _millisField.Value;
|
||||
_config.CheckOnStartup = _checkStartupField.Checked;
|
||||
_configManager.Save(_config);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
};
|
||||
_cancelButton = new Button { Text = "Cancel", AutoSize = true };
|
||||
_cancelButton.Click += (sender, e) =>
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
};
|
||||
buttonsPanel.Controls.Add(_saveButton);
|
||||
buttonsPanel.Controls.Add(_cancelButton);
|
||||
return buttonsPanel;
|
||||
}
|
||||
|
||||
private TableLayoutPanel GetConfigsPanel()
|
||||
{
|
||||
// Initialize the configurations panel
|
||||
var configsPanel = new TableLayoutPanel
|
||||
{
|
||||
AutoSize = true,
|
||||
Dock = DockStyle.Fill,
|
||||
ColumnCount = 2,
|
||||
RowCount = 2,
|
||||
ColumnStyles = { new ColumnStyle(SizeType.Absolute, 150), new ColumnStyle(SizeType.Percent, 100) }
|
||||
};
|
||||
|
||||
_millislabel = new Label { Text = "Millis", Width = 150};
|
||||
_millisField = new TrackBar { Minimum = 0, Maximum = 120, Value= _config.IntervalMinutes, Width = 300, TickStyle = TickStyle.None };
|
||||
FlowLayoutPanel millisPanel = new FlowLayoutPanel { FlowDirection = FlowDirection.LeftToRight, AutoSize = true };
|
||||
Label millisValue = new Label { Text = _millisField.Value.ToString() + " minutes", AutoSize = true, Padding = new Padding(10, 10, 0, 0) };
|
||||
millisPanel.Controls.Add(_millisField);
|
||||
millisPanel.Controls.Add(millisValue);
|
||||
|
||||
_millisField.Scroll += (sender, e) => { millisValue.Text = _millisField.Value.ToString() + " minutes"; };
|
||||
|
||||
_checkStartupLabel = new Label { Text = "Check on Startup:", Width = 150 };
|
||||
_checkStartupField = new CheckBox { Checked = _config.CheckOnStartup };
|
||||
|
||||
configsPanel.Controls.Add(_millislabel, 0, 0);
|
||||
configsPanel.Controls.Add(millisPanel, 1, 0);
|
||||
configsPanel.Controls.Add(_checkStartupLabel, 0, 1);
|
||||
configsPanel.Controls.Add(_checkStartupField, 1, 1);
|
||||
|
||||
return configsPanel;
|
||||
}
|
||||
|
||||
private TableLayoutPanel GetMainLayout()
|
||||
{
|
||||
// Initialize the main layout panel
|
||||
var mainLayout = new TableLayoutPanel
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
RowCount = 2,
|
||||
ColumnCount = 1
|
||||
};
|
||||
mainLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 150)); // Paths panel height
|
||||
mainLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 50)); // Button panel height
|
||||
Controls.Add(mainLayout);
|
||||
return mainLayout;
|
||||
}
|
||||
|
||||
// Add methods and properties for global configuration management here
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user