Exemplo n.º 1
0
        public static String uploadProcedure(FlowDocument toBeUploaded)
        {
            try
            {
                String ptext = MathBox.getDocumentUni(toBeUploaded);

                String htmlBody = new LMD_Document(ptext).getHTMLBody();

                return(NetworkManager.uploadData(ptext, htmlBody));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return("");
            }
        }
Exemplo n.º 2
0
        /// <returns>Whether the current action should continue</returns>
        public static String saveAsProcedure(FlowDocument document)
        {
            try
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName   = "Document";
                sfd.DefaultExt = ".txt";
                sfd.Filter     = "TXT (editable)|*.txt|HTML (read-only)|*.html";

                Nullable <bool> result = sfd.ShowDialog();
                if (result != true)
                {
                    return("");
                }

                DataStream ds = null;
                int        br = sfd.FilterIndex;

                String documentString = MathBox.getDocumentUni(document);

                if (br == 1)
                {
                    ds             = new DataStream(documentString, DataStream.Type.TXT);
                    lastRegistered = cloneFlowDocument(document);
                    fullPath       = sfd.FileName;
                    name           = sfd.SafeFileName;
                }
                else
                {
                    documentString = new LMD_Document(documentString).toHTML(LMD_Document.RenderingMode.WEB);
                    ds             = new DataStream(documentString, DataStream.Type.HTML);
                }

                FileManager.WriteDataToFile(ds, sfd.FileName);

                return(name);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return("");
            }
        }
Exemplo n.º 3
0
 public static String saveProcedure(FlowDocument current)
 {
     if (fullPath == "")
     {
         return(saveAsProcedure(current));
     }
     else
     {
         try
         {
             String     documentString = MathBox.getDocumentUni(current);
             DataStream ds             = new DataStream(documentString, DataStream.Type.TXT);
             FileManager.WriteDataToFile(ds, fullPath);
             lastRegistered = cloneFlowDocument(current);
             return(name);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
             return("");
         }
     }
 }