Редизайн + вынос настроек
This commit is contained in:
@@ -112,6 +112,12 @@
|
||||
<Compile Include="TaskTime\ITaskTimeCalculator.cs" />
|
||||
<Compile Include="TaskTime\TaskTimeByCommitsCalculator.cs" />
|
||||
<Compile Include="TaskTime\Objects\TaskTimeItem.cs" />
|
||||
<Compile Include="UI\frmSettings.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\frmSettings.Designer.cs">
|
||||
<DependentUpon>frmSettings.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\Tray\ITrayMenu.cs" />
|
||||
<Compile Include="UI\Tray\RestoreFromTray.cs" />
|
||||
<Compile Include="UI\Tray\TrayMenu.cs" />
|
||||
@@ -127,6 +133,9 @@
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="UI\frmSettings.resx">
|
||||
<DependentUpon>frmSettings.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
|
||||
Generated
+20
-168
@@ -30,17 +30,6 @@
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
|
||||
this.actTime = new System.Windows.Forms.DateTimePicker();
|
||||
this.txtJiraLogin = new System.Windows.Forms.TextBox();
|
||||
this.lbl1 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.txtJiraPassword = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txtMercurialEmail = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.btnSave = new System.Windows.Forms.Button();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.txtRepoPath = new System.Windows.Forms.TextBox();
|
||||
this.txtLog = new System.Windows.Forms.TextBox();
|
||||
this.btnStart = new System.Windows.Forms.Button();
|
||||
this.ntfyIcon = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
@@ -48,116 +37,22 @@
|
||||
this.txtDummyMode = new System.Windows.Forms.CheckBox();
|
||||
this.btnMeeting = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.chkAddComments = new System.Windows.Forms.CheckBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.txtRoundTo = new System.Windows.Forms.TextBox();
|
||||
this.btnSettings = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// actTime
|
||||
//
|
||||
this.actTime.Format = System.Windows.Forms.DateTimePickerFormat.Time;
|
||||
this.actTime.Location = new System.Drawing.Point(100, 147);
|
||||
this.actTime.Name = "actTime";
|
||||
this.actTime.Size = new System.Drawing.Size(100, 20);
|
||||
this.actTime.TabIndex = 0;
|
||||
//
|
||||
// txtJiraLogin
|
||||
//
|
||||
this.txtJiraLogin.Location = new System.Drawing.Point(100, 42);
|
||||
this.txtJiraLogin.Name = "txtJiraLogin";
|
||||
this.txtJiraLogin.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtJiraLogin.TabIndex = 1;
|
||||
//
|
||||
// lbl1
|
||||
//
|
||||
this.lbl1.AutoSize = true;
|
||||
this.lbl1.Location = new System.Drawing.Point(34, 45);
|
||||
this.lbl1.Name = "lbl1";
|
||||
this.lbl1.Size = new System.Drawing.Size(64, 13);
|
||||
this.lbl1.TabIndex = 2;
|
||||
this.lbl1.Text = "Логин Jira*:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(27, 71);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(71, 13);
|
||||
this.label1.TabIndex = 4;
|
||||
this.label1.Text = "Пароль Jira*:";
|
||||
//
|
||||
// txtJiraPassword
|
||||
//
|
||||
this.txtJiraPassword.Location = new System.Drawing.Point(100, 68);
|
||||
this.txtJiraPassword.Name = "txtJiraPassword";
|
||||
this.txtJiraPassword.PasswordChar = '*';
|
||||
this.txtJiraPassword.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtJiraPassword.TabIndex = 3;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 98);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(82, 13);
|
||||
this.label2.TabIndex = 6;
|
||||
this.label2.Text = "Mercurial name:";
|
||||
//
|
||||
// txtMercurialEmail
|
||||
//
|
||||
this.txtMercurialEmail.Location = new System.Drawing.Point(100, 95);
|
||||
this.txtMercurialEmail.Name = "txtMercurialEmail";
|
||||
this.txtMercurialEmail.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtMercurialEmail.TabIndex = 5;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(7, 151);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(91, 13);
|
||||
this.label3.TabIndex = 7;
|
||||
this.label3.Text = "Время запуска*:";
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.Location = new System.Drawing.Point(78, 196);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnSave.TabIndex = 8;
|
||||
this.btnSave.Text = "Save";
|
||||
this.btnSave.UseVisualStyleBackColor = true;
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(18, 19);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(76, 13);
|
||||
this.label4.TabIndex = 10;
|
||||
this.label4.Text = "Путь до репо:";
|
||||
//
|
||||
// txtRepoPath
|
||||
//
|
||||
this.txtRepoPath.Location = new System.Drawing.Point(100, 16);
|
||||
this.txtRepoPath.Name = "txtRepoPath";
|
||||
this.txtRepoPath.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtRepoPath.TabIndex = 9;
|
||||
//
|
||||
// txtLog
|
||||
//
|
||||
this.txtLog.Location = new System.Drawing.Point(218, 16);
|
||||
this.txtLog.Location = new System.Drawing.Point(12, 16);
|
||||
this.txtLog.Multiline = true;
|
||||
this.txtLog.Name = "txtLog";
|
||||
this.txtLog.ReadOnly = true;
|
||||
this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtLog.Size = new System.Drawing.Size(510, 294);
|
||||
this.txtLog.Size = new System.Drawing.Size(716, 294);
|
||||
this.txtLog.TabIndex = 11;
|
||||
//
|
||||
// btnStart
|
||||
//
|
||||
this.btnStart.Location = new System.Drawing.Point(9, 254);
|
||||
this.btnStart.Location = new System.Drawing.Point(12, 324);
|
||||
this.btnStart.Name = "btnStart";
|
||||
this.btnStart.Size = new System.Drawing.Size(114, 23);
|
||||
this.btnStart.TabIndex = 12;
|
||||
@@ -179,7 +74,7 @@
|
||||
// txtDummyMode
|
||||
//
|
||||
this.txtDummyMode.AutoSize = true;
|
||||
this.txtDummyMode.Location = new System.Drawing.Point(9, 231);
|
||||
this.txtDummyMode.Location = new System.Drawing.Point(208, 328);
|
||||
this.txtDummyMode.Name = "txtDummyMode";
|
||||
this.txtDummyMode.Size = new System.Drawing.Size(114, 17);
|
||||
this.txtDummyMode.TabIndex = 13;
|
||||
@@ -188,7 +83,7 @@
|
||||
//
|
||||
// btnMeeting
|
||||
//
|
||||
this.btnMeeting.Location = new System.Drawing.Point(142, 254);
|
||||
this.btnMeeting.Location = new System.Drawing.Point(132, 324);
|
||||
this.btnMeeting.Name = "btnMeeting";
|
||||
this.btnMeeting.Size = new System.Drawing.Size(70, 23);
|
||||
this.btnMeeting.TabIndex = 14;
|
||||
@@ -199,68 +94,39 @@
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Enabled = false;
|
||||
this.btnCancel.Location = new System.Drawing.Point(9, 286);
|
||||
this.btnCancel.Location = new System.Drawing.Point(328, 324);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(203, 23);
|
||||
this.btnCancel.Size = new System.Drawing.Size(190, 23);
|
||||
this.btnCancel.TabIndex = 15;
|
||||
this.btnCancel.Text = "Отменить операцию";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// chkAddComments
|
||||
// btnSettings
|
||||
//
|
||||
this.chkAddComments.AutoSize = true;
|
||||
this.chkAddComments.Location = new System.Drawing.Point(45, 175);
|
||||
this.chkAddComments.Name = "chkAddComments";
|
||||
this.chkAddComments.Size = new System.Drawing.Size(133, 17);
|
||||
this.chkAddComments.TabIndex = 16;
|
||||
this.chkAddComments.Text = "Добавлять описание";
|
||||
this.chkAddComments.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(-2, 124);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(100, 13);
|
||||
this.label5.TabIndex = 18;
|
||||
this.label5.Text = "Округл. времени*:";
|
||||
//
|
||||
// txtRoundTo
|
||||
//
|
||||
this.txtRoundTo.Location = new System.Drawing.Point(100, 121);
|
||||
this.txtRoundTo.Name = "txtRoundTo";
|
||||
this.txtRoundTo.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtRoundTo.TabIndex = 17;
|
||||
this.txtRoundTo.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
|
||||
this.btnSettings.Location = new System.Drawing.Point(645, 324);
|
||||
this.btnSettings.Name = "btnSettings";
|
||||
this.btnSettings.Size = new System.Drawing.Size(82, 23);
|
||||
this.btnSettings.TabIndex = 16;
|
||||
this.btnSettings.Text = "Настройки";
|
||||
this.btnSettings.UseVisualStyleBackColor = true;
|
||||
this.btnSettings.Click += new System.EventHandler(this.btnSettings_Click);
|
||||
//
|
||||
// frmMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(740, 318);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.txtRoundTo);
|
||||
this.Controls.Add(this.chkAddComments);
|
||||
this.ClientSize = new System.Drawing.Size(740, 357);
|
||||
this.Controls.Add(this.btnSettings);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnMeeting);
|
||||
this.Controls.Add(this.txtDummyMode);
|
||||
this.Controls.Add(this.btnStart);
|
||||
this.Controls.Add(this.txtLog);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.txtRepoPath);
|
||||
this.Controls.Add(this.btnSave);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.txtMercurialEmail);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.txtJiraPassword);
|
||||
this.Controls.Add(this.lbl1);
|
||||
this.Controls.Add(this.txtJiraLogin);
|
||||
this.Controls.Add(this.actTime);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.Name = "frmMain";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Бот логирования времени";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing);
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
@@ -271,18 +137,6 @@
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DateTimePicker actTime;
|
||||
private System.Windows.Forms.TextBox txtJiraLogin;
|
||||
private System.Windows.Forms.Label lbl1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox txtJiraPassword;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox txtMercurialEmail;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button btnSave;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox txtRepoPath;
|
||||
private System.Windows.Forms.TextBox txtLog;
|
||||
private System.Windows.Forms.Button btnStart;
|
||||
private System.Windows.Forms.NotifyIcon ntfyIcon;
|
||||
@@ -290,9 +144,7 @@
|
||||
private System.Windows.Forms.CheckBox txtDummyMode;
|
||||
private System.Windows.Forms.Button btnMeeting;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.CheckBox chkAddComments;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.TextBox txtRoundTo;
|
||||
private System.Windows.Forms.Button btnSettings;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace JiraTimeBotForm.UI
|
||||
private readonly IAllTasksProcessors _tasksProcessors;
|
||||
private readonly ITrayMenu _trayIcon;
|
||||
private CancellationTokenSource _tokenSource;
|
||||
private Settings _settings;
|
||||
|
||||
private CancellationTokenSource GetTokenSource()
|
||||
{
|
||||
@@ -45,11 +46,13 @@ namespace JiraTimeBotForm.UI
|
||||
_trayIcon = _container.Resolve<ITrayMenu>();
|
||||
_trayIcon.Create(this);
|
||||
|
||||
_settings = Settings.Load();
|
||||
|
||||
_job = _container.Resolve<Job>();
|
||||
_log = _container.Resolve<ILog>();
|
||||
_tasksProcessors = _container.Resolve<IAllTasksProcessors>();
|
||||
|
||||
_controls = new Control[] { txtJiraLogin, txtJiraPassword, txtMercurialEmail, actTime, txtRepoPath, txtDummyMode, btnSave, btnStart, btnMeeting, chkAddComments, txtRoundTo };
|
||||
_controls = new Control[] { txtDummyMode, btnStart, btnMeeting, btnSettings };
|
||||
}
|
||||
|
||||
private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -59,26 +62,11 @@ namespace JiraTimeBotForm.UI
|
||||
|
||||
public Settings ReadSettingsAndLock()
|
||||
{
|
||||
if (!int.TryParse(txtRoundTo.Text, out var roundTo))
|
||||
{
|
||||
roundTo = 15;
|
||||
}
|
||||
|
||||
var settings = new Settings
|
||||
{
|
||||
JiraUserName = txtJiraLogin.Text,
|
||||
JiraPassword = txtJiraPassword.Text,
|
||||
MercurialAuthorEmail = txtMercurialEmail.Text,
|
||||
ActivationTime = TimeSpan.Parse(actTime.Text),
|
||||
RepositoryPath = txtRepoPath.Text,
|
||||
DummyMode = txtDummyMode.Checked,
|
||||
AddCommentsToWorklog = chkAddComments.Checked,
|
||||
RountToMinutes = roundTo
|
||||
};
|
||||
_settings = Settings.Load();
|
||||
|
||||
LockUnlock(false);
|
||||
|
||||
return settings;
|
||||
return _settings;
|
||||
}
|
||||
|
||||
public void LockUnlock(bool enabled)
|
||||
@@ -91,41 +79,9 @@ namespace JiraTimeBotForm.UI
|
||||
btnCancel.Enabled = !enabled;
|
||||
tmrStart.Enabled = enabled;
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
var settings = ReadSettingsAndLock();
|
||||
LockUnlock(true);
|
||||
|
||||
settings.Save();
|
||||
|
||||
MessageBox.Show("Settings saved.");
|
||||
settings = Settings.Load();
|
||||
if (settings != null)
|
||||
{
|
||||
SetSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
var settings = Settings.Load();
|
||||
if (settings != null)
|
||||
{
|
||||
SetSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSettings(Settings settings)
|
||||
{
|
||||
txtJiraLogin.Text = settings.JiraUserName;
|
||||
txtJiraPassword.Text = settings.JiraPassword;
|
||||
txtMercurialEmail.Text = settings.MercurialAuthorEmail;
|
||||
txtRepoPath.Text = settings.RepositoryPath;
|
||||
actTime.Text = settings.ActivationTime.ToString("hh\\:mm\\:ss");
|
||||
txtDummyMode.Checked = settings.DummyMode;
|
||||
chkAddComments.Checked = settings.AddCommentsToWorklog;
|
||||
txtRoundTo.Text = settings.RountToMinutes.ToString();
|
||||
_settings = Settings.Load();
|
||||
}
|
||||
|
||||
private async void btnStart_Click(object sender, EventArgs e)
|
||||
@@ -156,7 +112,7 @@ namespace JiraTimeBotForm.UI
|
||||
|
||||
private async void tmrStart_Tick(object sender, EventArgs e)
|
||||
{
|
||||
var runTime = TimeSpan.Parse(actTime.Text);
|
||||
var runTime = _settings.ActivationTime;
|
||||
|
||||
if (Math.Abs((DateTime.Now.TimeOfDay - runTime).TotalSeconds) < 1)
|
||||
{
|
||||
@@ -208,5 +164,11 @@ namespace JiraTimeBotForm.UI
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar);
|
||||
}
|
||||
|
||||
private void btnSettings_Click(object sender, EventArgs e)
|
||||
{
|
||||
var frm = new frmSettings();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
namespace JiraTimeBotForm.UI
|
||||
{
|
||||
partial class frmSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.txtRoundTo = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.txtRepoPath = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txtMercurialEmail = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.txtJiraPassword = new System.Windows.Forms.TextBox();
|
||||
this.lbl1 = new System.Windows.Forms.Label();
|
||||
this.txtJiraLogin = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.actTime = new System.Windows.Forms.DateTimePicker();
|
||||
this.chkAddComments = new System.Windows.Forms.CheckBox();
|
||||
this.btnSave = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(7, 120);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(100, 13);
|
||||
this.label5.TabIndex = 28;
|
||||
this.label5.Text = "Округл. времени*:";
|
||||
//
|
||||
// txtRoundTo
|
||||
//
|
||||
this.txtRoundTo.Location = new System.Drawing.Point(109, 117);
|
||||
this.txtRoundTo.Name = "txtRoundTo";
|
||||
this.txtRoundTo.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtRoundTo.TabIndex = 27;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(27, 15);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(76, 13);
|
||||
this.label4.TabIndex = 26;
|
||||
this.label4.Text = "Путь до репо:";
|
||||
//
|
||||
// txtRepoPath
|
||||
//
|
||||
this.txtRepoPath.Location = new System.Drawing.Point(109, 12);
|
||||
this.txtRepoPath.Name = "txtRepoPath";
|
||||
this.txtRepoPath.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtRepoPath.TabIndex = 25;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(21, 94);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(82, 13);
|
||||
this.label2.TabIndex = 24;
|
||||
this.label2.Text = "Mercurial name:";
|
||||
//
|
||||
// txtMercurialEmail
|
||||
//
|
||||
this.txtMercurialEmail.Location = new System.Drawing.Point(109, 91);
|
||||
this.txtMercurialEmail.Name = "txtMercurialEmail";
|
||||
this.txtMercurialEmail.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtMercurialEmail.TabIndex = 23;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(36, 67);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(71, 13);
|
||||
this.label1.TabIndex = 22;
|
||||
this.label1.Text = "Пароль Jira*:";
|
||||
//
|
||||
// txtJiraPassword
|
||||
//
|
||||
this.txtJiraPassword.Location = new System.Drawing.Point(109, 64);
|
||||
this.txtJiraPassword.Name = "txtJiraPassword";
|
||||
this.txtJiraPassword.PasswordChar = '*';
|
||||
this.txtJiraPassword.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtJiraPassword.TabIndex = 21;
|
||||
//
|
||||
// lbl1
|
||||
//
|
||||
this.lbl1.AutoSize = true;
|
||||
this.lbl1.Location = new System.Drawing.Point(43, 41);
|
||||
this.lbl1.Name = "lbl1";
|
||||
this.lbl1.Size = new System.Drawing.Size(64, 13);
|
||||
this.lbl1.TabIndex = 20;
|
||||
this.lbl1.Text = "Логин Jira*:";
|
||||
//
|
||||
// txtJiraLogin
|
||||
//
|
||||
this.txtJiraLogin.Location = new System.Drawing.Point(109, 38);
|
||||
this.txtJiraLogin.Name = "txtJiraLogin";
|
||||
this.txtJiraLogin.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtJiraLogin.TabIndex = 19;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(16, 147);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(91, 13);
|
||||
this.label3.TabIndex = 30;
|
||||
this.label3.Text = "Время запуска*:";
|
||||
//
|
||||
// actTime
|
||||
//
|
||||
this.actTime.Format = System.Windows.Forms.DateTimePickerFormat.Time;
|
||||
this.actTime.Location = new System.Drawing.Point(109, 143);
|
||||
this.actTime.Name = "actTime";
|
||||
this.actTime.Size = new System.Drawing.Size(100, 20);
|
||||
this.actTime.TabIndex = 29;
|
||||
//
|
||||
// chkAddComments
|
||||
//
|
||||
this.chkAddComments.AutoSize = true;
|
||||
this.chkAddComments.Location = new System.Drawing.Point(39, 169);
|
||||
this.chkAddComments.Name = "chkAddComments";
|
||||
this.chkAddComments.Size = new System.Drawing.Size(133, 17);
|
||||
this.chkAddComments.TabIndex = 31;
|
||||
this.chkAddComments.Text = "Добавлять описание";
|
||||
this.chkAddComments.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.Location = new System.Drawing.Point(61, 203);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnSave.TabIndex = 32;
|
||||
this.btnSave.Text = "Сохранить";
|
||||
this.btnSave.UseVisualStyleBackColor = true;
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// frmSettings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(220, 238);
|
||||
this.Controls.Add(this.btnSave);
|
||||
this.Controls.Add(this.chkAddComments);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.actTime);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.txtRoundTo);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.txtRepoPath);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.txtMercurialEmail);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.txtJiraPassword);
|
||||
this.Controls.Add(this.lbl1);
|
||||
this.Controls.Add(this.txtJiraLogin);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "frmSettings";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Настройки";
|
||||
this.Load += new System.EventHandler(this.frmSettings_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.TextBox txtRoundTo;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox txtRepoPath;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox txtMercurialEmail;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox txtJiraPassword;
|
||||
private System.Windows.Forms.Label lbl1;
|
||||
private System.Windows.Forms.TextBox txtJiraLogin;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.DateTimePicker actTime;
|
||||
private System.Windows.Forms.CheckBox chkAddComments;
|
||||
private System.Windows.Forms.Button btnSave;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
|
||||
namespace JiraTimeBotForm.UI
|
||||
{
|
||||
public partial class frmSettings : Form
|
||||
{
|
||||
public frmSettings()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void frmSettings_Load(object sender, EventArgs e)
|
||||
{
|
||||
var settings = Settings.Load();
|
||||
SetSettings(settings);
|
||||
}
|
||||
|
||||
private void SetSettings(Settings settings)
|
||||
{
|
||||
txtJiraLogin.Text = settings.JiraUserName;
|
||||
txtJiraPassword.Text = settings.JiraPassword;
|
||||
txtMercurialEmail.Text = settings.MercurialAuthorEmail;
|
||||
txtRepoPath.Text = settings.RepositoryPath;
|
||||
actTime.Text = settings.ActivationTime.ToString("hh\\:mm\\:ss");
|
||||
//txtDummyMode.Checked = settings.DummyMode;
|
||||
chkAddComments.Checked = settings.AddCommentsToWorklog;
|
||||
txtRoundTo.Text = settings.RountToMinutes.ToString();
|
||||
}
|
||||
|
||||
public Settings ReadSettingsAndLock()
|
||||
{
|
||||
if (!int.TryParse(txtRoundTo.Text, out var roundTo))
|
||||
{
|
||||
roundTo = 15;
|
||||
}
|
||||
|
||||
var settings = new Settings
|
||||
{
|
||||
JiraUserName = txtJiraLogin.Text,
|
||||
JiraPassword = txtJiraPassword.Text,
|
||||
MercurialAuthorEmail = txtMercurialEmail.Text,
|
||||
ActivationTime = TimeSpan.Parse(actTime.Text),
|
||||
RepositoryPath = txtRepoPath.Text,
|
||||
//DummyMode = txtDummyMode.Checked,
|
||||
AddCommentsToWorklog = chkAddComments.Checked,
|
||||
RountToMinutes = roundTo
|
||||
};
|
||||
|
||||
//LockUnlock(false);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
var settings = ReadSettingsAndLock();
|
||||
settings.Save();
|
||||
MessageBox.Show("Настройки сохранены.");
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user