コード例 #1
0
        //Make a collection of all files
        public async void CreateCollection()
        {
            _allFiles.Clear();
            Files.Clear();

            /*StorageFolder textFolder = ApplicationData.Current.LocalFolder;
             *
             * IReadOnlyList<StorageFile> storageFiles = await textFolder.GetFilesAsync();
             *
             *
             *
             *
             * //For each file input into all files list
             * foreach (StorageFile file in storageFiles)
             * {
             *  //If file is null don't do anything
             *  if (file != null) {
             *      //this.Files.Add(new TextFileModel(file.Path, file.DisplayName, text));
             *      try {
             *
             *          _allFiles.Add(new TextFileModel(file.Path, file.DisplayName, await FileIO.ReadTextAsync(file)));
             *       }
             *      catch (FileNotFoundException e)
             *      {
             *          Console.WriteLine(e);
             *      }
             *  }
             * }*/

            _allFiles = DataRepo.GetData();

            PerformFiltering();
        }
コード例 #2
0
        public MainPage()
        {
            this.InitializeComponent();

            DataRepo.InitializeDB();
            //Make a new view model
            this.viewModel = new TextFileViewModel(fileText);
        }
コード例 #3
0
        public async void Execute(object parameter)
        {
            //Text block text
            string txt = myTextBox.Text;

            //If the text is new
            if (viewModel.isNew)
            {
                //Open a save dialog box
                SaveDialog saveDialog = new SaveDialog(viewModel);
                await saveDialog.ShowAsync();

                //If the result isn't empty then create a new file
                if (!saveDialog.Exited)
                {
                    //viewModel.CreateNewFile(saveDialog.Result, txt);

                    DataRepo.AddData(txt, saveDialog.Result);
                }
            }
            else
            {
                //Write to an existing file and save the new content
                //viewModel.WriteToFile(txt);

                DataRepo.UpdateData(viewModel.SelectedFile.NoteID, txt);
            }


            //Remake the collection of files and perform filtering
            viewModel.CreateCollection();
            viewModel.PerformFiltering();

            //Set properties
            viewModel.canEdit    = false;
            viewModel.canDelete  = false;
            viewModel.canSave    = false;
            myTextBox.IsReadOnly = true;

            //Invoke changes
            viewModel.changesMade();

            //Set text box to blank
            myTextBox.Text = "";
        }
コード例 #4
0
        public async void Execute(object parameter)
        {
            DeleteDialog deleteDialog = new DeleteDialog();
            await deleteDialog.ShowAsync();

            if (deleteDialog.canDelete == true)
            {
                //Delete current selected file
                //viewModel.DeleteFile();
                DataRepo.DeleteData(viewModel.SelectedFile.NoteID);


                //Set everything to empty
                viewModel.SelectedFile = new TextFileModel("", "", "");

                viewModel.canEdit = false;
                viewModel.canSave = false;

                viewModel.changesMade();
                viewModel.PerformFiltering();
                viewModel.CreateCollection();
            }
        }