Esempio n. 1
0
 protected void ASPxRichEdit1_Callback(object sender, CallbackEventArgsBase e)
 {
     if (FileManager.SelectedFile != null)
     {
         ASPxRichEdit1.Open(Server.MapPath(FileManager.SelectedFile.FullName));
     }
 }
Esempio n. 2
0
    protected void PopupWithDocument_WindowCallback(object source, DevExpress.Web.PopupWindowCallbackArgs e)
    {
        String fullFileName = e.Parameter;

        object format = DocumentFormatHelper.GetFormat(fullFileName);

        if (format == null)
        {
            return;
        }

        Boolean isSpreadsheet = format is DevExpress.Spreadsheet.DocumentFormat;

        ASPxSpreadsheet1.Visible = isSpreadsheet;
        ASPxRichEdit1.Visible    = !isSpreadsheet;

        var docId   = Guid.NewGuid().ToString();
        var docPath = Server.MapPath(fullFileName);

        if (isSpreadsheet)
        {
            ASPxSpreadsheet1.Open(docId, (DevExpress.Spreadsheet.DocumentFormat)format, () => File.ReadAllBytes(docPath));
        }
        else
        {
            ASPxRichEdit1.Open(docId, (DevExpress.XtraRichEdit.DocumentFormat)format, () => File.ReadAllBytes(docPath));
        }
    }
Esempio n. 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DocumentManager.CloseAllDocuments();
         ASPxRichEdit1.Open(Server.MapPath("TextWithImages.rtf"));
     }
 }
    protected void ASPxRichEdit1_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
    {
        DocumentManager.CloseDocument("testID");
        MemoryStream           stream = new MemoryStream();
        RichEditDocumentServer server = new RichEditDocumentServer();

        server.LoadDocument(System.Web.HttpContext.Current.Server.MapPath("Doc 1.docx"), DocumentFormat.OpenXml);
        server.Document.AppendDocumentContent(System.Web.HttpContext.Current.Server.MapPath("Doc 2.docx"), DocumentFormat.OpenXml);
        server.SaveDocument(stream, DocumentFormat.OpenXml);
        stream.Position = 0;
        ASPxRichEdit1.Open("testID", DevExpress.XtraRichEdit.DocumentFormat.OpenXml, () => { return(stream); });
    }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dt = LoadFromDB();

            ASPxRichEdit1.Open(dt.Rows[0]["QuestionID"].ToString(), DocumentFormat.Rtf, () => (byte[])dt.Rows[0]["Question"]);

            ASPxRichEditA.Open(dt.Rows[0]["QuestionID"] + "_A1", DocumentFormat.Rtf, () => (byte[])dt.Rows[0]["Answer1"]);

            ASPxRichEditB.Open(dt.Rows[0]["QuestionID"] + "_A2", DocumentFormat.Rtf, () => (byte[])dt.Rows[0]["Answer2"]);

            ASPxRichEditC.Open(dt.Rows[0]["QuestionID"] + "_A3", DocumentFormat.Rtf, () => (byte[])dt.Rows[0]["Answer3"]);

            ASPxRichEditD.Open(dt.Rows[0]["QuestionID"] + "_A4", DocumentFormat.Rtf, () => (byte[])dt.Rows[0]["Answer4"]);
        }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ASPxRichEdit1.CreateDefaultRibbonTabs(true);
        ASPxRichEdit1.RibbonTabs[0].Groups[0].Items.RemoveAt(1);
        var openItem = new RibbonButtonItem("Open");

        openItem.LargeImage.IconID = IconID.ActionsOpen32x32;
        openItem.Size = RibbonItemSize.Large;
        ASPxRichEdit1.RibbonTabs[0].Groups[0].Items.Add(openItem);

        if (!IsPostBack)
        {
            FileManagerFile file = FileManager.SelectedFolder.GetFiles().FirstOrDefault();
            if (file != null)
            {
                FileManager.SelectedFile = file;
                ASPxRichEdit1.Open(Server.MapPath(file.FullName));
            }
        }
    }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsCallback && !IsPostBack)
            {
                HiddenInvoiceId.Value = Request.Params["OrderID"];

                var arrayInvoice = new ArrayList();

                using (SqlConnection con = new SqlConnection(conStr))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = con;

                        cmd.CommandText = @"select i.InvoiceID, i.OrderID, i.InvoiceRtf 
                                            from Invoices i                                                             
                                            where i.OrderID = " + HiddenInvoiceId.Value + " order by i.InvoiceID desc";

                        con.Open();
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            arrayInvoice.Add(reader["InvoiceID"]);
                            arrayInvoice.Add(reader["OrderID"]);
                            arrayInvoice.Add(reader["InvoiceRtf"]);
                        }

                        reader.Close();
                        con.Close();
                    }
                }

                if (arrayInvoice.Count > 0)
                {
                    MemoryStream rtfStream = new MemoryStream((byte[])arrayInvoice[2]);
                    ASPxRichEdit1.Open("rtf" + Guid.NewGuid().ToString(), DocumentFormat.Rtf, () => { return(rtfStream.ToArray()); });
                }
            }
        }
Esempio n. 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ASPxRichEdit1.Open(Server.MapPath("CharacterFormatting.rtf"));
        }

        ASPxRichEdit1.CreateDefaultRibbonTabs(true);

        var copyItem = new RibbonButtonItem("Copy format");

        copyItem.LargeImage.IconID = "edit_copy_32x32office2013";
        copyItem.Size = RibbonItemSize.Large;
        ASPxRichEdit1.RibbonTabs[1].Groups[1].Items.Add(copyItem);

        var pasteItem = new RibbonButtonItem("Paste format");

        pasteItem.LargeImage.IconID = "edit_paste_32x32office2013";
        pasteItem.Size = RibbonItemSize.Large;
        ASPxRichEdit1.RibbonTabs[1].Groups[1].Items.Add(pasteItem);
    }
    protected void ASPxRichEdit1_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
    {
        MemoryStream memoryStream = new MemoryStream();

        ASPxRichEdit1.SaveCopy(memoryStream, DocumentFormat.Rtf);
        memoryStream.Position = 0;

        var server = new RichEditDocumentServer();

        server.LoadDocument(memoryStream, DocumentFormat.Rtf);
        var pos = server.Document.CreatePosition(Convert.ToInt32(e.Parameter));

        server.Document.InsertRtfText(pos, rtf);

        memoryStream = new MemoryStream();
        server.SaveDocument(memoryStream, DocumentFormat.Rtf);
        ASPxRichEdit1.Open(Guid.NewGuid().ToString(), DocumentFormat.Rtf, () =>
        {
            return(memoryStream.ToArray());
        });
    }
Esempio n. 10
0
        private void initFuncMode()
        {
            FMode = getMode();
            HELPER.CWebPage.ResetPanel(pnEdit);
            if (FMode == CGlobal.FunctionMode.AddMode || FMode == CGlobal.FunctionMode.EditMode)
            {
                pnMain.Visible = false;
                pnEdit.Visible = true;
                validateInitTableTestCase();
                initTableTestCase();

                if (FMode == CGlobal.FunctionMode.EditMode)
                {
                    btnEditTestCases.Visible = true;
                    DataTable dt = obj.LoadByID(getHdf(hdfID));
                    HELPER.CWebPage.BindPanel(pnEdit, dt);
                    try
                    {
                        ASPxRichEdit1.Open(
                            Server.MapPath(CConstant.C_WORK_DIRECTORY_PROBLEMS + txtURL_Content.Text)
                            );
                    }
                    catch (Exception)
                    {
                        HELPER.Client.Alert(this, "Không tìm thấy file nội dung!");
                    }
                }
                else // add mode
                {
                    btnEditTestCases.Visible = false;
                }
            }
            else if (FMode == CGlobal.FunctionMode.CloseMode || FMode == CGlobal.FunctionMode.SearchMode)
            {
                //pnMain.Visible = true;
                //pnEdit.Visible = false;
                //pnTestCase.Visible = false;
                Response.Redirect(Request.RawUrl);
            }
        }
Esempio n. 11
0
    private void NewDocument()
    {
        RichEditDocumentServer server = new RichEditDocumentServer();

        server.Document.Sections[0].Page.Landscape = false;
        server.Document.Unit = DevExpress.Office.DocumentUnit.Millimeter;
        server.Document.Sections[0].Margins.Left   = 0.5f;
        server.Document.Sections[0].Margins.Right  = 0.5f;
        server.Document.Sections[0].Margins.Top    = 0.5f;
        server.Document.Sections[0].Margins.Bottom = 0.5f;

        server.Document.DefaultCharacterProperties.FontName  = "Arial";
        server.Document.DefaultCharacterProperties.FontSize  = 12f;
        server.Document.DefaultCharacterProperties.ForeColor = Color.Red;

        server.Document.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.Custom;
        server.Document.Sections[0].Page.Width     = 105f;
        server.Document.Sections[0].Page.Height    = 297f;

        MemoryStream memoryStream = new MemoryStream();

        server.SaveDocument(memoryStream, DocumentFormat.Rtf);
        ASPxRichEdit1.Open("document" + Guid.NewGuid().ToString(), DocumentFormat.Rtf, () => { return(memoryStream.ToArray()); });
    }
Esempio n. 12
0
        private void initForm()
        {
            long problemsInContest = getQueryString("ProblemsInContest");
            long problemId         = getDataByColum("ProblemsId");
            long contestId         = getDataByColum("ContestsId");

            if (!objMyContest.CheckIsAccepted(contestId))
            {
                HELPER.Client.Alert(this, "KHÓA HỌC NÀY CHƯA ĐƯỢC PHÊ DUYỆT");
                Response.Redirect("MyContests.aspx");
            }
            if (!objContest.CheckIsAvailable(contestId))
            {
                HELPER.Client.Alert(this, "KHÓA HỌC NÀY ĐÃ HẾT HIỆU LỰC");
                Response.Redirect("MyContests.aspx");
            }



            HELPER.CWebPage.BindPanel(pnMain, obj.LoadByID(problemId));
            ASPxRichEdit1.Open(
                Server.MapPath(CConstant.C_WORK_DIRECTORY_PROBLEMS + txtURL_Content.Text)
                );
        }
Esempio n. 13
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsCallback && !IsPostBack)
            {
                HiddenInvoiceId.Value = Request.Params["OrderID"];

                var arrayInvoice = new ArrayList();

                using (SqlConnection con = new SqlConnection(conStr))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = con;

                        cmd.CommandText = @"select i.InvoiceID, i.OrderID, i.InvoiceRtf 
                                            from Invoices i                                                             
                                            where i.OrderID = " + HiddenInvoiceId.Value + " order by i.InvoiceID desc";

                        con.Open();
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            arrayInvoice.Add(reader["InvoiceID"]);
                            arrayInvoice.Add(reader["OrderID"]);
                            arrayInvoice.Add(reader["InvoiceRtf"]);
                        }

                        reader.Close();
                        con.Close();
                    }
                }

                if (arrayInvoice.Count > 0)
                {
                    // Stream var
                    MemoryStream updatedStream = new MemoryStream();

                    // Load stream from database
                    MemoryStream stream = new MemoryStream((byte[])arrayInvoice[2]);

                    // Load document from stream
                    RichEditDocumentServer docServer = new RichEditDocumentServer();
                    docServer.LoadDocument(stream, DocumentFormat.Rtf);

                    // Create document server
                    Document document = docServer.Document;

                    // If the document is not protected
                    if (!document.IsDocumentProtected)
                    {
                        // Protect the document with a password
                        document.Protect("123", DocumentProtectionType.ReadOnly);

                        // Tables
                        DevExpress.XtraRichEdit.API.Native.Table table1 = document.Tables[1];
                        DocumentRange rangeTable1 = table1.Rows[1].Range;

                        DevExpress.XtraRichEdit.API.Native.Table table2 = document.Tables[2];
                        DocumentRange rangeTable2 = table2.Rows[1].Range;

                        // Add table1 as range / Allow editing row 1 over table1
                        RangePermissionCollection coletionTable1   = document.BeginUpdateRangePermissions();
                        RangePermission           permissionTable1 = coletionTable1.CreateRangePermission(rangeTable1);
                        permissionTable1.Group = "Everyone";
                        coletionTable1.Add(permissionTable1);
                        document.EndUpdateRangePermissions(coletionTable1);

                        // Add table2 as range / Allow editing row 1 over table2
                        RangePermissionCollection coletionTable2   = document.BeginUpdateRangePermissions();
                        RangePermission           permissionTable2 = coletionTable2.CreateRangePermission(rangeTable2);
                        permissionTable2.Group = "Everyone";
                        coletionTable2.Add(permissionTable2);
                        document.EndUpdateRangePermissions(coletionTable2);
                    }

                    // Update updatedStream var from stream var
                    document.SaveDocument(updatedStream, DocumentFormat.Rtf);

                    // Open document from updatedStream var
                    ASPxRichEdit1.Open(Guid.NewGuid().ToString(), DocumentFormat.Rtf, () => { return(updatedStream.ToArray()); });
                }
            }
        }