mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-30 06:46:19 +00:00
Change ExName to Attached Property
It is more powerfull and better then inherence and we can use colour emojies easier.
This commit is contained in:
parent
1d4c5876c9
commit
fcf1e9d23a
3 changed files with 662 additions and 650 deletions
|
@ -1,9 +0,0 @@
|
|||
using System.Windows.Controls;
|
||||
|
||||
namespace v2rayN.Base
|
||||
{
|
||||
internal class MyDGTextColumn : DataGridTextColumn
|
||||
{
|
||||
public string ExName { get; set; }
|
||||
}
|
||||
}
|
20
v2rayN/v2rayN/Base/MyDgTextColumnAttachedProperties.cs
Normal file
20
v2rayN/v2rayN/Base/MyDgTextColumnAttachedProperties.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System.Windows;
|
||||
|
||||
namespace v2rayN.Base
|
||||
{
|
||||
public static class MyDgTextColumnAttachedProperties
|
||||
{
|
||||
public static readonly DependencyProperty ExNameProperty =
|
||||
DependencyProperty.RegisterAttached("ExName", typeof(string), typeof(MyDgTextColumnAttachedProperties), new PropertyMetadata(default(string)));
|
||||
|
||||
public static void SetExName(DependencyObject element, string value)
|
||||
{
|
||||
element.SetValue(ExNameProperty, value);
|
||||
}
|
||||
|
||||
public static string GetExName(DependencyObject element)
|
||||
{
|
||||
return (string)element.GetValue(ExNameProperty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -313,7 +313,7 @@ namespace v2rayN.Views
|
|||
return;
|
||||
}
|
||||
|
||||
var colName = ((MyDGTextColumn)colHeader.Column).ExName;
|
||||
var colName = MyDgTextColumnAttachedProperties.GetExName(colHeader.Column);
|
||||
ViewModel?.SortServer(colName);
|
||||
}
|
||||
|
||||
|
@ -484,9 +484,10 @@ namespace v2rayN.Views
|
|||
var displayIndex = 0;
|
||||
foreach (var item in lvColumnItem)
|
||||
{
|
||||
foreach (MyDGTextColumn item2 in lstProfiles.Columns)
|
||||
foreach (var item2 in lstProfiles.Columns)
|
||||
{
|
||||
if (item2.ExName == item.Name)
|
||||
var colName = MyDgTextColumnAttachedProperties.GetExName(item2);
|
||||
if (colName == item.Name)
|
||||
{
|
||||
if (item.Width < 0)
|
||||
{
|
||||
|
@ -525,10 +526,10 @@ namespace v2rayN.Views
|
|||
List<ColumnItem> lvColumnItem = new();
|
||||
for (int k = 0; k < lstProfiles.Columns.Count; k++)
|
||||
{
|
||||
var item2 = (MyDGTextColumn)lstProfiles.Columns[k];
|
||||
var item2 = lstProfiles.Columns[k];
|
||||
lvColumnItem.Add(new()
|
||||
{
|
||||
Name = item2.ExName,
|
||||
Name = MyDgTextColumnAttachedProperties.GetExName(item2),
|
||||
Width = item2.Visibility == Visibility.Visible ? Utils.ToInt(item2.ActualWidth) : -1,
|
||||
Index = item2.DisplayIndex
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue