Skip to content

Commit

Permalink
+ support hide to tray if minimalized
Browse files Browse the repository at this point in the history
 + support start minimalized

 * repaired SettingsForm check box value load for RunOnLogOn
  • Loading branch information
Marek committed Jan 12, 2019
1 parent a36dad9 commit 5d695bf
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 37 deletions.
14 changes: 10 additions & 4 deletions NoLockScreenHelper2/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ public Configuration()
Automat = false;
Activated = false;
EnableNotificationBubbles = true;
HideToTrayIfMinimized = false;
StartMinimalized = false;
}
static readonly string ConfigurationsPath = "Settings.xml";

[XmlAttribute]
public bool Automat { get; set; }

public event EventHandler ActivationChanged;
Expand All @@ -36,12 +38,16 @@ private void RaiseActivationChanged()
RaiseActivationChanged();
}
}

[XmlAttribute]
public bool ActivateOnStartup { get; set; }

[XmlIgnore]
public bool RunOnLogOn { get; set; }

[XmlAttribute]
public bool EnableNotificationBubbles { get; set; }
[XmlAttribute]
public bool HideToTrayIfMinimized { get; set; }
[XmlAttribute]
public bool StartMinimalized { get; set; }

public Networks Networks {get;set;}

Expand Down
12 changes: 7 additions & 5 deletions NoLockScreenHelper2/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura IncludeDebugSymbls="false">
<!-- <IncludeAssemblies>
<Weavers>
<Costura IncludeDebugSymbls='false'>
<!-- <IncludeAssemblies>
Interop.NETWORKLIST
</IncludeAssemblies>
error CS1752: Interop type 'NetworkListManagerClass' cannot be embedded. Use the applicable interface instead.
Expand All @@ -12,5 +12,7 @@
<Unmanaged64Assemblies>
Interop.NETWORKLIST
</Unmanaged64Assemblies>
</Costura>
</Weavers>
</Costura>
</Weavers>


56 changes: 56 additions & 0 deletions NoLockScreenHelper2/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ public partial class MainForm : Form
Stopwatch stopky = new Stopwatch();
Timer casovatSopek = new Timer();
Task kontrolor;
MenuItem menuItemShow = new MenuItem("Zobrazit");
MenuItem menuItemStop = new MenuItem("Stop");
MenuItem menuItemStart = new MenuItem("Start");
MenuItem menuItemAuto = new MenuItem("Auto");

public MainForm()
{
InitializeComponent();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
this.FormClosing += MainForm_FormClosing;
this.Resize += MainForm_Resize;
this.Load += MainForm_Load;

// vymazani casovace na formulari
toolStripStatusLabelTimer.Text = "";
Expand All @@ -39,6 +45,16 @@ public MainForm()

NI.Visible = true;
NI.Icon = Properties.Resources.zamceno;
NI.MouseDoubleClick += NI_MouseDoubleClick;
NI.ContextMenu = new ContextMenu();
menuItemShow.Click += MenuItemShow_Click;
menuItemStart.Click += buttonStart_Click;
menuItemStop.Click += buttonStop_Click;
menuItemAuto.Click += buttonAuto_Click;
NI.ContextMenu.MenuItems.Add(menuItemShow);
NI.ContextMenu.MenuItems.Add(menuItemStart);
NI.ContextMenu.MenuItems.Add(menuItemStop);
NI.ContextMenu.MenuItems.Add(menuItemAuto);

if (!Config.Automat && Config.ActivateOnStartup)
activate();
Expand All @@ -49,8 +65,12 @@ public MainForm()
{
automat.Start();
buttonAuto.Enabled = false;
menuItemAuto.Enabled = false;
}

if (Config.StartMinimalized)
this.WindowState = FormWindowState.Minimized;


kontrolor = Task.Factory.StartNew(() =>
{
Expand Down Expand Up @@ -83,6 +103,33 @@ public MainForm()

}

private void MainForm_Load(object sender, EventArgs e)
{
if (Config.HideToTrayIfMinimized && WindowState == FormWindowState.Minimized)
{
Hide();
}
}

private void MenuItemShow_Click(object sender, EventArgs e)
{
Show();
this.WindowState = FormWindowState.Normal;
}

private void NI_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show();
this.WindowState = FormWindowState.Normal;
}

private void MainForm_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized && Config.HideToTrayIfMinimized)
{
Hide();
}
}

private void CasovatSopek_Tick(object sender, EventArgs e)
{
Expand Down Expand Up @@ -142,6 +189,8 @@ void activate()
//Tools.Activate();
buttonStart.Enabled = false;
buttonStop.Enabled = true;
menuItemStart.Enabled = false;
menuItemStop.Enabled = true;
Icon = NI.Icon = Properties.Resources.odemceno;
if (Config.Automat)
{
Expand Down Expand Up @@ -169,6 +218,8 @@ void deactivate()
//Tools.Deactivate();
buttonStart.Enabled = true;
buttonStop.Enabled = false;
menuItemStart.Enabled = true;
menuItemStop.Enabled = false;
Icon = NI.Icon = Properties.Resources.zamceno;
if (Config.Automat)
{
Expand All @@ -190,6 +241,7 @@ private void buttonStart_Click(object sender, EventArgs e)
{
activate();
buttonAuto.Enabled = true;
menuItemAuto.Enabled = true;
Config.Automat = false;
automat.Stop();
Config.Activated = true;
Expand All @@ -199,6 +251,7 @@ private void buttonStop_Click(object sender, EventArgs e)
{
deactivate();
buttonAuto.Enabled = true;
menuItemAuto.Enabled = true;
Config.Automat = false;
automat.Stop();
Config.Activated = false;
Expand All @@ -207,8 +260,11 @@ private void buttonStop_Click(object sender, EventArgs e)
private void buttonAuto_Click(object sender, EventArgs e)
{
buttonStart.Enabled = true;
menuItemStart.Enabled = true;
buttonStop.Enabled = true;
menuItemStop.Enabled = true;
buttonAuto.Enabled = false;
menuItemAuto.Enabled = false;
Config.Automat = true;
automat.Start();
}
Expand Down
12 changes: 6 additions & 6 deletions NoLockScreenHelper2/NoLockScreenHelper2.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.3.2.2\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.2.2\build\Costura.Fody.props')" />
<Import Project="..\packages\Costura.Fody.3.1.6\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.1.6\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -40,8 +40,8 @@
<ApplicationIcon>Resources\desktop-default_128.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=3.2.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.3.2.2\lib\net40\Costura.dll</HintPath>
<Reference Include="Costura, Version=3.1.6.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.3.1.6\lib\net46\Costura.dll</HintPath>
</Reference>
<Reference Include="Interop.NETWORKLIST">
<HintPath>DLLS\Interop.NETWORKLIST.dll</HintPath>
Expand Down Expand Up @@ -141,12 +141,12 @@
<None Include="Resources\desktop-default_128.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.3.3.5\build\Fody.targets" Condition="Exists('..\packages\Fody.3.3.5\build\Fody.targets')" />
<Import Project="..\packages\Fody.3.2.16\build\Fody.targets" Condition="Exists('..\packages\Fody.3.2.16\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.3.3.5\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.3.5\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.3.2.2\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.2.2\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Fody.3.2.16\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.2.16\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.3.1.6\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.1.6\build\Costura.Fody.props'))" />
</Target>
</Project>
64 changes: 44 additions & 20 deletions NoLockScreenHelper2/SettingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5d695bf

Please sign in to comment.