Пример #1
0
        private void filesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListView    listview = (ListView)sender;
            Encryptable selected = (Encryptable)listview.SelectedItem;

            if (selected != null)
            {
                selectedFile.FilePath = selected.FilePath;
                selectedFile.Name     = selected.Name;
                selectedFile.Index    = selected.Index;
            }
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();

            _password1 = new Password();
            _password2 = new Password();
            _password  = new Password();

            encryptFileButton.IsEnabled = false;
            decryptFileButton.IsEnabled = false;

            items = new ObservableCollection <Encryptable>();
            filesListBox.ItemsSource   = items;
            selectedFile               = new Encryptable();
            selectedFile.ValueChanged += SelectedFile_ValueChanged;
        }
Пример #3
0
        private void browseButton_Click(object sender, RoutedEventArgs e)
        {
            Stream         myStream        = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "Image Files(*.txt;*.csv;*.config)|*.txt;*.csv;*.config";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == true)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            string fName = openFileDialog1.FileName;
                            if (fName != null)
                            {
                                Encryptable newFile = new Encryptable()
                                {
                                    Name     = System.IO.Path.GetFileName(openFileDialog1.FileName),
                                    FilePath = fName,
                                    Index    = items.Count
                                };
                                items.Add(newFile);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }