protected void re_Init(object sender, EventArgs e) { ASPxRichEdit richEdit = sender as ASPxRichEdit; GridViewEditItemTemplateContainer container = richEdit.NamingContainer as GridViewEditItemTemplateContainer; string documentID = GetDocumentID(container.Grid); if (!OpenedCanceledDocumentIDs.Contains(documentID)) { OpenedCanceledDocumentIDs.Add(documentID); } if (container.Grid.IsNewRowEditing) { richEdit.DocumentId = documentID; return; } //for text in db string rtfText = container.Grid.GetRowValues(container.VisibleIndex, "RtfContent").ToString(); //for binary in db //byte[] rtfBinary = (byte[])container.Grid.GetRowValues(container.VisibleIndex, "RtfContent"); richEdit.Open(documentID, DocumentFormat.Rtf, () => { //for text in db return(Encoding.UTF8.GetBytes(rtfText)); //for binary in db //return rtfBinary; }); }
private Guid OpenDocumentID(string documentID) { var unitOfWork = new DocumentsUnitOfWork(); var documentItem = unitOfWork.ItemRepository.GetByID(long.Parse(documentID)); var documentItemInfo = new DocumentItemInfo(documentItem); var editorType = documentItemInfo.DocumentProcessorType; OfficeWorkSessionControl editor = null; if (editorType == OfficeDocumentProcessorType.Spreadsheet) { var spreadsheetControl = new ASPxSpreadsheet(); spreadsheetControl.Open( documentItemInfo.Id, (DevExpress.Spreadsheet.DocumentFormat)DocumentFormatUtils.GetDocumentFormat(documentItemInfo.NameExtension), () => documentItem.Content.Data); editor = spreadsheetControl; } if (editorType == OfficeDocumentProcessorType.RichEdit) { var richEditControl = new ASPxRichEdit(); richEditControl.Open( documentItemInfo.Id, (DevExpress.XtraRichEdit.DocumentFormat)DocumentFormatUtils.GetDocumentFormat(documentItemInfo.NameExtension), () => documentItem.Content.Data); editor = richEditControl; } return(editor.GetWorkSessionID()); }
protected void ASPxRichEdit1_Init(object sender, EventArgs e) { ASPxRichEdit richEdit = (ASPxRichEdit)sender; //Disable Horizontal Ruler richEdit.Settings.HorizontalRuler.Visibility = RichEditRulerVisibility.Hidden; }
private void OpenWordFile(string fileFullPath) { ASPxRichEdit richEdit = new ASPxRichEdit(); richEdit.ID = "richEdit"; ASPxPopupControl1.Controls.Add(richEdit); richEdit.Open(fileFullPath); }
protected void ASPxRichEdit1_Init(object sender, EventArgs e) { ASPxRichEdit richEdit = (ASPxRichEdit)sender; richEdit.CreateDefaultRibbonTabs(true); //Hide Mail Merge Tab richEdit.RibbonTabs.Find(tab => tab.Text == "Mail Merge").Visible = false; //Hide Page Layout Tab richEdit.RibbonTabs.Find(tab => tab.Text == "Page Layout").Visible = false; //Hide File Tab richEdit.RibbonTabs.Find(tab => tab.Text == "File").Visible = false; //Hide Group Buttons by Name richEdit.RibbonTabs.Find(tab => tab.Text == "Insert").Groups.Find(group => group.Text == "Pages").Visible = false; richEdit.RibbonTabs.Find(tab => tab.Text == "Insert").Groups.Find(group => group.Text == "Illustrations").Visible = false; richEdit.RibbonTabs.Find(tab => tab.Text == "Insert").Groups.Find(group => group.Text == "Header & Footer").Visible = false; //richEdit.RibbonTabs.Find(tab => tab.Text == "Page Layout").Groups.Find(group => group.Text == "Background").Visible = false; //richEdit.RibbonTabs.Find(tab => tab.Text == "Page Layout").Groups.Find(group => group.Text == "Page Setup").Visible = false; //Hide Page Layout Buttons by Name Id it is not working well //richEdit.RibbonTabs.Find(tab => tab.Text == "Page Layout").Groups.Find(group => group.Text == "Page Setup").Items[0].Visible = false; //richEdit.RibbonTabs.Find(tab => tab.Text == "Page Layout").Groups.Find(group => group.Text == "Page Setup").Items[1].Visible = false; //richEdit.RibbonTabs.Find(tab => tab.Text == "Page Layout").Groups.Find(group => group.Text == "Page Setup").Items[2].Visible = false; //richEdit.RibbonTabs.Find(tab => tab.Text == "Page Layout").Groups.Find(group => group.Text == "Page Setup").Items[3].Visible = false; //Hide Page Layout Buttons by Index Id it is not working well //richEdit.RibbonTabs[3].Groups[1].Items[0].Visible = false; //richEdit.RibbonTabs[3].Groups[0].Items[0].Visible = false; //richEdit.RibbonTabs[3].Groups[0].Items[1].Visible = false; //richEdit.RibbonTabs[3].Groups[0].Items[2].Visible = false; //richEdit.RibbonTabs[3].Groups[0].Items[3].Visible = false; //Disable Header and Footer //richEdit.Settings.DocumentCapabilities.HeadersFooters = DevExpress.XtraRichEdit.DocumentCapability.Disabled; //Hide Bookmark richEdit.Settings.DocumentCapabilities.Bookmarks = DevExpress.XtraRichEdit.DocumentCapability.Hidden; //Hide Hyperlink richEdit.Settings.DocumentCapabilities.Hyperlinks = DevExpress.XtraRichEdit.DocumentCapability.Hidden; //Hide buttons richEdit.Settings.Behavior.SaveAs = DevExpress.XtraRichEdit.DocumentCapability.Hidden; richEdit.Settings.Behavior.Open = DevExpress.XtraRichEdit.DocumentCapability.Hidden; richEdit.Settings.Behavior.CreateNew = DevExpress.XtraRichEdit.DocumentCapability.Hidden; // Show Confirmation Message richEdit.ShowConfirmOnLosingChanges = false; // Definitions Page //RichEditDocumentServer server = new RichEditDocumentServer(); //server.Document.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.A4; }
public static void HideFileTab(ASPxRichEdit richEdit) { richEdit.CreateDefaultRibbonTabs(true); richEdit.RibbonTabs.RemoveAt(0); RERFileCommonGroup gr = new RERFileCommonGroup(); gr.Items.Add(new RERSaveCommand()); gr.Items.Add(new RERPrintCommand()); richEdit.RibbonTabs[0].Groups.Insert(0, gr); richEdit.ActiveTabIndex = 0; }
private void ProcessDocument(ASPxGridView grid, OrderedDictionary newValues) { ASPxRichEdit richEdit = GetRichEdit(grid); //for text in db newValues["RtfContent"] = Encoding.UTF8.GetString(richEdit.SaveCopy(DocumentFormat.Rtf)); //for binary in db //newValues["RtfContent"] = richEdit.SaveCopy(DocumentFormat.Rtf); throw new CustomCallbackException("Data modifications are not allowed in online demos"); //Note that data modifications are not allowed in online demos. To allow editing in local/offline mode, download the example and comment out the "throw..." operation in the ASPxGridView.RowUpdating event handler. OpenedCanceledDocumentIDs.Remove(richEdit.DocumentId); DocumentManager.CloseDocument(richEdit.DocumentId); }
protected void reNotes_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) { string[] parameters = e.Parameter.Split('|'); if (parameters[0] == "open") { if (parameters.Length > 2) { OpenNote(decimal.Parse(parameters[1]), parameters[2].Trim()); } else { OpenNote(decimal.Parse(parameters[1]), "A"); } } else { ASPxRichEdit rich = sender as ASPxRichEdit; using (MemoryStream ms = new MemoryStream()) { rich.SaveCopy(ms, DocumentFormat.Html); ms.Position = 0; decimal protocolversion = decimal.Parse(txtProtocolVersion.Text); string user = Request.Cookies["UserSettings"]["UserCKey"].ToString(); // Session["userckey"].ToString(); int index = lstTags.SelectedIndex; string tag = lstTags.Items[index].Text.Trim(); if (tag == "-- New --") { //generate new tag tag = ""; } Note note = new Note(); note.saveNote(protocolversion, decimal.Parse(user), tag, txtNoteTitle.Text, ms); lstTags.DataSource = note.getTags(protocolversion); } } }
protected void pageControlDetails_Load(object sender, EventArgs e) { if (Session["fileNameToDownload"] != null) { string fileURL = Session["fileNameToDownload"].ToString().Split('|')[0]; string FileExtn = Session["fileNameToDownload"].ToString().Split('|')[1]; string fileName = Session["fileNameToDownload"].ToString().Split('|')[2]; string storageFileName = Session["fileNameToDownload"].ToString().Split('|')[3]; ASPxPageControl pageControlDetails = (ASPxPageControl)sender; //HtmlGenericControl documentDownloadLink = (HtmlGenericControl)pageControlDetails.FindControl("previewNotAvailableText"); //documentDownloadLink.Visible = true; //documentDownloadLink.InnerHtml = "<a href=\"" + fileURL + "\" download=\"" + fileName + "\">Download File</a>"; if (FileExtn == ".txt") { ASPxRichEdit richEditPreview = (ASPxRichEdit)pageControlDetails.FindControl("richDetailsPreview"); richEditPreview.Visible = true; //richEditPreview.Open(Path.GetTempPath() + "\\" + fileURL); richEditPreview.Open(Guid.NewGuid().ToString(), DevExpress.XtraRichEdit.DocumentFormat.PlainText, () => { byte[] fileData = null; using (var wc = new System.Net.WebClient()) fileData = wc.DownloadData(fileURL); return(new MemoryStream(fileData)); }); } else if (FileExtn == ".doc") { ASPxRichEdit richEditPreview = (ASPxRichEdit)pageControlDetails.FindControl("richDetailsPreview"); richEditPreview.Visible = true; //richEditPreview.Open(Path.GetTempPath() + "\\" + fileURL); richEditPreview.Open(Guid.NewGuid().ToString(), DevExpress.XtraRichEdit.DocumentFormat.Doc, () => { byte[] fileData = null; using (var wc = new System.Net.WebClient()) fileData = wc.DownloadData(fileURL); return(new MemoryStream(fileData)); }); } else if (FileExtn == ".docx") { ASPxRichEdit richEditPreview = (ASPxRichEdit)pageControlDetails.FindControl("richDetailsPreview"); richEditPreview.Visible = true; //richEditPreview.Open(Path.GetTempPath() + "\\" + fileURL); richEditPreview.Open(Guid.NewGuid().ToString(), DevExpress.XtraRichEdit.DocumentFormat.OpenXml, () => { byte[] fileData = null; using (var wc = new System.Net.WebClient()) fileData = wc.DownloadData(fileURL); return(new MemoryStream(fileData)); }); } else if (FileExtn == ".xls") { DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet spreadSheetPreview = (ASPxSpreadsheet)pageControlDetails.FindControl("spreadSheetPreview"); spreadSheetPreview.Visible = true; MemoryStream stream = new MemoryStream(); spreadSheetPreview.Open(Guid.NewGuid().ToString(), DevExpress.Spreadsheet.DocumentFormat.Xls, () => { byte[] fileData = null; using (var wc = new System.Net.WebClient()) fileData = wc.DownloadData(fileURL); return(new MemoryStream(fileData)); }); //spreadSheetPreview. } else if (FileExtn == ".xlsx") { DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet spreadSheetPreview = (ASPxSpreadsheet)pageControlDetails.FindControl("spreadSheetPreview"); spreadSheetPreview.Visible = true; MemoryStream stream = new MemoryStream(); spreadSheetPreview.Open(Guid.NewGuid().ToString(), DevExpress.Spreadsheet.DocumentFormat.Xlsx, () => { byte[] fileData = null; using (var wc = new System.Net.WebClient()) fileData = wc.DownloadData(fileURL); return(new MemoryStream(fileData)); }); //spreadSheetPreview. } else if (FileExtn == ".pdf") { HtmlGenericControl pdfPreview = (HtmlGenericControl)pageControlDetails.FindControl("pdfPreview"); pdfPreview.Visible = true; using (var client = new System.Net.WebClient()) { client.DownloadFile(fileURL, Server.MapPath("~/TempFiles") + "/" + fileName); } //pdfPreview.InnerHtml = "<embed src = \""+ Path.GetTempPath() + "\\" + fileURL+"\" />"; pdfPreview.InnerHtml = "<iframe src=\"" + "../TempFiles" + "/" + fileName + "\" style = \"width:100%; height:500px;\" frameborder = \"0\" ></iframe> "; //pdfPreview.InnerHtml = "<iframe src = \"" + fileURL + "\" style = \"width:600px; height:500px;\" frameborder = \"0\"></iframe>"; } else if (FileExtn == ".jpg" || FileExtn == ".jpeg") { HtmlGenericControl imgPreview = (HtmlGenericControl)pageControlDetails.FindControl("pdfPreview"); imgPreview.Visible = true; imgPreview.InnerHtml = "<img class=\"preview\" src = \"" + fileURL + "\">"; } else { HtmlGenericControl previewNotAvailableText = (HtmlGenericControl)pageControlDetails.FindControl("documentDownloadLink"); previewNotAvailableText.Visible = true; previewNotAvailableText.InnerHtml = "<h1>Preview Not Available</h1>"; } } }
public static void HideFileTab(ASPxRichEdit richedit) { richedit.CreateDefaultRibbonTabs(true); RemoveRibbonTab(richedit.RibbonTabs, typeof(RERFileTab)); richedit.ActiveTabIndex = 0; }