private void deleteRuleButton_Click(object sender, RoutedEventArgs e) { MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel; DialogResult diagResult = MessageBox.Show("Are you sure you want to delete this rule ?", "Delete Rule", buttons, MessageBoxIcon.Warning); if (diagResult == DialogResult.Yes) { System.Windows.Controls.Button button = sender as System.Windows.Controls.Button; //Getting the datacontext of the button which is the listbox index of the element it is embedded in. int index = EntryListBox.Items.IndexOf(button.DataContext); EntryListView chosenEntry = (EntryListView)EntryListBox.Items[index]; //Delete rule var response = comElements.delete("Entry/" + chosenEntry.Id, ""); if (response.StatusCode == HttpStatusCode.OK) { buttons = MessageBoxButtons.OK; MessageBox.Show("Rule deleted", "Rule deleted", buttons); } else { buttons = MessageBoxButtons.OK; MessageBox.Show("Rule not found", "Database Error", buttons); } //Update the context with the latest saved game for autoupdate of changes in the listboxes. SelectionChangedEventArgs savedChoice = savedGame; GamesListBox_OnSelectionChanged(this, savedChoice); } }
///<summary> This method sorts SchoolYear data into a list and displays it by calling a view ///Calls the method for the next sorting: SortCurrentOrAllProject method ///</summary> public static void SortBySchoolYear() { var schoolyear = App.DB[DBTable.FormYear].Entries.ToList().ConvertAll(entry => (FormYear)entry); Dictionary <string, string> conversionTable = new Dictionary <string, string>(); for (int i = 0; i < schoolyear.Count; i++) { conversionTable.Add($"{i}", schoolyear[i].UUID); } EntryListView ListPage = new EntryListView(schoolyear.ToDictionary( s => conversionTable.First(kvp => kvp.Value.Equals(s.UUID)).Key, s => $"{s.GradeName}"), "school year" ); var userRequest = App.Renderer.Render(ListPage); string uuid = conversionTable[userRequest.GetSelectedValue()]; FormYear target = (FormYear)App.DB[DBTable.FormYear][uuid]; SortCurrentOrAllProjects(target); }
/// <summary> /// This method sorts all the courses into a list, and displays it by calling a view /// Calls the method for the next sorting: DisplayProject method /// </summary> public static void SortByCourses() { var courses = App.DB[DBTable.Courses].Entries.ToList().ConvertAll(entry => (Course)entry); Dictionary <string, string> conversionTable = new Dictionary <string, string>(); for (int i = 0; i < courses.Count; i++) { conversionTable.Add($"{i}", courses[i].UUID); } EntryListView ListPage = new EntryListView(courses.ToDictionary( c => conversionTable.First(kvp => kvp.Value.Equals(c.UUID)).Key, c => $"{c.Name} with {c.TeachersToString()}"), "course" ); var userRequest = App.Renderer.Render(ListPage); string uuid = conversionTable[userRequest.GetSelectedValue()]; Course target = (Course)App.DB[DBTable.Courses][uuid]; List <Project> projects = ((Course)target).Projects.ConvertAll(e => (Project)e).OrderBy(x => x.Topic).ToList(); DisplayProjectList(projects); }
///<summary> This method sorts Person by subclass into a list, and displays it by calling a view ///Calls the method for the next sorting: SortCurrentOrAllProject method ///</summary> public static void SortByPerson <T>() { var persons = ((PersonDataTable)App.DB[DBTable.Person]).GetPersonsOfType <T>(); // Renderer's selectors only accepts [0-9]{1,2} as value Dictionary <string, string> conversionTable = new Dictionary <string, string>(); for (int i = 0; i < persons.Count; i++) { conversionTable.Add($"{i}", persons[i].UUID); } EntryListView ListPage = new EntryListView(persons.ToDictionary( p => conversionTable.First(kvp => kvp.Value.Equals(p.UUID)).Key, p => $"{p.ToString()}"), typeof(T).Name.ToLower() ); var userRequest = App.Renderer.Render(ListPage); string uuid = conversionTable[userRequest.GetSelectedValue()]; Person target = (Person)App.DB[DBTable.Person][uuid]; SortCurrentOrAllProjects(target); }
///<summary> This method sorts all Promotions into a list and displays it by calling a view ///Calls the method for the next sorting: SortCurrentOrAllProject method ///</summary> public static void SortByPromotions() { var promo = App.DB[DBTable.Promotion].Entries.ToList().ConvertAll(entry => (Promotion)entry); Dictionary <string, string> conversionTable = new Dictionary <string, string>(); for (int i = 0; i < promo.Count; i++) { conversionTable.Add($"{i}", promo[i].UUID); } EntryListView ListPage = new EntryListView(promo.ToDictionary( p => conversionTable.First(kvp => kvp.Value.Equals(p.UUID)).Key, p => $"{p.Name} {p.GraduationYear} {p.Grade.GradeName}"), // "promotion" ); var userRequest = App.Renderer.Render(ListPage); string uuid = conversionTable[userRequest.GetSelectedValue()]; Promotion target = (Promotion)App.DB[DBTable.Promotion][uuid]; List <Project> projects = ((Promotion)target).Projects.ConvertAll(e => (Project)e).OrderBy(x => x.Topic).ToList(); DisplayProjectList(projects);; }
public EditRule(int tocListId, EntryListView entryData) { InitializeComponent(); this.tocListId = tocListId; this.entryData = entryData; //Fill out the windows controls with data from the selected Entry paragraphNumberTextBox.Text = this.entryData.ParagraphNumber; headlineTextBox.Text = this.entryData.Headline; ruleTextBox.Text = this.entryData.Txt; revisionTextBox.Text = this.entryData.Revision; editorTextBox.Text = this.entryData.Editor; }
private static Role AskContribRole(Person contrib) { var roles = Enum.GetValues(typeof(Role)).Cast <Role>(); EntryListView rolePage = new EntryListView(roles.ToDictionary( r => r.ToString("D"), r => r.ToString("G")), "role" ); var roleRequested = App.Renderer.Render(rolePage).GetSelectedValue(); return((Role)int.Parse(roleRequested)); }
private void CoreWindowOnKeyDown(CoreWindow sender, KeyEventArgs args) { if (args.VirtualKey == VirtualKey.Escape) { //deactivate Search & Garbage before navigating back if (ViewModel.InSearchMode) { ViewModel.InSearchMode = false; args.Handled = true; } else if (ViewModel.InGarbageMode) { ViewModel.InGarbageMode = false; args.Handled = true; } return; } //if in SearchBox prevent KeyBindings if (ViewModel.InSearchMode) { //SearchBox.FocusState foes not work as expected //as FocusState does not represent the active state of the control //it still returns Unfocused even if this event has been invoked while writing into the SearchBox return; } if (args.VirtualKey == VirtualKey.F) { FolderListView.Focus(FocusState.Keyboard); } else if (args.VirtualKey == VirtualKey.E) { EntryListView.Focus(FocusState.Keyboard); } else if (args.VirtualKey == VirtualKey.S) { ViewModel.InSearchMode = !ViewModel.InSearchMode; } else if (args.VirtualKey == VirtualKey.G) { ViewModel.InGarbageMode = !ViewModel.InGarbageMode; } }
private static Person AskContributor(Project project, string personType) { Dictionary <string, string> conversionTable = new Dictionary <string, string>(); List <Person> persons = new List <Person>(); switch (personType) { case "student": project.Promotions.ForEach(prom => persons.AddRange(prom.Students)); break; case "teacher": persons.AddRange(App.DB[DBTable.Person].Entries .Where(entry => ((Person)entry) is Teacher).ToList() .ConvertAll(p => (Teacher)p)); break; case "extern": persons.AddRange(App.DB[DBTable.Person].Entries .Where(entry => ((Person)entry) is Extern).ToList() .ConvertAll(e => (Extern)e)); break; } for (int i = 0; i < persons.Count; i++) { conversionTable.Add($"{i}", persons[i].UUID); } EntryListView contribPage = new EntryListView(persons.ToDictionary( p => conversionTable.First(kvp => kvp.Value.Equals(p.UUID)).Key, p => $"{p}"), personType ); var contribRequested = App.Renderer.Render(contribPage).GetSelectedValue(); string uuid = conversionTable[contribRequested]; return((Person)App.DB[DBTable.Person][uuid]); }
private static Deliverable AskDeliverable() { var delivTypes = Enum.GetValues(typeof(DeliverableType)).Cast <DeliverableType>(); EntryListView rolePage = new EntryListView(delivTypes.ToDictionary( r => r.ToString("D"), r => r.ToString("G")), "deliverable type" ); var typeRequested = App.Renderer.Render(rolePage).GetSelectedValue(); var delivInfoRequest = App.Renderer.Render(new NewDeliverableView()); return(new Deliverable() { Type = (DeliverableType)int.Parse(typeRequested), Information = delivInfoRequest.GetUserInputs()[0] }); }
private static Course AskCourse() { Dictionary <string, string> conversionTable = new Dictionary <string, string>(); var courses = App.DB[DBTable.Courses].Entries.ConvertAll(x => (Course)x); for (int i = 0; i < courses.Count; i++) { conversionTable.Add($"{i}", courses[i].UUID); } EntryListView coursePage = new EntryListView(courses.ToDictionary( c => conversionTable.First(kvp => kvp.Value.Equals(c.UUID)).Key, c => c.Name), "course" ); var courseRequested = App.Renderer.Render(coursePage).GetSelectedValue(); string uuid = conversionTable[courseRequested]; return((Course)App.DB[DBTable.Courses][uuid]); }
private static Promotion AskPromotion() { Dictionary <string, string> conversionTable = new Dictionary <string, string>(); var promotions = App.DB[DBTable.Promotion].Entries.ConvertAll(x => (Promotion)x); for (int i = 0; i < promotions.Count; i++) { conversionTable.Add($"{i}", promotions[i].UUID); } EntryListView promPage = new EntryListView(promotions.ToDictionary( p => conversionTable.First(kvp => kvp.Value.Equals(p.UUID)).Key, p => $"{p}"), "promotion" ); var promRequested = App.Renderer.Render(promPage).GetSelectedValue(); string uuid = conversionTable[promRequested]; return((Promotion)App.DB[DBTable.Promotion][uuid]); }