-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Drommedhar
committed
Oct 6, 2024
1 parent
4d96c32
commit 4658308
Showing
94 changed files
with
3,006 additions
and
1,731 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,31 @@ | ||
<UserControl x:Class="DLSSUpdater.Controls.ChangelogPanel" | ||
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:DLSSUpdater.Controls" | ||
xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI" | ||
xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI" | ||
xmlns:adonisExtensions="clr-namespace:AdonisUI.Extensions;assembly=AdonisUI" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800" x:Name="ctrlChangelog" Loaded="ctrlChangelog_Loaded" SizeChanged="ctrlChangelog_SizeChanged"> | ||
<Grid> | ||
<GroupBox Margin="5,0,0,-16" Background="#FF1d263c" | ||
adonisExtensions:GroupBoxExtension.HeaderBackground="#FF0e141b"> | ||
<GroupBox.Header> | ||
<Grid> | ||
<Label Content="{Binding HeaderText, ElementName=ctrlChangelog}" FontWeight="Bold" FontSize="16" /> | ||
<Button | ||
BorderBrush="{x:Null}" | ||
adonisExtensions:CursorSpotlightExtension.BackgroundBrush="#0AFFFFFF" | ||
adonisExtensions:CursorSpotlightExtension.BorderBrush="#0FFFFFFF" | ||
adonisExtensions:CursorSpotlightExtension.RelativeSpotlightSize="10000.0" | ||
adonisExtensions:RippleExtension.BackgroundBrush="#0AFFFFFF" | ||
adonisExtensions:RippleExtension.BorderBrush="#14FFFFFF" | ||
Background="Transparent" Margin="-10,-10,-10,-8" Click="Button_Click" /> | ||
</Grid> | ||
</GroupBox.Header> | ||
<StackPanel Name="TextBlockContainer" Orientation="Vertical" Margin="10,-6,10,10" Visibility="{Binding Expanded, ElementName=ctrlChangelog}" IsHitTestVisible="False"/> | ||
</GroupBox> | ||
</Grid> | ||
</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,157 @@ | ||
using System; | ||
using System.Windows.Controls; | ||
using System.Windows.Documents; | ||
using System.Windows.Media; | ||
using static DlssUpdater.Defines.DlssTypes; | ||
|
||
namespace DLSSUpdater.Controls | ||
{ | ||
/// <summary> | ||
/// Interaction logic for ChangelogPanel.xaml | ||
/// </summary> | ||
public partial class ChangelogPanel : UserControl | ||
{ | ||
public static readonly DependencyProperty HeaderTextProperty = | ||
DependencyProperty.Register("HeaderText", typeof(string), typeof(ChangelogPanel)); | ||
|
||
public string HeaderText | ||
{ | ||
get => (string)GetValue(HeaderTextProperty); | ||
set => SetValue(HeaderTextProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty ContentTextProperty = | ||
DependencyProperty.Register("ContentText", typeof(string), typeof(ChangelogPanel)); | ||
|
||
public string ContentText | ||
{ | ||
get => (string)GetValue(ContentTextProperty); | ||
set => SetValue(ContentTextProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty ExpandedProperty = | ||
DependencyProperty.Register("Expanded", typeof(Visibility), typeof(ChangelogPanel)); | ||
|
||
private int indentSize = 30; // Indentation size for wrapped lines | ||
|
||
public Visibility Expanded | ||
{ | ||
get => (Visibility)GetValue(ExpandedProperty); | ||
set => SetValue(ExpandedProperty, value); | ||
} | ||
|
||
public ChangelogPanel() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
// Function to split text and create individual TextBlocks for each line | ||
private void UpdateTextBlocks() | ||
{ | ||
// Clear existing TextBlocks | ||
TextBlockContainer.Children.Clear(); | ||
|
||
// Replace tab with 4 spaces for consistency | ||
string text = ContentText.Replace("\t", new string(' ', 4)); | ||
|
||
// Create a FormattedText to help measure the width of the text | ||
double availableWidth = TextBlockContainer.ActualWidth; | ||
|
||
if (availableWidth <= 0) return; // No point in proceeding if the width isn't ready | ||
|
||
string[] words = text.Split(' '); | ||
string currentLine = ""; | ||
bool isFirstLine = true; | ||
|
||
foreach (var word in words) | ||
{ | ||
// Add the next word to the line (with a space if not the first word) | ||
string testLine = (currentLine.Length == 0 ? currentLine : currentLine + " ") + word; | ||
|
||
// Measure the test line's width | ||
var formattedTestLine = CreateFormattedText(testLine); | ||
|
||
// Check if the current line exceeds the available width | ||
if (formattedTestLine.Width > availableWidth) | ||
{ | ||
// The current line is too long, so we finalize the current line and move to the next | ||
AddTextBlockToContainer(currentLine, isFirstLine); | ||
|
||
// Get indent from last line | ||
var lines = currentLine.Split("\n", StringSplitOptions.RemoveEmptyEntries); | ||
var spaces = lines[^1].TakeWhile(Char.IsWhiteSpace).Count(); | ||
// Now check if the line starts with a '-", so we add 2 more spaces | ||
if (lines[^1].Trim().StartsWith("-")) | ||
{ | ||
spaces += 3; | ||
} | ||
|
||
// Start a new line with indentation for wrapped lines | ||
currentLine = new string(' ', spaces) + word; | ||
isFirstLine = false; | ||
} | ||
else | ||
{ | ||
// If the line fits, continue adding to the current line | ||
currentLine = testLine; | ||
} | ||
} | ||
|
||
// Add the final line (if any) | ||
if (!string.IsNullOrEmpty(currentLine)) | ||
{ | ||
AddTextBlockToContainer(currentLine, isFirstLine); | ||
} | ||
} | ||
|
||
// Create and measure a FormattedText for line width calculation | ||
private FormattedText CreateFormattedText(string text) | ||
{ | ||
return new FormattedText( | ||
text, | ||
System.Globalization.CultureInfo.CurrentCulture, | ||
FlowDirection.LeftToRight, | ||
new Typeface("Segoe UI"), // Use the font you prefer | ||
16, // Font size | ||
Brushes.White, | ||
VisualTreeHelper.GetDpi(this).PixelsPerDip); | ||
} | ||
|
||
// Add a new TextBlock to the StackPanel container for each line | ||
private void AddTextBlockToContainer(string text, bool isFirstLine) | ||
{ | ||
TextBlock textBlock = new TextBlock | ||
{ | ||
Text = text, | ||
FontSize = 16, | ||
FontFamily = new FontFamily("Segoe UI"), | ||
TextWrapping = TextWrapping.NoWrap, // We handle wrapping manually | ||
Margin = new Thickness(0, 0, 0, 0) // Indent wrapped lines | ||
}; | ||
|
||
TextBlockContainer.Children.Add(textBlock); | ||
} | ||
|
||
private void ctrlChangelog_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
UpdateTextBlocks(); | ||
} | ||
|
||
private void ctrlChangelog_SizeChanged(object sender, SizeChangedEventArgs e) | ||
{ | ||
UpdateTextBlocks(); | ||
} | ||
|
||
private void Button_Click(object sender, RoutedEventArgs e) | ||
{ | ||
if (Expanded == Visibility.Visible) | ||
{ | ||
Expanded = Visibility.Collapsed; | ||
} | ||
else | ||
{ | ||
Expanded = Visibility.Visible; | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,22 +1,27 @@ | ||
<UserControl x:Class="DlssUpdater.Controls.DownloadButton" | ||
<UserControl x:Class="DLSSUpdater.Controls.DownloadButton" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI" | ||
xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI" | ||
xmlns:adonisExtensions="clr-namespace:AdonisUI.Extensions;assembly=AdonisUI" | ||
x:Name="downloadButton" | ||
Loaded="downloadButton_Loaded"> | ||
<Grid | ||
Width="{Binding ActualWidth, | ||
RelativeSource = {RelativeSource AncestorType = {x:Type UserControl}}}" | ||
Height="{Binding ActualHeight, | ||
RelativeSource ={RelativeSource AncestorType = {x:Type UserControl}}}" | ||
Background="{DynamicResource ApplicationBackgroundBrush}"> | ||
<ProgressBar x:Name="prgDownload" Grid.Row="2" VerticalAlignment="Bottom" | ||
Height="{Binding ActualHeight, ElementName=downloadButton}" Foreground="Black" /> | ||
<ui:TextBlock Grid.Column="0" Grid.Row="1" Text="{Binding VersionText, ElementName=downloadButton}" | ||
Foreground="{DynamicResource TextFillColorPrimaryBrush}" VerticalAlignment="Center" | ||
<Grid> | ||
<Button x:Name="btnAction" Grid.Column="1" Grid.Row="1" Click="Button_Click" | ||
Foreground="White" | ||
BorderBrush="{x:Null}" | ||
adonisExtensions:CursorSpotlightExtension.BackgroundBrush="#0AFFFFFF" | ||
adonisExtensions:CursorSpotlightExtension.BorderBrush="#0FFFFFFF" | ||
adonisExtensions:CursorSpotlightExtension.RelativeSpotlightSize="0.5" | ||
adonisExtensions:RippleExtension.BackgroundBrush="#0AFFFFFF" | ||
adonisExtensions:RippleExtension.BorderBrush="#14FFFFFF" | ||
Background="#02646464"/> | ||
<TextBlock Grid.Column="0" Grid.Row="1" Text="{Binding VersionText, ElementName=downloadButton}" | ||
Foreground="White" VerticalAlignment="Center" | ||
HorizontalAlignment="Left" Margin="5,0,0,0" /> | ||
<ui:Button x:Name="btnAction" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Right" | ||
VerticalAlignment="Center" Icon="{Binding ButtonIcon, ElementName=downloadButton}" Height="50" | ||
Width="50" Margin="0,0,25,0" Click="Button_Click" /> | ||
<Label x:Name="lblAction" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0"/> | ||
<ContentControl x:Name="downloadIcon" ContentTemplate="{DynamicResource {x:Static adonisUi:Templates.LoadingBars}}" | ||
Foreground="#14FFFFFF" | ||
Focusable="False" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/> | ||
</Grid> | ||
</UserControl> |
Oops, something went wrong.