add resharper and hover effect for modules; change navigation bar
This commit is contained in:
@@ -4,22 +4,30 @@ using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
|
||||
/// <summary>
|
||||
/// Attached property base class
|
||||
/// </summary>
|
||||
/// <typeparam name="Parent"></typeparam>
|
||||
/// <typeparam name="Property"></typeparam>
|
||||
public abstract class BaseAttachedProperty<Parent, Property>
|
||||
where Parent : BaseAttachedProperty<Parent, Property>, new() {
|
||||
/// <typeparam name="TParent"></typeparam>
|
||||
/// <typeparam name="TProperty"></typeparam>
|
||||
public abstract class BaseAttachedProperty<TParent, TProperty>
|
||||
where TParent : BaseAttachedProperty<TParent, TProperty>, new() {
|
||||
|
||||
public event Action<DependencyObject, DependencyPropertyChangedEventArgs> ValueChanged = (sender, e) => { };
|
||||
public static Parent Instance { get; private set; } = new Parent();
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached("Value", typeof(Property), typeof(BaseAttachedProperty<Parent, Property>), new PropertyMetadata(new PropertyChangedCallback(OnValuePropertyChanged)));
|
||||
|
||||
public static TParent Instance { get; private set; } = new TParent();
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached("Value", typeof(TProperty), typeof(BaseAttachedProperty<TParent, TProperty>), new PropertyMetadata(new PropertyChangedCallback(OnValuePropertyChanged)));
|
||||
|
||||
private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
Instance.OnValueChanged(d, e);
|
||||
Instance.ValueChanged(d, e);
|
||||
}
|
||||
public static Property GetValue(DependencyObject d) => (Property)d.GetValue(ValueProperty);
|
||||
public static void SetValue(DependencyObject d, Property value) => d.SetValue(ValueProperty, value);
|
||||
public virtual void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { }
|
||||
|
||||
public static TProperty GetValue(DependencyObject d) => (TProperty)d.GetValue(ValueProperty);
|
||||
|
||||
public static void SetValue(DependencyObject d, TProperty value) => d.SetValue(ValueProperty, value);
|
||||
|
||||
public virtual void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,9 @@ using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
|
||||
public static class HyperlinkExtensions {
|
||||
|
||||
public static bool GetIsExternal(DependencyObject obj) {
|
||||
return (bool)obj.GetValue(IsExternalProperty);
|
||||
}
|
||||
@@ -14,23 +16,25 @@ namespace Server_Dashboard {
|
||||
public static void SetIsExternal(DependencyObject obj, bool value) {
|
||||
obj.SetValue(IsExternalProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsExternalProperty =
|
||||
DependencyProperty.RegisterAttached("IsExternal", typeof(bool), typeof(HyperlinkExtensions), new UIPropertyMetadata(false, OnIsExternalChanged));
|
||||
|
||||
private static void OnIsExternalChanged(object sender, DependencyPropertyChangedEventArgs args) {
|
||||
var hyperlink = sender as Hyperlink;
|
||||
|
||||
if ((bool)args.NewValue)
|
||||
hyperlink.RequestNavigate += Hyperlink_RequestNavigate;
|
||||
else
|
||||
if ((bool)args.NewValue) {
|
||||
if (hyperlink != null)
|
||||
hyperlink.RequestNavigate += Hyperlink_RequestNavigate;
|
||||
} else if (hyperlink != null)
|
||||
hyperlink.RequestNavigate -= Hyperlink_RequestNavigate;
|
||||
}
|
||||
|
||||
private static void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) {
|
||||
try {
|
||||
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri) { UseShellExecute = true });
|
||||
} catch { }
|
||||
} catch (Exception) { }
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,18 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
|
||||
public class MonitorPasswordProperty : BaseAttachedProperty<MonitorPasswordProperty, bool> {
|
||||
|
||||
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) {
|
||||
var passwordBox = sender as PasswordBox;
|
||||
if (passwordBox == null)
|
||||
if (!(sender is PasswordBox passwordBox))
|
||||
return;
|
||||
passwordBox.PasswordChanged -= PasswordBox_PasswordChanged;
|
||||
|
||||
if ((bool)e.NewValue) {
|
||||
HasTextProperty.SetValue(passwordBox);
|
||||
passwordBox.PasswordChanged += PasswordBox_PasswordChanged;
|
||||
}
|
||||
if (!(bool)e.NewValue)
|
||||
return;
|
||||
HasTextProperty.SetValue(passwordBox);
|
||||
passwordBox.PasswordChanged += PasswordBox_PasswordChanged;
|
||||
}
|
||||
|
||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) {
|
||||
@@ -21,8 +22,9 @@ namespace Server_Dashboard {
|
||||
}
|
||||
|
||||
public class HasTextProperty : BaseAttachedProperty<HasTextProperty, bool> {
|
||||
|
||||
public static void SetValue(DependencyObject sender) {
|
||||
SetValue(sender, ((PasswordBox)sender).SecurePassword.Length < 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
|
||||
public class CloseProperty : BaseAttachedProperty<CloseProperty, bool> {
|
||||
|
||||
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) {
|
||||
if (sender is Window window) {
|
||||
window.Loaded += (s, e) => {
|
||||
@@ -14,4 +16,4 @@ namespace Server_Dashboard {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user