private void BindToGridEvents(IEnumerable eventInfos)
        {
            DataTable dataTable = new DataTable();

            PropertyInfo[] properties = typeof(EventInfo).GetProperties();
            foreach (PropertyInfo propertyInfo in properties)
            {
                if (propertyInfo.Name != "CharacterInfo")
                {
                    dataTable.Columns.Add(propertyInfo.Name);
                }
            }
            foreach (EventInfo eventInfo in eventInfos)
            {
                DataRow row = dataTable.NewRow();
                foreach (PropertyInfo propertyInfo in properties)
                {
                    if (propertyInfo.Name == "Color")
                    {
                        PxColor pxColor = (PxColor)typeof(EventInfo).GetProperty(propertyInfo.Name).GetValue(eventInfo, null);
                        row[propertyInfo.Name] = (string)(object)pxColor.R + (object)"," + (string)(object)pxColor.G + "," + (string)(object)pxColor.B;
                    }
                    else if (propertyInfo.Name != "CharacterInfo")
                    {
                        row[propertyInfo.Name] = typeof(EventInfo).GetProperty(propertyInfo.Name).GetValue(eventInfo, null);
                    }
                }
                dataTable.Rows.Add(row);
            }

            dataGridView1.DataSource = dataTable;
        }
Пример #2
0
 public static IBrushFactory GetColor(PxColor color)
 {
     if (Colors.TryGetValue(color, out var outVal))
     {
         return(outVal);
     }
     outVal = new SolidColourBrushFactory(color);
     Colors.Add(color, outVal);
     return(outVal);
 }
        private static bool TryParse(string value, out PxColor colour)
        {
            if (!Regex.IsMatch(value, "^#[0-9A-Fa-f]+$"))
            {
                return(PxColorRegistry.TryGetColor(value, out colour));
            }

            switch (value.Length)
            {
            case 4:
                colour = PxColor.FromRgb(Convert.ToInt32(string.Format("{0}{0}{1}{1}{2}{2}", value[1], value[2], value[3]), 16));
                return(true);

            case 7:
                colour = PxColor.FromRgb(Convert.ToInt32(value.Substring(1), 16));
                return(true);

            default:
                colour = PxColors.Black;
                return(false);
            }
        }
Пример #4
0
 private SolidColourBrushFactory(PxColor color)
 {
     _brush = new SolidColorBrush(color);
 }
Пример #5
0
 public SolidColorBrush(PxColor color)
 {
     Tag   = "SCB:" + color;
     Color = color;
 }
Пример #6
0
 public static DX.Color4 ToDx4(this PxColor color)
 {
     return(new DX.Color4(color.R, color.G, color.B, color.A));
 }
Пример #7
0
 public static DXM.RawColor4 ToDx(this PxColor color, float opacity)
 {
     return(new DXM.RawColor4(color.R, color.G, color.B, color.A * opacity));
 }