Пример #1
0
 public FormBackupRestore(string currentFile)
 {
     _currentFile  = currentFile;
     _backupHelper = new BackupHelper(currentFile);
     InitializeComponent();
     Load += FormBackupRestore_Load;
 }
Пример #2
0
        private void btBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter           = "json Files (*.json)|*.json|All Files (*.*)|*.*",
                InitialDirectory = Config.LastOpenedDir
            };

            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                _currentFile  = openFileDialog.FileName;
                _backupHelper = new BackupHelper(_currentFile);
                Show();
            }
        }
Пример #3
0
        public void SaveFile(bool saveas)
        {
            _textBoxHelper.SaveState();

            string _selectedfile = CurrentFile;

            if (string.IsNullOrEmpty(_selectedfile))
            {
                saveas = true;
            }

            if (saveas == true)
            {
                SaveFileDialog d = new SaveFileDialog {
                    Filter = "json Files (*.json)|*.json|All Files (*.*)|*.*"
                };
                DialogResult dr = d.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                _selectedfile = d.FileName;
            }

            StopWatch _watch = new StopWatch();

            _watch.Start();

            if (IsOverwritingNewerFile(_selectedfile))
            {
                FormOverwrite f = new FormOverwrite();
                f.ShowDialog();
                switch (f.DlgResult)
                {
                case OverwriteMode.Cancel:
                    return;

                case OverwriteMode.Overwrite:
                    break;

                case OverwriteMode.Reload:
                    Reload();
                    return;
                }
            }

            CurrentFile     = _selectedfile;
            _lastOpenedDate = DateTime.Now;
            SetTitle();

            CodeSnippetCollection _collection = new CodeSnippetCollection {
                LastSaved = _lastOpenedDate
            };

            FormToCodeCollection(_treeViewLibrary.Nodes);
            if (_treeViewLibrary.SelectedNode != null)
            {
                _collection.LastSelected = _treeViewLibrary.SelectedNode.FullPath;
            }

            _mainform.SaveEditor();
            CodeLib.Instance.Save(_collection);

            BackupHelper backupHelper = new BackupHelper(CurrentFile);

            backupHelper.Backup();

            Save(_collection, _selectedfile);
        }