From 29c44e6027c378e081273ab6c512cd623c085d43 Mon Sep 17 00:00:00 2001 From: Danil Kislov Date: Tue, 26 Mar 2019 09:51:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B7=D0=B0?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .semver.txt | 2 +- src/JiraTimeBot/DI/ContainerBuilder.cs | 7 ++- src/JiraTimeBot/JiraTimeBot.csproj | 1 + src/JiraTimeBot/Properties/AssemblyInfo.cs | 62 +++++++++++----------- src/JiraTimeBot/UI/Startup/AutoStartUp.cs | 27 ++++++++++ src/JiraTimeBot/UI/frmMain.cs | 5 +- src/JiraTimeBot/UI/frmSettings.Designer.cs | 19 +++++-- src/JiraTimeBot/UI/frmSettings.cs | 9 +++- 8 files changed, 93 insertions(+), 39 deletions(-) create mode 100644 src/JiraTimeBot/UI/Startup/AutoStartUp.cs diff --git a/.semver.txt b/.semver.txt index e8eb7f1..ffcbe71 100644 --- a/.semver.txt +++ b/.semver.txt @@ -1 +1 @@ -1.0.33 +1.0.34 diff --git a/src/JiraTimeBot/DI/ContainerBuilder.cs b/src/JiraTimeBot/DI/ContainerBuilder.cs index e0aee42..63d03c3 100644 --- a/src/JiraTimeBot/DI/ContainerBuilder.cs +++ b/src/JiraTimeBot/DI/ContainerBuilder.cs @@ -9,6 +9,8 @@ using JiraTimeBot.TaskTime; using JiraTimeBot.UI.Tray; using System; using System.Windows.Forms; +using JiraTimeBot.UI; +using JiraTimeBot.UI.Startup; namespace JiraTimeBot.DI { @@ -50,9 +52,12 @@ namespace JiraTimeBot.DI _builder.RegisterType().AsSelf().As(); _builder.RegisterType().AsSelf().AsImplementedInterfaces(); - + _builder.Register(c => new Job(c.Resolve(), c.Resolve(), c.Resolve())).AsSelf(); + _builder.RegisterType().AsSelf().AsImplementedInterfaces(); + _builder.RegisterType().AsSelf().AsImplementedInterfaces(); + var container = _builder.Build(); return container; } diff --git a/src/JiraTimeBot/JiraTimeBot.csproj b/src/JiraTimeBot/JiraTimeBot.csproj index f8efc9e..72b3259 100644 --- a/src/JiraTimeBot/JiraTimeBot.csproj +++ b/src/JiraTimeBot/JiraTimeBot.csproj @@ -116,6 +116,7 @@ frmSettings.cs + diff --git a/src/JiraTimeBot/Properties/AssemblyInfo.cs b/src/JiraTimeBot/Properties/AssemblyInfo.cs index 896fe5a..7bb874d 100644 --- a/src/JiraTimeBot/Properties/AssemblyInfo.cs +++ b/src/JiraTimeBot/Properties/AssemblyInfo.cs @@ -1,31 +1,31 @@ -using System.Reflection; -using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JiraTimeBot")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JiraTimeBot")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.33")] -[assembly: AssemblyFileVersion("1.0.33")] -[assembly: AssemblyInformationalVersion("1.0.33")] +using System.Reflection; +using System.Runtime.InteropServices; +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("JiraTimeBot")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("JiraTimeBot")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")] +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.34")] +[assembly: AssemblyFileVersion("1.0.34")] +[assembly: AssemblyInformationalVersion("1.0.34")] diff --git a/src/JiraTimeBot/UI/Startup/AutoStartUp.cs b/src/JiraTimeBot/UI/Startup/AutoStartUp.cs new file mode 100644 index 0000000..f6ec89f --- /dev/null +++ b/src/JiraTimeBot/UI/Startup/AutoStartUp.cs @@ -0,0 +1,27 @@ +using System.Windows.Forms; +using Microsoft.Win32; + +namespace JiraTimeBot.UI.Startup +{ + public class AutoStartUp + { + readonly RegistryKey _rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); + + public bool Get() + { + return _rkApp.GetValue(Application.ProductName) != null; + } + + public void Set(bool autoStart) + { + if (autoStart) + { + _rkApp.SetValue(Application.ProductName, Application.ExecutablePath); + } + else + { + _rkApp.DeleteValue(Application.ProductName, false); + } + } + } +} diff --git a/src/JiraTimeBot/UI/frmMain.cs b/src/JiraTimeBot/UI/frmMain.cs index ff14a2f..b979f23 100644 --- a/src/JiraTimeBot/UI/frmMain.cs +++ b/src/JiraTimeBot/UI/frmMain.cs @@ -11,6 +11,7 @@ using System.IO.Compression; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using JiraTimeBot.UI.Startup; // This is the code for your desktop app. // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app. @@ -69,7 +70,7 @@ namespace JiraTimeBot.UI _settingsWindowShow = () => { - var frmSettings = new frmSettings(); + var frmSettings = new frmSettings(_container.Resolve()); frmSettings.ShowDialog(this); }; _settingsErrorReporter = msg => MessageBox.Show(msg, "Загрузка настроек", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);; @@ -201,7 +202,7 @@ namespace JiraTimeBot.UI private void btnSettings_Click(object sender, EventArgs e) { - var frm = new frmSettings(); + var frm = _container.Resolve(); frm.ShowDialog(); PrintStartMessage(); diff --git a/src/JiraTimeBot/UI/frmSettings.Designer.cs b/src/JiraTimeBot/UI/frmSettings.Designer.cs index eecb8a4..f5ba9ce 100644 --- a/src/JiraTimeBot/UI/frmSettings.Designer.cs +++ b/src/JiraTimeBot/UI/frmSettings.Designer.cs @@ -48,6 +48,7 @@ this.txtJQL = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); this.txtTimeControlTask = new System.Windows.Forms.TextBox(); + this.chkAutostart = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // label5 @@ -152,7 +153,7 @@ // chkAddComments // this.chkAddComments.AutoSize = true; - this.chkAddComments.Location = new System.Drawing.Point(56, 267); + this.chkAddComments.Location = new System.Drawing.Point(56, 277); this.chkAddComments.Name = "chkAddComments"; this.chkAddComments.Size = new System.Drawing.Size(133, 17); this.chkAddComments.TabIndex = 31; @@ -161,7 +162,7 @@ // // btnSave // - this.btnSave.Location = new System.Drawing.Point(72, 299); + this.btnSave.Location = new System.Drawing.Point(72, 310); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(75, 23); this.btnSave.TabIndex = 32; @@ -223,11 +224,22 @@ this.txtTimeControlTask.Size = new System.Drawing.Size(99, 20); this.txtTimeControlTask.TabIndex = 38; // + // chkAutostart + // + this.chkAutostart.AutoSize = true; + this.chkAutostart.Location = new System.Drawing.Point(56, 254); + this.chkAutostart.Name = "chkAutostart"; + this.chkAutostart.Size = new System.Drawing.Size(96, 17); + this.chkAutostart.TabIndex = 40; + this.chkAutostart.Text = "Автозагрузка"; + this.chkAutostart.UseVisualStyleBackColor = true; + // // frmSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(243, 334); + this.ClientSize = new System.Drawing.Size(243, 342); + this.Controls.Add(this.chkAutostart); this.Controls.Add(this.label8); this.Controls.Add(this.txtTimeControlTask); this.Controls.Add(this.label7); @@ -281,5 +293,6 @@ private System.Windows.Forms.TextBox txtJQL; private System.Windows.Forms.Label label8; private System.Windows.Forms.TextBox txtTimeControlTask; + private System.Windows.Forms.CheckBox chkAutostart; } } \ No newline at end of file diff --git a/src/JiraTimeBot/UI/frmSettings.cs b/src/JiraTimeBot/UI/frmSettings.cs index 157f125..3052cd8 100644 --- a/src/JiraTimeBot/UI/frmSettings.cs +++ b/src/JiraTimeBot/UI/frmSettings.cs @@ -1,13 +1,17 @@ using System; using System.Windows.Forms; using JiraTimeBot.Configuration; +using JiraTimeBot.UI.Startup; namespace JiraTimeBot.UI { public partial class frmSettings : Form { - public frmSettings() + private readonly AutoStartUp _autoStart; + + public frmSettings(AutoStartUp autoStart) { + _autoStart = autoStart; InitializeComponent(); } @@ -18,6 +22,8 @@ namespace JiraTimeBot.UI { SetSettings(settings); } + + chkAutostart.Checked = _autoStart.Get(); } private void SetSettings(Settings settings) @@ -67,6 +73,7 @@ namespace JiraTimeBot.UI { var settings = ReadSettingsAndLock(); settings.Save(); + _autoStart.Set(chkAutostart.Checked); MessageBox.Show("Настройки сохранены.");