示例#1
0
 public void SetUp()
 {
     note = new Note {
         Name = "My cool Note", Content = $"This is a note{Environment.NewLine}It is multiline.{Environment.NewLine}It contains some text{Environment.NewLine}Maybe even tags"
     };
     noteTags = new List <Tag> {
         new Tag {
             Name = "Test Tag"
         }, new Tag {
             Name = "Other tag"
         }
     }
     .Select(tag => new NoteTag()
     {
         Note = note, Tag = tag
     }).ToList();
     foreach (NoteTag noteTag in noteTags)
     {
         noteTag.Tag.NoteTags.Add(noteTag);
     }
     note.NoteTags = noteTags;
     doc           = new TxtDocument(new List <Note> {
         note
     });
 }
        private void NewCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            TxtDocument newDocument = new TxtDocument(null);

            _documents.Add(newDocument);
            _activeDocument            = newDocument;
            InputRichTextBox.IsEnabled = true;
        }
示例#3
0
    static void Main()
    {
        Document doc = new Document();

        doc.Title  = "My First Document";
        doc.Author = "Nakov";
        doc.Add(new Paragraph("I am a paragraph"));
        doc.Add(new Hyperlink("http://dir.bg"));
        doc.Add(new Paragraph("I am another paragraph"));
        doc.Add(new Heading("Heading 1"));
        Paragraph paragraph = new Paragraph();

        paragraph.Add(new TextElement("Default Font", Font.DefaultFont));
        paragraph.Add(new TextElement(" "));
        paragraph.Add(new TextElement("Second Red", new Font(color: Color.Red)));
        paragraph.Add(new TextElement(" "));
        paragraph.Add(new TextElement("Green Italic",
                                      new Font(color: Color.Green, style: FontStyle.Italic)));
        paragraph.Add(new Paragraph());
        paragraph.Add(
            new TextElement("Consolas Bold Blue Italic",
                            new Font(
                                color: Color.Blue,
                                style: FontStyle.BoldItalic,
                                name: "Consolas")));
        doc.Add(paragraph);

        doc.Add(new Heading("Heading 2<br>", 2));

        doc.Add(
            new Hyperlink("http://softuni.bg")
            .Add(Image.CreateFromFile("../../logo.png"))
            .Add(new TextElement("some text"))
            );
        doc.Add(paragraph);

        var htmlDoc = new HtmlDocument(doc);
        var writer  = new StringWriter();

        htmlDoc.Render(writer);
        Console.WriteLine(writer.ToString());
        File.WriteAllText("document.html", writer.ToString());

        var txtDoc = new TxtDocument(doc);

        writer = new StringWriter();
        txtDoc.Render(writer);
        Console.WriteLine(writer.ToString());
        File.WriteAllText("document.txt", writer.ToString());
    }
        private void OpenCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog
            {
                Filter   = DocumentBase.FileOpenFilter,
                FileName = "New file"
            };

            if (fileDialog.ShowDialog() == true)
            {
                string fileExtension = Path.GetExtension(fileDialog.SafeFileName);

                switch (fileExtension)
                {
                case ".txt":
                    DocumentBase txtDocument = new TxtDocument(fileDialog.FileName);
                    _documents.Add(txtDocument);
                    _activeDocument = txtDocument;
                    break;
                }

                try
                {
                    _activeDocument.Open();

                    InputRichTextBox.IsEnabled = true;

                    new TextRange(InputRichTextBox.Document.ContentStart,
                                  InputRichTextBox.Document.ContentEnd)
                    {
                        Text = _activeDocument.Content
                    };
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, "Exception occured", MessageBoxButton.OK);
                }
            }
        }
示例#5
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var result = openFile.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            var pathToFile = openFile.FileName;

            try
            {
                ITxtDocument service  = new TxtDocument(pathToFile);
                var          document = service.Read();

                textBoxFormat.Text            = document.Header.Format;
                textBoxSourceOfData.Text      = document.Header.SourceOfData;
                textBoxStationName.Text       = document.Header.StationName;
                textBoxIAGACODE.Text          = document.Header.IAGACODE;
                textBoxGeodeticLatitude.Text  = document.Header.GeodeticLatitude.ToString();
                textBoxGeodeticLongitude.Text = document.Header.GeodeticLatitude.ToString();
                textBoxElevation.Text         = document.Header.Elevation.ToString();
                textBoxReported.Text          = document.Header.Reported;
                textBoxSensorOrientation.Text = document.Header.SensorOrientation;
                textBoxDigitalSampling.Text   = document.Header.DigitalSampling;
                textBoxDataIntervalType.Text  = document.Header.DataIntervalType;
                textBoxDataType.Text          = document.Header.DataType;

                dataGrid1.DataSource = document.Body.Lines;
            }
            catch (Exception ex)
            {
                toolStripError.Text = ex.Message;
                return;
            }
        }