Ejemplo n.º 1
0
 public Steps(Document doc)
 {
     this.Document = doc;
     this.steps = new List<int>();
     this.steps.Add( 0 );
     this.GotoFirstStep();
 }
Ejemplo n.º 2
0
        public static void DocumentRemoveTasksTest()
        {
            var doc = new Document();

            doc.Remove( 0 );
            doc.RemoveDate( 0 );
            doc.RemoveTask( 0 );
            Assert.AreEqual( 0, doc.CountDates );
        }
Ejemplo n.º 3
0
        public static void DocumentAddTasksTest()
        {
            const int Max = 3;
            var doc = new Document();

            for (int i = 0; i < Max; ++i) {
                doc.AddLast();
            }

            Assert.AreEqual( Max, doc.CountDates );
            Assert.AreEqual( Max, doc.CountTasks );
        }
Ejemplo n.º 4
0
 /// <summary>
 /// The base <see cref="Bareplan.Core.DocumentExporter"/> class for all exporters.
 /// </summary>
 /// <param name='doc'>
 /// The <see cref="Bareplan.Core.Document"/> to export.
 /// </param>
 public DocumentExporter(Document doc, string path)
 {
     this.Document = doc;
     this.Path = path;
     this.Contents = "";
 }
Ejemplo n.º 5
0
 public HtmlExporter(Document doc, string path)
     : base(doc, path)
 {
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Ignoring the stored document, if it exists, loads a new document
        /// </summary>
        /// <param name="f">The file to load the document from.</param>
        public override Document Load(string f)
        {
            var xmlDoc = new XmlDocument();
            var doc = new Document();
            bool initialDateSet = false;

            xmlDoc.Load( f );

            // Interpret nodes
            var mainNode = xmlDoc.DocumentElement;

            if ( mainNode.Name.ToLower() == TasksTag ) {
                foreach(XmlNode node in mainNode.ChildNodes) {
                    var element = ( node as XmlElement );

                    if ( element != null ) {
                        if ( element.Name.ToLower() == TaskTag ) {
                            string task;
                            var date = element.Attributes.GetNamedItem( DateTag );

                            if ( date != null ) {
                                task = element.InnerText;
                            } else {
                                throw new XmlException( "missing date in task" );
                            }

                            doc.AddLast();
                            doc.Modify( doc.CountDates - 1,
                                       DateTime.Parse( date.InnerText ),
                                       task
                            );
                        }
                        else
                        if ( element.Name.ToLower() == StepsTag ) {
                            doc.Steps.SetSteps( element.InnerText );
                        }
                        else
                        if ( element.Name.ToLower() == InitialDateTag ) {
                            DateTime result;

                            initialDateSet = DateTime.TryParseExact(
                                                        element.InnerText,
                                                        "yyyy-MM-dd",
                                                        CultureInfo.InvariantCulture,
                                                        DateTimeStyles.None,
                                                        out result );
                            if ( initialDateSet ) {
                                doc.InitialDate = result;
                            }
                        }
                    }

                }
            } else {
                throw new XmlException( "missing main node: " + TasksTag );
            }

            // Finish document configuration
            if ( !initialDateSet ) {
                if ( doc.CountDates > 0 ) {
                    doc.InitialDate = doc.GetDate( 0 );
                } else {
                    doc.InitialDate = DateTime.Now;
                }
            }

            this.Document = doc;
            return doc;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Build a new document saver/loader by XML <see cref="Bareplan.XmlDocumentPersistence"/> class.
 /// </summary>
 /// <param name='doc'>
 /// The document, that can be null if its going to be loaded.
 /// </param>
 public XmlDocumentPersistence(Document doc)
     : base(doc)
 {
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new instance, prepared to load and save documents.
 /// </summary>
 /// <param name="doc">The document to save. Pass null if you are going to load a new one.</param>
 public DocumentPersistence(Document doc)
 {
     this.Document = doc;
 }