Exemple #1
0
    // Start loading from file
    public void LoadGameLevel(SaveFormat file)
    {
        fileToLoad  = file;
        gameRunning = true;

        StartCoroutine(LoadGameLevelCoroutine());
    }
Exemple #2
0
    void SaveAs(SaveFormat format)
    {
        var path = EditorUtility.SaveFilePanelInProject("Save combined texture", "CombinedTexture", (format == SaveFormat.PNG) ? "png" : "exr", "Save combined texture as...");

        if (!string.IsNullOrEmpty(path))
        {
            //save to file
            var osPath = (Application.dataPath + path.Substring(6)).Replace('/', System.IO.Path.DirectorySeparatorChar);
            //blit to render texture
            RefreshCombinedTexture(false);
            //set active render texture and read pixels
            RenderTexture.active = textureCombined;
            Texture2D texture2D = new Texture2D(textureCombined.width, textureCombined.height, (format == SaveFormat.PNG) ? TextureFormat.ARGB32 : TextureFormat.RGBAHalf, false);
            texture2D.ReadPixels(new Rect(0, 0, textureCombined.width, textureCombined.height), 0, 0);
            RenderTexture.active = null;
            //save file to disk
            byte[] data = (format == SaveFormat.PNG) ? texture2D.EncodeToPNG() : texture2D.EncodeToEXR(Texture2D.EXRFlags.CompressZIP);
            System.IO.File.WriteAllBytes(osPath, data);
            //import new file in Unity
            AssetDatabase.ImportAsset(path);
            //set metadata
            var importer = AssetImporter.GetAtPath(path);
            importer.userData = GetUserData();
            importer.SaveAndReimport();
            //load in UI and select in Project view
            textureSaved      = AssetDatabase.LoadAssetAtPath <Texture2D>(path);
            Selection.objects = new Object[] { textureSaved };
        }
    }
Exemple #3
0
        /// <summary>
        /// Contructor.
        /// </summary>
        /// <param name="name">Name of the file.</param>
        /// <param name="version">Version</param>
        /// <param name="path">Path to the foamfile.</param>
        /// <param name="attributes">Additional attributes besides default.</param>
        /// <param name="format">Ascii or Binary.</param>
        public FOAMFile(string name, Version version, string path, string _class, Dictionary <string, object> attributes, SaveFormat format)
        {
            m_Name = name;
            m_Path = path;

            if (_class == string.Empty)
            {
                m_Class = "dictionary";
            }
            else
            {
                m_Class = _class;
            }

            m_SaveFormat        = format;
            m_Version           = version;
            m_Attributes        = new Dictionary <string, object>();
            m_DefaultAttributes = new Dictionary <string, object>();

            Init();

            if (attributes != null)
            {
                foreach (var attribute in attributes)
                {
                    m_Attributes.Add(attribute.Key, attribute.Value);
                }
            }
        }
Exemple #4
0
        public void ExportPageMargins(SaveFormat saveFormat)
        {
            Document doc = new Document(MyDir + "HtmlSaveOptions.ExportPageMargins.docx");

            Aspose.Words.Saving.HtmlSaveOptions htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions
            {
                SaveFormat        = saveFormat,
                ExportPageMargins = true
            };

            switch (saveFormat)
            {
            case SaveFormat.Html:
                doc.Save(MyDir + "ExportPageMargins.html", htmlSaveOptions);
                break;

            case SaveFormat.Mhtml:
                doc.Save(MyDir + "ExportPageMargins.Mhtml", htmlSaveOptions);
                break;

            case SaveFormat.Epub:
                doc.Save(MyDir + "ExportPageMargins.Epub", htmlSaveOptions);     //There is draw images bug with epub. Need write to NSezganov
                break;
            }
        }
        public static T Load <T>(string fileName, SaveFormat saveFormat = SaveFormat.JSON) where T : class, new()
        {
            var filePath = string.IsNullOrEmpty(fileName)
                ? DefaultSavePath
                : Application.persistentDataPath + $"/{fileName}.gd";

            if (!File.Exists(filePath))
            {
                return(new T());
            }

            var data = default(T);

            switch (saveFormat)
            {
            case SaveFormat.JSON:
                var json = File.ReadAllText(filePath);
                data = JsonUtility.FromJson <T>(json);
                break;

            case SaveFormat.Binary:
                var fileStream = File.Open(filePath, FileMode.Open);

                data = (T)_binaryFormatter.Deserialize(fileStream);

                fileStream.Close();
                break;
            }

            return(data != null && data.Equals(default(T)) ? new T() : data);
        }
        /// <summary>
        /// Convert Workbook to different file format without using storage
        /// </summary>
        /// <param name="outputFileName"></param>
        /// <param name="outputFormat"></param>
        public void ConvertLocalFile(string inputPath, string outputPath, SaveFormat outputFormat)
        {
            try
            {
                //build URI
                string strURI = Aspose.Cloud.Common.Product.BaseProductUri + "/cells/convert?format=" + outputFormat;

                //sign URI
                string signedURI = Utils.Sign(strURI);

                FileStream stream = new FileStream(inputPath, FileMode.Open);

                //get response stream
                Stream responseStream = Utils.ProcessCommand(signedURI, "PUT", stream);

                using (Stream fileStream = System.IO.File.OpenWrite(outputPath))
                {
                    Utils.CopyStream(responseStream, fileStream);
                }
                responseStream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #7
0
 private void btnSavePlan_Click(object sender, EventArgs e)
 {
     if (Manager == null)
     {
         MessageBox.Show(this, "You did not create a plan", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     using (SaveFileDialog sfd = new SaveFileDialog()
     {
         Filter = "Football manager files (*.fm)|*.fm|Open Document Spreadsheet|*.ods | .xlsx Files as template (*.xlsx)|*.xlsx", ValidateNames = true, FilterIndex = 2
     })
     {
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             SaveFormat sf = SaveFormat.File;
             if (sfd.FileName.Contains(".ods"))
             {
                 sf = SaveFormat.Excel;
             }
             else if (sfd.FileName.Contains(".xlsx"))
             {
                 sf = SaveFormat.ExcelTemplate;
             }
             bool status = Manager.SavePlan(sf, sfd.FileName);
             if (status)
             {
                 MessageBox.Show(this, "Saved successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show(this, "An error ocurred during the saving process", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Exemple #8
0
 private void btnSaveTable_Click(object sender, EventArgs e)
 {
     if (Manager == null)
     {
         MessageBox.Show(this, "You don't have a table to save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     using (SaveFileDialog sfd = new SaveFileDialog()
     {
         Filter = "txt files (*.txt)|*.txt|Open Document Spreadsheet|*.ods", ValidateNames = true
     })
     {
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             SaveFormat sf = SaveFormat.File;
             if (sfd.FileName.Contains(".ods"))
             {
                 sf = SaveFormat.Excel;
             }
             bool status = Manager.SaveTable(sf, sfd.FileName);
             if (status)
             {
                 MessageBox.Show(this, "Save successfull", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show(this, "An error ocurred during the saving process", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
        private static SaveFormat GetSaveFormat(ImageFormat imageFormat)
        {
            SaveFormat sf = SaveFormat.Unknown;

            if (imageFormat.Equals(ImageFormat.Png))
            {
                sf = SaveFormat.Png;
            }
            else if (imageFormat.Equals(ImageFormat.Jpeg))
            {
                sf = SaveFormat.Jpeg;
            }
            else if (imageFormat.Equals(ImageFormat.Tiff))
            {
                sf = SaveFormat.Tiff;
            }
            else if (imageFormat.Equals(ImageFormat.Bmp))
            {
                sf = SaveFormat.Bmp;
            }
            else
            {
                sf = SaveFormat.Unknown;
            }
            return(sf);
        }
        /// <summary>
        /// 生成导出excel
        /// </summary>
        /// <param name="source">要导出的数据</param>
        /// <param name="code">配置信息</param>
        /// <param name="fileName">要导出的文件名</param>
        /// <returns></returns>
        public IActionResult ExportData(DataTable source, string code, string fileName)
        {
            string strSQL = @"SELECT * FROM Sys_ColumnsForModule WHERE cModuleCode=@code AND iShow=1
                            ORDER BY nOrderID";
            List <Sys_ColumnsForModule> lst = Db.ExecuteEntities <Sys_ColumnsForModule>(strSQL, new { code });


            for (int i = source.Columns.Count - 1; i >= 0; i--)
            {
                Sys_ColumnsForModule module = lst.Where(p => p.cField.ToLower() == source.Columns[i].ColumnName.ToLower()).FirstOrDefault();
                if (module == null)
                {
                    source.Columns.RemoveAt(i);
                }
                else
                {
                    source.Columns[i].ColumnName = module.cTitle;
                }
            }

            string     ext        = FileHelper.FileExtension(fileName);
            SaveFormat saveFormat = (SaveFormat)Enum.Parse(typeof(SaveFormat), ext, true);

            using (Workbook wb = new Workbook())
            {
                wb.Worksheets[0].Cells.ImportData(source, 0, 0, new ImportTableOptions {
                });
                wb.Worksheets[0].FreezePanes(1, 0, 1, source.Columns.Count);
                MemoryStream stream = new MemoryStream();
                wb.Save(stream, saveFormat);
                return(WebHelper.DownLoad(stream, fileName));
            }
        }
Exemple #11
0
        public void ExportOfficeMath(SaveFormat saveFormat, HtmlOfficeMathOutputMode outputMode)
        {
            Document doc = new Document(MyDir + "OfficeMath.docx");

            HtmlSaveOptions saveOptions = new HtmlSaveOptions
            {
                OfficeMathOutputMode = outputMode
            };

            Save(doc, @"\Artifacts\HtmlSaveOptions.ExportToHtmlUsingImage." + saveFormat.ToString().ToLower(),
                 saveFormat, saveOptions);

            switch (saveFormat)
            {
            case SaveFormat.Html:
                DocumentHelper.FindTextInFile(
                    MyDir + @"\Artifacts\HtmlSaveOptions.ExportToHtmlUsingImage." + saveFormat.ToString().ToLower(),
                    "<img src=\"HtmlSaveOptions.ExportToHtmlUsingImage.001.png\" width=\"49\" height=\"19\" alt=\"\" style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />");
                return;

            case SaveFormat.Mhtml:
                DocumentHelper.FindTextInFile(
                    MyDir + @"\Artifacts\HtmlSaveOptions.ExportToHtmlUsingImage." + saveFormat.ToString().ToLower(),
                    "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>A</mi><mo>=</mo><mi>π</mi><msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow></msup></math>");
                return;

            case SaveFormat.Epub:
                DocumentHelper.FindTextInFile(
                    MyDir + @"\Artifacts\HtmlSaveOptions.ExportToHtmlUsingImage." + saveFormat.ToString().ToLower(),
                    "<span style=\"font-family:\'Cambria Math\'\">A=π</span><span style=\"font-family:\'Cambria Math\'\">r</span><span style=\"font-family:\'Cambria Math\'\">2</span>");
                return;
            }
        }
Exemple #12
0
        public void SaveDocumentEncryptedWithAPassword(SaveFormat saveFormat)
        {
            //ExStart
            //ExFor:OdtSaveOptions.#ctor(SaveFormat)
            //ExFor:OdtSaveOptions.Password
            //ExFor:OdtSaveOptions.SaveFormat
            //ExSummary:Shows how to encrypted your odt/ott documents with a password.
            Document doc = new Document(MyDir + "Document.docx");

            OdtSaveOptions saveOptions = new OdtSaveOptions(saveFormat);

            saveOptions.Password = "******";

            // Saving document using password property of OdtSaveOptions
            doc.Save(ArtifactsDir + "OdtSaveOptions.SaveDocumentEncryptedWithAPassword" +
                     FileFormatUtil.SaveFormatToExtension(saveFormat), saveOptions);
            //ExEnd

            // Check that all documents are encrypted with a password
            FileFormatInfo docInfo = FileFormatUtil.DetectFileFormat(
                ArtifactsDir + "OdtSaveOptions.SaveDocumentEncryptedWithAPassword" +
                FileFormatUtil.SaveFormatToExtension(saveFormat));

            Assert.IsTrue(docInfo.IsEncrypted);
        }
Exemple #13
0
        }         // Save

        private byte[] ConvertFormat(string stringForConvert, SaveFormat format, string typeInputString = "html")
        {
            Log.Debug("Saving agreement for customer {0}: converting format {1} -> {2}...", _customerId, typeInputString, format.ToString());

            var doc        = new Document();
            var docBuilder = new DocumentBuilder(doc);

            if (typeInputString == "html")
            {
                docBuilder.InsertHtml(stringForConvert);
            }
            else
            {
                docBuilder.Write(stringForConvert);
            }

            byte[] oResult;

            using (var streamForDoc = new MemoryStream()) {
                doc.Save(streamForDoc, format);
                oResult = streamForDoc.ToArray();
            }             // using

            Log.Debug("Saving agreement for customer {0}: converted format {1} -> {2}.", _customerId, typeInputString, format.ToString());
            return(oResult);
        }         // ConvertFormat
Exemple #14
0
        public void ExportTextBoxAsSvg(SaveFormat saveFormat, bool isTextBoxAsSvg)
        {
            string[] dirFiles;

            Document doc = new Document(MyDir + "HtmlSaveOptions.ExportTextBoxAsSvg.docx");

            HtmlSaveOptions saveOptions = new HtmlSaveOptions(saveFormat);

            saveOptions.ExportTextBoxAsSvg = isTextBoxAsSvg;

            doc.Save(ArtifactsDir + "HtmlSaveOptions.ExportTextBoxAsSvg" + FileFormatUtil.SaveFormatToExtension(saveFormat), saveOptions);

            switch (saveFormat)
            {
            case SaveFormat.Html:

                dirFiles = Directory.GetFiles(ArtifactsDir, "HtmlSaveOptions.ExportTextBoxAsSvg.001.png", SearchOption.AllDirectories);
                Assert.IsEmpty(dirFiles);
                return;

            case SaveFormat.Epub:

                dirFiles = Directory.GetFiles(ArtifactsDir, "HtmlSaveOptions.ExportTextBoxAsSvg.001.png", SearchOption.AllDirectories);
                Assert.IsEmpty(dirFiles);
                return;

            case SaveFormat.Mhtml:     // ToDo: Check results of this assert

                dirFiles = Directory.GetFiles(ArtifactsDir, "HtmlSaveOptions.ExportTextBoxAsSvg.001.png", SearchOption.AllDirectories);
                Assert.IsEmpty(dirFiles);
                return;
            }
        }
Exemple #15
0
        // HERE

        public virtual System.IO.Stream ResizeImage(
            System.IO.Stream stream,
            SaveFormat saveFormat,
            System.Drawing.Size maxSize)
        {
            return(ResizeImage(stream, null, saveFormat, maxSize));
        }
Exemple #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    byte[] data = null;
                    using (var fs = new FileStream(ofd.FileName, FileMode.Open))
                    {
                        using (var x = File.Create(ofd.FileName + ".Rebuilded"))
                        {
                            SaveData.SaveFormat s = new SaveFormat(fs);
                            data = s.Rebuild();
                            x.Write(data, 0, data.Length);
                        }
                    }
                    if (!data.MemCompare(File.ReadAllBytes(ofd.FileName), 0))
                    {
                        MessageBox.Show(@"Invalid Comparison!");
                    }
                    else
                    {
                        MessageBox.Show("Rebuilded File Matches Original!\n Yeeaahhh :P!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #17
0
        private void radButton1_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    var sf = File.ReadAllBytes(ofd.FileName);
                    var s  = new SaveFormat(ofd.FileName);
                    var x  = s.Rebuild();
                    File.WriteAllBytes(ofd.FileName + ".New", x);
                    propertyGrid1.SelectedObject = s.DataStructure;
                    int offset = 0;
                    Dictionary <int, byte> fault = new Dictionary <int, byte>();
                    Dictionary <int, byte> valid = new Dictionary <int, byte>();
                    var same = sf.MemCompare(x, 0, ref fault, ref valid);
                    Console.Write(same + @"  ==> 0x" + offset.ToString("X2"));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #18
0
    public string SaveTextureAs(Texture2D texture2D, SaveFormat format = SaveFormat.JPG)
    {
        string savePath = string.Empty;

        switch (format)
        {
        case SaveFormat.JPG:
            savePath = GetJpgFullPath();
            WriteBytesToFile(savePath, texture2D.EncodeToJPG(90));
            break;

        case SaveFormat.PNG:
            savePath = GetPngFullPath();
            WriteBytesToFile(savePath, texture2D.EncodeToPNG());
            break;

        case SaveFormat.GIF:
#if PRO_GIF
            savePath = ProGifTexturesToGIF.Instance.Save(new List <Texture2D> {
                texture2D
            }, texture2D.width, texture2D.height, 1, -1, 10);
#endif
            break;
        }
        return(savePath);
    }
 internal XmlContentDisplayDialog(string xmlString, string header, bool allowEdit, bool allowFormat, bool allowExecute, SaveFormat saveFormat, FetchXmlBuilder caller)
 {
     InitializeComponent();
     format  = saveFormat;
     fxb     = caller;
     result  = null;
     execute = false;
     if (fxb.currentSettings.xmlWinSize != null && fxb.currentSettings.xmlWinSize.Width > 0 && fxb.currentSettings.xmlWinSize.Height > 0)
     {
         Width  = fxb.currentSettings.xmlWinSize.Width;
         Height = fxb.currentSettings.xmlWinSize.Height;
     }
     Text          = string.IsNullOrEmpty(header) ? "FetchXML Builder" : header;
     panOk.Visible = allowEdit;
     if (!allowEdit)
     {
         btnCancel.Text = "Close";
     }
     btnFormat.Visible     = allowFormat;
     btnDecode.Visible     = allowFormat;
     btnHtmlEncode.Visible = allowFormat;
     btnEscape.Visible     = allowFormat;
     btnExecute.Visible    = allowExecute;
     btnSave.Visible       = format != SaveFormat.None;
     UpdateXML(xmlString);
 }
        /// <summary>
        /// To convert a workbook
        /// </summary>
        /// <param name="outputFileName"></param>
        /// <param name="outputFormat"></param>
        public void Save(string outputFileName, SaveFormat outputFormat)
        {
            try
            {
                //check whether file is set or not
                if (FileName == "")
                {
                    throw new Exception("No file name specified");
                }

                //build URI
                string strURI = Aspose.Cloud.Common.Product.BaseProductUri + "/cells/" + FileName;
                strURI += "?format=" + outputFormat;

                //sign URI
                string signedURI = Utils.Sign(strURI);

                //get response stream
                Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

                using (Stream fileStream = System.IO.File.OpenWrite(outputFileName))
                {
                    Utils.CopyStream(responseStream, fileStream);
                }
                responseStream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            Workbook workbook = new Workbook();

            //Set default font
            Style style = workbook.DefaultStyle;
            style.Font.Name = "Tahoma";
            workbook.DefaultStyle = style;

            CreateStaticReport(workbook);

            //Create an object of SaveFormat
            SaveFormat saveFormat = new SaveFormat();

            //Check file format is xls
            if (ddlFileVersion.SelectedItem.Value == "XLS")
            {
                //Set save format optoin to xls
                saveFormat = SaveFormat.Excel97To2003;
            }
            //Check file format is xlsx
            else if (ddlFileVersion.SelectedItem.Value == "XLSX")
            {
                //Set save format optoin to xlsx
                saveFormat = SaveFormat.Xlsx;
            }

            //Save file and send to client browser using selected format
            workbook.Save(HttpContext.Current.Response, "ImageFillFormat." + ddlFileVersion.SelectedItem.Value.ToLower(), ContentDisposition.Attachment, new XlsSaveOptions(saveFormat));

            // note by Vit - end response to avoid unneeded html after xls
            Response.End();
        }
Exemple #22
0
    // When a file button is clicked, load details
    private void LoadFileDetails(string filename)
    {
        // Load file and associated image
        file = Application.persistentDataPath + "/SavedGames/" + filename + ".stdm";
        string image = Application.persistentDataPath + "/SaveImages/" + filename + ".png";

        // Read as string var
        string loadJson = File.ReadAllText(file);

        if (fileToLoad != null)
        {
            fileToLoad = null;
        }

        // Convert into the SaveFormat using JsonUtility
        fileToLoad = JsonUtility.FromJson <SaveFormat>(loadJson);

        // Get file info
        FileInfo[] fileInfo = info.GetFiles(filename + ".stdm");

        // Display file info
        loadDetails.text  = "Scene: " + fileToLoad.sceneName;
        loadDetails.text += "\nLast Played: " + fileInfo[0].LastWriteTime;

        // Load associated save image and display
        byte[]    bytes = File.ReadAllBytes(image);
        Texture2D tex   = new Texture2D(200, 200);

        tex.filterMode = FilterMode.Trilinear;
        tex.LoadImage(bytes);

        loadImage.texture = tex;
    }
Exemple #23
0
        public IHttpActionResult LoadSummaryData(string taskId, string corp, string org, string name, string username)
        {
            bool c1 = !string.IsNullOrEmpty(corp) && corp == "1";         //公司
            bool c2 = !string.IsNullOrEmpty(org) && org == "1";           //组织架构
            bool c3 = !string.IsNullOrEmpty(name) && name == "1";         //姓名
            bool c4 = !string.IsNullOrEmpty(username) && username == "1"; //账号

            TaskCollectionDataBuilder tdb = new TaskCollectionDataBuilder(taskId, null);
            string fileExt = ".xls";
            //Workbook dataBook = tdb.BuildData(c1, c2, c3, c4, out fileExt);
            Workbook   dataBook = tdb.BuildDataFormula(c1, c2, c3, c4, out fileExt);
            SaveFormat format   = SaveFormat.Excel97To2003;

            if (fileExt == ".xlsx")
            {
                format = SaveFormat.Xlsx;
            }
            MemoryStream stream = new MemoryStream();

            dataBook.Save(stream, format);
            stream.Seek(0, SeekOrigin.Begin);
            var fileName = string.Format("{0}{1}", dataBook.FileName, fileExt);

            //return BizResult(FileUploadHelper.GetPreviewUrlByStream(stream, fileName));
            return(new FileResult(fileName, stream.ToArray(), Request));
        }
Exemple #24
0
        /// <summary>
        /// 生成Excel文件流
        /// </summary>
        /// <param name="titles"></param>
        /// <param name="fields"></param>
        /// <param name="list"></param>
        /// <param name="saveFormat"></param>
        /// <param name="isPropertyNameShown"></param>
        /// <param name="firstRow"></param>
        /// <param name="firstColumn"></param>
        /// <param name="insertRows"></param>
        /// <param name="dateFormatString"></param>
        /// <param name="convertStringToNumber"></param>
        /// <param name="sheetName"></param>
        /// <returns></returns>
        public static byte[] GenerateExcelFileStream(string[] titles, string[] fields, ICollection list
                                                     , SaveFormat saveFormat, bool isPropertyNameShown, int firstRow, int firstColumn
                                                     , bool insertRows, string dateFormatString, bool convertStringToNumber, string sheetName = "Sheet1")
        {
            AsposeXls.Workbook  workbook = new AsposeXls.Workbook();
            AsposeXls.Worksheet sheet    = workbook.Worksheets[0];
            sheet.Name = sheetName;

            sheet.FreezePanes(1, 1, 1, 0); //冻结第一行

            for (int i = 0; i < titles.Length; i++)
            {
                sheet.Cells[0, i].PutValue(titles[i]);
            }

            sheet.Cells.ImportCustomObjects(list, fields, isPropertyNameShown, firstRow, firstColumn,
                                            list.Count, insertRows, dateFormatString, convertStringToNumber);

            sheet.AutoFitColumns();//让各列自适应宽度,这个很有用
            using (MemoryStream stream = new MemoryStream())
            {
                workbook.Save(stream, saveFormat);
                return(stream.ToArray());
            }
        }
Exemple #25
0
        public IHttpActionResult LoadSummaryPreviewUrl(string taskId, string corp, string org, string name, string username)
        {
            bool c1 = !string.IsNullOrEmpty(corp) && corp == "1";         //公司
            bool c2 = !string.IsNullOrEmpty(org) && org == "1";           //组织架构
            bool c3 = !string.IsNullOrEmpty(name) && name == "1";         //姓名
            bool c4 = !string.IsNullOrEmpty(username) && username == "1"; //账号

            TaskCollectionDataBuilder tdb = new TaskCollectionDataBuilder(taskId, null);
            string     fileExt            = ".xls";
            Workbook   dataBook           = tdb.BuildData(c1, c2, c3, c4, out fileExt);
            SaveFormat format             = SaveFormat.Excel97To2003;

            if (fileExt == ".xlsx")
            {
                format = SaveFormat.Xlsx;
            }
            MemoryStream stream = new MemoryStream();

            dataBook.Save(stream, format);
            stream.Seek(0, SeekOrigin.Begin);
            var fileName   = string.Format("{0}{1}", dataBook.FileName, fileExt);
            var attachment = AttachmentOperator.Instance.CommonUpload(taskId, "DownLoadTaskSummaryFile", fileName, stream);

            return(BizResult(string.Format("/api/attachments/orgstream/{0}", attachment.ID)));
        }
Exemple #26
0
        /// <summary>
        /// combined event for content / media / member
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="savedEntities"></param>
        private void Saved(IService sender, IEnumerable <IContentBase> savedEntities)
        {
            foreach (IContentBase savedEntity in savedEntities)
            {
                // for each property
                foreach (PropertyType propertyType in savedEntity.PropertyTypes.Where(x => PickerPropertyValueConverter.IsPicker(x.PropertyEditorAlias)))
                {
                    // create picker supplying all values
                    Picker picker = new Picker(
                        savedEntity.Id,
                        savedEntity.ParentId,
                        propertyType.Alias,
                        propertyType.DataTypeDefinitionId,
                        propertyType.PropertyEditorAlias,
                        savedEntity.GetValue(propertyType.Alias));

                    if (!string.IsNullOrWhiteSpace(picker.RelationTypeAlias))
                    {
                        bool isRelationsOnly = picker.GetDataTypePreValue("saveFormat").Value == "relationsOnly";

                        if (isRelationsOnly)
                        {
                            if (picker.SavedValue == null)
                            {
                                picker.PickedKeys = new string[] { };
                            }
                            else
                            {
                                // manually set on picker obj, so it doesn't then attempt to read picked keys from the database
                                picker.PickedKeys = SaveFormat.GetKeys(picker.SavedValue.ToString()).ToArray();

                                // delete saved value (setting it to null)
                                savedEntity.SetValue(propertyType.Alias, null);

                                if (sender is IContentService)
                                {
                                    ((IContentService)sender).Save((IContent)savedEntity, 0, false);
                                }
                                else if (sender is IMediaService)
                                {
                                    ((IMediaService)sender).Save((IMedia)savedEntity, 0, false);
                                }
                                else if (sender is IMemberService)
                                {
                                    ((IMemberService)sender).Save((IMember)savedEntity, false);
                                }
                            }
                        }

                        // update database
                        RelationMapping.UpdateRelationMapping(
                            picker.ContextId,                               // savedEntity.Id
                            picker.PropertyAlias,                           // propertyType.Alias
                            picker.RelationTypeAlias,
                            isRelationsOnly,
                            picker.PickedIds.ToArray());
                    }
                }
            }
        }
        GetEncoder(SaveFormat saveFormat)
        {
            SixLabors.ImageSharp.Formats.IImageEncoder enc = null;
            switch (saveFormat)
            {
            case SaveFormat.Png:
                enc = new SixLabors.ImageSharp.Formats.Png.PngEncoder();
                break;

            case SaveFormat.Jpg:
                enc = new SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder();
                break;

            case SaveFormat.Gif:
                enc = new SixLabors.ImageSharp.Formats.Gif.GifEncoder();
                break;

            case SaveFormat.Bmp:
                enc = new SixLabors.ImageSharp.Formats.Bmp.BmpEncoder();
                break;

            default:
                enc = new SixLabors.ImageSharp.Formats.Png.PngEncoder();
                break;
            }

            return(enc);
        } // End Function GetEncoder
Exemple #28
0
        public void WorkWithEncryptedDocument(SaveFormat saveFormat)
        {
            //ExStart
            //ExFor:OdtSaveOptions.#ctor(String)
            //ExSummary:Shows how to load and change odt/ott encrypted document.
            Document doc = new Document(MyDir + "Encrypted" +
                                        FileFormatUtil.SaveFormatToExtension(saveFormat),
                                        new LoadOptions("@sposeEncrypted_1145"));

            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.MoveToDocumentEnd();
            builder.Writeln("Encrypted document after changes.");

            // Saving document using new instance of OdtSaveOptions
            doc.Save(ArtifactsDir + "OdtSaveOptions.WorkWithEncryptedDocument" +
                     FileFormatUtil.SaveFormatToExtension(saveFormat), new OdtSaveOptions("@sposeEncrypted_1145"));
            //ExEnd

            // Check that document is still encrypted with a password
            FileFormatInfo docInfo =
                FileFormatUtil.DetectFileFormat(ArtifactsDir + "OdtSaveOptions.WorkWithEncryptedDocument" + FileFormatUtil.SaveFormatToExtension(saveFormat));

            Assert.IsTrue(docInfo.IsEncrypted);
        }
Exemple #29
0
        /// <summary>
        /// Save the specified data, if it receives a null it will ignore the request.
        /// </summary>
        public static void SerializeToFile(string name, [NotNull] SaveData data, SaveFormat format, string path)
        {
            // Check if the path is valid.
            if (!Uri.IsWellFormedUriString(path, UriKind.RelativeOrAbsolute))
            {
                Debug.LogWarning("The path was a invalid. The file was not serialized");
                return;
            }

            // Tries to save the file.
            try {
                switch (format)
                {
                case SaveFormat.Binary:
                    SerializeBinaryFile(data, path, false, name);
                    break;

                case SaveFormat.Json:
                    SerializeJsonFile(data, path, false, name);
                    break;

                default:
                    Debug.LogWarning("Something went wrong. Probably the save settings were null or they weren't loaded.");
                    break;
                }
            } catch (Exception e) {
                Debug.LogError(e);
            }
        }
Exemple #30
0
        private string BuildFileName()
        {
            var time = DateTime.Now;
            var name = time.ToString("yyyy-mm-dd_hh.mm.ss");

            return(String.Format("{0}.{1}", name, SaveFormat.ToString()).ToLower());
        }
        /// <summary>
        /// convert a document to SaveFormat
        /// </summary>
        /// <param name="output">the location of the output file</param>
        /// /// <param name="output">SaveFormat of the output file</param>
        public void Convert(string output, SaveFormat OutputType)
        {
            try
            {
                //check whether file is set or not
                if (FileName == "")
                    throw new Exception("No file name specified");

                //build URI
                string strURI = Product.BaseProductUri + "/words/" + FileName;
                strURI += "?format=" + OutputType;

                //sign URI
                string signedURI = Utils.Sign(strURI);

                //get response stream
                Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

                using (Stream fileStream = System.IO.File.OpenWrite(output))
                {
                    Utils.CopyStream(responseStream, fileStream);
                }
                responseStream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 public void Init(MeshGenerator generator)
 {
     titleContent = new GUIContent("Bake Mesh");
     meshGen      = generator;
     filter       = generator.GetComponent <MeshFilter>();
     if (EditorPrefs.HasKey("BakeWindow_isStatic"))
     {
         isStatic = EditorPrefs.GetBool("BakeWindow_isStatic");
     }
     if (EditorPrefs.HasKey("BakeWindow_copy"))
     {
         copy = EditorPrefs.GetBool("BakeWindow_copy");
     }
     if (EditorPrefs.HasKey("BakeWindow_removeComputer"))
     {
         removeComputer = EditorPrefs.GetBool("BakeWindow_removeComputer");
     }
     if (EditorPrefs.HasKey("BakeWindow_permanent"))
     {
         permanent = EditorPrefs.GetBool("BakeWindow_permanent");
     }
     format  = (SaveFormat)EditorPrefs.GetInt("BakeWindow_format", 0);
     minSize = new Vector2(340, 220);
     maxSize = minSize;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="saveFormat">The file format.</param>
 /// <param name="exportRange">The export range.</param>
 public Settings(SaveFormat saveFormat, ElementsExportRange exportRange)
 {
     m_SaveFormat = saveFormat;
     m_ExportRange = exportRange;
     m_IncludeLinkedModels = false;
     m_exportColor = false;
     m_exportSharedCoordinates = false;
     m_SelectedCategories = new List<Category>();
     m_Units = DisplayUnitType.DUT_UNDEFINED;
 }
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            //Open xls file template
            string path = MapPath("~/designer/FinancialPlan.xls");

            //Create a new workbook
            Workbook workbook = new Workbook(path);

            //Add style settings
            AddStyles(workbook);

            //Fill "Model Inputs" sheet
            FillModelInputs(workbook);

            //Fill "Profit and Loss" sheet
            FillProfitLoss(workbook);

            //Fill "Balance Sheet" sheet
            FillBalanceSheet(workbook);

            //Fill "Cash Flow" sheet
            FillCashFlow(workbook);

            //Fill "Loan Payment Calculator" sheet
            FillLoanPaymentCalculator(workbook);

            //Create an object of SaveFormat
            SaveFormat saveFormat = new SaveFormat();

            //Check file format is xls
            if (ddlFileVersion.SelectedItem.Value == "XLS")
            {
                //Set save format optoin to xls
                saveFormat = SaveFormat.Excel97To2003;
            }
            //Check file format is xlsx
            else if (ddlFileVersion.SelectedItem.Value == "XLSX")
            {
                //Set save format optoin to xlsx
                saveFormat = SaveFormat.Xlsx;
            }

            //Save file and send to client browser using selected format
            workbook.Save(HttpContext.Current.Response, "FinancialPlan." + ddlFileVersion.SelectedItem.Value.ToLower(), ContentDisposition.Attachment, new XlsSaveOptions(saveFormat));

            // note by Vit - end response to avoid unneeded html after xls
            Response.End();
        }
        /// <summary>
        /// Saves the document into various formats without uploading to any storage
        /// </summary>
        /// <param name="inputFile">Input file stream</param>
        /// <param name="outputPath">Save the output file to</param>
        /// <param name="saveFormat">Output format to save</param>
        public void Convert(Stream inputFile, string outputPath, SaveFormat saveFormat)
        {

            //build URI to convert presentation
            string strURI = Product.BaseProductUri + "/slides/convert?format=" + saveFormat;

            string signedURI = Utils.Sign(strURI);

            Stream responseStream = Utils.ProcessCommand(signedURI, "PUT", inputFile);

            //Save output file
            using (Stream fileStream = System.IO.File.OpenWrite(outputPath))
            {
                Utils.CopyStream(responseStream, fileStream);
            }
            responseStream.Close();
        }
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            //Create a dataset object
            DataSet ds = new DataSet();

            //Get data from xml file
            string path = MapPath(".");
            path = path.Substring(0, path.LastIndexOf("\\"));
            path += @"\Database\CostPareto.xml";

            //Load data from xml file to dataset
            ds.ReadXml(path, XmlReadMode.ReadSchema);

            //Create a new workbook
            Workbook workbook = new Workbook();

            //Generate first data sheet
            GenerateDataSheet(workbook, ds);

            //Generate second chart sheet
            GenerateChartSheet(workbook, ds);

            //Create an object of SaveFormat
            SaveFormat saveFormat = new SaveFormat();

            //Check file format is xls
            if(ddlFileVersion.SelectedItem.Value == "XLS")
            {
                //Set save format optoin to xls
                saveFormat = SaveFormat.Excel97To2003;
            }
            //Check file format is xlsx
            else if (ddlFileVersion.SelectedItem.Value == "XLSX")
            {
                //Set save format optoin to xlsx
                saveFormat = SaveFormat.Xlsx;
            }

            //Save file and send to client browser using selected format
            workbook.Save(HttpContext.Current.Response, "CostPareto." + ddlFileVersion.SelectedItem.Value.ToLower(), ContentDisposition.Attachment, new XlsSaveOptions(saveFormat));

            // note by Vit - end response to avoid unneeded html after xls
            Response.End();
        }
        /// <summary>
        /// save the document into various formats
        /// </summary>
        /// <param name="outputPath"></param>
        /// <param name="saveFormat"></param>
        public void Convert(string outputPath, SaveFormat saveFormat)
        {

            //build URI to get page count
            string strURI = Product.BaseProductUri + "/pdf/" + FileName;
            strURI += "?format=" + saveFormat;
            
            string signedURI = Utils.Sign(strURI);

            Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

            using (Stream fileStream = System.IO.File.OpenWrite(outputPath))
            {
                Utils.CopyStream(responseStream, fileStream);
            }
            responseStream.Close();
 

        }
	void OnGUI()
	{
		if (!terrain)
		{
			GUILayout.Label("No terrain found");
			if (GUILayout.Button("Cancel"))
			{
				EditorWindow.GetWindow<ExportTerrain>().Close();
			}
			return;
		}
		saveFormat = (SaveFormat) EditorGUILayout.EnumPopup("Export Format", saveFormat);
		
		saveResolution = (SaveResolution) EditorGUILayout.EnumPopup("Resolution", saveResolution);
		
		if (GUILayout.Button("Export"))
		{
			Export();
		}
	}
        /// <summary>
        /// Create workbbok, Insert dummy data
        /// and create a chart based on dummy data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            //Initialize Workbook
            Workbook workbook = new Workbook();

            //Set default font for workbook
            Style style = workbook.DefaultStyle;
            style.Font.Name = "Tahoma";
            workbook.DefaultStyle = style;

            //Insert Dummy Data
            CreateStaticData(workbook);

            //Apply Style on various cells
            CreateCellsFormatting(workbook);

            //Create Chart and Set Chart properties
            CreateStaticReport(workbook);

            //Create an object of SaveFormat
            SaveFormat saveFormat = new SaveFormat();

            //Check file format is xls
            if (ddlFileVersion.SelectedItem.Value == "XLS")
            {
                //Set save format optoin to xls
                saveFormat = SaveFormat.Excel97To2003;
            }
            //Check file format is xlsx
            else if (ddlFileVersion.SelectedItem.Value == "XLSX")
            {
                //Set save format optoin to xlsx
                saveFormat = SaveFormat.Xlsx;
            }

            //Save file and send to client browser using selected format
            workbook.Save(HttpContext.Current.Response, "PercentStackedArea." + ddlFileVersion.SelectedItem.Value.ToLower(), ContentDisposition.Attachment, new XlsSaveOptions(saveFormat));

            // note by Vit - end response to avoid unneeded html after xls
            Response.End();
        }
        public void ExportPageMargins(SaveFormat saveFormat)
        {
            Document doc = new Document(MyDir + "HtmlSaveOptions.ExportPageMargins.docx");

            Aspose.Words.Saving.HtmlSaveOptions htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions
            {
                SaveFormat = saveFormat, 
                ExportPageMargins = true
            };

            switch (saveFormat)
            {
                case SaveFormat.Html:
                    doc.Save(MyDir + "ExportPageMargins.html", htmlSaveOptions);
                    break;
                case SaveFormat.Mhtml:
                    doc.Save(MyDir + "ExportPageMargins.Mhtml", htmlSaveOptions);
                    break;
                case SaveFormat.Epub:
                    doc.Save(MyDir + "ExportPageMargins.Epub", htmlSaveOptions); //There is draw images bug with epub. Need write to NSezganov
                    break;
            }
        }
        /// <summary>
        /// Function to generate the Body Document.
        /// </summary>
        /// <param name="bodyTemplate"></param>
        /// <param name="schedule"></param>
        /// <param name="notice1"></param>
        /// <param name="recommendation"></param>
        /// <param name="natureOfAdvice"></param>
        /// <param name="documentValues"></param>
        /// <param name="draft"></param>
        /// <param name="saveFormat"></param>
        /// <returns></returns>
        public static byte[] GenerateBodyDoc(byte[] bodyTemplate, byte[] schedule, byte[] notice1, byte[] recommendation, byte[] natureOfAdvice,
            Tuple<Dictionary<string, string>, Dictionary<string, string[,]>> documentValues, bool draft, SaveFormat saveFormat)
        {
            Dictionary<string, string> docValues = documentValues.Item1;
            Dictionary<string, string[,]> docArrayValues = documentValues.Item2;

            MemoryStream newStream = null;
            if (bodyTemplate != null)
            {
                newStream = new MemoryStream(bodyTemplate);
            }

            // Read the document from the stream.
            Document doc = new Document(newStream);

            for (int index = 0; index < doc.Range.Bookmarks.Count; index++)
            {
                Bookmark bookmark = doc.Range.Bookmarks[index];
                string bookmarkName = bookmark.Name;
                if (
                            bookmarkName.StartsWith("ai_", true, CultureInfo.CurrentCulture)
                            || bookmarkName.StartsWith("ae_", true, CultureInfo.CurrentCulture)
                            || bookmarkName.StartsWith("ab_", true, CultureInfo.CurrentCulture)
                            )
                {
                    bookmarkName = bookmarkName.Substring(3);
                }

                string caseCorrectKey;
                if (TryGetKeyWithCorrectCase(docValues.Keys, bookmarkName, out caseCorrectKey) && bookmarkName != Bookmarks.POL_PARTICULARS)  //if (docValues.ContainsKey(bookmarkName) && bookmarkName != "pol_particulars")
                {
                    string suffix = "";
                    string tempValue;
                    if (docValues[caseCorrectKey] != "" && (bookmark.Text.EndsWith("\r") || bookmark.Text.EndsWith("\r\n")))
                    {
                        suffix = Environment.NewLine;
                    }

                    try
                    {
                        tempValue = docValues[caseCorrectKey] ?? "" + suffix;

                        if (String.IsNullOrWhiteSpace(bookmark.Text))
                        {
                            bookmark.Text = tempValue;
                        }
                    }
                    catch (Exception e)
                    {
                        string temp = e.Message;
                        bookmark.Remove();
                    }
                }

                string correctKey;
                if (TryGetKeyWithCorrectCase(docArrayValues.Keys, bookmarkName, out correctKey) && bookmarkName != Bookmarks.POL_PARTICULARS) //(docArrayValues.ContainsKey(bookmarkName) && bookmarkName != "pol_particulars")
                {
                    if (((Paragraph)bookmark.BookmarkStart.ParentNode).ParentNode.NodeType == NodeType.Cell)
                    {
                        DocumentBuilder builder = new DocumentBuilder(doc);
                        builder.MoveToBookmark(bookmark.Name);
                        Cell currentCell = (Cell)builder.CurrentParagraph.GetAncestor(NodeType.Cell);

                        string[,] data = docArrayValues[correctKey];

                        for (int rowIndex = 0; rowIndex <= data.GetUpperBound(0); rowIndex++)
                        {
                            for (int colIndex = 0; colIndex <= data.GetUpperBound(1); colIndex++)
                            {
                                if (data[rowIndex, colIndex] != null)
                                {
                                    builder.Write(data[rowIndex, colIndex]);
                                    if (!(rowIndex == data.GetUpperBound(0) && colIndex == data.GetUpperBound(1)))
                                    {
                                        currentCell = MoveToNextCell(builder, currentCell);
                                    }
                                }
                                else
                                {
                                    if (!(rowIndex == data.GetUpperBound(0) && colIndex == data.GetUpperBound(1)))
                                    {
                                        currentCell = MoveToNextCell(builder, currentCell);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Get collection of all FieldStart nodes in the document.
            NodeCollection fieldStarts = doc.GetChildNodes(NodeType.FieldStart, true);

            // We will use regular expression to get name of DOCVARIABLE.
            Regex regex = new Regex("DOCVARIABLE\\s+(?<name>[^\\s\"]+)|(\"(?<name>[^\"]+)\").*");

            // Look through all the field starts for the DOCVARIABLE field start.
            foreach (FieldStart start in fieldStarts)
            {
                try
                {

                    // Check whether the FieldStart is start of DOCVARIABLE field.
                    if (start.FieldType.Equals(FieldType.FieldDocVariable))
                    {
                        // We should get field code.
                        // Field code is the text between FieldStart and FieldSeparator nodes.
                        string fieldCode = "";

                        Node currentNode = start;

                        try
                        {
                            while (!(currentNode == null || currentNode.NodeType.Equals(NodeType.FieldSeparator)))
                            {
                                if (currentNode.NodeType.Equals(NodeType.Run))
                                {
                                    fieldCode += ((Run)currentNode).Text;
                                }

                                currentNode = currentNode.NextSibling;
                            }
                        }
                        catch (Exception ex3)
                        {
                            throw ex3;
                        }

                        // Get name of the DOCVARIABLE.
                        Match match = regex.Match(fieldCode);

                        // Print name of the DOCVARIABLE.
                        string docVarName = match.Groups["name"].Value;
                        if (
                            docVarName.StartsWith("ai_", true, CultureInfo.CurrentCulture)
                            || docVarName.StartsWith("ae_", true, CultureInfo.CurrentCulture)
                            || docVarName.StartsWith("ab_", true, CultureInfo.CurrentCulture)
                            )
                        {
                            docVarName = docVarName.Substring(3);
                        }
                        string keyA;
                        if (docVarName.StartsWith("CI___", true, CultureInfo.CurrentCulture) && !TryGetKeyWithCorrectCase(docValues.Keys, docVarName, out keyA))//docValues.ContainsKey(docVarName))
                        {
                            docVarName = docVarName.Substring(5);

                            string keyD;
                            if (TryGetKeyWithCorrectCase(docValues.Keys, "I___" + docVarName, out keyD)) // (docValues.ContainsKey("I___" + docVarName))
                            {
                                docVarName = keyD;
                            }
                        }
                        try
                        {
                            string keyB;
                            if (TryGetKeyWithCorrectCase(docValues.Keys, docVarName, out keyB) && docValues[keyB] != null)//(docValues.ContainsKey(docVarName) && docValues[docVarName] != null)
                            {
                                doc.Variables[match.Groups["name"].Value] = docValues[keyB];
                            }
                            else
                            {
                                string keyC;
                                if (TryGetKeyWithCorrectCase(docValues.Keys, "I___" + docVarName, out keyC) && docValues[keyC] != null) //(docValues.ContainsKey("I___" + docVarName) && docValues[docVarName] != null)
                                {
                                    doc.Variables[match.Groups["name"].Value] = docValues[keyC];
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            doc.UpdateFields();

            if (schedule  != null && schedule.Count() > 0)
            {
                try
                {

                    using (MemoryStream rtfStream = new MemoryStream(schedule))
                    {
                        Document rtfDoc = new Document(rtfStream);
                        InsertDocumentAtBookmark(Bookmarks.POL_PARTICULARS, doc, rtfDoc);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            if (notice1 != null && notice1.Count() > 0)
            {
                try
                {

                    using (MemoryStream rtfStream = new MemoryStream(notice1))
                    {
                        Document rtfDoc = new Document(rtfStream);
                        InsertDocumentAtBookmark(Bookmarks.FSRA_NOTICE1, doc, rtfDoc);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            if (draft)
            {
                InsertWatermarkText(doc,Bookmarks.DRAFT);
            }

            using (MemoryStream stream = new MemoryStream())
            {

                try
                {
                    doc.Save(stream, saveFormat);
                }
                catch (Exception e)
                {
                    throw e;
                }

                return stream.ToArray();
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="fileName">STL file name.</param>
 /// <param name="format">File format.</param>
 public SaveDataAsBinary(string fileName, SaveFormat format)
     : base(fileName, format)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="fileName">STL file name.</param>
 /// <param name="format">File format.</param>
 public SaveDataAsAscII(string fileName, SaveFormat format)
     : base(fileName, format)
 {
 }
		public virtual void Save(string path, SaveFormat format)
		{
			FileStream stream = null;

			//Create new filestream
			if (format != SaveFormat.Metafile)
			{
				stream = new FileStream(path, FileMode.Create);
			}

			//Save options
			if (format == SaveFormat.Binary)
			{
				BinaryFormatter formatter = new BinaryFormatter();
				SaveDiagram(stream,formatter);
			}
			else if (format == SaveFormat.Xml)
			{
				SoapFormatter formatter = new SoapFormatter();
				formatter.AssemblyFormat =  System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
				SaveDiagram(stream,formatter);
			}
			else if (format == SaveFormat.Svg)
			{
				ExportToSvg(stream);
			}
			else if (format == SaveFormat.Metafile)
			{
				ExportToMetafile(null,path);
			}
			//Export to image
			else if (format == SaveFormat.Bmp)
			{
				ExportToPicture(stream, ImageFormat.Bmp);
			}
			else if (format == SaveFormat.Gif)
			{
				ExportToPicture(stream, ImageFormat.Gif);
			}
			else if (format == SaveFormat.Jpeg)
			{
				ExportToPicture(stream, ImageFormat.Jpeg);
			}
			else if (format == SaveFormat.Png)
			{
				ExportToPicture(stream, ImageFormat.Png);
			}

			//Close filestream
			if (format != SaveFormat.Metafile)
			{
				stream.Close();
			}
		}
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="fileName">STL file name.</param>
 /// <param name="format">File format.</param>
 public SaveData(string fileName, SaveFormat format)
 {
     m_FileName = fileName;
     m_SaveFormat = format;
 }
        /// <summary>
        /// Convert Documentl to different file format without using storage
        /// </summary>
        /// <param name="outputFileName"></param>
        /// <param name="outputFormat"></param>
        public void ConvertLocalFile(string inputPath, string outputPath, SaveFormat outputFormat)
        {
            try
            {

                //build URI
                string strURI = Aspose.Cloud.Common.Product.BaseProductUri + "/words/convert?format=" + outputFormat;

                //sign URI
                string signedURI = Utils.Sign(strURI);

                FileStream stream = new FileStream(inputPath, FileMode.Open);

                //get response stream
                Stream responseStream = Utils.ProcessCommand(signedURI, "PUT", stream);

                using (Stream fileStream = System.IO.File.OpenWrite(outputPath))
                {
                    Utils.CopyStream(responseStream, fileStream);
                }
                responseStream.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="saveFormat">The file format.</param>
 /// <param name="exportRange">The export range.</param>
 /// <param name="includeLinkedModels">True to include linked models, false otherwise.</param>
 /// <param name="selectedCategories">The selected categories to be included.</param>
 public Settings(SaveFormat saveFormat, ElementsExportRange exportRange, bool includeLinkedModels,bool exportColor,bool exportSharedCoordinates,
     List<Category> selectedCategories, DisplayUnitType units)
 {
     m_SaveFormat = saveFormat;
     m_ExportRange = exportRange;
     m_IncludeLinkedModels = includeLinkedModels;
     m_exportColor = exportColor;
     m_exportSharedCoordinates = exportSharedCoordinates;
     m_SelectedCategories = selectedCategories;
     m_Units = units;
 }
        /// <summary>
        /// Convert Document to different file format without using storage
        /// </summary>
        /// <param name="outputFileName"></param>
        /// <param name="outputFormat"></param>
        public Stream ConvertLocalFile(Stream inputStream, SaveFormat outputFormat)
        {
            try
            {
                //build URI
                string strURI = Aspose.Cloud.Common.Product.BaseProductUri + "/words/convert?format=" + outputFormat;

                //sign URI
                string signedURI = Utils.Sign(strURI);

                Stream fileStream = new MemoryStream();

                Utils.CopyStream(Utils.ProcessCommand(signedURI, "PUT", inputStream), fileStream);

                return fileStream;

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }
		public virtual void Save(Stream stream, SaveFormat format)
		{
			if (format == SaveFormat.Binary)
			{
				BinaryFormatter formatter = new BinaryFormatter();
				SaveDiagram(stream,formatter);
			}
			else if (format == SaveFormat.Xml)
			{
				SoapFormatter formatter = new SoapFormatter();
				formatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
				SaveDiagram(stream,formatter);
			}
			else if (format == SaveFormat.Svg)
			{
				ExportToSvg(stream);
			}
			else if (format == SaveFormat.Metafile)
			{
				if (! (stream is FileStream)) throw new Exception("Stream must be a filestream when saving to the Metafile format.");
				
				FileStream file = (FileStream) stream;
				ExportToMetafile(file,null);
			}
				//Export to image
			else if (format == SaveFormat.Bmp)
			{
				ExportToPicture(stream, ImageFormat.Bmp);
			}
			else if (format == SaveFormat.Gif)
			{
				ExportToPicture(stream, ImageFormat.Gif);
			}
			else if (format == SaveFormat.Jpeg)
			{
				ExportToPicture(stream, ImageFormat.Jpeg);
			}
			else if (format == SaveFormat.Png)
			{
				ExportToPicture(stream, ImageFormat.Png);
			}
		}
        /// <summary>
        /// Saves the document from third party storage into various formats
        /// </summary>
        /// <param name="outputPath"></param>
        /// <param name="saveFormat"></param>
        /// <param name="storageType"></param>
        /// <param name="storageName">Name of the storage</param>
        /// <param name="folderName">In case of Amazon S3 storage the folder's path starts with Amazon S3 Bucket name.</param>
        public void SaveAs(string outputPath, SaveFormat saveFormat, StorageType storageType, string storageName, string folderName)
        {

            //build URI
            StringBuilder strURI = new StringBuilder(Product.BaseProductUri + "/slides/" + FileName
               + "?format=" + saveFormat + (string.IsNullOrEmpty(folderName) ? "" : "&folder=" + folderName));

            switch (storageType)
            {
                case StorageType.AmazonS3:
                    strURI.Append("&storage=" + storageName);
                    break;
            }

            string signedURI = Utils.Sign(strURI.ToString());

            Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

            using (Stream fileStream = System.IO.File.OpenWrite(outputPath))
            {
                Utils.CopyStream(responseStream, fileStream);
            }
            responseStream.Close();
        }
        /// <summary>
        /// Execute mail merge with regions.
        /// </summary>
        /// <param name="FileName"></param>
        /// <param name="strXML"></param>
        /// <param name="saveformat"></param>
        /// <param name="output"></param>
        /// <param name="documentFolder"></param>
        /// <param name="deleteFromStorage"></param>
        public void ExecuteMailMergewithRegions(string FileName, string strXML, SaveFormat saveformat, string output,
            string documentFolder = "", bool deleteFromStorage = false)
        {
            try
            {
                //build URI to get Image
                string strURI = Product.BaseProductUri + "/words/" + FileName + "/executeMailMerge?withRegions=true" +
                    (documentFolder == "" ? "" : "&folder=" + documentFolder);

                string signedURI = Utils.Sign(strURI);

                string outputFileName = null;

                using (Stream responseStream = Utils.ProcessCommand(signedURI, "POST", strXML, "xml"))
                {
                    string strResponse = null;

                    using (StreamReader reader = new StreamReader(responseStream))
                    {
                        //further process JSON response
                        strResponse = reader.ReadToEnd();
                    }

                    using (MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(strResponse)))
                    {
                        XPathDocument xPathDoc = new XPathDocument(ms);
                        XPathNavigator navigator = xPathDoc.CreateNavigator();

                        //get File Name
                        XPathNodeIterator nodes = navigator.Select("/SaaSposeResponse/Document/FileName");
                        nodes.MoveNext();
                        outputFileName = nodes.Current.InnerXml;
                        //build URI
                        strURI = Product.BaseProductUri + "/words/" + outputFileName;
                        strURI += "?format=" + saveformat + (documentFolder == "" ? "" : "&folder=" + documentFolder);
                    }
                }
                //sign URI
                signedURI = Utils.Sign(strURI);

                //get response stream
                using (Stream responseStream = Utils.ProcessCommand(signedURI, "GET"))
                {
                    using (Stream fileStream = System.IO.File.OpenWrite(output))
                    {
                        Utils.CopyStream(responseStream, fileStream);
                    }
                }

                if (deleteFromStorage)
                {
                    signedURI = Utils.Sign(Product.BaseProductUri + "/storage/file/" +
                        (documentFolder == "" ? outputFileName : documentFolder + "/" + outputFileName));
                    Utils.ProcessCommand(signedURI, "DELETE");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #52
0
    void OnGUI()
    {
        EditorGUI.DrawPreviewTexture(new Rect(10, 10, 280, 60), WorldIcon);

        if (Selection.gameObjects.Length > 0 && Selection.gameObjects[0].GetComponent(typeof(Terrain)))
        {
            terrainObject = (Terrain)Selection.gameObjects[0].GetComponent(typeof(Terrain));
            terrain = terrainObject.terrainData;
            terrainPos = terrainObject.transform.position;
            GUILayout.BeginArea(new Rect(10, 70, 140, 100));
            GUILayout.Label("Mesh Type:");
            saveFormat = (SaveFormat)EditorGUILayout.EnumPopup("", saveFormat);
            GUILayout.Label("Resolution:");
            saveResolution = (SaveResolution)EditorGUILayout.EnumPopup("", saveResolution);
            TerrainCollider[] tcs = UnityEngine.Object.FindObjectsOfType<TerrainCollider>();

            //check to see if the terrain is using the standard shader. if so, revert it to legacy diffuse so we render VC properly.
            if (terrainObject.materialType != Terrain.MaterialType.BuiltInLegacyDiffuse)
            {
                terrainObject.materialType = Terrain.MaterialType.BuiltInLegacyDiffuse;
                Debug.Log("Changing terrain material type to Legacy Diffuse so the vertex colors will render properly for PolyWorld Terrains.");
            }

            foreach (TerrainCollider t in tcs)
            {
                //if the two terrain datas match but we aren't looking at the same gameobject..
                if (t.terrainData.name.Equals(terrain.name) && t.gameObject != terrainObject.gameObject)
                {
                    targetGO = t.gameObject;
                    break;
                }
                else
                    targetGO = null;
            }
            //if there is a target gameobject in the scene
            if (targetGO)
            {
                usePrefab = GUILayout.Toggle(usePrefab, "Use Associated Mesh");//EditorGUILayout.Toggle("Use Associated Mesh", usePrefab);
            }
            else
                usePrefab = false;
            GUILayout.EndArea();

            //Generate Terrain
            if (GUI.Button(new Rect(160, 72, 130, 90), GenerateIcon))//GUILayout.Button(exportText))
            {
                bool badTerrain = false;
                if (terrain.size.x % terrain.size.z > 0)
                    badTerrain = true;
                if (badTerrain)
                    EditorUtility.DisplayDialog("Incompatible Terrain", "The terrain conversion has one requirement:\n\n1. " + terrainObject.name + " needs to have its length and width to be equal.", "Cancel Export");
                else if (targetGO == null && usePrefab)
                    EditorUtility.DisplayDialog("No Associated Mesh", "This terrain does not have an associated mesh generated yet. Uncheck 'Use Associated Mesh' and regenerate.", "OK");
                else if (terrainObject.name.Equals("Terrain"))
                    EditorUtility.DisplayDialog("Change Terrain Name", "Please give the Unity Terrain object a unique name other than 'Terrain.' This will make asset management easier for you.", "OK");
                else if (saveResolution == SaveResolution.Full && shownWarning==false)
                {
                    if (EditorUtility.DisplayDialog("Warning", "Warning: Exporting a full resolution terrain carries some significant risks:\n\n1. It will take some significant time to generate depending on the speed of your cpu.\n\n2. It will be more expensive to render it on your target platform as there is much more geometry to render.\n\n3. It will take longer to lightmap.\n\n Only choose 'Full Resolution' if you know what you are doing.\n\nAre you sure you want to render at Full Resolution?", "Yes", "Cancel"))
                    {
                        shownWarning = true;
                       // AssetDatabase.Refresh();

                        Export();
                    }
                }
                else
                {
                    //AssetDatabase.Refresh();
                    Export();
                }
            }
            if (usePrefab)
            {
                if (targetGO!=null)
                {
                    MeshFilter[] mf = targetGO.GetComponentsInChildren<MeshFilter>(true);

                    GUILayout.BeginArea(new Rect(10, 170, 280, 30));
                    GUILayout.Label("Editing: " + targetGO.name);
                    GUILayout.EndArea();
                    GUILayout.BeginArea(new Rect(10, 190, 140, 80));
                    meshHidden = GUILayout.Toggle(meshHidden,"Hide Associated Mesh");
                    terrainHidden = GUILayout.Toggle(terrainHidden, "Hide Terrain");
                    autoUpdateVC = GUILayout.Toggle(autoUpdateVC,"Auto Bake VC");
                    smoothVertColor = GUILayout.Toggle(smoothVertColor,"Smooth Vertex Color");
                    GUILayout.EndArea();
                    GUILayout.BeginArea(new Rect(160, 187, 130, 60));
                    if (GUILayout.Button("Use Custom Shaders"))
                    {
                        Shader s = Shader.Find("QuantumTheory/VertexColors/Unity5/Diffuse");
                        if (s != null)
                        {
                            MeshRenderer[] meshRenderers = targetGO.GetComponentsInChildren<MeshRenderer>();

                            foreach (MeshRenderer m in meshRenderers)
                                m.sharedMaterial.shader = s;
                            Debug.Log("Shaders applied successfully.");
                        }
                        else
                            Debug.LogWarning("Custom shaders not found! Please manually assign a shader that supports vertex colors.");

                    }

                    if (GUILayout.Button("Bake Vertex Colors"))
                            RenderVertexColors(targetGO);
                    GUILayout.EndArea();
                   // EditorGUI.DrawPreviewTexture(new Rect(10, 265, 280, DividerIcon.height), DividerIcon);

                    //if there are no chunk meshes in the prefab
                    if (!mf[0].sharedMesh.name.Contains("-Chunk"))
                    {
                        GUILayout.BeginArea(new Rect(10, 275, 280, 30));
                        chunkValUI = EditorGUILayout.IntSlider("Chunk Density:", chunkValUI, 1, 5, null);
                        GUILayout.EndArea();
                        float faceSize = GetFaceSize(mf[0].sharedMesh);
                        float newBoundSize = (float)(faceSize * chunkVal[chunkValUI - 1]);
                        int numMeshes = Mathf.CeilToInt(terrain.size.x / newBoundSize);
                        EditorGUI.HelpBox(new Rect(10, 295, 280, 40), "Chunk Size:  " + newBoundSize + "m\n" + "Terrain Size:  " + terrain.size.x + "m x " + terrain.size.z + "m\n" + "Approximate Mesh Count: " + numMeshes * numMeshes, MessageType.None);
                        GUILayout.BeginArea(new Rect(10, 340, 280, 30));
                        //DIVIDE MESH
                        if (GUILayout.Button("Divide Mesh into Chunks"))
                        {
                            //add a check here to see if there is a folder with chunks inside. Delete them since we'll regenerate them.
                            string basePath = Application.dataPath;
                            string pathB = AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(targetGO));
                            pathB = pathB.Replace(targetGO.name + ".prefab", "");
                            basePath = basePath.Replace("Assets", pathB + terrainObject.name + "-Chunks");
                            if (Directory.Exists(basePath))
                                FileUtil.DeleteFileOrDirectory(basePath);
                            AssetDatabase.Refresh();
                            DivideMesh();
                            mf = null;
                        }
                        GUILayout.EndArea();
                    }

                    else
                        EditorGUI.HelpBox(new Rect(10, 295, 280, 40), "Regenerate the terrain to use different Chunk sizes.", MessageType.None);
                    if (mf!=null)
                    {
                        if (meshHidden == false && mf[0].GetComponent<Renderer>().enabled != true)
                            ShowTerrainMesh(mf);
                        else if (meshHidden == true && mf[0].GetComponent<Renderer>().enabled != false)
                        {
                            HideTerrainMesh(mf);
                            if (terrainHidden)
                            {
                                terrainObject.enabled = true;
                                terrainHidden = false;
                            }
                        }
                    }
                    if (terrainHidden == false && terrainObject.enabled!=true)
                    {
                        terrainObject.enabled = true;
                    }
                    else if (terrainHidden == true && terrainObject.enabled != false)
                    {
                        terrainObject.enabled = false;
                        if (meshHidden == true)
                        {
                            ShowTerrainMesh(mf);
                            meshHidden = false;
                        }
                    }

                }
            }
            //else we are generating a new mesh
            else
            {
                usePrefab = false;
                targetGO = null;
                EditorGUI.HelpBox(new Rect(10, 295, 280, 60), "Select your mesh type, then pick the resolution. Be careful though, if you have a large terrain, some resolutions might be too much.\nTurn on 'use associated mesh' to apply the changes to the mesh if one is available.", MessageType.Warning);
            }

        }
        else //nothing is selected
        {
            targetGO = null;
            EditorGUI.HelpBox(new Rect(10, 295, 280, 40), "Select a Unity Terrain to get started!", MessageType.Warning);
        }
    }
 //ExEnd
 //ExStart
 //ExId:SaveSignature
 //ExSummary:Shows difference in .NET and Java in signatures of a method with an enum parameter.
 // The saveFormat parameter is a SaveFormat enum value.
 void Save(string fileName, SaveFormat saveFormat)
 {
     // Do nothing.
 }
        public void ExportModel(string filename, SaveFormat format) {
            if (format == SaveFormat.Svg) {
                // Suspend Model
                this.Suspend();
                this.SuspendEvents = true;
                if (ModelSettings.Default.EnableUndoRedo) {
                    this.UndoList.Suspend();
                }

                // Fix: Adjust size of table to be slightly bigger than the "HeadingHeight"
                // TODO: Remove when SVG Export Bug is fixed
                foreach (Element element in this.Shapes.Values) {
                    if (element is EsriTable) {
                        EsriTable table = (EsriTable)element;
                        if (table.Height <= table.HeadingHeight) {
                            table.Height = table.HeadingHeight + 1;
                        }
                    }
                }

                // Resume and Refresh Model
                if (ModelSettings.Default.EnableUndoRedo) {
                    this.UndoList.Resume();
                }
                this.SuspendEvents = false;
                this.Resume();
                this.Refresh();

                // Export Model to SVG
                SvgDocument document = new SvgDocument();
                foreach (Element element in this.Shapes.Values) {
                    Type type = element.GetType();
                    if (!document.Formatters.ContainsKey(type)) {
                        if (type.IsSubclassOf(typeof(EsriTable))) {
                            document.RegisterFormatter(type, typeof(TableFormatter));
                        }
                        else if (type.IsSubclassOf(typeof(Shape))) {
                            document.RegisterFormatter(type, typeof(ShapeFormatter));
                        }
                    }
                }
                foreach (Element element in this.Lines.Values) {
                    Type type = element.GetType();
                    if (!document.Formatters.ContainsKey(type)) {
                        if (type.IsSubclassOf(typeof(Link))) {
                            document.RegisterFormatter(type, typeof(LinkFormatter));
                        }
                    }
                }
                document.AddDiagram(this);
                document.Save(filename);
            }
            else {
                this.Save(filename, format);
            }
        }
        private static SaveOptions AddBookmarkSaveOptions(SaveFormat saveFormat)
        {
            PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
            XpsSaveOptions xpsSaveOptions = new XpsSaveOptions();
            SwfSaveOptions swfSaveOptions = new SwfSaveOptions();

            switch (saveFormat)
            {
                case SaveFormat.Pdf:

                    //Add bookmarks to the document
                    pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("My Bookmark", 1);
                    pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Nested Bookmark", 2);
                    pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Bookmark_WithoutWhiteSpaces", 3);

                    return pdfSaveOptions;

                case SaveFormat.Xps:

                    //Add bookmarks to the document
                    xpsSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("My Bookmark", 1);
                    xpsSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Nested Bookmark", 2);
                    xpsSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Bookmark_WithoutWhiteSpaces", 3);

                    return xpsSaveOptions;

                case SaveFormat.Swf:

                    //Add bookmarks to the document
                    swfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("My Bookmark", 1);
                    swfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Nested Bookmark", 2);
                    swfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("Bookmark_WithoutWhiteSpaces", 3);

                    return swfSaveOptions;
            }

            return null;
        }
        public void AddBookmarkWithWhiteSpaces(SaveFormat saveFormat)
        {
            Document doc = new Document();

            InsertBookmarks(doc);

            if (saveFormat == SaveFormat.Pdf)
            {
                //Save document with pdf save options
                doc.Save(MyDir + @"\Artifacts\Bookmark_WhiteSpaces.pdf", AddBookmarkSaveOptions(SaveFormat.Pdf));

                //Bind pdf with Aspose PDF
                PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
                bookmarkEditor.BindPdf(MyDir + @"\Artifacts\Bookmark_WhiteSpaces.pdf");

                //Get all bookmarks from the document
                Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();

                Assert.AreEqual(3, bookmarks.Count);

                //Assert that all the bookmarks title are with witespaces
                Assert.AreEqual("My Bookmark", bookmarks[0].Title);
                Assert.AreEqual("Nested Bookmark", bookmarks[1].Title);

                //Assert that the bookmark title without witespaces
                Assert.AreEqual("Bookmark_WithoutWhiteSpaces", bookmarks[2].Title);
            }
            else
            {
                MemoryStream dstStream = new MemoryStream();
                doc.Save(dstStream, AddBookmarkSaveOptions(saveFormat));

                //Get bookmarks from the document
                BookmarkCollection bookmarks = doc.Range.Bookmarks;

                Assert.AreEqual(3, bookmarks.Count);

                //Assert that all the bookmarks title are with witespaces
                Assert.AreEqual("My Bookmark", bookmarks[0].Name);
                Assert.AreEqual("Nested Bookmark", bookmarks[1].Name);

                //Assert that the bookmark title without witespaces
                Assert.AreEqual("Bookmark_WithoutWhiteSpaces", bookmarks[2].Name);
            }
        }