-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/powershell_path
- Loading branch information
Showing
12 changed files
with
346 additions
and
42 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 |
---|---|---|
@@ -1,19 +1,32 @@ | ||
**Please provide some details about this pull request:** | ||
- | ||
## Changes proposed in this pull request | ||
|
||
- | ||
- | ||
|
||
Fixes #{issue number} | ||
## Related issue(s) | ||
|
||
- Fixes #{issue number} | ||
|
||
## Copilot generated summary | ||
|
||
Provide a Copilot generated summary of the changes in this pull request. | ||
|
||
<details> | ||
<summary>Copilot summary</summary> | ||
|
||
{generated summary} | ||
|
||
</details> | ||
|
||
**ToDo:** | ||
## To-Do | ||
|
||
- [ ] Update [documentation](https://github.com/BornToBeRoot/NETworkManager/tree/main/Website/docs) to reflect this changes | ||
- [ ] Update [changelog](https://github.com/BornToBeRoot/NETworkManager/tree/main/Website/docs/changelog) to reflect this changes | ||
|
||
--- | ||
## Contributing | ||
|
||
**By submitting this pull request, I confirm the following:** | ||
|
||
- [ ] I have read and understood the [contributing guidelines](https://github.com/BornToBeRoot/NETworkManager/blob/main/CONTRIBUTING.md) and the [code of conduct](https://github.com/BornToBeRoot/NETworkManager/blob/main/CODE_OF_CONDUCT.md). | ||
- [ ] I have have added my name, username or email to the [contributors](https://github.com/BornToBeRoot/NETworkManager/blob/main/CONTRIBUTORS.md) list or don't want to. | ||
- [ ] The code or resource is compatible with the [GNU General Public License v3.0](https://github.com/BornToBeRoot/NETworkManager/blob/main/LICENSE). | ||
- [ ] The code or resource is compatible with the [GNU General Public License v3.0](https://github.com/BornToBeRoot/NETworkManager/blob/main/LICENSE). |
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,139 @@ | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace NETworkManager; | ||
|
||
/// <summary> | ||
/// A control featuring a range of loading indicating animations. | ||
/// Source: https://github.com/zeluisping/LoadingIndicators.WPF | ||
/// </summary> | ||
[TemplatePart(Name = "Border", Type = typeof(Border))] | ||
public class LoadingIndicator : Control | ||
{ | ||
/// <summary> | ||
/// Identifies the <see cref="NETworkManager.LoadingIndicator.SpeedRatio"/> dependency property. | ||
/// </summary> | ||
public static readonly DependencyProperty SpeedRatioProperty = | ||
DependencyProperty.Register(nameof(SpeedRatio), typeof(double), typeof(LoadingIndicator), new PropertyMetadata(1d, (o, e) => | ||
{ | ||
LoadingIndicator li = (LoadingIndicator)o; | ||
|
||
if (li.PART_Border == null || li.IsActive == false) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(li.PART_Border)) | ||
{ | ||
if (group.Name == "ActiveStates") | ||
{ | ||
foreach (VisualState state in group.States) | ||
{ | ||
if (state.Name == "Active") | ||
{ | ||
state.Storyboard.SetSpeedRatio(li.PART_Border, (double)e.NewValue); | ||
} | ||
} | ||
} | ||
} | ||
})); | ||
|
||
/// <summary> | ||
/// Identifies the <see cref="NETworkManager.LoadingIndicator.IsActive"/> dependency property. | ||
/// </summary> | ||
public static readonly DependencyProperty IsActiveProperty = | ||
DependencyProperty.Register(nameof(IsActive), typeof(bool), typeof(LoadingIndicator), new PropertyMetadata(true, (o, e) => | ||
{ | ||
LoadingIndicator li = (LoadingIndicator)o; | ||
|
||
if (li.PART_Border == null) | ||
{ | ||
return; | ||
} | ||
|
||
if ((bool)e.NewValue == false) | ||
{ | ||
VisualStateManager.GoToElementState(li.PART_Border, "Inactive", false); | ||
li.PART_Border.Visibility = Visibility.Collapsed; | ||
} | ||
else | ||
{ | ||
VisualStateManager.GoToElementState(li.PART_Border, "Active", false); | ||
li.PART_Border.Visibility = Visibility.Visible; | ||
|
||
foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(li.PART_Border)) | ||
{ | ||
if (group.Name == "ActiveStates") | ||
{ | ||
foreach (VisualState state in group.States) | ||
{ | ||
if (state.Name == "Active") | ||
{ | ||
state.Storyboard.SetSpeedRatio(li.PART_Border, li.SpeedRatio); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
})); | ||
|
||
// Variables | ||
protected Border PART_Border; | ||
|
||
/// <summary> | ||
/// Get/set the speed ratio of the animation. | ||
/// </summary> | ||
public double SpeedRatio | ||
{ | ||
get { return (double)GetValue(SpeedRatioProperty); } | ||
set { SetValue(SpeedRatioProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// Get/set whether the loading indicator is active. | ||
/// </summary> | ||
public bool IsActive | ||
{ | ||
get { return (bool)GetValue(IsActiveProperty); } | ||
set { SetValue(IsActiveProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// When overridden in a derived class, is invoked whenever application code | ||
/// or internal processes call System.Windows.FrameworkElement.ApplyTemplate(). | ||
/// </summary> | ||
public override void OnApplyTemplate() | ||
{ | ||
base.OnApplyTemplate(); | ||
|
||
PART_Border = (Border)GetTemplateChild("PART_Border"); | ||
|
||
if (PART_Border != null) | ||
{ | ||
VisualStateManager.GoToElementState(PART_Border, (this.IsActive ? "Active" : "Inactive"), false); | ||
foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(PART_Border)) | ||
{ | ||
if (group.Name == "ActiveStates") | ||
{ | ||
foreach (VisualState state in group.States) | ||
{ | ||
if (state.Name == "Active") | ||
{ | ||
state.Storyboard.SetSpeedRatio(PART_Border, this.SpeedRatio); | ||
} | ||
} | ||
} | ||
} | ||
|
||
PART_Border.Visibility = (IsActive ? Visibility.Visible : Visibility.Collapsed); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NETworkManager.LoadingIndicator"/> class. | ||
/// </summary> | ||
public LoadingIndicator() | ||
{ | ||
|
||
} | ||
} |
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
110 changes: 110 additions & 0 deletions
110
Source/NETworkManager/Resources/Styles/LoadingIndicatorArcsStyle.xaml
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,110 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:networkManager="clr-namespace:NETworkManager"> | ||
<!-- | ||
Source: https://github.com/BornToBeRoot/NETworkManager/issues/2949 | ||
--> | ||
<Style x:Key="LoadingIndicatorArcsStyleKey" TargetType="{x:Type networkManager:LoadingIndicator}"> | ||
<Setter Property="Foreground" Value="{DynamicResource ResourceKey=MahApps.Brushes.Accent}"/> | ||
<Setter Property="VerticalAlignment" Value="Center"/> | ||
<Setter Property="HorizontalAlignment" Value="Center"/> | ||
<Setter Property="Width" Value="40"/> | ||
<Setter Property="Height" Value="40"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type networkManager:LoadingIndicator}"> | ||
<Border x:Name="PART_Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="SizeStates"> | ||
<VisualState x:Name="Large" /> | ||
<VisualState x:Name="Small" /> | ||
</VisualStateGroup> | ||
<VisualStateGroup x:Name="ActiveStates"> | ||
<VisualState x:Name="Inactive"/> | ||
<VisualState x:Name="Active"> | ||
<Storyboard SpeedRatio="{TemplateBinding SpeedRatio}"> | ||
<DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetName="PART_Canvas0" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"> | ||
<LinearDoubleKeyFrame KeyTime="0:0:0.000" Value="0"/> | ||
<LinearDoubleKeyFrame KeyTime="0:0:3.000" Value="360"/> | ||
</DoubleAnimationUsingKeyFrames> | ||
<DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetName="PART_Canvas1" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"> | ||
<LinearDoubleKeyFrame KeyTime="0:0:0.000" Value="0"/> | ||
<LinearDoubleKeyFrame KeyTime="0:0:2.000" Value="-360"/> | ||
</DoubleAnimationUsingKeyFrames> | ||
</Storyboard> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
|
||
<Border.Resources> | ||
<Style TargetType="{x:Type Canvas}"> | ||
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/> | ||
<Setter Property="RenderTransform"> | ||
<Setter.Value> | ||
<RotateTransform/> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</Border.Resources> | ||
|
||
<Grid Background="Transparent"> | ||
<Grid.RenderTransform> | ||
<TransformGroup> | ||
<ScaleTransform ScaleX="0.5" ScaleY="0.5"/> | ||
<TranslateTransform X="10" Y="10"/> | ||
</TransformGroup> | ||
</Grid.RenderTransform> | ||
<Canvas x:Name="PART_Canvas0" Opacity="1.0"> | ||
<Path Stroke="{TemplateBinding Foreground}" StrokeThickness="10"> | ||
<Path.Data> | ||
<PathGeometry> | ||
<PathGeometry.Transform> | ||
<TranslateTransform X="20" Y="-20"/> | ||
</PathGeometry.Transform> | ||
<PathGeometry.Figures> | ||
<PathFigureCollection> | ||
<PathFigure StartPoint="0,0"> | ||
<PathFigure.Segments> | ||
<PathSegmentCollection> | ||
<ArcSegment Size="40,40" IsLargeArc="True" SweepDirection="CounterClockwise" Point="40,40" /> | ||
</PathSegmentCollection> | ||
</PathFigure.Segments> | ||
</PathFigure> | ||
</PathFigureCollection> | ||
</PathGeometry.Figures> | ||
</PathGeometry> | ||
</Path.Data> | ||
</Path> | ||
</Canvas> | ||
|
||
<Canvas x:Name="PART_Canvas1" Opacity="0.3"> | ||
<Path Stroke="{TemplateBinding Foreground}" StrokeThickness="10"> | ||
<Path.Data> | ||
<PathGeometry> | ||
<PathGeometry.Transform> | ||
<TranslateTransform X="-7" Y="7"/> | ||
</PathGeometry.Transform> | ||
<PathGeometry.Figures> | ||
<PathFigureCollection> | ||
<PathFigure StartPoint="0,0"> | ||
<PathFigure.Segments> | ||
<PathSegmentCollection> | ||
<ArcSegment Size="30,30" IsLargeArc="True" SweepDirection="Clockwise" Point="40,40" /> | ||
</PathSegmentCollection> | ||
</PathFigure.Segments> | ||
</PathFigure> | ||
</PathFigureCollection> | ||
</PathGeometry.Figures> | ||
</PathGeometry> | ||
</Path.Data> | ||
</Path> | ||
</Canvas> | ||
</Grid> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<Style x:Key="LoadingIndicatorArcsStyle" TargetType="{x:Type networkManager:LoadingIndicator}" BasedOn="{StaticResource LoadingIndicatorArcsStyleKey}"/> | ||
</ResourceDictionary> |
Oops, something went wrong.