private static async void SetUserFolder() { var UserFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("OffMode", Windows.Storage.CreationCollisionOption.OpenIfExists); if (UserFolder != null) { _userfolder = await UserFolder.CreateFolderAsync(Login.UserAccount.PersonnelId.ToString(), Windows.Storage.CreationCollisionOption.OpenIfExists); } }
public Capture() { this.InitializeComponent(); DataContext = this; localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; InitializeMediaCaptureAsync(); }
public MainPage() { this.InitializeComponent(); localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; if (localSettings.Values["NightScoutURL"] != null) NightScoutURL = localSettings.Values["NightScoutURL"].ToString(); this.NavigationCacheMode = NavigationCacheMode.Required; }
private async void btn5_Tapped_5(object sender, TappedRoutedEventArgs e) { MediaElement clip = new MediaElement(); Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets"); Windows.Storage.StorageFile file = await folder.GetFileAsync("Im Panicking.mp3"); var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); clip.SetSource(stream, file.ContentType); clip.Play(); }
private async void Folderpicker_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { var folderPicker = new Windows.Storage.Pickers.FolderPicker(); folderPicker.FileTypeFilter.Add("*"); Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder != null) { StreamingFilePath.Text = folder.Path; } }
public async static void CreateLog() { return; // Create sample file; replace if exists. Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Log.LogFile = await storageFolder.CreateFileAsync("BLElog.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); Windows.Storage.FileIO.WriteTextAsync(Log.LogFile, "Execution Log:\n"); }
private async void btnSave_Click(object sender, RoutedEventArgs e) { Debug.WriteLine("Saving patient..."); Patient patient = new DementiaApp.Patient(); patient.Name = txtName.Text; patient.Age = Convert.ToInt16(txtAge.Text); Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile patientFile = await storageFolder.CreateFileAsync("patient.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); await Windows.Storage.FileIO.WriteTextAsync(patientFile, patient.ToJson()); }
private async void Alemanha(object sender, RoutedEventArgs e) { Info.Text = "Country selected: \n\n Germany \n\n Average price for coffee: \n\n 2.65€ \n\n Popular brands: \n\n --- \n\n How to ask for coffee: \n\n Gib mir Kaffee. Bitte."; Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets"); Windows.Storage.StorageFile file = await folder.GetFileAsync("Doitch.mp3"); player.AutoPlay = false; player.Source = MediaSource.CreateFromStorageFile(file); player.Play(); }
public MainPage() { this.InitializeComponent(); localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; if (localSettings.Values["NightScoutURL"] != null) { NightScoutURL = localSettings.Values["NightScoutURL"].ToString(); } this.NavigationCacheMode = NavigationCacheMode.Required; }
private async void Espanha(object sender, RoutedEventArgs e) { Info.Text = " Country selected: \n\n Espanha \n\n Average price for coffee: 1.65€ \n\n Popular brands: \n\n --- \n\n How to ask for coffee: \n\n Dame un café solo, por favor."; Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets"); Windows.Storage.StorageFile file = await folder.GetFileAsync("Spanish.mp3"); player.AutoPlay = false; player.Source = MediaSource.CreateFromStorageFile(file); player.Play(); }
private async void Portugal(object sender, RoutedEventArgs e) { Info.Text = " Country selected: \n\n Portugal \n\n Average price for coffee: \n\n 0.65€ \n\n Popular brands: \n\n Delta \n\n How to ask for coffee: \n\n Dê-me um café, se faz favor."; Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets"); Windows.Storage.StorageFile file = await folder.GetFileAsync("Portuguese.mp3"); player.AutoPlay = false; player.Source = MediaSource.CreateFromStorageFile(file); player.Play(); }
public MainViewModel(INavigationService navigationService) { this.navigationService = navigationService; MessengerInstance.Register <NotificationMessage>(this, ReceiveMessage); Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; string folderPath = localFolder.Path; chemin = Path.Combine(folderPath, @"Contact.bin"); if (File.Exists(chemin) == true) { Contact = (List <Model.Contact>)Serialisation.Deserialiser(chemin); } }
public async Task PlaySound() { MediaElement mysong = new MediaElement(); Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets"); Windows.Storage.StorageFile file = await folder.GetFileAsync("not-bad.mp3"); var stream = await file.OpenReadAsync(); mysong.SetSource(stream, file.ContentType); mysong.Play(); }
public static async Task PlayUsingMediaPlayerAsync() { Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets"); Windows.Storage.StorageFile file = await folder.GetFileAsync("Click.wav"); _mediaPlayer.AutoPlay = false; _mediaPlayer.Source = MediaSource.CreateFromStorageFile(file); _mediaPlayer.MediaOpened += _mediaPlayer_MediaOpened; _mediaPlayer.IsLoopingEnabled = true; }
//Warns user with text and sound on 5th wrong guess, sets warning to true so sound won't repeat on subsequent correct guesses private async void Warning() { tbError.Text = "You're on your last leg! ;)"; warning = true; //audio code adapted from code at https://www.youtube.com/watch?v=hPxExtLCMK0 Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets\Audio"); Windows.Storage.StorageFile file = await folder.GetFileAsync("51752__erkanozan__warning.wav"); player.Source = MediaSource.CreateFromStorageFile(file); player.Play(); }
private async void Inglaterra(object sender, RoutedEventArgs e) { Info.Text = "Country selected: \n\n England \n\n Average price for coffee: \n\n £4.27 \n\n Popular brands: \n\n --- \n\n How to ask for coffee: \n\n One coffee. Please."; Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets"); Windows.Storage.StorageFile file = await folder.GetFileAsync("English.mp3"); player.AutoPlay = false; player.Source = MediaSource.CreateFromStorageFile(file); player.Play(); }
private async void PlayBeep() { MediaElement myBeep = new MediaElement(); Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets"); Windows.Storage.StorageFile file = await folder.GetFileAsync("beep.wav"); var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); myBeep.SetSource(stream, file.ContentType); myBeep.Play(); }
public static async System.Threading.Tasks.Task <string> CacheFileAsync(string sourceFilePath) { string fileName = Path.GetFileName(sourceFilePath); Windows.Storage.StorageFile sourceStorageFile = UwpFileBrowser.LastOpenFile; Windows.Storage.StorageFolder cacheStorageFolder = Windows.Storage.ApplicationData.Current.LocalCacheFolder; var cacheStorageFile = await sourceStorageFile.CopyAsync( cacheStorageFolder, fileName, Windows.Storage.NameCollisionOption.ReplaceExisting); string cacheFilePath = cacheStorageFile.Path; return(cacheFilePath); }
private async void EnterAppAsync(object sender, RoutedEventArgs e) { loading.Visibility = Visibility.Visible; ConnectDB db = new ConnectDB(); user user = await db.GetUserByMailAsync(email.Text); if (user == null) { loading.Visibility = Visibility.Collapsed; result.Text = "user doesn't exists"; } else { if (user.password.Equals(password.Password.ToString()) && user.type.Equals("Teacher")) { Common.who_am_i = email.Text; Common.garden = user.gardenname; Common.isConectet = true; Common.garden = user.gardenname; Common.GetGardenChildrenAsync(); try { Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile userFile = await storageFolder.CreateFileAsync("userTeacher.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); await Windows.Storage.FileIO.WriteTextAsync(userFile, email.Text + "+" + password.Password.ToString() + "+" + Common.garden); } catch { } loading.Visibility = Visibility.Collapsed; result.Text = "welcome " + user.firstname + "!"; Frame toHome = Window.Current.Content as Frame; toHome.Navigate(typeof(MainPage)); } else if (!user.type.Equals("Teacher")) { loading.Visibility = Visibility.Collapsed; result.Text = "Type is not a teacher"; } else { loading.Visibility = Visibility.Collapsed; result.Text = "incorrect password"; } } }
private async void ImportPlaylist_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { ClearErrorMessage(); if (comboPlayList.SelectedItem is Models.PlayList) { Models.PlayList p = comboPlayList.SelectedItem as Models.PlayList; if (p != null) { Windows.Storage.StorageFolder playlistFolder = await Helpers.StorageHelper.GetFolder("playlist"); if (playlistFolder == null) { playlistFolder = await Helpers.StorageHelper.CreateLocalFolder("playlist"); } if (playlistFolder != null) { string folderName = System.IO.Path.GetFileName(playlistFolder.Path); string fileName = System.IO.Path.GetFileName(p.Path); // Remove existing imported playlist if (!string.IsNullOrEmpty(p.ImportedPath)) { await Helpers.StorageHelper.RemoveFile(p.ImportedPath); } // Get a unique filename string destFileName = fileName; destFileName = await Helpers.StorageHelper.GetUniqueFileName(folderName, fileName); Windows.Storage.StorageFile importedPlaylistfile = await Helpers.StorageHelper.CopyFileToFolder(p.Path, folderName, destFileName); if (importedPlaylistfile != null) { p.ImportedPath = importedPlaylistfile.Path; ObservableCollection <Models.PlayList> pll = ViewModelLocator.Settings.PlayListList; if ((pll != null) && (comboPlayList.SelectedIndex < pll.Count)) { pll[comboPlayList.SelectedIndex] = p; ViewModelLocator.Settings.PlayListList = pll; if (!SelectPlaylistWithName(p.Name)) { ImportButton.IsEnabled = false; RemoveButton.IsEnabled = false; } } } } } } }
private async void butSave_ClickAsync(object sender, RoutedEventArgs e) { //WRITE THE TICKET TO A LOCAL DATABASE (txt)// //Create the text file to hold the data Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile saveFile = await storageFolder.CreateFileAsync("saveQuote.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); //Write data to the file await Windows.Storage.FileIO.WriteTextAsync(saveFile, "saveQuote.txt"); //read file string savedQuotes = await Windows.Storage.FileIO.ReadTextAsync(saveFile); }
public MainNueva() { this.InitializeComponent(); ContentFrame.Navigate(typeof(HomePage)); Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; localSettings.Values["apiKey"] = "5ff19b57095a4d10bf64274ed9e6ef30"; localSettings.Values["apiKeyCV"] = "47826cdef9984c8faa9cd47be4dd3c79"; localSettings.Values["PredictionKey"] = "47826cdef9984c8faa9cd47be4dd3c79"; }
public void StoreInRoaming(string key, Dictionary <object, object> values) { Windows.Storage.StorageFolder roamingFolder = Windows.Storage.ApplicationData.Current.RoamingFolder; Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue(); foreach (KeyValuePair <object, object> pair in values) { composite[pair.Key.ToString()] = pair.Value; } //if (roamingSettings.Values.ContainsKey(key)) _roamingSettings.Values[key] = composite; }
/// <summary> /// Saves a favorites or settings -file. /// </summary> /// <param name="fileType">File type enum: SETTINGS or FAVORITES</param> /// <param name="filename">Filename</param> private async void YtSaveFile(FileType fileType, string filename) { Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile sampleFile = await storageFolder.CreateFileAsync(filename, Windows.Storage.CreationCollisionOption.ReplaceExisting); Windows.Storage.StorageFile jsonFile = await storageFolder.GetFileAsync(filename); string serialized = (fileType == FileType.FAVORITES) ? JsonConvert.SerializeObject(YtFavoritesList.ToArray(), Formatting.Indented) : JsonConvert.SerializeObject(AppSettings, Formatting.Indented); await Windows.Storage.FileIO.WriteTextAsync(jsonFile, serialized); }
private async void Write_to_text_file_Click(object sender, RoutedEventArgs e) { // Get the sample file Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile sampleFile = await storageFolder.GetFileAsync("sample.txt"); // Write text to the sample file await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow"); // Test sample file Access_sample_file(); }
/// <summary> /// Læser værdier fra fil, returnerer værdier som string. /// </summary> /// <param name="fileName">Navnet på den lokale fil</param> /// <returns></returns> public static async Task <string> DeSerializeBoligFileAsync(String fileName) { string fileString = null; Windows.Storage.StorageFolder myStorageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; if (await myStorageFolder.TryGetItemAsync(fileName) != null) { Windows.Storage.StorageFile myStorageFile = await myStorageFolder.GetFileAsync(fileName); fileString = await Windows.Storage.FileIO.ReadTextAsync(myStorageFile); } return(fileString); }
public MainNueva() { this.InitializeComponent(); ContentFrame.Navigate(typeof(HomePage)); Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; localSettings.Values["apiKey"] = "5ff19b57095a4d10bf64274ed9e6ef30"; localSettings.Values["apiKeyCV"] = "[tu clave custom vision]"; localSettings.Values["PredictionKey"] = "[tu clave custom vision prediction]"; }
private async void Read_text_file_Click(object sender, RoutedEventArgs e) { // Get the sample file Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile sampleFile = await storageFolder.GetFileAsync("sample.txt"); // Read sample file string text = await Windows.Storage.FileIO.ReadTextAsync(sampleFile); // Show contents of file this.Read_File_Contents.Text = text; }
public async void playBackground() { //Main Song mySong.IsLooping = true; Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets"); Windows.Storage.StorageFile file; file = await folder.GetFileAsync("Background.mp3"); var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); mySong.SetSource(stream, file.ContentType); mySong.Play(); }
public async System.Threading.Tasks.Task <string> ReadOnFileAsync(string name) { Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile sampleFile = await storageFolder.GetFileAsync(name + ".txt"); var buffer = await Windows.Storage.FileIO.ReadBufferAsync(sampleFile); using (var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(buffer)) { string text = dataReader.ReadString(buffer.Length); Task.WaitAll(); return(text); } }
private async void Button_Click(object sender, RoutedEventArgs e) { Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile savedFile = await storageFolder.GetFileAsync("Profile.txt"); var stream = await savedFile.OpenAsync(Windows.Storage.FileAccessMode.Read); using (StreamReader reader = new StreamReader(stream.AsStream())) { textBlock.Text = reader.ReadToEnd(); //textBlock.DataContext = reader.ReadToEnd(); } }
/*Create a file in localFolder. when user input text in "userInput text box", save the text which is just inputed to the local file.*/ private async void CreateAFile_BTN_Click(object sender, RoutedEventArgs e) { // Create sample file; replace if exists. Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; // show path FilePath_TxtBox.Text = storageFolder.Path; //Save file and name is sample.txt Windows.Storage.StorageFile sampleFile = await storageFolder.CreateFileAsync("sample.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); // user input text await Windows.Storage.FileIO.WriteTextAsync(sampleFile, (string)userInput.Text); }
public async void Save() { Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile sampleFile = await storageFolder.CreateFileAsync("FirstRichEdit.rtf", Windows.Storage.CreationCollisionOption.ReplaceExisting); IRandomAccessStream documentStream = await sampleFile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); _richEditBox.Document.SaveToStream(TextGetOptions.FormatRtf, documentStream); documentStream.Dispose(); }
public ITR_Master() { this.InitializeComponent(); Serializer = new CControlSerializer(); DocRepository = new CDocRepository(Windows.Storage.ApplicationData.Current.LocalFolder, "FiwpItrList.xml"); Doc = new QAQCDoc(); BaseFolder = Lib.ContentPath.OffModeUserFolder; Helper = new WinAppLibrary.Utilities.Helper(); ProximityHandler = new Lib.ProximityHandler(); ProximityHandler.OnException += ProximityHandler_OnException; ProximityHandler.OnMessage += ProximityHandler_OnMessage; lvNFCSignList.SelectionChanged += lvNFCSignList_SelectionChanged; // uiSlideButton.SetImage(WinAppLibrary.Utilities.Helper.BaseUri + "Assets/stop.png"); // uiSlideButton.ContentClick += uiSlideButton_ContentClick; }
private static async void SetLoginFolder() { string foldername = string.IsNullOrEmpty(WinAppLibrary.Utilities.Helper.LoginID) ? Login.UserAccount.LoginName.ToString() : WinAppLibrary.Utilities.Helper.LoginID; var UserFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("OffMode", Windows.Storage.CreationCollisionOption.OpenIfExists); _loginfolder = await UserFolder.CreateFolderAsync(foldername, Windows.Storage.CreationCollisionOption.OpenIfExists); }
private static async void SetOffFolder() { _offfolder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("OffMode", Windows.Storage.CreationCollisionOption.OpenIfExists); }
private int _fiwpID = 0; //Convert.ToInt32(navigationParameter.ToString()); public DownloadITR() { this.InitializeComponent(); Login.MasterPage.SetPageTitle("Select Inspection & Test Record"); BaseFolder = Lib.ContentPath.OffModeUserFolder; }
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { _projectid = Login.UserAccount.CurProjectID; _moduleid = Login.UserAccount.CurModuleID; _loginid = string.IsNullOrEmpty(WinAppLibrary.Utilities.Helper.LoginID) ? Login.UserAccount.LoginName.ToString() : WinAppLibrary.Utilities.Helper.LoginID; BaseFolder = Lib.ContentPath.OffModeUserFolder; //Login.MasterPage.DoBeforeBack += MasterPage_DoBeforeBack; Login.MasterPage.ShowBackButton = false; try { btnRemove.Visibility = Visibility.Visible; departmentId = WinAppLibrary.Utilities.Department.Foreman; // 1. QC Manager의 경우 foreman이 작업한 내용만 list up fmode = navigationParameter != null ? navigationParameter.ToString() : "1"; switch (fmode) { case "1": // FillOut Mode Login.MasterPage.SetPageTitle("Select Download Inspection & Test Record"); txtTitle.Text = "Fill Out Inspection & Test Record"; btnFillout.Visibility = Windows.UI.Xaml.Visibility.Visible; btnSubmit.Visibility = Windows.UI.Xaml.Visibility.Collapsed; BindList(); break; case "2": // Submit Mode Login.MasterPage.SetPageTitle("Inspection & Test Record To Submit"); txtTitle.Text = "Submit Inspection & Test Record"; btnFillout.Visibility = Windows.UI.Xaml.Visibility.Collapsed; btnSubmit.Visibility = Windows.UI.Xaml.Visibility.Visible; BindList(); break; case "3": // Approval Mode Login.MasterPage.SetPageTitle("Inspection & Test Record To Approval"); txtTitle.Text = "Approval Inspection & Test Record"; btnFillout.Visibility = Windows.UI.Xaml.Visibility.Visible; btnSubmit.Visibility = Windows.UI.Xaml.Visibility.Collapsed; btnRemove.Visibility = Visibility.Collapsed; departmentId = WinAppLibrary.Utilities.Department.QualityManagement; bindListfromService(); break; } //departmentId = await GetDepartmentID(); //if (departmentId == 14) // Foreman //{ // btnRemove.Visibility = Visibility.Visible; // BindList(); //} //if (departmentId == 18) // Quality Management //{ // btnRemove.Visibility = Visibility.Collapsed; //} } catch (Exception ex) { (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(ex, "LoadState"); } }
internal StorageFolder(Windows.Storage.StorageFolder folder) { _folder = folder; }