Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Add user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGuardianWolf committed Apr 25, 2020
1 parent 9253e18 commit 1d4fe13
Show file tree
Hide file tree
Showing 17 changed files with 948 additions and 36 deletions.
14 changes: 14 additions & 0 deletions ThunderbirdTray.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,35 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3FE78D25-63E2-43D7-9D6F-B3E36AEF5D10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FE78D25-63E2-43D7-9D6F-B3E36AEF5D10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FE78D25-63E2-43D7-9D6F-B3E36AEF5D10}.Debug|x64.ActiveCfg = Debug|x64
{3FE78D25-63E2-43D7-9D6F-B3E36AEF5D10}.Debug|x64.Build.0 = Debug|x64
{3FE78D25-63E2-43D7-9D6F-B3E36AEF5D10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FE78D25-63E2-43D7-9D6F-B3E36AEF5D10}.Release|Any CPU.Build.0 = Release|Any CPU
{3FE78D25-63E2-43D7-9D6F-B3E36AEF5D10}.Release|x64.ActiveCfg = Release|x64
{3FE78D25-63E2-43D7-9D6F-B3E36AEF5D10}.Release|x64.Build.0 = Release|x64
{522F1071-295D-4D66-94FE-C29BC1CBF551}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{522F1071-295D-4D66-94FE-C29BC1CBF551}.Debug|Any CPU.Build.0 = Debug|Any CPU
{522F1071-295D-4D66-94FE-C29BC1CBF551}.Debug|x64.ActiveCfg = Debug|x64
{522F1071-295D-4D66-94FE-C29BC1CBF551}.Debug|x64.Build.0 = Debug|x64
{522F1071-295D-4D66-94FE-C29BC1CBF551}.Release|Any CPU.ActiveCfg = Release|Any CPU
{522F1071-295D-4D66-94FE-C29BC1CBF551}.Release|Any CPU.Build.0 = Release|Any CPU
{522F1071-295D-4D66-94FE-C29BC1CBF551}.Release|x64.ActiveCfg = Release|x64
{522F1071-295D-4D66-94FE-C29BC1CBF551}.Release|x64.Build.0 = Release|x64
{E17F3300-6E84-4A9E-93BA-CA6653D0CECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E17F3300-6E84-4A9E-93BA-CA6653D0CECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E17F3300-6E84-4A9E-93BA-CA6653D0CECA}.Debug|x64.ActiveCfg = Debug|x64
{E17F3300-6E84-4A9E-93BA-CA6653D0CECA}.Debug|x64.Build.0 = Debug|x64
{E17F3300-6E84-4A9E-93BA-CA6653D0CECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E17F3300-6E84-4A9E-93BA-CA6653D0CECA}.Release|Any CPU.Build.0 = Release|Any CPU
{E17F3300-6E84-4A9E-93BA-CA6653D0CECA}.Release|x64.ActiveCfg = Release|x64
{E17F3300-6E84-4A9E-93BA-CA6653D0CECA}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 4 additions & 4 deletions lib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("ThunderbirdTray.Lib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("PixelCollider")]
[assembly: AssemblyProduct("ThunderbirdTray")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyCopyright("Open Source - MIT")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// 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.*")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
38 changes: 38 additions & 0 deletions lib/Properties/Settings.Designer.cs

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

9 changes: 9 additions & 0 deletions lib/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ThunderbirdTray.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="MinimiseOnStart" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
44 changes: 44 additions & 0 deletions lib/ThunderbirdTray.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -32,6 +33,26 @@
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.2.9.0\lib\net46\Serilog.dll</HintPath>
Expand All @@ -42,22 +63,45 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationClient" />
<Reference Include="UIAutomationTypes" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="TrayBird.cs" />
<Compile Include="Views\UserOptions.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Views\UserOptions.Designer.cs">
<DependentUpon>UserOptions.cs</DependentUpon>
</Compile>
<Compile Include="Win32.cs" />
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\UserOptions.resx">
<DependentUpon>UserOptions.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
35 changes: 16 additions & 19 deletions lib/TrayBird.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Serilog.Core;
using ThunderbirdTray.Win32;
using System.Text;
using ThunderbirdTray.Views;

namespace ThunderbirdTray
{
Expand All @@ -25,6 +26,7 @@ public partial class TrayBird : ApplicationContext

private NotifyIcon notifyIcon;
private ContextMenuStrip contextMenu;
private Form optionsForm;

private Task initTask;
private Process thunderbirdProcess;
Expand Down Expand Up @@ -83,11 +85,10 @@ public TrayBird(bool debugLog=true)
ToolStripMenuItem showMenuItem = new ToolStripMenuItem("Show / Hide Thunderbird", null, new EventHandler(ToggleShowThunderbird));
showMenuItem.Font = new Font(showMenuItem.Font, showMenuItem.Font.Style | FontStyle.Bold);
showMenuItem.Enabled = false;
//ToolStripMenuItem configMenuItem = new ToolStripMenuItem("Configuration", null, new EventHandler(ShowConfig));
//configMenuItem.Enabled = false;
ToolStripMenuItem configMenuItem = new ToolStripMenuItem("Options", null, new EventHandler(ShowConfig));
ToolStripMenuItem exitMenuItem = new ToolStripMenuItem("Exit", null, new EventHandler(Exit));
contextMenu = new ContextMenuStrip();
contextMenu.Items.AddRange(new ToolStripMenuItem[] { showMenuItem, /*configMenuItem,*/ exitMenuItem });
contextMenu.Items.AddRange(new ToolStripMenuItem[] { showMenuItem, configMenuItem, exitMenuItem });
notifyIcon = new NotifyIcon();
notifyIcon.Text = "ThunderbirdTray - Starting up...";
notifyIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
Expand Down Expand Up @@ -195,7 +196,7 @@ public void StartThunderbird()
{
FileName = filename,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Minimized,
WindowStyle = Properties.Settings.Default.MinimiseOnStart ? ProcessWindowStyle.Minimized : ProcessWindowStyle.Normal,
UseShellExecute = true
}
}
Expand Down Expand Up @@ -230,14 +231,14 @@ private void HideThunderbird()

private void ShowConfig(object sender, EventArgs e)
{
//if (configWindow.Visible)
//{
// configWindow.Activate();
//}
//else
//{
// configWindow.ShowDialog();
//}
optionsForm = new UserOptions();
optionsForm.FormClosed += OptionsForm_FormClosed;
optionsForm.Show();
}

private void OptionsForm_FormClosed(object sender, FormClosedEventArgs e)
{
optionsForm = null;
}

private bool HookThunderbird()
Expand Down Expand Up @@ -286,22 +287,18 @@ private bool HookThunderbird()
// If not already hidden and is currently minimised, hide immediately
var isIconic = User32.IsIconic(thunderbirdMainWindowHandle);

if (trayLaunched)
if (trayLaunched && Properties.Settings.Default.MinimiseOnStart)
{
log.Information("Thunderbird launched with tray application, hiding now. {@thunderbirdShown}.", thunderbirdShown);
lastVisualState = (WindowVisualState)thunderbirdAutomationElement.GetCurrentPropertyValue(WindowPattern.WindowVisualStateProperty);
HideThunderbird();

}
if ((thunderbirdShown && isIconic) || trayLaunched)
if (thunderbirdShown && isIconic)
{
log.Information("Thunderbird is already minimised, hiding now. {@thunderbirdShown}, {@isIconic}.", thunderbirdShown, isIconic);
HideThunderbird();
}
else
{
lastVisualState = (WindowVisualState)thunderbirdAutomationElement.GetCurrentPropertyValue(WindowPattern.WindowVisualStateProperty);
}
lastVisualState = (WindowVisualState)thunderbirdAutomationElement.GetCurrentPropertyValue(WindowPattern.WindowVisualStateProperty);
log.Debug("Setting visual state as {@lastVisualState}.", lastVisualState);

return true;
Expand Down
118 changes: 118 additions & 0 deletions lib/Views/UserOptions.Designer.cs

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

0 comments on commit 1d4fe13

Please sign in to comment.