private void CopySession_Click(object sender, RoutedEventArgs e) { if (SessionsBox.SelectedItem != null) { DatabaseSession session = (DatabaseSession)SessionsBox.SelectedItem; Dictionary <string, UserInputWindow.Input> input = new Dictionary <string, UserInputWindow.Input>(); input["names"] = new UserInputWindow.Input() { Label = "Name", DefaultValue = session.Name }; UserInputWindow dialog = new UserInputWindow("Enter new name (if several separate by ';')", input); dialog.ShowDialog(); if (dialog.DialogResult == true) { string names = dialog.Result("names"); string[] tokens = names.Split(';'); foreach (string token in tokens) { DatabaseSession newSession = new DatabaseSession() { Name = token, Date = session.Date, Language = session.Language, Location = session.Location }; DatabaseHandler.AddSession(newSession); } GetSessions(session.Name); } } }
private void ImportfromFolder_Click(object sender, RoutedEventArgs e) { string path = ""; var dialog = new System.Windows.Forms.FolderBrowserDialog(); dialog.SelectedPath = Properties.Settings.Default.DatabaseDirectory; dialog.ShowNewFolderButton = true; dialog.Description = "Select the root folder of your sessions."; System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.None; try { dialog.SelectedPath = Properties.Settings.Default.DatabaseDirectory; result = dialog.ShowDialog(); } catch { dialog.SelectedPath = ""; result = dialog.ShowDialog(); } if (result == System.Windows.Forms.DialogResult.OK) { path = dialog.SelectedPath; DatabaseSession session = new DatabaseSession(); DatabaseAdminSessionWindow sessiondialog = new DatabaseAdminSessionWindow(ref session, false); sessiondialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; sessiondialog.ShowDialog(); if (sessiondialog.DialogResult == true) { foreach (var d in System.IO.Directory.GetDirectories(path)) { var dir = new DirectoryInfo(d); var dirName = dir.Name; DatabaseSession newSession = new DatabaseSession() { Name = dirName, Date = session.Date, Language = session.Language, Location = session.Location }; DatabaseHandler.AddSession(newSession); } GetSessions(); } } }
private void AddSession_Click(object sender, RoutedEventArgs e) { if (DatabaseBox.SelectedItem != null) { DatabaseSession session = new DatabaseSession() { Date = DateTime.Today }; DatabaseAdminSessionWindow dialog = new DatabaseAdminSessionWindow(ref session); dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.ShowDialog(); if (dialog.DialogResult == true) { if (DatabaseHandler.AddSession(session)) { GetSessions(session.Name); } } } }