diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e844774248..c0570eda3a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -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. + +
+Copilot summary + +{generated summary} + +
-**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). \ No newline at end of file +- [ ] The code or resource is compatible with the [GNU General Public License v3.0](https://github.com/BornToBeRoot/NETworkManager/blob/main/LICENSE). diff --git a/Source/NETworkManager/App.xaml b/Source/NETworkManager/App.xaml index 6c7b9ed511..ea78b717b3 100644 --- a/Source/NETworkManager/App.xaml +++ b/Source/NETworkManager/App.xaml @@ -17,21 +17,8 @@ Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml" /> - - - - - - - - @@ -44,6 +31,8 @@ + + diff --git a/Source/NETworkManager/LoadingIndicators.cs b/Source/NETworkManager/LoadingIndicators.cs new file mode 100644 index 0000000000..1953c304fe --- /dev/null +++ b/Source/NETworkManager/LoadingIndicators.cs @@ -0,0 +1,139 @@ +using System.Windows; +using System.Windows.Controls; + +namespace NETworkManager; + +/// +/// A control featuring a range of loading indicating animations. +/// Source: https://github.com/zeluisping/LoadingIndicators.WPF +/// +[TemplatePart(Name = "Border", Type = typeof(Border))] +public class LoadingIndicator : Control +{ + /// + /// Identifies the dependency property. + /// + 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); + } + } + } + } + })); + + /// + /// Identifies the dependency property. + /// + 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; + + /// + /// Get/set the speed ratio of the animation. + /// + public double SpeedRatio + { + get { return (double)GetValue(SpeedRatioProperty); } + set { SetValue(SpeedRatioProperty, value); } + } + + /// + /// Get/set whether the loading indicator is active. + /// + public bool IsActive + { + get { return (bool)GetValue(IsActiveProperty); } + set { SetValue(IsActiveProperty, value); } + } + + /// + /// When overridden in a derived class, is invoked whenever application code + /// or internal processes call System.Windows.FrameworkElement.ApplyTemplate(). + /// + 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); + } + } + + /// + /// Initializes a new instance of the class. + /// + public LoadingIndicator() + { + + } +} diff --git a/Source/NETworkManager/NETworkManager.csproj b/Source/NETworkManager/NETworkManager.csproj index 980e8c2301..f83b5b7d27 100644 --- a/Source/NETworkManager/NETworkManager.csproj +++ b/Source/NETworkManager/NETworkManager.csproj @@ -66,7 +66,6 @@ - diff --git a/Source/NETworkManager/Resources/Styles/LoadingIndicatorArcsStyle.xaml b/Source/NETworkManager/Resources/Styles/LoadingIndicatorArcsStyle.xaml new file mode 100644 index 0000000000..c86db2d15d --- /dev/null +++ b/Source/NETworkManager/Resources/Styles/LoadingIndicatorArcsStyle.xaml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +