コード例 #1
0
 public void Load(MonoDocument document)
 {
     undo_manager.FreezeUndo();
     DocumentBufferArchiver.Deserialize(this, document.Xml);
     document_loaded = true;
     undo_manager.ThrawUndo();
 }
コード例 #2
0
        private void OnOpenActivated(object sender, System.EventArgs e)
        {
            string        filename = String.Empty;
            OpenDocDialog dialog   = new OpenDocDialog();

            if (dialog.Run() == (int)ResponseType.Ok)
            {
                filename = dialog.Document;
            }

            dialog.Destroy();

            if (filename != String.Empty)
            {
                try {
                    MonoDocument doc = new MonoDocument(filename);

                    if (!current_tab.Title.Equals("Untitled"))
                    {
                        AddTab();
                    }

                    current_tab.Title = doc.Filename;
                    current_tab.Buffer.Load(doc);
                    SaveAs.Sensitive = Save.Sensitive = true;
                } catch (ArgumentException emsg) {
                    // TODO: Add message dialog about error.
                    Console.WriteLine(emsg.Message);
                }
            }
        }
コード例 #3
0
        public void TestDeserializePerformance()
        {
            foreach (string file in files)
            {
                DocumentEditor editor = new DocumentEditor();
                DocumentBuffer buffer = (DocumentBuffer)editor.Buffer;

                MonoDocument document = new MonoDocument(file);
                string       filename = Path.GetFileName(file);

                buffer.Undoer.FreezeUndo();
                DateTime startTime = DateTime.Now;
                DocumentBufferArchiver.Deserialize(buffer, document.Xml);
                DateTime stopTime = DateTime.Now;
                buffer.Undoer.ThrawUndo();

                TimeSpan duration = stopTime - startTime;
                Assert.Less(duration.TotalMilliseconds, 1000, "SP:" + filename);
            }
        }
コード例 #4
0
        public void TestSerialize()
        {
            string originalXml, newXml, filename;

            foreach (string file in files)
            {
                DocumentEditor editor = new DocumentEditor();
                DocumentBuffer buffer = (DocumentBuffer)editor.Buffer;

                MonoDocument document = new MonoDocument(file);
                filename    = Path.GetFileName(file);
                originalXml = document.Xml;

                buffer.Undoer.FreezeUndo();
                DocumentBufferArchiver.Deserialize(buffer, originalXml);
                buffer.Undoer.ThrawUndo();
                newXml = DocumentBufferArchiver.Serialize(buffer);

                Assert.AreEqual(originalXml, newXml, "SR:" + filename);
            }
        }