Ejemplo n.º 1
0
        private void StartDatabase(object sender, RoutedEventArgs e)
        {
            if (ExistingDatabaseRadio.IsChecked == true)
            {
                //Selecting existing Database file
                if (File.Exists(ExistingDatabasePath.Text))
                {
                    using (StreamReader sr = File.OpenText(ExistingDatabasePath.Text))
                    {
                        Database database = JsonConvert.DeserializeObject <Database>(sr.ReadToEnd());
                        if (database.Password.Equals(ExistingDatabasePassword.Password))
                        {
                            OpenedDatabaseWindow win = new OpenedDatabaseWindow(ExistingDatabasePath.Text, ExistingDatabasePassword.Password);
                            win.Show();
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Incorrect password", "Error");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Select valid database file", "Error");
                }
            }
            else
            {
                //Creating new Database file
                if (!File.Exists(NewDatabasePath.Text))
                {
                    using (StreamWriter sw = File.CreateText(NewDatabasePath.Text))
                    {
                        Database database = new Database();
                        database.Password = NewDatabasePassword.Password;

                        database.Groups.Add(new Group("All"));
                        database.Groups.Add(new Group("Social"));
                        database.Groups.Add(new Group("Work"));
                        database.Groups.Add(new Group("Productivity"));

                        database.Entries.Add(new Entry("Personal Email", "*****@*****.**", "password", "This is the entry for my personal email!", "Productivity"));
                        sw.Write(JsonConvert.SerializeObject(database));
                    }

                    OpenedDatabaseWindow win = new OpenedDatabaseWindow(NewDatabasePath.Text, NewDatabasePassword.Password);
                    win.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Database file already exists", "Error");
                }
            }
        }
Ejemplo n.º 2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.OpenedDatabase = ((TechVault.OpenedDatabaseWindow)(target));
                return;

            case 2:

            #line 25 "..\..\OpenedDatabaseWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.AddEntry);

            #line default
            #line hidden
                return;

            case 3:

            #line 33 "..\..\OpenedDatabaseWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.AddGroup);

            #line default
            #line hidden
                return;

            case 4:
                this.EntryGroupsList = ((System.Windows.Controls.ListView)(target));

            #line 49 "..\..\OpenedDatabaseWindow.xaml"
                this.EntryGroupsList.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.SelectedGroupChanged);

            #line default
            #line hidden
                return;

            case 5:
                this.EntryList = ((System.Windows.Controls.ListView)(target));

            #line 62 "..\..\OpenedDatabaseWindow.xaml"
                this.EntryList.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(this.EditEntry);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }