private void ExecuteLoadDatabaseCommand(object o) { var dbFileOpener = new OpenFileService() { AcceptNonExistingFiles = true }; if (!dbFileOpener.OpenFile(OpenFileService.SqliteDatabaseFilter)) { return; } Connection.Connect(dbFileOpener.SelectedFile); if (!dbFileOpener.SelectedFileExists) { new DatabaseService { Connection = Connection }.InitializeDatabase(); } Repository = new Repository() { Connection = Connection }; BusinessObjectList.Clear(); LoadAllDataFromDatabase(); LoadTags(SearchQuery.NoFilter); IsReady = true; }
private ICommand CreateOpenFileCommand(string filter) { var service = new OpenFileService(); service.FileOpened += (sender, args) => SelectedFile = args.File; return(new Command <string>(file => service.OpenFileDialog(file, filter))); }
private void openFileCommandMethod(object parameter) { try { var basePath = string.IsNullOrWhiteSpace(FilePath) || !File.Exists(FilePath) ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) : Path.GetDirectoryName(FilePath); FilePath = OpenFileService.GetFilePath(basePath); if (string.IsNullOrWhiteSpace(FilePath) || !File.Exists(FilePath)) { return; } using (var stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read)) using (var reader = new StreamReader(stream)) FileContent = reader.ReadToEnd(); } catch (Exception ex) { //Sample quality error handling //obviously you're not supposed to handle exceptions like this in production! FileContent = ex.Message; } }
private void Script_TextChanged(object sender, TextChangedEventArgs e) { if (_IsDoneInitializing) { OpenFileService.FileTextChanged(_FilePath); } }
private void OpenFile() { OpenFileService.DefaultExtension = ".rtf"; OpenFileService.Filter = string.Join("", new string[] { "Documento de texto enriquecido (*.rtf)|*.rtf|", "Documento de texto (*.txt)|*.txt|", "Todos los archivos (*.*)|*.*" }); OpenFileService.FilterIndex = 1; OpenFileService.MultiSelect = false; OpenFileService.Title = "Abrir archivo"; if (OpenFileService.ShowDialog() == true && OpenFileService.FileName.Length > 0) { if (OpenFileService.FilterIndex == 1) { RichEdit.Document.OpenFile(OpenFileService.FileName, TextOpenSaveOptions.RTF); } else { RichEdit.Document.OpenFile(OpenFileService.FileName, TextOpenSaveOptions.Default); } MainWindow.Title = $"{Path.GetFileName(RichEdit.Document.Name)} - "; } }
private void OpenFileCommandExecute() { cartridge = OpenFileService.OpenCartridgeFile(); if (cartridge != null) { console.InsertCartridge(cartridge); (Reset as RelayCommand).Execute(); } }
private void SetupCompositionRoot() { IOpenFileService openFileService = new OpenFileService(Filter, InitialDirectory); IModelProvider modelProvider = new ModelProvider(); IMessageService messageService = new MessageService(); var viewModelFactory = new ViewModelFactory(openFileService, modelProvider, messageService); mainWindow = new MainWindowView(viewModelFactory); }
private Dictionary <string, string> GetRunInputsFromUI() { var output = new Dictionary <string, string>(); var availableTypes = TypeService.GetAvailableTypes(); var inputs = GetInputsFromUI(); foreach (var child in RunInputs.Children) { var grid = child as Grid; if (grid != null) { var typeID = ((Label)grid.Children[2]).Content.ToString(); var thisType = availableTypes.First(x => x.ID == Guid.Parse(typeID)); if (thisType.ID.ToString() == TypeService.SecretTypeID) { var variableFriendlyName = ((Label)grid.Children[0]).Content as String; var value = ((ComboBox)grid.Children[1]).SelectedValue.ToString(); var variableName = inputs.First(x => x.FriendlyName == variableFriendlyName).VariableName; var vaults = OpenFileService.GetOpenVaults(); foreach (var vault in vaults) { // This is a bug - we need to use the secret's ID to look it up later // once support for multiple vaults is added. if (vault.Vault.Secrets.Any(x => x.Key == value)) { var secret = vault.Vault.Secrets.First(x => x.Key == value); output.Add(variableName, secret.Value); } } continue; } if (!thisType.HasMultipleValues) { var variableFriendlyName = ((Label)grid.Children[0]).Content as String; var value = ((TextBox)grid.Children[1]).Text; var variableName = inputs.First(x => x.FriendlyName == variableFriendlyName).VariableName; output.Add(variableName, value); } else { var variableFriendlyName = ((Label)grid.Children[0]).Content as String; var value = ((ComboBox)grid.Children[1]).SelectedValue.ToString(); var variableName = inputs.First(x => x.FriendlyName == variableFriendlyName).VariableName; output.Add(variableName, value); } } } return(output); }
public void ZaczytajPlik() { string fileName = OpenFileService.Show(); if (string.IsNullOrEmpty(fileName)) { return; } LicConfig lic = LicConfig.GetInstance; lic.ZaczytajNowa(fileName); LicencjaClass licust = lic.UstawieniaLicencji; if (licust != null) { NAZWAFIRMY = licust.Firma.Nazwa; NIP = licust.Firma.NIP; string krypto = Krypto.Encrypt(NAZWAFIRMY + NIP); IHP_PARAMETRY ihp = context.IHP_PARAMETRY?.FirstOrDefault(x => x.ID_IHP_PARAMETRY == 0); if (ihp != null) { try { krypto = krypto.Substring(1, 35); ihp.WARTOSC = krypto; context.IHP_PARAMETRY.Attach(ihp); context.Entry(ihp).State = EntityState.Modified; context.SaveChanges(); lic.Zapisz(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { LogManager.WriteLogMessage(LogManager.LogType.Error, String.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State)); foreach (var ve in eve.ValidationErrors) { LogManager.WriteLogMessage(LogManager.LogType.Error, String.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } } //throw; } } } }
private void InsertImage() { OpenFileService.DefaultExtension = ".jpg"; OpenFileService.Filter = string.Join("", new string[] { "BMP (*.bmp;*.dip;*.rle)|*.bmp;*.dip;*.rle|", //Mapa de bits de Windows "JPG (*.jpg;*.jpeg;*.jpe;*.jfif)|*.jpg;*.jpeg;*.jpe;*.jfif|", //Formato de intercambio de archivos JPEG "PNG (*.png)|*.png|", //Portable Network Graphics "Todos los archivos de imagen (*.bmp;*.dip;*.rle;*.jpg;*.jpeg;*.jpe;*.jfif;*.png)|.bmp;*.dip;*.rle;*.jpg;*.jpeg;*.jpe;*.jfif;*.png", }); OpenFileService.FilterIndex = 4; OpenFileService.MultiSelect = true; OpenFileService.Title = "Insertar imagen"; if (OpenFileService.ShowDialog() == true && OpenFileService.FileNames.All(filename => filename.Length > 0)) { foreach (var filename in OpenFileService.FileNames) { RichEdit.InsertImage(filename); } } }
private void VaultModified() { OpenFileService.FileTextChanged(_Vault.VaultFilePath); }
private void Save_Click(object sender, RoutedEventArgs e) { OpenFileService.SaveAllOpenFiles(); }
private void ScriptEditor_TextChanged(object sender, TextChangedEventArgs e) { OpenFileService.FileTextChanged(_FilePath); }
public SelectFilesService(OpenFileService openFileService, FileInfoService fileInfoService) { this.openFileService = openFileService; this.fileInfoService = fileInfoService; }
private void ListItems_TextChanged(object sender, TextChangedEventArgs e) { OpenFileService.FileTextChanged(_FilePath); }