コード例 #1
0
        private void SaveDocument()
        {
            DocumentSaver.Save(Document, Filename);
            Document.Manipulator.ResetUndoStack();

            MessageBus.Publish(new DocumentSavedEvent());
        }
コード例 #2
0
 public CurrencyGeneratorView()
 {
     InitializeComponent();
     Coinpurses     = new List <Currency>();
     _documentSaver = new DocumentSaver();
     UpdateLabel();
 }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: HL971/Gemstone
        public void Test2()
        {
            var documentSaver = new DocumentSaver();
            var currency      = CurrencyGenerator.GenerateForLevel(15);

            for (int x = 0; x < 25; x++)
            {
                var currency2 = CurrencyGenerator.GenerateForLevel(20);
                currency.Merge(currency2);
            }

            documentSaver.SaveCurrency("test.txt", currency);
        }
コード例 #4
0
ファイル: GetEpub.cs プロジェクト: HPRIOR/WikEpub
        /// <summary>
        /// Creates an epub from the given urls.
        /// </summary>
        /// <remarks>
        /// This method makes use of a record created for each html that is given by a url.
        /// The records contain information from the html needed to create the various files which
        /// constitute the epub format. An immutable record is created initially so the data collected can be used
        /// accross various parts of the program. For example, the record contains a mapping (src map) for each image.
        /// This maps the current src of the image to a new local one - this is then used to change the sources of the
        /// html images to a local directory and also to download the images to the relevant local directory.
        /// </remarks>
        /// <param name="urls"></param>
        /// <param name="rootDirectory">Path in which the book will be created</param>
        /// <param name="bookTitle">Name of the book</param>
        /// <param name="guid">Unique identifier for the folder</param>
        /// <returns></returns>
        public async Task FromAsync(IEnumerable <string> urls, string rootDirectory, string bookTitle, Guid guid)
        {
            var htmlDocs = _htmlInput.GetHtmlDocumentsFromAsync(urls, new HtmlWeb());

            var directoryPaths    = GetDirectoryContext(rootDirectory, guid);
            var createDirectories = _epubOutput.CreateDirectoriesAsync(directoryPaths);

            var wikiPageRecords =
                (await htmlDocs).Select(doc => _getRecords.From(doc, "image_repo")).ToList();
            var downloadImages =
                Task.WhenAll(wikiPageRecords.SelectMany(record => _epubOutput.DownloadImages(record, directoryPaths)));

            var createEpubDocuments = Task.WhenAll(_getEpubDocs.From(wikiPageRecords, bookTitle, directoryPaths));

            // Save the produced files to relevant directory and compress them
            await createDirectories;
            var   saveDocuments  = DocumentSaver.Save(await createEpubDocuments);
            var   createMimeType = _epubOutput.CreateMimeFile(directoryPaths);

            Task.WaitAll(saveDocuments, createMimeType, downloadImages);
            await _epubOutput.ZipFiles(directoryPaths, guid);
        }
コード例 #5
0
        protected void ViewXMLSource(object sender, WriterCommandEventArgs args)
        {
            if (args.Mode == WriterCommandEventMode.QueryState)
            {
                args.Enabled = args.Document != null;
            }
            else if (args.Mode == WriterCommandEventMode.Invoke)
            {
                System.IO.StringWriter writer = new System.IO.StringWriter();
                DocumentSaver.SaveXmlFile(writer, args.Document);

                string xml = writer.ToString();
                if (args.ShowUI)
                {
                    using (frmViewXML frm = new frmViewXML())
                    {
                        frm.XMLSource = xml;
                        frm.ShowDialog(args.EditorControl);
                    }
                }
                args.Result       = xml;
                args.RefreshLevel = UIStateRefreshLevel.None;
            }
        }
コード例 #6
0
 public WeaponWindow()
 {
     InitializeComponent();
     _documentSaver = new DocumentSaver();
 }