private void tscmbZoom_SelectedIndexChanged(object sender, EventArgs e) { if (this.MdiChildren.Length == 0) { return; } RichTextBoxPrintCtrl rtf = ((FormEditor)ActiveMdiChild).rtfEditor; switch (tscmbZoom.SelectedIndex) { case 0: rtf.ZoomFactor = (float)0.50; break; case 1: rtf.ZoomFactor = (float)0.75; break; case 2: rtf.ZoomFactor = (float)1; break; case 3: rtf.ZoomFactor = (float)1.25; break; case 4: rtf.ZoomFactor = (float)1.5; break; } }
public LetterView() { InitializeComponent(); mTempTextControl = new RichTextBoxPrintCtrl(); m_printdlg = new PrintLetterDialog(); stopPrintButton.Enabled = false; MaxCountTextBox.Text = m_printdlg.MaxCount.ToString(); }
private void setTextForRich(RichTextBoxPrintCtrl obj, string question) { if (question != null && question.Contains("\\rtf1\\ansi")) { obj.Rtf = question; } else if (question != null && question.Length > 0) { obj.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang16393{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs20" + question + @"}"; } }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { RichTextBoxPrintCtrl rtf = ((FormEditor)ActiveMdiChild).rtfEditor; checkPrint = rtf.Print(checkPrint, rtf.TextLength, e); if (checkPrint < rtf.TextLength) { e.HasMorePages = true; } else { e.HasMorePages = false; } }
private void tscmbFontName_SelectedIndexChanged(object sender, EventArgs e) { if (this.MdiChildren.Length == 0) { return; } if (tscmbFontName.SelectedItem != null) { try { RichTextBoxPrintCtrl rtf = ((FormEditor)ActiveMdiChild).rtfEditor; rtf.SelectionFont = new Font(tscmbFontName.SelectedItem.ToString(), rtf.SelectionFont.Size); } catch { } } }
private void setTextForRich(RichTextBoxPrintCtrl obj, string question) { // obj.Visible = true; //if (question == null || question == "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}}\n\\viewkind4\\uc1\\pard\\f0\\fs17\\par\n}\n") //{ // obj.Visible = false; //else if (question != null && Utility.Base64Decode(question).Contains("\\rtf1\\ansi")) { obj.Rtf = Utility.Base64Decode(question); } else if (question != null && question.Length > 0) { obj.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang16393{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs20" + question + @"}"; } // if (obj.TextLength == 0) // obj.Visible = false; }
// overloaded constructor accepteing main form as // an argument public frmFindReplace(RichTextBoxPrintCtrl f) { InitializeComponent(); _rtbDoc = f; }
public string prepararTexto(string idDocumento, string appPath) { if (!idDocumento.StartsWith(classId + "_")) { return(""); } int id = int.Parse(idDocumento.Replace(classId + "_", "")); try { Dictionary <string, CamposImpresion> camposImpresionPorCodigo; Dictionary <string, CamposImpresion> camposImpresionPorCampo = obtenerCamposImpresion(out camposImpresionPorCodigo); if (camposImpresionPorCodigo == null || camposImpresionPorCampo == null) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion", "prepararTexto(int)", 0, "No puedo imprimir un documento si no hay campos definidos. Id: " + id, "", "", true, LogManager.EMensaje.Advertencia, ""); Notify(m); return(""); } Dictionary <string, string> valEnc = obtenerValoresEncabezado(camposImpresionPorCampo, id); if (valEnc == null) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion", "prepararTexto(int)", 0, "No puedo imprimir un documento si no hay valores de encabezado. Id: " + id, "", "", true, LogManager.EMensaje.Advertencia, ""); Notify(m); return(""); } List <Dictionary <string, string> > valItems = obtenerValoresItems(camposImpresionPorCampo, id); if (valItems == null) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion", "prepararTexto(int)", 0, "No puedo imprimir un documento si no hay valores de items. Id: " + id, "", "", true, LogManager.EMensaje.Advertencia, ""); Notify(m); return(""); } RichTextBoxPrintCtrl richTextBoxPrintCtrl = new RichTextBoxPrintCtrl(); richTextBoxPrintCtrl.LoadFile(appPath + @"\Templates\1.rtf"); string texto = richTextBoxPrintCtrl.Rtf; int position = 0, posicionAnterior = 0; while (texto.IndexOf('#') > 0) { position = texto.IndexOf('#'); int indiceCambioRegistroItem = texto.Substring(posicionAnterior, position - posicionAnterior).IndexOf('~'); if (indiceCambioRegistroItem > 0) { StringBuilder sb = new StringBuilder(texto); sb[posicionAnterior + indiceCambioRegistroItem] = ' '; texto = sb.ToString(); if (valItems.Count > 0) { valItems.RemoveAt(0); } } if (position < 0) { break; } int nPos = position + 2; while (true) { char caracter = texto.Substring(nPos, 1)[0]; if (caracter == '-' || caracter == '(' || caracter == ')' || ((int)caracter > 47 && (int)caracter < 58)) { nPos++; } else { break; } } string variable = texto.Substring(position + 1, nPos - position - 1).Trim(); string textoReemplazo = ""; if (!valEnc.TryGetValue(variable.Replace("-", "").Replace("(", "").Replace(")", "").ToUpper(), out textoReemplazo)) { if (valItems.Count > 0) { valItems[0].TryGetValue(variable.Replace("-", "").Replace("(", "").Replace(")", "").ToUpper(), out textoReemplazo); } } if (textoReemplazo == null) { textoReemplazo = ""; } CamposImpresion myValue = camposImpresionPorCodigo[variable.Replace("-", "").Replace("(", "").Replace(")", "").ToUpper()]; switch (myValue.AlineaciĆ³n) { case "D": textoReemplazo = textoReemplazo.PadLeft(nPos - position, ' '); break; case "I": textoReemplazo = textoReemplazo.PadRight(nPos - position, ' '); break; case "C": textoReemplazo = centrarCadena(textoReemplazo, nPos - position); break; default: textoReemplazo = textoReemplazo.PadLeft(nPos - position, ' '); break; } texto = texto.Substring(0, position) + textoReemplazo + texto.Substring(nPos, texto.Length - nPos); posicionAnterior = position + textoReemplazo.Length; } return(texto); } catch (Exception ex) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion", "prepararTexto(int)", 0, "Error al intentar preparar el documento a imprimir. Id: " + id, ex.Message, "", true, LogManager.EMensaje.Critico, ex.StackTrace); Notify(m); return(""); } }