Beispiel #1
0
        private void OnNew(object parameter)
        {
            RakunFileViewModel _newDocument = new RakunFileViewModel();

            _newDocument.Title = "rakun" + countingfiledefalt.ToString();
            countingfiledefalt++;
            _files.Add(_newDocument);
            ActiveDocument = _files.Last();
            //ActiveDocument = _newDocument;

            StatusString = "File Create Successfuly";
        }
Beispiel #2
0
        public RakunFileViewModel Open(string filepath)
        {
            var RakunFileViewModel = _files.FirstOrDefault(fm => fm.FilePath == filepath);

            if (RakunFileViewModel != null)
            {
                return(RakunFileViewModel);
            }

            RakunFileViewModel = new RakunFileViewModel(filepath);
            _files.Add(RakunFileViewModel);
            return(RakunFileViewModel);
        }
Beispiel #3
0
        internal void Save(RakunFileViewModel fileToSave, bool saveAsFlag = false)
        {
            if (fileToSave.FilePath == null || saveAsFlag)
            {
                var dlg = new SaveFileDialog();
                dlg.Filter = "Arduino Files|*.ino";
                dlg.Title  = "Save Arduino File";
                if (dlg.ShowDialog().GetValueOrDefault())
                {
                    fileToSave.FilePath = dlg.FileName;
                }
            }

            File.WriteAllText(fileToSave.FilePath, fileToSave.TextContent);
            ActiveDocument.IsDirty = false;


            StatusString = fileToSave.FileName + " Saved";
        }
Beispiel #4
0
        internal void Close(RakunFileViewModel fileToClose)
        {
            if (fileToClose.IsDirty)
            {
                var res = MessageBox.Show(string.Format("Save changes for file '{0}'?", fileToClose.FileName), "AvalonDock Test App", MessageBoxButton.YesNoCancel);
                if (res == MessageBoxResult.Cancel)
                {
                    return;
                }
                if (res == MessageBoxResult.Yes)
                {
                    Save(fileToClose);
                }
            }

            _files.Remove(fileToClose);

            StatusString = fileToClose.FileName + " Closed";
        }