Example #1
0
        async Task <string> ed(string command)
        {
            string result = " ";
            string name   = "";
            Folder parent = CurrentFolder;

            if (command.Substring(3) == "")
            {
                return("No File Name");
            }
            else
            {
                name = command.Substring(3);
            }

            // Check the existence of the File
            bool IsExist = await ICheckFileExist(name, parent.iFolder);

            if (IsExist)
            {
                foreach (File file in parent.Files)
                {
                    if (file.Name == name)
                    {
                        FileEditor.Text = await IReadFile(file.iFile);

                        CurrentFile = file;
                        break;
                    }
                }
            }
            else
            {
                File file = new File()
                {
                    Name   = name,
                    Parent = parent
                };
                file.iFile = await ICreateFile(file, parent.iFolder);

                parent.Files.Add(file);

                CurrentFile = file;
            }

            FileEditorTitle.Text     = "File Name: " + CurrentFile.Name;
            FileEditorGrid.IsVisible = true;

            // Editor.Focus() doesn't work due to timing probelm(?),
            // so maake it into Timer
            Device.StartTimer(TimeSpan.FromMilliseconds(1), () =>
            {
                FileEditor.Focus();
                return(false);   // Timer Cycle is only one time
            });

            return(result);
        }
Example #2
0
        // Pop up the file editor
        string ed(string command)
        {
            string result = " ";
            string name   = "";

            if (command.Substring(3) == "")
            {
                return("No File Name");
            }
            else
            {
                name = command.Substring(3);
            }

            // Check the existence of the File
            bool IsExist = File.Exists(WorkingDir + name);


            if (IsExist)    // Get all text of the file
            {
                FileEditor.Text = File.ReadAllText(WorkingDir + name);
                OriginalFile    = FileEditor.Text;
            }
            else            // If no file, create a new file
            {
                //File.Create(name).Close();
                File.Create(name);
                FileEditor.Text = "";
            }

            FileEditorTitle.Text     = "File Name: " + name;
            FileEditorGrid.IsVisible = true;    // Make the file editor visible

            // Editor.Focus() doesn't work due to timing probelm(?),
            // so maake it into Timer
            Device.StartTimer(TimeSpan.FromMilliseconds(1), () =>
            {
                FileEditor.Focus();
                return(false);   // Timer Cycle is only one time
            });

            return(result);
        }