Skip to content

Commit

Permalink
Merge branch 'main' into feature/powershell_path
Browse files Browse the repository at this point in the history
  • Loading branch information
BornToBeRoot committed Dec 22, 2024
2 parents 3d2833e + 32f1f59 commit 7f3a6dd
Show file tree
Hide file tree
Showing 12 changed files with 346 additions and 42 deletions.
25 changes: 19 additions & 6 deletions .github/pull_request_template.md
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).
15 changes: 2 additions & 13 deletions Source/NETworkManager/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,8 @@
Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatSlider.xaml" />

<!-- Dragablz -->
<ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/MahApps.xaml" />
<!-- LoadingIndicators.WPF -->
<ResourceDictionary Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles.xaml" />
<ResourceDictionary
Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles/LoadingWave.xaml" />
<ResourceDictionary
Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles/LoadingThreeDots.xaml" />
<ResourceDictionary
Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles/LoadingFlipPlane.xaml" />
<ResourceDictionary
Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles/LoadingPulse.xaml" />
<ResourceDictionary
Source="pack://application:,,,/LoadingIndicators.WPF;component/Styles/LoadingDoubleBounce.xaml" />
<!-- Context menu (import berfore styles)-->
<ResourceDictionary Source="/Resources/ContextMenu/ContextMenu.xaml" />
<!-- Control templates (import before styles) -->
Expand All @@ -44,6 +31,8 @@
<ResourceDictionary Source="/Resources/Styles/DropDownButtonStyles.xaml" />
<ResourceDictionary Source="/Resources/Styles/GridSplitterStyles.xaml" />
<ResourceDictionary Source="/Resources/Styles/GroupBoxStyles.xaml" />
<ResourceDictionary Source="/Resources/Styles/LoadingIndicatorArcsStyle.xaml" />
<ResourceDictionary Source="/Resources/Styles/LoadingIndicatorPulseStyle.xaml" />
<ResourceDictionary Source="/Resources/Styles/MenuItemStyles.xaml" />
<ResourceDictionary Source="/Resources/Styles/MetroDialogStyles.xaml" />
<ResourceDictionary Source="/Resources/Styles/NumericUpDownStyles.xaml" />
Expand Down
139 changes: 139 additions & 0 deletions Source/NETworkManager/LoadingIndicators.cs
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()
{

}
}
1 change: 0 additions & 1 deletion Source/NETworkManager/NETworkManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<PackageReference Include="IPNetwork2" Version="3.0.667" />
<PackageReference Include="Lextm.SharpSnmpLib" Version="12.5.5" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="LoadingIndicators.WPF" Version="0.0.1" />
<PackageReference Include="log4net" Version="3.0.3" />
<PackageReference Include="MahApps.Metro" Version="2.4.10" />
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="5.1.0" />
Expand Down
110 changes: 110 additions & 0 deletions Source/NETworkManager/Resources/Styles/LoadingIndicatorArcsStyle.xaml
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>
Loading

0 comments on commit 7f3a6dd

Please sign in to comment.