Exemple #1
0
        public static void OpenDocument(string fileName)
        {
            //TODO: error checking: if no filename exists

            using (var ms = new MemoryStream())
            {
                // serialize file from disk
                var input = CryptoHelper.Decrypt(File.ReadAllBytes(fileName));
                ms.Write(input, 0, input.Length);
                ms.Position = 0; // move back to beginning of stream

                var bf = new BinaryFormatter();
                _document = (Document)bf.Deserialize(ms);
            }

            // reset the is modified flag
            _document.IsModified = false;

            FireDocumentOpened();
        }
Exemple #2
0
        public static void NewDocument()
        {
            foreach (var group in _document.Groups)
            {
                // this method deletes the keys prior to the group
                DeleteKeys(group);
            }

            _document.Groups.Clear();

            _document = new Document();

            FireDocumentNew();
        }