private void newListButton_Click(object sender, EventArgs e) { ModeListEditor editor = new ModeListEditor(ModeListEditors.Count); this.modesListsFlowPanel.Controls.Add(editor); ModeListEditors.Add(editor); Storage.sequenceData.ModeLists.Add(editor.ListModes); LayoutPage(); }
/// <summary> /// Returns the ID of input editor. /// </summary> /// <returns>Returns the ID of editor, or 0 if the input is null.</returns> public int GetHashCode(ModeListEditor editor) { if (editor == null) { return(0); } return(editor.GetHashCode()); }
public bool RemoveModeListEditor(ModeListEditor editor) { modesListsFlowPanel.Controls.Remove(editor); Storage.sequenceData.RemoveModeListID(editor.ListModes.ID); Storage.sequenceData.ModeLists.Remove(editor.ListModes); bool result = ModeListEditors.Remove(editor); if (result) { ReassignAllEditorIDs(); } LayoutPage(); return(result); }
private void pasteListButton_Click(object sender, EventArgs e) { if (CopyEditor != null) { if (ModeListEditors.Contains(CopyEditor)) { CopyEditor = new ModeListEditor(ModeListEditors.Count, CopyEditor); } this.modesListsFlowPanel.Controls.Add(CopyEditor); ModeListEditors.Add(CopyEditor); Storage.sequenceData.ModeLists.Add(CopyEditor.ListModes); LayoutPage(); } }
/// <summary> /// Create a new mode list editor that is identical to copyMe except for the name and ID. /// </summary> /// <param name="newID">A unique ID number for the new editor.</param> /// <param name="copyMe">A new editor will be created that is identical to this one.</param> public ModeListEditor(int newID, ModeListEditor copyMe) { InitializeComponent(); ListModes.Name = copyMe.ListModes.Name + "-copy"; //ListModes.ID = Storage.sequenceData.GenerateNewModeListID(); listName.Text = ListModes.Name; ListModes.Description = copyMe.ListModes.Description; listDescription.Text = ListModes.Description; ID = newID; CopyOverModesAndButtons(copyMe.ListModes.Modes); populateModesComboBox(); EnableAndDisableControls(); fontSizeControl.Value = copyMe.fontSizeControl.Value; fontSizeControl_ValueChanged(new object(), new EventArgs()); }
/// <summary> /// Call to create mode list editors for each mode list stored in Storage.sequenceData /// </summary> public void LayoutPage() { this.modesListsFlowPanel.SuspendLayout(); if (sortModeLists.Checked) { OrderModeListEditors(orderModeListsMethod.SelectedItem as String); } //Remove all the ordering group labels foreach (Control con in modesListsFlowPanel.Controls) { if (con is Label && con.Name.EndsWith("group box")) { modesListsFlowPanel.Controls.Remove(con); } } if (Storage.sequenceData != null && Storage.sequenceData.ModeLists != null) { int diff = Storage.sequenceData.ModeLists.Count - ModeListEditors.Count; ModeListEditor editor; if (diff > 0) //we need to create more mode list editors { for (int ind = 0; ind < diff; ind++) { editor = new ModeListEditor(ModeListEditors.Count); modesListsFlowPanel.Controls.Add(editor); ModeListEditors.Add(editor); } } else if (diff < 0) //We have too many mode list editors and must remove some { diff = Math.Abs(diff); for (int ind = 0; ind < diff; ind++) { editor = ModeListEditors[0]; modesListsFlowPanel.Controls.Remove(editor); editor.Dispose(); ModeListEditors.RemoveAt(0); } } // Now that we have the correct number of editors, let's update them to //point at the correct mode lists for (int ind = 0; ind < ModeListEditors.Count; ind++) { ModeListEditors[ind].SetModeList(Storage.sequenceData.ModeLists[ind]); } } else //If there are no ModeLists saved in Storage: { //Remove all of the editors from the flow panel, and empty ModeListEditors foreach (ModeListEditor editorToDelete in ModeListEditors) { this.modesListsFlowPanel.Controls.Remove(editorToDelete); editorToDelete.Dispose(); } ModeListEditors = new List <ModeListEditor>(); //Repopulate the flow panel and hash set with any ModeLists saved in Storage if (Storage.sequenceData != null) { ModeListEditor editor; foreach (ModeList list in Storage.sequenceData.ModeLists) { editor = new ModeListEditor(ModeListEditors.Count, list); this.modesListsFlowPanel.Controls.Add(editor); ModeListEditors.Add(editor); } } } if (ModeListEditors.Count > 0) { arrangeModeListEditorLocations(); } this.modesListsFlowPanel.ResumeLayout(); }
/// <summary> /// Two mode list editors are considered equivalent if their mode lists are identical. /// </summary> public static bool Equivalent(ModeListEditor a, ModeListEditor b) { return(ModeList.Equivalent(a.ListModes, b.ListModes)); }