-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
3,013 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="ParsecVDisplay.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:ParsecVDisplay" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
using System.Windows; | ||
using System.Linq; | ||
using System.Windows.Interop; | ||
using System.Windows.Media; | ||
|
||
namespace ParsecVDisplay | ||
{ | ||
public partial class App : Application | ||
{ | ||
const string ID = "QpHOX8IBUHBznGtqk9xm1"; | ||
public const string NAME = "ParsecVDisplay"; | ||
public const string VERSION = "0.45.0"; | ||
|
||
public static bool Silent { get; private set; } | ||
|
||
static App() | ||
{ | ||
var displays = Display.GetAllDisplays(); | ||
return; | ||
} | ||
|
||
protected override void OnStartup(StartupEventArgs e) | ||
{ | ||
if (e.Args.Length >= 2 && e.Args[0] == "-custom") | ||
{ | ||
var modes = Display.ParseModes(e.Args[1]); | ||
ParsecVDD.SetCustomDisplayModes(modes); | ||
|
||
Shutdown(); | ||
return; | ||
} | ||
|
||
Silent = e.Args.Contains("-silent"); | ||
|
||
var signal = new EventWaitHandle(false, | ||
EventResetMode.AutoReset, ID, out var isOwned); | ||
|
||
if (!isOwned) | ||
{ | ||
signal.Set(); | ||
Shutdown(); | ||
return; | ||
} | ||
|
||
var status = ParsecVDD.QueryStatus(); | ||
if (status != Device.Status.OK) | ||
{ | ||
if (status == Device.Status.RESTART_REQUIRED) | ||
{ | ||
MessageBox.Show("You must restart your PC to complete the driver setup.", | ||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning); | ||
} | ||
else if (status == Device.Status.DISABLED) | ||
{ | ||
MessageBox.Show($"{ParsecVDD.ADAPTER} is disabled, please enable it.", | ||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning); | ||
} | ||
else if (status == Device.Status.NOT_INSTALLED) | ||
{ | ||
MessageBox.Show("Please install the driver first.", | ||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning); | ||
} | ||
else | ||
{ | ||
MessageBox.Show($"The driver is not OK, please check again. Current status: {status}.", | ||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning); | ||
} | ||
|
||
Shutdown(); | ||
return; | ||
} | ||
|
||
if (ParsecVDD.Init() == false) | ||
{ | ||
MessageBox.Show("Failed to obtain the device handle, please check the driver installation again.", | ||
NAME, MessageBoxButton.OK, MessageBoxImage.Warning); | ||
|
||
Shutdown(); | ||
return; | ||
} | ||
|
||
Task.Run(() => | ||
{ | ||
while (signal.WaitOne()) | ||
{ | ||
Tray.ShowApp(); | ||
} | ||
}); | ||
|
||
base.OnStartup(e); | ||
|
||
// Disable GPU to prevent flickering when adding display | ||
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; | ||
} | ||
|
||
protected override void OnExit(ExitEventArgs e) | ||
{ | ||
ParsecVDD.Uninit(); | ||
base.OnExit(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<UserControl | ||
x:Class="ParsecVDisplay.Components.Button" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:ParsecVDisplay.Components" | ||
mc:Ignorable="d" | ||
d:DesignHeight="120" d:DesignWidth="216" | ||
d:Background="Black" | ||
> | ||
<Border BorderThickness="1" BorderBrush="#FFF"> | ||
<Button Foreground="White" Click="Button_Click"> | ||
<Button.Content> | ||
<ContentPresenter Content="{Binding Children}" /> | ||
</Button.Content> | ||
<Button.Style> | ||
<Style TargetType="{x:Type Button}"> | ||
<Setter Property="Background" Value="#1FFF"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Button}"> | ||
<Border Background="{TemplateBinding Background}"> | ||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Background" Value="#4FFF"/> | ||
</Trigger> | ||
<Trigger Property="IsPressed" Value="True"> | ||
<Setter Property="Background" Value="#8FFF"/> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</Button.Style> | ||
</Button> | ||
</Border> | ||
<UserControl.Style> | ||
<Style TargetType="{x:Type UserControl}"> | ||
<Style.Triggers> | ||
<Trigger Property="IsEnabled" Value="True"> | ||
<Setter Property="Opacity" Value="1"/> | ||
</Trigger> | ||
<Trigger Property="IsEnabled" Value="False"> | ||
<Setter Property="Opacity" Value="0.5"/> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</UserControl.Style> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace ParsecVDisplay.Components | ||
{ | ||
public partial class Button : UserControl | ||
{ | ||
public event EventHandler Click; | ||
public object Children { get; set; } | ||
|
||
public Button() | ||
{ | ||
InitializeComponent(); | ||
DataContext = this; | ||
} | ||
|
||
private void Button_Click(object sender, RoutedEventArgs e) | ||
{ | ||
Click?.Invoke(sender, e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<UserControl | ||
x:Class="ParsecVDisplay.Components.CloseButton" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:ParsecVDisplay.Components" | ||
mc:Ignorable="d" | ||
d:DesignHeight="40" d:DesignWidth="60" | ||
d:Background="Black" | ||
> | ||
<Button Foreground="White" Content="✕" FontSize="16" Click="Button_Click"> | ||
<Button.Style> | ||
<Style TargetType="{x:Type Button}"> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Button}"> | ||
<Border Background="{TemplateBinding Background}"> | ||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Background" Value="#4FFF"/> | ||
</Trigger> | ||
<Trigger Property="IsPressed" Value="True"> | ||
<Setter Property="Background" Value="#8FFF"/> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</Button.Style> | ||
</Button> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace ParsecVDisplay.Components | ||
{ | ||
public partial class CloseButton : UserControl | ||
{ | ||
public CloseButton() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void Button_Click(object sender, RoutedEventArgs e) | ||
{ | ||
var window = Window.GetWindow(this); | ||
window?.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<Page | ||
x:Class="ParsecVDisplay.Components.CustomPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:ParsecVDisplay.Components" | ||
mc:Ignorable="d" | ||
|
||
Loaded="Page_Loaded" | ||
Unloaded="Page_Unloaded" | ||
|
||
d:DesignHeight="450" d:DesignWidth="800" | ||
d:Background="#222" | ||
> | ||
<Grid> | ||
<Label Content="Custom Display Modes" Foreground="White" Margin="5,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" /> | ||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> | ||
<StackPanel.Resources> | ||
<Style TargetType="{x:Type StackPanel}"> | ||
<Setter Property="Margin" Value="0,5,0,0"/> | ||
</Style> | ||
<Style TargetType="{x:Type Label}"> | ||
<Setter Property="Foreground" Value="#DDD"/> | ||
</Style> | ||
<Style TargetType="{x:Type TextBox}"> | ||
<Setter Property="HorizontalContentAlignment" Value="Center"/> | ||
<Setter Property="VerticalContentAlignment" Value="Center"/> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="Foreground" Value="White"/> | ||
<Setter Property="CaretBrush" Value="White"/> | ||
</Style> | ||
</StackPanel.Resources> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="50">Slot 1</Label> | ||
<TextBox Width="80" /> | ||
<Label>×</Label> | ||
<TextBox Width="80" /> | ||
<Label>@</Label> | ||
<TextBox Width="60" /> | ||
<Label>Hz</Label> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="50">Slot 2</Label> | ||
<TextBox Width="80" /> | ||
<Label>×</Label> | ||
<TextBox Width="80" /> | ||
<Label>@</Label> | ||
<TextBox Width="60" /> | ||
<Label>Hz</Label> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="50">Slot 3</Label> | ||
<TextBox Width="80" /> | ||
<Label>×</Label> | ||
<TextBox Width="80" /> | ||
<Label>@</Label> | ||
<TextBox Width="60" /> | ||
<Label>Hz</Label> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="50">Slot 4</Label> | ||
<TextBox Width="80" /> | ||
<Label>×</Label> | ||
<TextBox Width="80" /> | ||
<Label>@</Label> | ||
<TextBox Width="60" /> | ||
<Label>Hz</Label> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="50">Slot 5</Label> | ||
<TextBox Width="80" /> | ||
<Label>×</Label> | ||
<TextBox Width="80" /> | ||
<Label>@</Label> | ||
<TextBox Width="60" /> | ||
<Label>Hz</Label> | ||
</StackPanel> | ||
</StackPanel> | ||
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal" Margin="0,0,25,25"> | ||
<local:Button Click="ApplyChanges" Width="120" Height="36" Foreground="White"> | ||
<local:Button.Children> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition /> | ||
</Grid.ColumnDefinitions> | ||
<Image Source="../Resources/admin.png" Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center" /> | ||
<TextBlock Grid.Column="1" Text="APPLY" Margin="6,0,0,0" /> | ||
</Grid> | ||
</local:Button.Children> | ||
</local:Button> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
Oops, something went wrong.