private void lbConflictResolutionColumns_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int indexFromPoint = lbConflictResolutionColumns.IndexFromPoint(e.Location); if (indexFromPoint != -1) { var RightClickMenu = new ContextMenuStrip(); IResolveDuplication resolver = (IResolveDuplication)lbConflictResolutionColumns.Items[indexFromPoint]; string target = resolver.DuplicateRecordResolutionIsAscending ? "DESC" : "ASC"; string currently = resolver.DuplicateRecordResolutionIsAscending ? "ASC" : "DESC"; RightClickMenu.Items.Add( "Set " + resolver.GetRuntimeName() + " to " + target + " (Currently resolution order is " + currently + ")", null, delegate { //flip its bit resolver.DuplicateRecordResolutionIsAscending = !resolver.DuplicateRecordResolutionIsAscending; //save it to database resolver.SaveToDatabase(); //refresh UI RefreshUIFromDatabase(); }); RightClickMenu.Show(lbConflictResolutionColumns.PointToScreen(e.Location)); } } }
private void SaveOrderIntoDatabase() { for (int i = 0; i < lbConflictResolutionColumns.Items.Count; i++) { IResolveDuplication extractionInformation = (IResolveDuplication)lbConflictResolutionColumns.Items[i]; extractionInformation.DuplicateRecordResolutionOrder = i; extractionInformation.SaveToDatabase(); } RefreshUIFromDatabase(); }