/// <summary> /// This executes the closing event when the Edit Assumptions window is closed. /// The method refreshes the groups list and rebinds the visible assumptions. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ParseGroupWindow_Closed(object sender, EventArgs e) { //Execute assumption window closing event groupCombo.ItemsSource = null; groupCombo.ItemsSource = ParseGroup.GetParseGroups(); groupCombo.SelectedValue = ParseGroup.GetParseGroups().ToArray()[0]; }
/// <summary> /// Remove the given ParseGroup as long as it is not predefined. /// </summary> /// <param name="pg">The ParseGroup to remove.</param> public static void RemoveGroup(ParseGroup pg) { if (!pg.Predefined) { Groups.Remove(pg); } }
/// <summary> /// Add a new ParseGroup. /// </summary> /// <param name="Name">The name of the group.</param> /// <param name="Assumptions">A list of assumptions to add to the group.</param> /// <returns>The new group.</returns> public static ParseGroup AddParseGroup(string Name, List <Assumption> Assumptions) { ParseGroup pg = AddParseGroup(Name); pg.Assumptions.AddRange(Assumptions); return(pg); }
/// <summary> /// This event is executed whem the Group selection is changed. /// The method updates the inner grid with the relevant assumptions. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GroupSelectionChanged(object sender, SelectionChangedEventArgs e) { ParseGroup selected = GroupSelector.SelectedValue as ParseGroup; if (selected == null) { return; } RefreshAssumptionLists(selected); }
/// <summary> /// Get all non-predefined parse groups. /// </summary> /// <returns>All non-predefined parse groups.</returns> public static List <ParseGroup> GetUserGroups() { List <ParseGroup> userGroups = new List <ParseGroup>(); foreach (ParseGroup pg in ParseGroup.GetParseGroups()) { if (!pg.Predefined) { userGroups.Add(pg); } } return(userGroups); }
/// <summary> /// This event is executed when the Remove group button is clicked. /// The method will remove the currently selected group. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RemoveGroupButton_Click(object sender, RoutedEventArgs e) { ParseGroup selected = GroupSelector.SelectedValue as ParseGroup; if (selected == null) { return; } ParseGroup.RemoveGroup(selected); GroupSelector.ItemsSource = null; GroupSelector.ItemsSource = GetUserGroups(); RefreshAssumptionLists(selected); }
/// <summary> /// This event is executed when the remove assumption buttin is clicked. /// The method will move all selected items in the selected pane to the deselected pane. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RemoveAssumptionButton_Click(object sender, RoutedEventArgs e) { ParseGroup selectedGroup = GroupSelector.SelectedValue as ParseGroup; if (selectedGroup == null) { return; } foreach (object value in SelectedAssumptions.SelectedItems) { Assumption a = value as Assumption; selectedGroup.Assumptions.Remove(a); } RefreshAssumptionLists(selectedGroup); }
/// <summary> /// Create the predefined groups. /// </summary> private static void CreatePredefGroups() { Groups = new List <ParseGroup>(); List <Assumption> assumptions = new List <Assumption>(Assumption.GetAssumptions().Values); //All assumptions ParseGroup pg = new ParseGroup("All"); pg.Predefined = true; pg.Assumptions.AddRange(assumptions); //Axioms pg = new ParseGroup("Axioms"); pg.Predefined = true; foreach (Assumption a in assumptions) { if (a.Type == Assumption.AssumptionType.Axiom) { pg.Assumptions.Add(a); } } //Definitions pg = new ParseGroup("Definitions"); pg.Predefined = true; foreach (Assumption a in assumptions) { if (a.Type == Assumption.AssumptionType.Definition) { pg.Assumptions.Add(a); } } //Theorems pg = new ParseGroup("Theorems"); pg.Predefined = true; foreach (Assumption a in assumptions) { if (a.Type == Assumption.AssumptionType.Theorem) { pg.Assumptions.Add(a); } } }
/// <summary> /// This event is executed when the AddParseGroupWindow is closed. /// The method carries out the action of adding the new group. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddGroupWindow_Closed(object sender, EventArgs e) { if (AddParseGroupWindow.GroupName.Equals("")) { return; } ParseGroup.AddParseGroup(AddParseGroupWindow.GroupName); GroupSelector.ItemsSource = null; GroupSelector.ItemsSource = GetUserGroups(); ParseGroup selected = GroupSelector.SelectedValue as ParseGroup; if (selected == null) { return; } RefreshAssumptionLists(selected); }
/// <summary> /// This method refreshes the selected and deselected assumption panes. /// </summary> /// <param name="selected">The current ParseGroup that is selected in the groups pane.</param> private void RefreshAssumptionLists(ParseGroup selected) { //Update selected pane SelectedAssumptions.ItemsSource = null; SelectedAssumptions.ItemsSource = selected.Assumptions; //Get unselected assumptions List <Assumption> unselectedAssumptions = new List <Assumption>(); foreach (Assumption a in Assumption.GetAssumptions().Values) { if (!selected.Assumptions.Contains(a)) { unselectedAssumptions.Add(a); } } //Update unselected pane UnselectedAssumptions.ItemsSource = null; UnselectedAssumptions.ItemsSource = unselectedAssumptions; }
/// <summary> /// This executes a selection changed event when the group selection combo box has anew item selected. /// The method will update the visibile assumptions to match the selected assumption group. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AssumptionGroupChanged(object sender, SelectionChangedEventArgs e) { ParseGroup selected = groupCombo.SelectedItem as ParseGroup; if (selected == null) { return; } List <CheckBox> checkBoxes = new List <CheckBox>(); //Add the check box foreach assumption in the group to the list foreach (Assumption a in selected.Assumptions) { CheckBox value; if (assumptionCheckboxes.TryGetValue(a, out value)) { checkBoxes.Add(value); } } visibibleAssumptions.ItemsSource = null; visibibleAssumptions.ItemsSource = checkBoxes; }
/// <summary> /// Create the predefined groups. /// </summary> private static void CreatePredefGroups() { Groups = new List<ParseGroup>(); List<Assumption> assumptions = new List<Assumption>(Assumption.GetAssumptions().Values); //All assumptions ParseGroup pg = new ParseGroup("All"); pg.Predefined = true; pg.Assumptions.AddRange(assumptions); //Axioms pg = new ParseGroup("Axioms"); pg.Predefined = true; foreach (Assumption a in assumptions) { if (a.Type == Assumption.AssumptionType.Axiom) { pg.Assumptions.Add(a); } } //Definitions pg = new ParseGroup("Definitions"); pg.Predefined = true; foreach (Assumption a in assumptions) { if (a.Type == Assumption.AssumptionType.Definition) { pg.Assumptions.Add(a); } } //Theorems pg = new ParseGroup("Theorems"); pg.Predefined = true; foreach (Assumption a in assumptions) { if (a.Type == Assumption.AssumptionType.Theorem) { pg.Assumptions.Add(a); } } }
/// <summary> /// Layout the content of the window. /// </summary> private void LayoutDesign() { //Set up grid Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); //Create group selection box and label StackPanel comboLabelStack = new StackPanel(); TextBlock comboLabel = new TextBlock(); comboLabel.Text = "Select Group:"; comboLabelStack.Children.Add(comboLabel); StackPanel comboStack = new StackPanel() { Orientation = Orientation.Horizontal }; Button editGroupButton = new Button(); editGroupButton.Content = "Edit"; editGroupButton.Margin = new Thickness(0, 0, 5, 0); editGroupButton.Click += new RoutedEventHandler(EditGroupButton_Click); comboStack.Children.Add(editGroupButton); groupCombo = new ComboBox(); groupCombo.ItemsSource = ParseGroup.GetParseGroups(); groupCombo.SelectionChanged += new SelectionChangedEventHandler(AssumptionGroupChanged); comboStack.Children.Add(groupCombo); comboStack.MaxWidth = 400; comboLabelStack.Children.Add(comboStack); comboLabelStack.Margin = new Thickness(0, 0, 0, 10); //Create Assumption checkbox list visibibleAssumptions = new ListBox(); visibibleAssumptions.MaxWidth = 400; visibibleAssumptions.MaxHeight = 800; visibibleAssumptions.MinWidth = 400; visibibleAssumptions.MinHeight = 200; visibibleAssumptions.Margin = new Thickness(0, 0, 0, 10); groupCombo.SelectedValue = ParseGroup.GetParseGroups().ToArray()[0]; //Create Select and Deselect All buttons StackPanel selectDeselectPanel = new StackPanel() { Orientation = Orientation.Horizontal }; selectDeselectPanel.HorizontalAlignment = HorizontalAlignment.Center; Button selectBtn = new Button(); selectBtn.Content = "Select All"; selectBtn.Width = 75; selectBtn.Click += new RoutedEventHandler(SelectAllButton_Click); selectBtn.Margin = new Thickness(0, 0, 10, 0); selectDeselectPanel.Children.Add(selectBtn); Button deselectBtn = new Button(); deselectBtn.Content = "Deselect All"; deselectBtn.Width = 75; deselectBtn.Click += new RoutedEventHandler(DeselectAllButton_Click); selectDeselectPanel.Children.Add(deselectBtn); //Set element locations in grid and add to grid Grid.SetColumn(visibibleAssumptions, 0); Grid.SetRow(visibibleAssumptions, 1); grid.Children.Add(visibibleAssumptions); Grid.SetColumn(comboLabelStack, 0); Grid.SetRow(comboLabelStack, 0); grid.Children.Add(comboLabelStack); Grid.SetColumn(selectDeselectPanel, 0); Grid.SetRow(selectDeselectPanel, 2); grid.Children.Add(selectDeselectPanel); //Set the content of the window to be the newly designed layout this.Content = grid; }
/// <summary> /// This method refreshes the selected and deselected assumption panes. /// </summary> /// <param name="selected">The current ParseGroup that is selected in the groups pane.</param> private void RefreshAssumptionLists(ParseGroup selected) { //Update selected pane SelectedAssumptions.ItemsSource = null; SelectedAssumptions.ItemsSource = selected.Assumptions; //Get unselected assumptions List<Assumption> unselectedAssumptions = new List<Assumption>(); foreach (Assumption a in Assumption.GetAssumptions().Values) { if (!selected.Assumptions.Contains(a)) { unselectedAssumptions.Add(a); } } //Update unselected pane UnselectedAssumptions.ItemsSource = null; UnselectedAssumptions.ItemsSource = unselectedAssumptions; }