Пример #1
0
        public bool CheckFileExists(string fileName)
        {
            Debug.WriteLine($"Checking that {fileName} exists...");

            try
            {
                if (string.IsNullOrEmpty(fileName))
                {
                    Debug.WriteLine($"File name was empty");
                    return(false);
                }

                try
                {
                    var files = new FileAccessProvider().GetFileCollectionFromContractsShare();

                    if (!files.Any())
                    {
                        throw new FileNotFoundException();
                    }

                    for (int i = 0; i < files.Count(); i++)
                    {
                        var extendedFileName = Path.GetFileName(files.ElementAt(i).FullName);

                        if (extendedFileName.Equals(fileName, StringComparison.Ordinal))
                        {
                            return(true);
                        }
                    }

                    Debug.WriteLine($"No matches found with => {fileName}");

                    return(false);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine($"Failed to get File Collection from Contracts Share : {ex.Message}");
                    throw;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Unexpected Exception : {ex.Message}");
                throw;
            }
        }
Пример #2
0
        private void SaveButtonClicked(object sender, EventArgs e)
        {
            string[] script = Editor?.Text.Split('\n') ?? new string[0];

            // Open save file dialogue. If it completes, write to file.
            Navigation.PushModalAsync(new SaveLuaPage(
                                          title,
                                          (string file) => {
                title = file;

                string dest = "Scripts/" + file + ".lua";
                FileAccessProvider.WriteText(dest, script);

                changes = false;
            },
                                          () => { }
                                          ));
        }
Пример #3
0
        public OpenLuaPage(OnFileChosen callback)
        {
            InitializeComponent();

            this.callback = callback;

            List <ListItem> items = new List <ListItem>();

            foreach (string file in FileAccessProvider.ListFiles("Scripts"))
            {
                string[] contents   = FileAccessProvider.ReadText(file);
                string   mgcontents = string.Join(" ", contents);

                items.Add(new ListItem {
                    Title    = file.Split('/').Last(),
                    Desc     = mgcontents.Length > 30 ? (mgcontents.Substring(0, 27) + "...") : mgcontents,
                    contents = contents
                });
            }

            FileList.ItemsSource = items;
        }