public static Cell BuildCell(int index, ExcelColumn col, RowHandler row) { Cell cell = null; CellConstruct constr = new CellConstruct(index, col, row); switch (col.ColumnType) { case ExcelColumn.ColumnTypes.Counter: case ExcelColumn.ColumnTypes.Text: case ExcelColumn.ColumnTypes.Note: case ExcelColumn.ColumnTypes.Number: case ExcelColumn.ColumnTypes.Unknown: cell = new CellText(constr); break; case ExcelColumn.ColumnTypes.Choice: cell = new CellTextDropdown(constr); break; case ExcelColumn.ColumnTypes.Custom: cell = col.CellBuilder(constr, col.BuilderArgs); break; default: break; } return cell; }
void Control_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ExcelColumn thisColumn = ((CellHeaderControl)sender).ExcelColumn; if (thisColumn == CurrentColumnSort) { HideFilter(); } else { CurrentColumnSort = thisColumn; DisplayFilter(); } }
public NumberConverter(ExcelColumn column) { _column = column; }
ExcelColumn InitializeExcelColumn(XElement x) { ExcelColumn column = null; if (x.Attribute("Hidden") == null) { string displayName = (string)x.Attribute("DisplayName"); if (displayName != null) { string internalName = (string)x.Attribute("Name"); column = new ExcelColumn(displayName, internalName); column.Mandatory = false; if (x.Attribute("Required") != null) column.Mandatory = x.Attribute("Required").Value == "TRUE"; column.ReadOnly = false; if (x.Attribute("ReadOnly") != null) column.ReadOnly = x.Attribute("ReadOnly").Value == "TRUE"; if (x.Element(NSSoap + "Default") != null) column.Default = x.Element(NSSoap + "Default").Value; switch ((string)x.Attribute("Type")) { case "Text": column.ColumnType = ExcelColumn.ColumnTypes.Text; column.Converter = new ObjectConverter(); break; case "Number": column.ColumnType = ExcelColumn.ColumnTypes.Number; column.Converter = new NumberConverter(column); break; case "Counter": column.ColumnType = ExcelColumn.ColumnTypes.Counter; column.Converter = new NumberConverter(column); break; case "Note": column.ColumnType = ExcelColumn.ColumnTypes.Note; column.Converter = new HTMLNoteConverter(); break; case "Choice": column.ColumnType = ExcelColumn.ColumnTypes.Choice; column.Converter = new ObjectConverter(); var options = new List<string>(); foreach (XElement choice in x.Descendants(NSSoap + "CHOICE")) { options.Add(choice.Value); } column.Options = options; break; default: column.ColumnType = ExcelColumn.ColumnTypes.Unknown; column.Converter = new ObjectConverter(); break; } } } return column; }
ExcelColumn InitializeExcelColumn(PropertyInfo x) { ExcelColumn column = null; String displayName = ((GridColumnNameAttribute)Attribute.GetCustomAttribute(x,typeof(GridColumnNameAttribute))).ColumnName; if (displayName != null) { string internalName = x.Name; column = new ExcelColumn(displayName, internalName); column.Mandatory = false; //if (x.Attribute("Required") != null) // column.Mandatory = x.Attribute("Required").Value == "TRUE"; column.ReadOnly = false; //if (x.Attribute("ReadOnly") != null) // column.ReadOnly = x.Attribute("ReadOnly").Value == "TRUE"; //if (x.Element(NSSoap + "Default") != null) // column.Default = x.Element(NSSoap + "Default").Value; String PropertyColumnType = ((ColumnTypeAttribute)Attribute.GetCustomAttribute(x, typeof(ColumnTypeAttribute))).ColumnType.ToString(); switch (PropertyColumnType) { case "Text": column.ColumnType = ExcelColumn.ColumnTypes.Text; column.Converter = new ObjectConverter(); break; case "Number": column.ColumnType = ExcelColumn.ColumnTypes.Number; column.Converter = new NumberConverter(column); break; //case "Counter": // column.ColumnType = ExcelColumn.ColumnTypes.Counter; // column.Converter = new NumberConverter(column); // break; //case "Note": // column.ColumnType = ExcelColumn.ColumnTypes.Note; // column.Converter = new HTMLNoteConverter(); // break; case "Choice": String choiceGroup = ((ColumnTypeAttribute)Attribute.GetCustomAttribute(x, typeof(ColumnTypeAttribute))).ChoiceGroupName.ToString(); column.ColumnType = ExcelColumn.ColumnTypes.Choice; column.Converter = new ObjectConverter(); var options = new List<string>(); var dataoptions = StaticData[choiceGroup]; //JsonConvert.DeserializeObject<Dictionary<int, string>>(staticData["BusinessUnits"].ToString()); foreach (var o in dataoptions) { options.Add(o.Value); } column.Options = options; break; default: column.ColumnType = ExcelColumn.ColumnTypes.Unknown; column.Converter = new ObjectConverter(); break; } } return column; }
public ID1Converter(IExcelParams excelParams, ExcelColumn column) { Column = column; ExcelParams = excelParams; }
public void FilterColumn(ExcelColumn sortColumn, FilterEventArgs.FilterTypes filterType, bool ascending, string value) { CurrentColumnSort = sortColumn; // If there's no current filter data, its the main dataset if (CurrentFilterData == null) CurrentFilterData = ExcelParams.ItemsSource; // If there was a last sort column, set it to non. if (LastColumnSort != null) LastColumnSort.Control.OrderBy = CellHeaderControl.OrderBys.None; IEnumerable<Dictionary<string, object>> filtered = null; // If its a sort.. if (filterType == FilterEventArgs.FilterTypes.Sort) { // if its ascending, do an orderby ascending if (ascending) { filtered = from x in CurrentFilterData orderby x[CurrentColumnSort.PropertyBind] ascending select x; CurrentColumnSort.Control.OrderBy = CellHeaderControl.OrderBys.Ascending; } else { filtered = from x in CurrentFilterData orderby x[CurrentColumnSort.PropertyBind] descending select x; CurrentColumnSort.Control.OrderBy = CellHeaderControl.OrderBys.Descending; } } else { // otherwise filter by the value if (value == GridConstants.All) CurrentColumnSort.Control.Filtered = false; else CurrentColumnSort.Control.Filtered = true; CurrentColumnSort.CurrentFilter = value; filtered = ExcelParams.ItemsSource; // As it's would be complicated to remember all the other filters on columns, just use the // full dataset again and build each filter in if the CurrentFilter on the column is not empty. foreach (string key in ExcelParams.Columns.Keys) { ExcelColumn column = ExcelParams.Columns[key]; Cell builderCell = CellBuilder.BuildCell(column.Index, column, null); filtered = builderCell.Filter(filtered); /*if (!string.IsNullOrEmpty(column.CurrentFilter)) { filtered = from x in filtered where (x[column.PropertyBind] == null ? "" : x[column.PropertyBind].ToString()).Contains(column.CurrentFilter) select x; }*/ } } CurrentFilterData = filtered; ExcelParams.PopulateData(CurrentFilterData.ToList<Dictionary<string, object>>()); }
public void HideFilter() { LastColumnSort = CurrentColumnSort; if(filterControl != null && filterControl.Visibility == Visibility.Visible) filterControl.Visibility = Visibility.Collapsed; CurrentColumnSort = null; }
public DefaultConverter(ExcelColumn column) { Column = column; }
public Cell(CellConstruct cellConst) { State = States.Normal; Column = cellConst.Column; Col = cellConst.Col; rowHandler = cellConst.rowHandler; CellTooltip = null; }
internal void AddColumn(ExcelColumn column) { int currentIndex = NoOfColumns; // Add the column definitions for the header and the data grid ColumnDefinition colDefHeader = new ColumnDefinition(); ColumnDefinition colDefMain = new ColumnDefinition(); colDefHeader.Width = new GridLength(column.Width); colDefMain.Width = new GridLength(column.Width); grdHeaderGrid.ColumnDefinitions.Add(colDefHeader); grdMain.ColumnDefinitions.Add(colDefMain); // Bind the grid columns width to the header column widths // Only works in SL4 so need to use mousemove on the splitter instead //Binding bdnWidth = new Binding(); //bdnWidth.Source = colDefHeader; //bdnWidth.Path = new PropertyPath("Width"); //BindingOperations.SetBinding(colDefMain, ColumnDefinition.WidthProperty, bdnWidth); // Create the header control and add it to the header CellHeaderControl newHeader = new CellHeaderControl(); Binding colorBinding = new Binding("HeaderColor"); colorBinding.Source = this; newHeader.SetBinding(CellHeaderControl.BackgroundColorProperty, colorBinding); newHeader.Text = column.Header; newHeader.HeaderFontColor = HeaderFontColor; newHeader.HeaderFontFamily = HeaderFontFamily; newHeader.HeaderFontWeight = HeaderFontWeight; newHeader.HeaderFontSize = HeaderFontSize; newHeader.SetValue(Grid.RowProperty, 0); newHeader.SetValue(Grid.ColumnProperty, currentIndex); grdHeaderGrid.Children.Add(newHeader); column.Control = newHeader; newHeader.ExcelColumn = column; if (column.Width == 0) { colDefHeader.Width = new GridLength((int)newHeader.TextWidth + 40); ResizeMainColumn(currentIndex, colDefHeader.Width); } // Create th gridSplitter control and add it to the header. GridSplitter splitter = new GridSplitter(); splitter.SetValue(Grid.RowProperty, 0); splitter.SetValue(Grid.ColumnProperty, currentIndex); splitter.Style = (Style)Resources["ColSplitter"]; splitter.Background = HeaderBorderBrush; splitter.MouseMove += new MouseEventHandler(splitter_MouseMove); grdHeaderGrid.Children.Add(splitter); }
public CellConstruct(int _col, ExcelColumn _column, RowHandler _rowHandler) { Col = _col; Column = _column; rowHandler = _rowHandler; }