Возможность автозагрузки
This commit is contained in:
@@ -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<JiraDescriptionSource>().AsSelf().As<IJiraDescriptionSource>();
|
||||
_builder.RegisterType<JiraApi>().AsSelf().AsImplementedInterfaces();
|
||||
|
||||
|
||||
_builder.Register(c => new Job(c.Resolve<IAllMercurialProviders>(), c.Resolve<ITaskTimeCalculator>(), c.Resolve<ILog>())).AsSelf();
|
||||
|
||||
_builder.RegisterType<AutoStartUp>().AsSelf().AsImplementedInterfaces();
|
||||
_builder.RegisterType<frmSettings>().AsSelf().AsImplementedInterfaces();
|
||||
|
||||
var container = _builder.Build();
|
||||
return container;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
<Compile Include="UI\frmSettings.Designer.cs">
|
||||
<DependentUpon>frmSettings.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\Startup\AutoStartUp.cs" />
|
||||
<Compile Include="UI\Tray\SingleInstance.cs" />
|
||||
<Compile Include="UI\Tray\ITrayMenu.cs" />
|
||||
<Compile Include="UI\Tray\RestoreFromTray.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")]
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<AutoStartUp>());
|
||||
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<frmSettings>();
|
||||
frm.ShowDialog();
|
||||
|
||||
PrintStartMessage();
|
||||
|
||||
+16
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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("Настройки сохранены.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user