Skip to content

Commit

Permalink
Removing unnecesary dependencies, cleaning up code , removing those u…
Browse files Browse the repository at this point in the history
…gly underscores - grr I hate those, removing weird 3rd party installer, removing config dialog & tray icon, using "standard" config file format
  • Loading branch information
fr34kyn01535 committed Mar 18, 2020
1 parent 2ee39a2 commit 867994f
Show file tree
Hide file tree
Showing 18 changed files with 207 additions and 907 deletions.
11 changes: 0 additions & 11 deletions Background-Terminal.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Background-Terminal", "Background-Terminal\Background-Terminal.csproj", "{8EB72BE9-4392-421A-9845-00022CC1555B}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Background-Terminal-Setup", "Background-Terminal-Setup\Background-Terminal-Setup.wixproj", "{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -29,15 +27,6 @@ Global
{8EB72BE9-4392-421A-9845-00022CC1555B}.Release|x64.Build.0 = Release|x64
{8EB72BE9-4392-421A-9845-00022CC1555B}.Release|x86.ActiveCfg = Release|x86
{8EB72BE9-4392-421A-9845-00022CC1555B}.Release|x86.Build.0 = Release|x86
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Debug|Any CPU.ActiveCfg = Debug|x86
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Debug|x64.ActiveCfg = Debug|x86
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Debug|x86.ActiveCfg = Debug|x86
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Debug|x86.Build.0 = Debug|x86
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Release|Any CPU.ActiveCfg = Release|x86
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Release|x64.ActiveCfg = Release|x64
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Release|x64.Build.0 = Release|x64
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Release|x86.ActiveCfg = Release|x86
{CB5B11AE-E0F1-4A87-B85F-04EFD0AD2712}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
13 changes: 13 additions & 0 deletions Background-Terminal/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Key1" value="162"/>
<add key="Key2" value="66"/>
<add key="FontSize" value="12"/>
<add key="FontColor" value="#FFFFFFFF"/>
<add key="PosX" value="0"/>
<add key="PosY" value="0"/>
<add key="Width" value="500"/>
<add key="Height" value="500"/>
</appSettings>
</configuration>
10 changes: 1 addition & 9 deletions Background-Terminal/App.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
<Application x:Class="Background_Terminal.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Background_Terminal"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
<Application x:Class="Background_Terminal.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Background_Terminal"></Application>
60 changes: 57 additions & 3 deletions Background-Terminal/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,70 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using static Background_Terminal.TerminalWindow;

namespace Background_Terminal
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private TerminalWindow terminalWindow;
private Key key1, key2;
private ProcessHandler processHandler;


public App()
{
terminalWindow = new TerminalWindow();
processHandler = new ProcessHandler("cmd.exe");

terminalWindow.OnReadLine += (string line) =>
{
Console.WriteLine("> " + line);
processHandler.WriteLine(line);
};

processHandler.OnOutputDataReceived += (object sender, DataReceivedEventArgs e) =>
{
Console.WriteLine("< " + e.Data);
terminalWindow.WriteLine(e.Data);
};

key1 = KeyInterop.KeyFromVirtualKey(Int32.Parse(ConfigurationManager.AppSettings["Key1"]));
key2 = KeyInterop.KeyFromVirtualKey(Int32.Parse(ConfigurationManager.AppSettings["Key2"]));

Win32Interop.KeyTriggered = OnKeyTriggered;
Win32Interop.SetKeyhook();

Exit += OnExit;
processHandler.Run();
}

private void OnExit(object sender, EventArgs e)
{
Win32Interop.DestroyKeyhook();
terminalWindow.Close();
Environment.Exit(0);
}

private void OnKeyTriggered(int keyCode)
{
int vKey1 = KeyInterop.VirtualKeyFromKey((Key)key1);
int vKey2 = KeyInterop.VirtualKeyFromKey((Key)key2);

if (keyCode == vKey2 && Win32Interop.IsKeyDown(vKey1))
{
Win32Interop.ClickSimulateFocus(terminalWindow);
Win32Interop.SetForegroundWindow(terminalWindow.Handle);
Win32Interop.SetActiveWindow(terminalWindow.Handle);
terminalWindow.Focus();
terminalWindow.Activate();
}
}
}
}
10 changes: 0 additions & 10 deletions Background-Terminal/AssemblyInfo.cs

This file was deleted.

20 changes: 0 additions & 20 deletions Background-Terminal/Background-Terminal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@
<Platforms>AnyCPU;x86;x64</Platforms>
</PropertyGroup>

<ItemGroup>
<None Remove="Images\background-terminal-small.png" />
<None Remove="Images\background-terminal.ico" />
<None Remove="Images\exit.png" />
<None Remove="Images\minimize.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreMeter" Version="1.0.2" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf.NetCore" Version="1.0.10" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup>
<Resource Include="Images\background-terminal-small.png" />
<Resource Include="Images\background-terminal.ico" />
<Resource Include="Images\exit.png" />
<Resource Include="Images\minimize.png" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
Expand Down
19 changes: 0 additions & 19 deletions Background-Terminal/BackgroundTerminalSettings.cs

This file was deleted.

Binary file not shown.
Binary file removed Background-Terminal/Images/background-terminal.ico
Binary file not shown.
Binary file removed Background-Terminal/Images/exit.png
Binary file not shown.
Binary file removed Background-Terminal/Images/minimize.png
Binary file not shown.
Loading

0 comments on commit 867994f

Please sign in to comment.