コード例 #1
0
ファイル: DialogManager.cs プロジェクト: lulzzz/Lyzard
        public static ManagedFile SaveFileAs(string text)
        {
            ManagedFile file     = null;
            var         lastPath = StateManager.SystemState.LastFileOpenLocation;

            if (string.IsNullOrEmpty(lastPath))
            {
                lastPath = CommonFolders.UserProjects;
            }
            var dlg = new SaveFileDialog();

            dlg.InitialDirectory = lastPath;
            dlg.DefaultExt       = ".cs";
            dlg.Filter           = "C Sharp (*.cs)|*.cs|Visual Basic (*.vb)|*.vb|All File (*.*)|*.*";
            var result = dlg.ShowDialog();

            if (result == DialogResult.OK)
            {
                file = ManagedFile.Create(dlg.FileName);
                file.Save(text);
                StateManager.SystemState.LastFileOpenLocation = file.FilePath;
                if (file.Extension == ".lyzard")
                {
                    StateManager.SystemState.RecentProjects.Add(file.FullPath);
                }
                else
                {
                    StateManager.SystemState.RecentFiles.Add(file.FullPath);
                }
            }
            return(file);
        }
コード例 #2
0
ファイル: CodeEditorViewModel.cs プロジェクト: lulzzz/Lyzard
        public override void Save(object param)
        {
            if (_file != null)
            {
                SystemLog.Instance.LogInfo($"Saving file...{_file.FileName}");

                _file.Save(_document.Text);
            }
            else
            {
                SaveAs(null);
            }
        }
コード例 #3
0
 private Settings LoadSettings()
 {
     _file = ManagedFile.Create(_settingsPath);
     if (_file.Load().Length > 0)
     {
         return(_file.Load <Settings>());
     }
     else
     {
         var settings = new Settings();
         _file.Save <Settings>(Settings);
         return(settings);
     }
 }
コード例 #4
0
 public void SaveSettings()
 {
     _file.Save <Settings>(Settings);
 }
コード例 #5
0
ファイル: StateManager.cs プロジェクト: lulzzz/Lyzard
 public static void SaveState()
 {
     _stateFile.Save(_stateInstance);
 }