redesign to material standards and clean up some sylings
This commit is contained in:
37
Server Dashboard/AttachedProperty/HyperlinkProperties.cs
Normal file
37
Server Dashboard/AttachedProperty/HyperlinkProperties.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
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 { }
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
@@ -22,22 +19,10 @@ namespace Server_Dashboard {
|
||||
HasTextProperty.SetValue((PasswordBox)sender);
|
||||
}
|
||||
}
|
||||
|
||||
public class HasTextProperty : BaseAttachedProperty<HasTextProperty, bool> {
|
||||
public static void SetValue(DependencyObject sender) {
|
||||
SetValue(sender, ((PasswordBox)sender).SecurePassword.Length < 1);
|
||||
}
|
||||
}
|
||||
public class CloseProperty : BaseAttachedProperty<CloseProperty, bool> {
|
||||
public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) {
|
||||
if(sender is Window window) {
|
||||
window.Loaded += (s, e) => {
|
||||
if(window.DataContext is IWindowHelper wh) {
|
||||
wh.Close += () => {
|
||||
window.Close();
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
Server Dashboard/AttachedProperty/WindowProperties.cs
Normal file
17
Server Dashboard/AttachedProperty/WindowProperties.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
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) => {
|
||||
if (window.DataContext is IWindowHelper wh) {
|
||||
wh.Close += () => {
|
||||
window.Close();
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user