Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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)));
        }
Esempio n. 3
0
        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);
     }
 }
Esempio n. 5
0
        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)} - ";
            }
        }
Esempio n. 6
0
 private void OpenFileCommandExecute()
 {
     cartridge = OpenFileService.OpenCartridgeFile();
     if (cartridge != null)
     {
         console.InsertCartridge(cartridge);
         (Reset as RelayCommand).Execute();
     }
 }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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;
                    }
                }
            }
        }
Esempio n. 10
0
        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);
                }
            }
        }
Esempio n. 11
0
 private void VaultModified()
 {
     OpenFileService.FileTextChanged(_Vault.VaultFilePath);
 }
Esempio n. 12
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     OpenFileService.SaveAllOpenFiles();
 }
Esempio n. 13
0
 private void ScriptEditor_TextChanged(object sender, TextChangedEventArgs e)
 {
     OpenFileService.FileTextChanged(_FilePath);
 }
 public SelectFilesService(OpenFileService openFileService, FileInfoService fileInfoService)
 {
     this.openFileService = openFileService;
     this.fileInfoService = fileInfoService;
 }
Esempio n. 15
0
 private void ListItems_TextChanged(object sender, TextChangedEventArgs e)
 {
     OpenFileService.FileTextChanged(_FilePath);
 }