Skip to content

Commit a4660a5

Browse files
committed
Add project files.
1 parent d24345e commit a4660a5

10 files changed

Lines changed: 517 additions & 0 deletions
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: RedLightForWindows CI
2+
3+
on:
4+
push:
5+
tags: [ "v*" ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
# --------------------------------------------------------
12+
# Release build for pushes & tags on main
13+
# --------------------------------------------------------
14+
build-release:
15+
if: github.event_name == 'push'
16+
runs-on: windows-latest
17+
permissions:
18+
contents: write # allow release-action to create GitHub Release
19+
20+
env:
21+
Solution_Name: RedLightForWindows.sln
22+
Configuration: Release
23+
24+
steps:
25+
- name: Checkout source
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Setup .NET SDK
31+
uses: actions/setup-dotnet@v4
32+
with:
33+
dotnet-version: 10.0.x
34+
cache: true
35+
cache-dependency-path: '**/*.csproj'
36+
37+
- name: Restore dependencies
38+
run: dotnet restore RedLightForWindows.csproj
39+
40+
- name: Build (Release)
41+
run: dotnet build RedLightForWindows.csproj --configuration ${{ env.Configuration }} --no-restore -p:Version=${{ github.run_number }}
42+
43+
- name: Publish self-contained
44+
run: dotnet publish RedLightForWindows.csproj --configuration ${{ env.Configuration }} --runtime win-x64 --self-contained false --output ./publish -p:Version=${{ github.run_number }}
45+
46+
- name: Compress artifact
47+
shell: pwsh
48+
run: Compress-Archive -Path ./publish/* -DestinationPath RedLightForWindows.zip
49+
50+
- name: Upload artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: RedLightForWindows
54+
path: RedLightForWindows.zip
55+
56+
- name: Create GitHub Release (tag push)
57+
if: startsWith(github.ref, 'refs/tags/')
58+
uses: ncipollo/release-action@v1
59+
with:
60+
artifacts: |
61+
RedLightForWindows.zip
62+
publish/RedLightForWindows.exe
63+
body: "Automated release from GitHub Actions"
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
# --------------------------------------------------------
67+
# Static code analysis with CodeQL
68+
# --------------------------------------------------------
69+
codeql:
70+
name: CodeQL
71+
runs-on: windows-latest
72+
permissions:
73+
security-events: write
74+
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Initialize CodeQL
79+
uses: github/codeql-action/init@v3
80+
with:
81+
languages: csharp
82+
83+
- name: Autobuild
84+
uses: github/codeql-action/autobuild@v3
85+
86+
- name: Perform CodeQL analysis
87+
uses: github/codeql-action/analyze@v3
88+
89+
# --------------------------------------------------------
90+
# Secret scanning with Gitleaks
91+
# --------------------------------------------------------
92+
secret-scan:
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Checkout source
96+
uses: actions/checkout@v4
97+
with:
98+
fetch-depth: 0
99+
100+
- name: Run Gitleaks
101+
uses: gitleaks/gitleaks-action@v2
102+
with:
103+
fail: true

‎App.xaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="RedLight.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:RedLight"
5+
ShutdownMode="OnExplicitShutdown">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

‎App.xaml.cs‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using System.Windows;
3+
using WinForms = System.Windows.Forms;
4+
using System.Drawing;
5+
6+
namespace RedLight;
7+
8+
/// <summary>
9+
/// Interaction logic for App.xaml
10+
/// </summary>
11+
public partial class App : System.Windows.Application
12+
{
13+
private WinForms.NotifyIcon? _notifyIcon;
14+
private MainWindow? _mainWindow;
15+
16+
protected override void OnStartup(StartupEventArgs e)
17+
{
18+
base.OnStartup(e);
19+
20+
try
21+
{
22+
NativeMethods.MagInitialize();
23+
}
24+
catch (Exception ex)
25+
{
26+
System.Windows.MessageBox.Show($"Failed to initialize Magnification API: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
27+
Shutdown();
28+
return;
29+
}
30+
31+
_mainWindow = new MainWindow();
32+
_mainWindow.Show();
33+
34+
_notifyIcon = new WinForms.NotifyIcon();
35+
_notifyIcon.Icon = new Icon("icon.ico");
36+
_notifyIcon.Text = "Red Light";
37+
_notifyIcon.Visible = true;
38+
39+
var contextMenu = new WinForms.ContextMenuStrip();
40+
contextMenu.Items.Add("Show", null, Show_Click);
41+
contextMenu.Items.Add("Exit", null, Exit_Click);
42+
_notifyIcon.ContextMenuStrip = contextMenu;
43+
_notifyIcon.DoubleClick += Show_Click;
44+
}
45+
46+
private void Show_Click(object? sender, EventArgs e)
47+
{
48+
if (_mainWindow == null)
49+
{
50+
_mainWindow = new MainWindow();
51+
}
52+
_mainWindow.Show();
53+
_mainWindow.WindowState = WindowState.Normal;
54+
_mainWindow.Activate();
55+
}
56+
57+
private void Exit_Click(object? sender, EventArgs e)
58+
{
59+
Shutdown();
60+
}
61+
62+
protected override void OnExit(ExitEventArgs e)
63+
{
64+
if (_notifyIcon != null)
65+
{
66+
_notifyIcon.Dispose();
67+
_notifyIcon = null;
68+
}
69+
70+
try
71+
{
72+
// Reset to identity matrix to remove any color effect
73+
var identity = new float[]
74+
{
75+
1, 0, 0, 0, 0,
76+
0, 1, 0, 0, 0,
77+
0, 0, 1, 0, 0,
78+
0, 0, 0, 1, 0,
79+
0, 0, 0, 0, 1
80+
};
81+
var effect = new NativeMethods.MagColorEffect(identity);
82+
NativeMethods.MagSetFullscreenColorEffect(ref effect);
83+
84+
NativeMethods.MagUninitialize();
85+
}
86+
catch (Exception)
87+
{
88+
// Suppress errors on exit
89+
}
90+
base.OnExit(e);
91+
}
92+
}
93+

‎AssemblyInfo.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly:ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]

‎MainWindow.xaml‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<Window x:Class="RedLight.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:RedLight"
7+
mc:Ignorable="d"
8+
Title="Red Light" Height="300" Width="400"
9+
Closing="Window_Closing">
10+
<Window.Resources>
11+
<Style x:Key="ColorPickerPanelStyle" TargetType="StackPanel">
12+
<Setter Property="Visibility" Value="Collapsed"/>
13+
<Style.Triggers>
14+
<DataTrigger Binding="{Binding ElementName=FilterTypeComboBox, Path=SelectedItem.Content}" Value="Color Tint">
15+
<Setter Property="Visibility" Value="Visible"/>
16+
</DataTrigger>
17+
</Style.Triggers>
18+
</Style>
19+
</Window.Resources>
20+
<Grid Margin="10">
21+
<StackPanel>
22+
<CheckBox x:Name="EnableFilterCheckBox" Content="Enable Fullscreen Filter" Margin="5" Checked="ApplyFilter" Unchecked="ApplyFilter"/>
23+
<TextBlock Text="Filter Type:" Margin="5,10,5,0"/>
24+
<ComboBox x:Name="FilterTypeComboBox" Margin="5" SelectionChanged="ApplyFilter">
25+
<ComboBoxItem Content="Red" IsSelected="True"/>
26+
<ComboBoxItem Content="Grayscale"/>
27+
<ComboBoxItem Content="Red/Green (Protanopia)"/>
28+
<ComboBoxItem Content="Green/Red (Deuteranopia)"/>
29+
<ComboBoxItem Content="Blue/Yellow (Tritanopia)"/>
30+
<ComboBoxItem Content="Color Tint"/>
31+
</ComboBox>
32+
<TextBlock Text="Intensity:" Margin="5,10,5,0"/>
33+
<Slider x:Name="IntensitySlider" Minimum="0" Maximum="1" Value="1" Margin="5" ValueChanged="IntensitySlider_ValueChanged"/>
34+
35+
<StackPanel Orientation="Horizontal" Margin="5" Style="{StaticResource ColorPickerPanelStyle}">
36+
<Button x:Name="ColorPickerButton" Content="Choose Tint Color" Click="ColorPickerButton_Click" />
37+
<Rectangle x:Name="ColorPreview" Width="100" Height="20" Fill="Red" Margin="10,0,0,0" Stroke="Black" StrokeThickness="1"/>
38+
</StackPanel>
39+
40+
</StackPanel>
41+
</Grid>
42+
</Window>

0 commit comments

Comments
 (0)