Commit 5d631bd5 authored by 潘栩锋's avatar 潘栩锋 🚴
parents 3d9c1da0 e1cebe18
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
namespace Misc
{
......@@ -28,6 +29,8 @@ namespace Misc
/// <param name="v"></param>
public static void SetValue(object obj, string propertyName, object v)
{
//if (!getRootProperty(ref obj, ref propertyName))
// return;
PropertyInfo property = obj.GetType().GetProperty(propertyName);
if (property != null)
{
......@@ -35,6 +38,36 @@ namespace Misc
}
}
static bool getRootProperty(ref object obj, ref string propertyName) {
Regex r = new Regex(@"(\S+)\[(\d+)\]");
string[] lvs = propertyName.Split('.');
if (lvs.Count() > 1)
{
//这个是多级的
for (int i = 0; i < lvs.Count() - 1; i++)
{
PropertyInfo property;
string name = lvs[i];
int index = 0;
var match = r.Match(name);
if (match.Success)
{
name = match.Groups[1].Value;
index = int.Parse(match.Groups[2].Value);
}
property = obj.GetType().GetProperty(name);
if (property == null)
return false;//异常
if(match.Success)
obj = property.GetValue(obj,new object[] { index });
else
obj = property.GetValue(obj);
}
propertyName = lvs.Last();
}
return true;
}
/// <summary>
/// 设定参数(属性)的值,触发属性值变化“通知”,writeVal
/// </summary>
......@@ -43,6 +76,9 @@ namespace Misc
/// <param name="val"></param>
public static void SetValue(object obj, string propertyName, string val)
{
//if (!getRootProperty(ref obj, ref propertyName))
// return;
PropertyInfo property = obj.GetType().GetProperty(propertyName);
if (property != null)
{
......@@ -59,6 +95,9 @@ namespace Misc
/// <returns></returns>
public static object GetValue(object obj, string propertyName)
{
//if (!getRootProperty(ref obj, ref propertyName))
// return null;
PropertyInfo property = obj.GetType().GetProperty(propertyName);
if (property != null)
{
......
......@@ -13,6 +13,10 @@
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="DataGridCell" >
<Setter Property="FontSize" Value="16"/>
</Style>
</ResourceDictionary>
</Page.Resources>
<Grid Name="root_grid" >
......@@ -41,28 +45,14 @@
</Button>
</StackPanel>
</Grid>
<Grid x:Name="grid_window" Grid.Row="1">
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border Style="{StaticResource BorderStyle_paramSection}" >
<TextBlock Text="历史报警&#x0a;列表" />
</Border>
<Grid Grid.Column="1" x:Name="grid_window">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="751*"/>
<ColumnDefinition Width="54*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.ColumnSpan="2">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
......@@ -94,12 +84,10 @@
</StackPanel>
</Grid>
<DataGrid Grid.Row="1" ItemsSource="{Binding Record}" AutoGenerateColumns="False" IsReadOnly="True" Grid.ColumnSpan="2" AlternationCount="5" >
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="FontSize" Value="20"/>
</Style>
</DataGrid.CellStyle>
<DataGrid Grid.Row="1" ItemsSource="{Binding Record}" AutoGenerateColumns="False" IsReadOnly="True" Grid.ColumnSpan="2"
AlternationCount="5" AlternatingRowBackground="LightGray"
>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Time,StringFormat={}{0:MM/dd HH:mm}}" >
<DataGridTextColumn.Header>
......@@ -133,7 +121,7 @@
</DataGrid>
</Grid>
</Grid>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment