1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Windows;
- using InABox.Core;
- namespace InABox.DynamicGrid
- {
- public class ColumnNameGenerator : LookupGenerator<object>
- {
- public ColumnNameGenerator(object[] items) : base(items)
- {
- //DynamicGridColumns cols = new DynamicGridColumns();
- //cols.ExtractColumns(type, "");
- //foreach (DynamicGridColumn col in cols.Where(x => (x.Editor != null) && (x.Editor.Visible != Visible.Disabled)))
- // AddValue(col.ColumnName, col.ColumnName);
- }
- }
- public class DynamicGridColumn : DynamicColumnBase
- {
- public DynamicGridColumn()
- {
- Editor = new NullEditor();
- Lookups = new Dictionary<object, object>();
- }
- [ComboLookupEditor(typeof(ColumnNameGenerator))]
- [EditorSequence(1)]
- public string ColumnName { get; set; }
- [EditorSequence(2)]
- public int Width { get; set; }
- [EditorSequence(3)]
- public string Format { get; set; }
- [EditorSequence(4)]
- public string Caption { get; set; }
- [EnumLookupEditor(typeof(Alignment))]
- [EditorSequence(5)]
- public Alignment Alignment { get; set; }
- [NullEditor]
- public Dictionary<object, object> Lookups { get; set; }
- public BaseEditor Editor { get; set; }
- public VerticalAlignment VerticalAlignment()
- {
- if (Alignment.Equals(Alignment.NotSet))
- return System.Windows.VerticalAlignment.Center;
- if (Alignment.Equals(Alignment.TopLeft) || Alignment.Equals(Alignment.TopCenter) || Alignment.Equals(Alignment.TopRight))
- return System.Windows.VerticalAlignment.Top;
- if (Alignment.Equals(Alignment.MiddleLeft) || Alignment.Equals(Alignment.MiddleCenter) || Alignment.Equals(Alignment.MiddleRight))
- return System.Windows.VerticalAlignment.Center;
- return System.Windows.VerticalAlignment.Bottom;
- }
- public HorizontalAlignment HorizontalAlignment(Type datatype)
- {
- if (Alignment.Equals(Alignment.NotSet))
- return datatype.IsNumeric() ? System.Windows.HorizontalAlignment.Right :
- datatype == typeof(bool) ? System.Windows.HorizontalAlignment.Center : System.Windows.HorizontalAlignment.Left;
- if (Alignment.Equals(Alignment.TopLeft) || Alignment.Equals(Alignment.MiddleLeft) || Alignment.Equals(Alignment.BottomLeft))
- return System.Windows.HorizontalAlignment.Left;
- if (Alignment.Equals(Alignment.TopCenter) || Alignment.Equals(Alignment.MiddleCenter) || Alignment.Equals(Alignment.BottomCenter))
- return System.Windows.HorizontalAlignment.Center;
- return System.Windows.HorizontalAlignment.Right;
- }
- public override string ToString()
- {
- return ColumnName;
- }
- }
- }
|