protected override int CompareCells(XPTable.Models.Cell cell1, XPTable.Models.Cell cell2) { // check for null cells if (cell1 == null && cell2 == null) { return(0); } else if (cell1 == null) { return(-1); } else if (cell2 == null) { return(1); } if (cell1.Tag == null && cell2.Tag == null) { return(0); } else if (cell1.Tag == null) { return(-1); } else if (cell2.Tag == null) { return(1); } double cell1Val = (double)cell1.Tag; double cell2Val = (double)cell2.Tag; return(cell1Val.CompareTo(cell2Val)); }
/// <summary> /// Initializes a new instance of the CellEventArgs class with /// the specified Cell source, column index and row index /// </summary> /// <param name="source">The Cell that Raised the event</param> /// <param name="column">The Column index of the Cell</param> /// <param name="row">The Row index of the Cell</param> public CellEventArgsBase(Cell source, int column, int row) : base() { this.source = source; this.column = column; this.row = row; }
/// <summary> /// Creates a CellToolTipEventArgs using the values from args. /// </summary> /// <param name="cell"></param> /// <param name="location"></param> public CellToolTipEventArgs(Cell cell, Point location) : base(false) { this.Cell = cell; this.Location = location; this.ToolTipText = cell.ToolTipText; }
/// <summary> /// Compares two cells and returns a value indicating whether one is less /// than, equal to or greater than the other. /// </summary> /// <param name="cell1"></param> /// <param name="cell2"></param> /// <returns></returns> protected override int CompareCells(Cell cell1, Cell cell2) { int retVal = 0; if (cell1.Checked && !cell2.Checked) { retVal = -1; } else if (!cell1.Checked && cell2.Checked) { retVal = 1; } // if the cells have the same checked value and the CheckBoxColumn // they belong to allows text drawing, compare the text properties // to determine order if (retVal == 0 && ((CheckBoxColumn)this.TableModel.Table.ColumnModel.Columns[this.SortColumn]).DrawText) { // check for null data if (cell1.Text == null && cell2.Text == null) { return 0; } else if (cell1.Text == null) { return -1; } retVal = cell1.Text.CompareTo(cell2.Text); } return retVal; }
public override Control UpdateControl(Cell cell, Control control) { // We either show a loading circle with the given colour, or just load an image. Control newControl = null; if (cell.Data is Color) { Color color = (Color)cell.Data; if (control is LoadingCircle) { LoadingCircle lc = (LoadingCircle)control; lc.Color = color; } } else { // We are getting rid of the control now - so remove event handlers if (control is LoadingCircle && this.ClickEventHandler != null) ((LoadingCircle)control).Click -= ClickEventHandler; PictureBox pic = new PictureBox(); pic.Image = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Resources\EmailRead.bmp"); newControl = pic; } return newControl; }
private void DoColspan() { Table table = this.table; // The Table control on a form - already initialised table.SelectionStyle = SelectionStyle.Grid; table.BeginUpdate(); table.EnableWordWrap = true; // If false, then Cell.WordWrap is ignored table.GridLines = GridLines.Rows; TextColumn col1 = new TextColumn("col A", 100); TextColumn col2 = new TextColumn("col B", 100); TextColumn col3 = new TextColumn("col C", 100); table.ColumnModel = new ColumnModel(new Column[] { col1, col2, col3 }); TableModel model = new TableModel(); Row row; Cell cell; // Add all 3 cells for row 1 row = new Row(); row.Cells.Add(new Cell("Short 1a")); //row1.Cells.Add(new Cell("Short 1")); cell = new Cell("This is long text that will just be truncated"); row.Cells.Add(cell); row.Cells.Add(new Cell("Short 1c")); model.Rows.Add(row); // Add only 2 cells for row 2 row = new Row(); row.Cells.Add(new Cell("Short 2a")); cell = new Cell("This is text that will go over to the next column"); cell.ColSpan = 2; // The row height will be increased so we can see all the text row.Cells.Add(cell); // We don't add the next cell model.Rows.Add(row); // Add all 3 cells for row 3 row = new Row(); row.Cells.Add(new Cell("Short 3")); //row1.Cells.Add(new Cell("Short 1")); cell = new Cell("This is a cell with some really long text that wraps more than the other text"); cell.WordWrap = true; // The row height will be increased so we can see all the text row.Cells.Add(cell); row.Cells.Add(new Cell("Short 3c")); model.Rows.Add(row); // Add only 2 cells for row 4 row = new Row(); row.Cells.Add(new Cell("Short 4")); cell = new Cell("This is a cell with some really long text that wraps more than the other text"); cell.WordWrap = true; // Colspan and Wordwrap!! cell.ColSpan = 2; row.Cells.Add(cell); model.Rows.Add(row); this.table.TableModel = model; this.table.EndUpdate(); }
void VisualizeEvent(LogEvent e) { XPTable.Models.Row row = new XPTable.Models.Row(); XPTable.Models.Cell cell1 = new XPTable.Models.Cell(); XPTable.Models.CellStyle cellStyle1 = new XPTable.Models.CellStyle(); XPTable.Models.Cell cell2 = new XPTable.Models.Cell(); XPTable.Models.CellStyle cellStyle2 = new XPTable.Models.CellStyle(); cell1.Data = e.time; cell1.ToolTipText = e.time.ToString("dd.MM.yyyy"); cell2.Image = e.icon; cell2.Text = e.text; if (e.lines.Length == 1) { cell2.ToolTipText = e.lines[0].Second; } row.Cells.AddRange(new XPTable.Models.Cell[] { cell1, cell2 }); row.ChildIndex = 0; row.Editable = false; row.Tag = e; tableModel.Rows.Add(row); publishedEvents.Add(e, row); }
private void AddEmailRows(TableModel table, bool read, string from, string sent, string subject, string preview) { Row row = new Row(); row.Cells.Add(new Cell()); // always starts off showing all subrows row.Cells.Add(new Cell("", read ? _read : _unread)); row.Cells.Add(new Cell(from)); row.Cells.Add(new Cell(DateTime.Parse(sent))); row.Cells.Add(new Cell("hi")); table.Rows.Add(row); // Add a sub-row that shows just the email subject in grey (single line only) Row subrow = new Row(); subrow.Cells.Add(new Cell()); // Extra column for +/- subrow.Cells.Add(new Cell()); Cell cell = new Cell(subject); cell.ForeColor = Color.Gray; cell.ColSpan = 3; subrow.Cells.Add(cell); row.SubRows.Add(subrow); // Add a sub-row that shows just a preview of the email body in blue, and wraps too subrow = new Row(); subrow.Cells.Add(new Cell()); // Extra column for +/- subrow.Cells.Add(new Cell()); cell = new Cell(preview); cell.ForeColor = Color.Blue; cell.ColSpan = 3; cell.WordWrap = true; subrow.Cells.Add(cell); row.SubRows.Add(subrow); }
/// <summary> /// Called to determine whether this cell can be shown by this filter /// </summary> /// <param name="cell"></param> /// <returns></returns> public bool CanShow(Cell cell) { if (_allowedItems == null) return true; if (cell == null) return true; return _allowedItems.Contains(cell.Text); }
/// <summary> /// Returns the height that is required to render this cell. If zero is returned then the default row height is used. /// </summary> /// <param name="graphics"></param> /// <param name="cell"></param> /// <returns></returns> public override int GetCellHeight(Graphics graphics, Cell cell) { if (cell != null) { this.Font = cell.Font; // Need to set this.Bounds before we access Client rectangle SizeF size = graphics.MeasureString(cell.Text, this.Font, this.ClientRectangle.Width, this.StringFormat); return (int)Math.Ceiling(size.Height); } else return 0; }
private void DoWrap() { Table table = this.table; // The Table control on a form - already initialised table.BeginUpdate(); table.EnableWordWrap = true; // If false, then Cell.WordWrap is ignored table.SelectionStyle = SelectionStyle.Grid; table.GridLines = GridLines.Rows; TextColumn col1 = new TextColumn("col A", 100); TextColumn col2 = new TextColumn("col B", 100); table.ColumnModel = new ColumnModel(new Column[] { col1, col2 }); TableModel model = new TableModel(); Row row; Cell cell; row = new Row(); row.Cells.Add(new Cell("Short 1")); //row1.Cells.Add(new Cell("Short 1")); cell = new Cell("This is a cell with quite long text"); cell.WordWrap = true; // The row height will be increased so we can see all the text row.Cells.Add(cell); model.Rows.Add(row); row = new Row(); row.Cells.Add(new Cell("Short 2")); cell = new Cell("This is long text that will just be truncated"); cell.WordWrap = false; // Not needed - it is false by default row.Cells.Add(cell); model.Rows.Add(row); row = new Row(); row.Cells.Add(new Cell("Short 3")); //row1.Cells.Add(new Cell("Short 1")); cell = new Cell("This is a cell with some really long text that wraps more than the other text"); cell.WordWrap = true; // The row height will be increased so we can see all the text row.Cells.Add(cell); model.Rows.Add(row); row = new Row(); row.Cells.Add(new Cell("Short ")); cell = new Cell("This is long text that will just be truncated"); cell.WordWrap = false; // Not needed - it is false by default row.Cells.Add(cell); model.Rows.Add(row); this.table.TableModel = model; this.table.EndUpdate(); }
/// <summary> /// Compares two cells and returns a value indicating whether one is less /// than, equal to or greater than the other. /// </summary> /// <param name="cell1"></param> /// <param name="cell2"></param> /// <returns></returns> protected override int CompareCells(Cell cell1, Cell cell2) { // check for null data if (cell1.Data == null && cell2.Data == null) { return 0; } else if (cell1.Data == null) { return -1; } else if (cell2.Data == null) { return 1; } Color color1 = (Color) cell1.Data; Color color2 = (Color) cell2.Data; if (color1.GetHue() < color2.GetHue()) { return -1; } else if (color1.GetHue() > color2.GetHue()) { return 1; } else { if (color1.GetSaturation() < color2.GetSaturation()) { return -1; } else if (color1.GetSaturation() > color2.GetSaturation()) { return 1; } else { if (color1.GetBrightness() < color2.GetBrightness()) { return -1; } else if (color1.GetBrightness() > color2.GetBrightness()) { return 1; } return 0; } } }
/// <summary> /// Gets the ButtonCellRenderer specific data used by the Renderer from /// the specified Cell /// </summary> /// <param name="cell">The Cell to get the ButtonCellRenderer data for</param> /// <returns>The ButtonCellRenderer data for the specified Cell</returns> protected ButtonRendererData GetButtonRendererData(Cell cell) { object rendererData = this.GetRendererData(cell); if (rendererData == null || !(rendererData is ButtonRendererData)) { rendererData = new ButtonRendererData(); this.SetRendererData(cell, rendererData); } return (ButtonRendererData) rendererData; }
/// <summary> /// Adds the specified Cell to the end of the collection /// </summary> /// <param name="cell">The Cell to add</param> public int Add(Cell cell) { if (cell == null) { throw new System.ArgumentNullException("Cell is null"); } int index = this.List.Add(cell); this.OnCellAdded(new RowEventArgs(this.owner, cell, index, index)); return index; }
private void AddEmailRows(TableModel table, bool read, string from, string sent, string subject, string preview) { Row row = new Row(); //row.Alignment = RowAlignment.Top; row.Cells.Add(new Cell()); // always starts off showing all subrows row.Cells.Add(new Cell("", read ? _read : _unread)); Cell fro = new Cell(null); //from); fro.WordWrap = true; row.Cells.Add(fro); Cell cellSent = new Cell(DateTime.Parse(sent)); if (sent == "5/4/2007 9:13") { cellSent.CellStyle = new CellStyle(ColumnAlignment.Left); cellSent.CellStyle.LineAlignment = RowAlignment.Top; } row.Cells.Add(cellSent); row.Cells.Add(new Cell("hi")); row.RowStyle = new XPTable.Models.RowStyle(); row.RowStyle.Alignment = RowAlignment.Top; table.Rows.Add(row); // Add a sub-row that shows just the email subject in grey (single line only) Row subrow = new Row(); subrow.Cells.Add(new Cell()); // Extra column for +/- subrow.Cells.Add(new Cell()); subrow.RowStyle = new XPTable.Models.RowStyle(); subrow.RowStyle.Alignment = RowAlignment.Bottom; Cell cell = new Cell(subject); cell.ForeColor = Color.Gray; cell.ColSpan = 3; subrow.Cells.Add(cell); row.SubRows.Add(subrow); // Add a sub-row that shows just a preview of the email body in blue, and wraps too subrow = new Row(); subrow.Cells.Add(new Cell()); // Extra column for +/- subrow.Cells.Add(new Cell()); cell = new Cell(preview); cell.ForeColor = Color.Blue; cell.ColSpan = 3; cell.WordWrap = true; subrow.RowStyle = new XPTable.Models.RowStyle(); subrow.RowStyle.Alignment = RowAlignment.Bottom; subrow.Cells.Add(cell); row.SubRows.Add(subrow); }
/// <summary> /// Adds the specified Cell to the end of the collection /// </summary> /// <param name="cell">The Cell to add</param> public int Add(Cell cell) { if (cell == null) { throw new System.ArgumentNullException("Cell is null"); } int index = this.List.Add(cell); this.OnCellAdded(new RowEventArgs(this.owner, cell, index, index)); for (int i = 1; i < cell.ColSpan; i++) { this.Add(new Cell(string.Empty)); } return index; }
/// <summary> /// Compares two cells and returns a value indicating whether one is less /// than, equal to or greater than the other. /// </summary> /// <param name="cell1"></param> /// <param name="cell2"></param> /// <returns></returns> protected override int CompareCells(Cell cell1, Cell cell2) { // check for null data if (cell1.Data == null && cell2.Data == null) { return 0; } else if (cell1.Data == null) { return -1; } else if (cell2.Data == null) { return 1; } return Convert.ToDateTime(cell1.Data).CompareTo(Convert.ToDateTime(cell2.Data)); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public void AddColumns(ColumnModel model) { this.model = model; CellStyle cellStyle = new CellStyle(); cellStyle.Padding = new CellPadding(6, 0, 0, 0); this.columnTable.BeginUpdate(); for (int i=0; i<model.Columns.Count; i++) { Row row = new Row(); Cell cell = new Cell(model.Columns[i].Text, model.Columns[i].Visible); cell.Tag = model.Columns[i].Width; cell.CellStyle = cellStyle; row.Cells.Add(cell); this.columnTable.TableModel.Rows.Add(row); } this.columnTable.SelectionChanged += new Events.SelectionEventHandler(OnSelectionChanged); this.columnTable.CellCheckChanged += new Events.CellCheckBoxEventHandler(OnCellCheckChanged); if (this.columnTable.VScroll) { this.columnTable.ColumnModel.Columns[0].Width -= SystemInformation.VerticalScrollBarWidth; } if (this.columnTable.TableModel.Rows.Count > 0) { this.columnTable.TableModel.Selections.SelectCell(0, 0); this.showButton.Enabled = !this.model.Columns[0].Visible; this.hideButton.Enabled = this.model.Columns[0].Visible; this.widthTextBox.Text = this.model.Columns[0].Width.ToString(); } this.columnTable.EndUpdate(); }
private void UpdateTable() { iTable.BeginUpdate(); iTableModel.Rows.Clear(); // long total = iDistribution.Total; foreach (DictionaryEntry entry in iDistribution) { uint size = (uint)(entry.Key); uint instanceCount = (uint)entry.Value; uint totalForSize = size * instanceCount; double percentageDistribution = ((double)(totalForSize) / ((double)total)) * 100.0; double percentageHeap = ((double)(totalForSize) / ((double)TotalHeapSize)) * 100.0; string percentageTextDistribution = NumberFormattingUtils.NumberAsPercentageTwoDP(totalForSize, total) + " %"; string percentageTextHeap = NumberFormattingUtils.NumberAsPercentageTwoDP(totalForSize, TotalHeapSize) + " %"; // XPTable.Models.Row row = new XPTable.Models.Row(); // XPTable.Models.Cell cellSize = new XPTable.Models.Cell(size.ToString() + " bytes"); cellSize.Tag = size; XPTable.Models.Cell cellInstanceCount = new XPTable.Models.Cell(instanceCount.ToString()); cellInstanceCount.Data = instanceCount; XPTable.Models.Cell cellTotalForSize = new XPTable.Models.Cell(totalForSize.ToString()); cellTotalForSize.Data = totalForSize; XPTable.Models.Cell cellPercentage = new XPTable.Models.Cell(percentageTextDistribution); cellPercentage.Tag = percentageDistribution; XPTable.Models.Cell cellPercentageOfHeap = new XPTable.Models.Cell(percentageTextHeap); cellPercentageOfHeap.Tag = percentageHeap; // row.Cells.Add(cellSize); row.Cells.Add(cellInstanceCount); row.Cells.Add(cellTotalForSize); row.Cells.Add(cellPercentage); row.Cells.Add(cellPercentageOfHeap); // iTableModel.Rows.Add(row); } // iTable.EndUpdate(); }
/// <summary> /// Compares two cells and returns a value indicating whether one is less /// than, equal to or greater than the other. /// </summary> /// <param name="cell1"></param> /// <param name="cell2"></param> /// <returns></returns> protected override int CompareCells(Cell cell1, Cell cell2) { string cell1Text = ""; string cell2Text = ""; if (cell1.Text != null) { cell1Text = cell1.Text; } if (cell2.Text != null) { cell2Text = cell2.Text; } // check for null data and empty text. if (cell1.Data == null && cell2.Data == null && cell1Text.Length == 0 && cell2Text.Length == 0) { return 0; } else if (cell1.Data == null && cell1Text.Length == 0) { return -1; } else if (cell2.Data == null && cell2Text.Length == 0) { return 1; } if (cell1.Data != null && cell2.Data != null) { // Compare using cell data. return Convert.ToDateTime(cell1.Data).CompareTo(Convert.ToDateTime(cell2.Data)); } else { // Compare using cell text. return Convert.ToDateTime(cell1Text).CompareTo(Convert.ToDateTime(cell2Text)); } }
public override Control GetControl(Cell cell) { LoadingCircle circle = null; if (cell.Data != null && cell.Data is Color) { // Yes - we do want to show a control circle = new LoadingCircle(); // We assign the event handler in this way so that when it is clicked, the event is handled // *directly* by the form - it doesnt get processed at all by this object (the Spinner Factory) if (this.ClickEventHandler != null) circle.Click += ClickEventHandler; circle.SetCircleAppearance(12, 2, 5, 11); circle.Active = true; circle.Height = 12; circle.Width = 12; circle.Color = ((Color)cell.Data); // We've already checked the type of cell.Data above } return circle; }
/// <summary> /// Compares two cells and returns a value indicating whether one is less /// than, equal to or greater than the other. /// </summary> /// <param name="cell1"></param> /// <param name="cell2"></param> /// <returns></returns> protected override int CompareCells(Cell cell1, Cell cell2) { int retVal = 0; // check for null data if (cell1.Data == null && cell2.Data == null) { retVal = 0; } else if (cell1.Data == null) { retVal = -1; } else if (cell2.Data == null) { retVal = 1; } // since images aren't comparable, if retVal = 0 and the ImageColumn // they belong to allows text drawing, compare the text properties // to determine order if (retVal == 0 && ((ImageColumn) this.TableModel.Table.ColumnModel.Columns[this.SortColumn]).DrawText) { // check for null data if (cell1.Text == null && cell2.Text == null) { return 0; } else if (cell1.Text == null) { return -1; } retVal = cell1.Text.CompareTo(cell2.Text); } return retVal; }
/// <summary> /// Compares two cells and returns a value indicating whether one is less /// than, equal to or greater than the other. /// </summary> /// <param name="cell1"></param> /// <param name="cell2"></param> /// <returns></returns> protected override int CompareCells(Cell cell1, Cell cell2) { string s1 = cell1.Text; string s2 = cell2.Text; // check for null cells if (s1 == null && s2 == null) { return 0; } else if (s1 == null) { return -1; } else if (s2 == null) { return 1; } else { return s1.CompareTo(s2); } }
/// <summary> /// Returns the cell to add to a row for the given value, depending on the type of column it will be /// shown in. /// If the column is a TextColumn then just the Text property is set. For all other /// column types just the Data value is set. /// </summary> /// <param name="column"></param> /// <param name="val"></param> /// <returns></returns> public virtual Cell GetCell(Column column, object val) { Cell cell = null; switch (column.GetType().Name) { case "TextColumn": cell = new Cell(val.ToString()); break; case "CheckBoxColumn": bool check = false; if (val is Boolean) check = (bool)val; cell = new Cell("", check); break; default: cell = new Cell(val); break; } return cell; }
/// <summary> /// Initializes a new instance of the CellMouseEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="cellPos"></param> /// <param name="cellRect">The Cell's bounding rectangle</param> public CellMouseEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect) : base(MouseButtons.None, 0, -1, -1, 0) { this.cell = cell; this.table = table; this.row = cellPos.Row; this.column = cellPos.Column; this.cellRect = cellRect; }
/// <summary> /// Initializes a new instance of the CellMouseEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="cellPos"></param> /// <param name="cellRect">The Cell's bounding rectangle</param> /// <param name="mea"></param> public CellMouseEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, MouseEventArgs mea) : base(mea.Button, mea.Clicks, mea.X, mea.Y, mea.Delta) { this.cell = cell; this.table = table; this.row = cellPos.Row; this.column = cellPos.Column; this.cellRect = cellRect; }
/// <summary> /// Initializes a new instance of the CellMouseEventArgs class with /// the specified source Cell, table, row index, column index and /// cell bounds /// </summary> /// <param name="cell">The Cell that Raised the event</param> /// <param name="table">The Table the Cell belongs to</param> /// <param name="row">The Row index of the Cell</param> /// <param name="column">The Column index of the Cell</param> /// <param name="cellRect">The Cell's bounding rectangle</param> public CellMouseEventArgs(Cell cell, Table table, int row, int column, Rectangle cellRect) : base(MouseButtons.None, 0, -1, -1, 0) { this.cell = cell; this.table = table; this.row = row; this.column = column; this.cellRect = cellRect; }
/// <summary> /// Prepares the CellEditor to edit the specified Cell /// </summary> /// <param name="cell">The Cell to be edited</param> /// <param name="table">The Table that contains the Cell</param> /// <param name="cellPos">A CellPos representing the position of the Cell</param> /// <param name="cellRect">The Rectangle that represents the Cells location and size</param> /// <param name="userSetEditorValues">Specifies whether the ICellEditors /// starting value has already been set by the user</param> /// <returns>true if the ICellEditor can continue editing the Cell, false otherwise</returns> public override bool PrepareForEditing(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, bool userSetEditorValues) { if (!(table.ColumnModel.Columns[cellPos.Column] is DropDownColumn)) { throw new InvalidOperationException("Cannot edit Cell as DropDownCellEditor can only be used with a DropDownColumn"); } return base.PrepareForEditing (cell, table, cellPos, cellRect, userSetEditorValues); }
/// <summary> /// Returns the index of the specified Cell in the model /// </summary> /// <param name="cell">The Cell to look for</param> /// <returns>The index of the specified Cell in the model</returns> public int IndexOf(Cell cell) { for (int i=0; i<this.Count; i++) { if (this[i] == cell) { return i; } } return -1; }
/// <summary> /// Inserts an array of Cells into the collection at the specified index /// </summary> /// <param name="index">The zero-based index at which the cells should be inserted</param> /// <param name="cells">An array of Cells to be inserted into the collection</param> public void InsertRange(int index, Cell[] cells) { if (cells == null) { throw new System.ArgumentNullException("Cell[] is null"); } if (index < 0) { throw new IndexOutOfRangeException(); } if (index >= this.Count) { this.AddRange(cells); } else { for (int i=cells.Length-1; i>=0; i--) { this.Insert(index, cells[i]); } } }
/// <summary> /// Inserts a Cell into the collection at the specified index /// </summary> /// <param name="index">The zero-based index at which the Cell /// should be inserted</param> /// <param name="cell">The Cell to insert</param> public void Insert(int index, Cell cell) { if (cell == null) { return; } if (index < 0) { throw new IndexOutOfRangeException(); } if (index >= this.Count) { this.Add(cell); } else { base.List.Insert(index, cell); this.OnCellAdded(new RowEventArgs(this.owner, cell, index, index)); } }
/// <summary> /// Removes an array of Cell objects from the collection /// </summary> /// <param name="cells">An array of Cell objects to remove /// from the collection</param> public void RemoveRange(Cell[] cells) { if (cells == null) { throw new System.ArgumentNullException("Cell[] is null"); } for (int i=0; i<cells.Length; i++) { this.Remove(cells[i]); } }
/// <summary> /// Removes the specified Cell from the model /// </summary> /// <param name="cell">The Cell to remove</param> public void Remove(Cell cell) { int cellIndex = this.IndexOf(cell); if (cellIndex != -1) { this.RemoveAt(cellIndex); } }
/// <summary> /// Parses the CSS. /// </summary> /// <param name="css">The CSS.</param> /// <remarks>Documented by Dev03, 2008-03-05</remarks> private void ParseCSS(string css) { // ignore comments when parsing css Regex stripComments = new Regex(@"/\*(.|\n)*?\*/", RegexOptions.Multiline); css = stripComments.Replace(css, String.Empty); string[] elements = css.Split(new char[] { '{', '}' }); xslElements = new List <XSLStyleElement>(); for (int i = 0; i < elements.Length - 1; i++) { XSLStyleElement element = new XSLStyleElement(); element.Name = elements[i].Trim(); i++; string subElements = elements[i].Trim(); Regex whitespace = new Regex("[\n\r\t]"); subElements = whitespace.Replace(subElements, String.Empty); string[] pairs = subElements.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string pair in pairs) { string[] parts = pair.Split(new char[] { ':' }, 2); element.Items[parts[0].ToLower().Trim()] = parts[1].Trim(); } // end parsing xslElements.Add(element); } tableXSL.TableModel.Rows.Clear(); foreach (XSLStyleElement element in xslElements) { tableXSL.TableModel.Rows.Add(new XPTable.Models.Row(new string[] { element.Name.StartsWith(".") ? element.Name.Substring(1) : element.Name })); Cell colorCell; if (element.Items.ContainsKey("color")) { int colorValue; if (Int32.TryParse(element.Items["color"].Substring(1, 6), System.Globalization.NumberStyles.AllowHexSpecifier, null, out colorValue)) { colorCell = new XPTable.Models.Cell(Color.FromArgb(255, Color.FromArgb(colorValue))); } else { colorCell = new XPTable.Models.Cell(Color.Empty); } } else { colorCell = new XPTable.Models.Cell(Color.Empty); } colorCell.PropertyChanged += new XPTable.Events.CellEventHandler(XSLStyleEdit_PropertyChanged); colorCell.Tag = element; colorCell.ToolTipText = "color"; tableXSL.TableModel.Rows[tableXSL.TableModel.Rows.Count - 1].Cells.Add(colorCell); Cell backgroundColorCell; if (element.Items.ContainsKey("background-color")) { int colorValue; if (Int32.TryParse(element.Items["background-color"].Substring(1, 6), System.Globalization.NumberStyles.AllowHexSpecifier, null, out colorValue)) { backgroundColorCell = new XPTable.Models.Cell(Color.FromArgb(255, Color.FromArgb(colorValue))); } else { backgroundColorCell = new XPTable.Models.Cell(Color.Empty); } } else { backgroundColorCell = new XPTable.Models.Cell(Color.Empty); } backgroundColorCell.PropertyChanged += new XPTable.Events.CellEventHandler(XSLStyleEdit_PropertyChanged); backgroundColorCell.Tag = element; backgroundColorCell.ToolTipText = "background-color"; tableXSL.TableModel.Rows[tableXSL.TableModel.Rows.Count - 1].Cells.Add(backgroundColorCell); Cell cellToAdd = new XPTable.Models.Cell(Properties.Resources.STYLEEDIT_SELECTFONTBUTTON); cellToAdd.PropertyChanged += new XPTable.Events.CellEventHandler(XSLStyleEdit_PropertyChanged); cellToAdd.Tag = element; cellToAdd.ToolTipText = "font"; tableXSL.TableModel.Rows[tableXSL.TableModel.Rows.Count - 1].Cells.Add(cellToAdd); cellToAdd = new XPTable.Models.Cell(); cellToAdd.PropertyChanged += new XPTable.Events.CellEventHandler(XSLStyleEdit_PropertyChanged); cellToAdd.Tag = element; cellToAdd.ToolTipText = "HAlign"; tableXSL.TableModel.Rows[tableXSL.TableModel.Rows.Count - 1].Cells.Add(cellToAdd); EnumLocalizer hNone = new EnumLocalizer(Properties.Resources.ResourceManager, MLifter.DAL.Interfaces.HorizontalAlignment.None); if (element.Items.ContainsKey("text-align")) { EnumLocalizer textAlign = horizontalElements.Find(delegate(EnumLocalizer loc) { return(loc.value.ToString().Equals(element.Items["text-align"], StringComparison.InvariantCultureIgnoreCase)); }); cellToAdd.Text = (textAlign != null) ? textAlign.ToString() : hNone.ToString(); } else if (element.Items.ContainsKey("float")) { cellToAdd.Text = element.Items["float"]; cellToAdd.ToolTipText = "float"; } else { cellToAdd.Text = hNone.ToString(); } cellToAdd = new XPTable.Models.Cell(); cellToAdd.PropertyChanged += new XPTable.Events.CellEventHandler(XSLStyleEdit_PropertyChanged); cellToAdd.Tag = element; cellToAdd.ToolTipText = "VAlign"; tableXSL.TableModel.Rows[tableXSL.TableModel.Rows.Count - 1].Cells.Add(cellToAdd); EnumLocalizer vNone = new EnumLocalizer(Properties.Resources.ResourceManager, MLifter.DAL.Interfaces.VerticalAlignment.None); if (element.Items.ContainsKey("vertical-align")) { EnumLocalizer verticalAlign = verticalElements.Find(delegate(EnumLocalizer loc) { return(loc.value.ToString().Equals(element.Items["vertical-align"], StringComparison.InvariantCultureIgnoreCase)); }); cellToAdd.Text = (verticalAlign != null) ? verticalAlign.ToString() : vNone.ToString(); } else { cellToAdd.Text = vNone.ToString(); } } SaveFile(); }
void table_MouseClick(object sender, MouseEventArgs ev) { int rindex = table.RowIndexAt(ev.X, ev.Y); if (rindex < 0) { return; } if (rindex >= table.TableModel.Rows.Count) { return; } XPTable.Models.Row row = table.TableModel.Rows[rindex]; if (row.Parent != null) { return; } LogEvent e = row.Tag as LogEvent; if (row.SubRows.Count > 0) { int index = row.Index + 1; while (true) { if (table.TableModel.Rows.Count <= index) { break; } XPTable.Models.Row xrow = table.TableModel.Rows[index]; if (xrow.ChildIndex == 0) { break; } table.TableModel.Rows.Remove(xrow); } row.SubRows.Clear(); } else { foreach (Pair <Bitmap, string> line in e.lines) { XPTable.Models.Row subrow = new XPTable.Models.Row(); XPTable.Models.Cell subcell1 = new XPTable.Models.Cell(); XPTable.Models.CellStyle subcellStyle1 = new XPTable.Models.CellStyle(); XPTable.Models.Cell subcell2 = new XPTable.Models.Cell(); XPTable.Models.CellStyle subcellStyle2 = new XPTable.Models.CellStyle(); subcell2.Image = line.First; subcell2.Text = line.Second; subcell2.ColSpan = 2; subcell2.ForeColor = Color.Gray; subrow.Cells.Add(subcell1); subrow.Cells.Add(subcell2); subrow.Editable = false; row.SubRows.Add(subrow); } } }