Inheritance: Kajabity.Tools.Forms.Document
コード例 #1
0
        public override void Load(string filename)
        {
            Debug.WriteLine("Loading " + filename);
            CsvDocument csvDoc = new CsvDocument(filename);

            FileStream fileStream = null;

            try
            {
                //Console.WriteLine("Loading " + filename);
                fileStream = File.OpenRead(filename);
                CsvReader reader = new CsvReader(fileStream);

                string[][] records = reader.ReadAll();
                csvDoc.Rows = records;
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }

            document = csvDoc;
            base.Load(filename);
        }
コード例 #2
0
        public override void Save(string filename)
        {
            //FileInfo info = new FileInfo( filename );
            Debug.WriteLine("Saving " + filename);

            FileStream outStream = null;

            try
            {
                outStream = File.OpenWrite(filename);
                outStream.SetLength(0L);

                CsvWriter writer = new CsvWriter(outStream);
                //writer.QuoteLimit = -1;
                CsvDocument csvDoc = this.CsvDocument;

                writer.WriteAll(csvDoc.Rows);
                outStream.Flush();
            }
            finally
            {
                if (outStream != null)
                {
                    outStream.Close();
                }
            }

            base.Save(filename);
        }
コード例 #3
0
        public override void NewDocument()
        {
            document = new CsvDocument();
            ((CsvDocument)document).Rows = new string[0][];

            base.NewDocument();
        }
コード例 #4
0
        public override void NewDocument()
        {
            document = new CsvDocument();
            ((CsvDocument)document).Rows = new string[0][];

            base.NewDocument();
        }
コード例 #5
0
        public override void Load( string filename )
        {
            Debug.WriteLine( "Loading " + filename );
            CsvDocument csvDoc = new CsvDocument(filename);

            FileStream fileStream = null;
            try
            {
                //Console.WriteLine("Loading " + filename);
                fileStream = File.OpenRead( filename );
                CsvReader reader = new CsvReader( fileStream );

                string[][] records = reader.ReadAll();
                csvDoc.Rows = records;
            }
            finally
            {
                if( fileStream != null )
                {
                    fileStream.Close();
                }
            }

            document = csvDoc;
            base.Load( filename );
        }
コード例 #6
0
        public override void DocumentChanged()
        {
            // Clear the list.
            this.listView.Items.Clear();
            this.listView.Columns.Clear();

            if (manager.Opened)
            {
                //	Update main form heading.
                this.Text = Application.ProductName + " - " + manager.Document.Name;

                CsvDocument    doc        = (CsvDocument)manager.Document;
                ListViewItem[] lvItems    = new ListViewItem[doc.Rows.Length];
                int            counter    = 0;
                int            maxColumns = 1;

                foreach (string[] row in doc.Rows)
                {
                    var lvItem = new ListViewItem(row);
                    lvItems[counter] = lvItem;
                    counter++;

                    if (row.Length > maxColumns)
                    {
                        maxColumns = row.Length;
                    }
                }

                for (int col = 0; col < maxColumns; col++)
                {
                    this.listView.Columns.Add(columnName(col));
                }

                listView.BeginUpdate();
                listView.Items.AddRange(lvItems);
                listView.EndUpdate();
            }
            else
            {
                //	Update main form heading.
                this.Text = Application.ProductName;
            }

            //	Force a display update.
            //this.Refresh();
        }
コード例 #7
0
        public override void NewDocument()
        {
            document = new CsvDocument();

            base.NewDocument();
        }