private void SaveFileAction() { IDialogService service = DialogServiceFactory.GetServiceInstance(); try { bool okToContinue = true; string filePath = m_ExplorerVm.ActiveFile.FilePath; if (!m_ExplorerVm.ActiveFile.IsFileBackedPhysically) { var options = new DialogOptions() { DefaultFileName = "Untitled.jef", FileFilter = "JEF Compiled File (*.jef)|*.jef", WindowTitle = "Save File" }; okToContinue = service.ShowSaveFileDialog(options, out filePath); } if (okToContinue) { m_ExplorerVm.SaveFileCommand.Execute(filePath); } } catch (Exception ex) { service.ShowErrorDialog("Save Error", ex.Message); } }
private void LoadFileAction() { IDialogService service = DialogServiceFactory.GetServiceInstance(); try { var options = new DialogOptions() { FileFilter = "RISC-V Assembly File (*.asm)|*.asm", WindowTitle = "Open File" }; bool okToContinue = service.ShowOpenFileDialog(options, out string filePath); if (okToContinue) { Cursor.Current = Cursors.WaitCursor; m_EditorVm.LoadFileCommand.Execute(filePath); } } catch (Exception ex) { service.ShowErrorDialog("Save Error", ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private void ImportFileAction() { IDialogService service = DialogServiceFactory.GetServiceInstance(); try { var options = new DialogOptions() { FileFilter = "RISC-V ELF object file (*.o)|*.o|RISC-V JEF object file (*.jef)|*.jef", WindowTitle = "Import Compiled File" }; bool okToContinue = service.ShowOpenFileDialog(options, out string filePath); if (okToContinue) { m_EditorVm.DisassembleAndImportCmd.Execute(filePath); } } catch (Exception ex) { service.ShowErrorDialog("Import Error", ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private void SaveFileAction() { IDialogService service = DialogServiceFactory.GetServiceInstance(); try { bool okToContinue = true; string filePath = m_EditorVm.ActiveFile.FilePath; if (!m_EditorVm.ActiveFile.IsFileBackedPhysically) { var options = new DialogOptions() { DefaultFileName = "Untitled.asm", FileFilter = "RISC-V Assembly File (*.asm)|*.asm", WindowTitle = "Save File" }; okToContinue = service.ShowSaveFileDialog(options, out filePath); } if (okToContinue) { Cursor.Current = Cursors.WaitCursor; m_EditorVm.SaveFileCommand.Execute(filePath); } } catch (Exception ex) { service.ShowErrorDialog("Save Error", ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private void SaveFileAsAction() { IDialogService service = DialogServiceFactory.GetServiceInstance(); try { string defaultFileName = m_EditorVm.ActiveFile.FileName; if (string.IsNullOrEmpty(defaultFileName)) { defaultFileName = "Untitled.asm"; } // if there is an asterisk, strike that prior to printing. if (defaultFileName[defaultFileName.Length - 1] == '*') { defaultFileName = defaultFileName.Remove(defaultFileName.Length - 1); } var options = new DialogOptions() { DefaultFileName = defaultFileName, FileFilter = "RISC-V Assembly File (*.asm)|*.asm", WindowTitle = "Save File" }; bool okToContinue = service.ShowSaveFileDialog(options, out string filePath); if (okToContinue) { Cursor.Current = Cursors.WaitCursor; m_EditorVm.SaveFileCommand.Execute(filePath); } } catch (Exception ex) { service.ShowErrorDialog("Save Error", ex.Message); } finally { Cursor.Current = Cursors.Default; } }
public MainWindowViewModel() { _dialogService = DialogServiceFactory.GetDialogServiceInstance(); _fbTokenService = FacebookServiceFactory.GetFacebookTokenServiceInstance(); _settingsRepos = SettingsCreatorFactory.GetSetingsInstance(); GetTokenCommand = new DelegateCommand(async _ => { //Reset result ErrorMsg = null; FBToken = null; //End of - Reset result //Open loading indicator IsGettingData = true; Debug.WriteLine($"Email: {UserEmail} - Password: {UserPassword}"); string lastEmail = _settingsRepos.LastLoggedInEmail; if (UserEmail != lastEmail) { //Lưu lại email đã dùng để lấy token mới _settingsRepos.LastLoggedInEmail = UserEmail; } //Request new Facebook token var getTokenResult = await _fbTokenService.GetTokenInfoAsyncByLocMai(UserEmail, UserPassword); if (!getTokenResult.Success) { ErrorMsg = getTokenResult.Message; Debug.WriteLine(ErrorMsg); } else { FBToken = getTokenResult.UserTokenInfo.AccessToken; Debug.WriteLine($"Token: {FBToken}"); } //Remove loading indicator IsGettingData = false; }, _ => !string.IsNullOrEmpty(UserEmail) && !string.IsNullOrEmpty(UserPassword) && !IsGettingData); SaveTokenCommand = new DelegateCommand(_ => { //Cách lưu file text: https://stackoverflow.com/questions/45276878/creating-a-txt-file-and-write-to-it string filePath = _dialogService.ShowSaveFileDialog(); if (filePath == null) { return; } using (var tw = new StreamWriter(filePath, false)) { try { tw.Write(FBToken); //Thực hiện ghi file Debug.WriteLine($"Token was written to file: {filePath}"); } catch (Exception ex) { Debug.WriteLine(ex); } } }); }