private void btnSetConditions_Click(object sender, EventArgs e) { // create a new dialog form frmCellFormat frmCellFormat = new frmCellFormat(); // check, if there are existing filter instructions CellFilterInstructions cellFilterInstructions = (CellFilterInstructions)JsonConvert.DeserializeObject( textControl1.Tables.GetItem().Cells.GetItem().Name, typeof(CellFilterInstructions)); if (cellFilterInstructions == null) { // create new instructions Color cCellBackColor = textControl1.Tables.GetItem().Cells.GetItem().CellFormat.BackColor; cellFilterInstructions = new CellFilterInstructions() { TrueColor = cCellBackColor, FalseColor = cCellBackColor }; } // show the form frmCellFormat.CellFilterInstructions = cellFilterInstructions; if (frmCellFormat.ShowDialog() == DialogResult.OK) { // save the instructions in the Name property textControl1.Tables.GetItem().Cells.GetItem().Name = JsonConvert.SerializeObject(frmCellFormat.CellFilterInstructions); } }
private void MailMerge_FieldMerged(object sender, TXTextControl.DocumentServer.MailMerge.FieldMergedEventArgs e) { // custom field handling if (e.TableCell == null) { return; } // if TableCell.Name has instructions, create a CellFilterInstructions object // and evaluate the instructions and set the table cell color if (e.TableCell.Name != "") { CellFilterInstructions instructions = (CellFilterInstructions)JsonConvert.DeserializeObject(e.TableCell.Name, typeof(CellFilterInstructions)); // retrieve the color Color?color = instructions.GetColor(e.MailMergeFieldAdapter.ApplicationField.Text); // apply the color if (color != null) { e.TableCell.CellFormat.BackColor = (Color)color; } } }
private void btnReset_Click(object sender, EventArgs e) { m_CellFilterInstructions = new CellFilterInstructions(); UpdateControls(); }