private void OnAskUserWhatToDoWithDataInWritingSystemToBeDeleted(object sender, WhatToDoWithDataInWritingSystemToBeDeletedEventArgs args)
		{
			//If no one is listening for the help button we won't offer it to the user
			bool showHelpButton = UserWantsHelpWithDeletingWritingSystems != null;
			using (var deleteDialog = new DeleteInputSystemDialog(args.WritingSystemIdToDelete, _model.WritingSystemDefinitions, showHelpButton))
			{
				deleteDialog.HelpWithDeletingWritingSystemsButtonClickedEvent += OnHelpWithDeletingWritingSystemsButtonClicked;
				var dialogResult = deleteDialog.ShowDialog();

				if (dialogResult != DialogResult.OK)
				{
					args.WhatToDo = WhatToDos.Nothing;
				}
				else
				{
					switch (deleteDialog.Choice)
					{
						case DeleteInputSystemDialog.Choices.Cancel:
							args.WhatToDo = WhatToDos.Nothing;
							break;
						case DeleteInputSystemDialog.Choices.Merge:
							args.WhatToDo = WhatToDos.Conflate;
							args.WritingSystemIdToConflateWith = deleteDialog.WritingSystemToConflateWith;
							break;
						case DeleteInputSystemDialog.Choices.Delete:
							args.WhatToDo = WhatToDos.Delete;
							break;
					}
				}
			}
		}
		/// <summary>
		/// Deletes the currently selected writing system.
		/// </summary>
		public void DeleteCurrent()
		{
			if (!_usingRepository)
			{
				throw new InvalidOperationException("Unable to delete current selection when there is no writing system store.");
			}
			if (!HasCurrentSelection)
			{
				throw new InvalidOperationException("Unable to delete current selection when there is no current selection.");
			}

			var whatToDo = new WhatToDoWithDataInWritingSystemToBeDeletedEventArgs(CurrentDefinition);
			if(AskUserWhatToDoWithDataInWritingSystemToBeDeleted != null)
			{
				AskUserWhatToDoWithDataInWritingSystemToBeDeleted(this, whatToDo);
			}

			switch(whatToDo.WhatToDo)
			{
				case WhatToDos.Nothing:
						return;
				case WhatToDos.Conflate:
					var wsToConflateWith = whatToDo.WritingSystemIdToConflateWith;
						var okToConflateEventArgs = new AskIfOkToConflateEventArgs(CurrentDefinition.LanguageTag,
																					wsToConflateWith.LanguageTag);
						if (AskIfOkToConflateWritingSystems != null)
						{
							AskIfOkToConflateWritingSystems(this, okToConflateEventArgs);
						}
						if (!okToConflateEventArgs.CanConflate)
						{
							string message = okToConflateEventArgs.ErrorMessage ?? String.Empty;
							ErrorReport.NotifyUserOfProblem(
								String.Format("Can not conflate the input system {0} to {1}. {2}",
												CurrentDefinition.LanguageTag,
												wsToConflateWith, message));
							return;
						}
						if (CurrentDefinition != null && _writingSystemRepository.Contains(CurrentDefinition.LanguageTag))
						{
							if (wsToConflateWith != null)
							{
								_writingSystemRepository.Conflate(CurrentDefinition.LanguageTag, wsToConflateWith.LanguageTag);
							}
						}
					break;
				case WhatToDos.Delete:
					var okToDeleteEventArgs = new AskIfOkToDeleteEventArgs(CurrentDefinition.LanguageTag);
					if (AskIfOkToDeleteWritingSystems != null)
					{
						AskIfOkToDeleteWritingSystems(this, okToDeleteEventArgs);
					}
					if (!okToDeleteEventArgs.CanDelete)
					{
						string message = okToDeleteEventArgs.ErrorMessage ?? String.Empty;
						ErrorReport.NotifyUserOfProblem(
							String.Format("Can not delete the input system {0}. {1}",
											CurrentDefinition.LanguageTag, message));
						return;
					}
					// If you play around with renaming/revising writing systems, the Id assigned to
					// the writing system keeps up with the changes, but the StoreID which is the
					// real key for IWritingSystemRepository methods stays the same.  I find this
					// a questionable design decision myself, but there may be good reasons for it.
					// However, not calling _writingSystemRepository.Remove() can cause problems
					// with data getting out of sync.  (See https://jira.sil.org/browse/WS-281 for
					// an example of such problems.)
					if (CurrentDefinition != null && _writingSystemRepository.Contains(CurrentDefinition.Id))
					{
						_writingSystemRepository.Remove(CurrentDefinition.Id);
					}
					break;
			}
			// new index will be next writing system or previous if this was the last in the list
			int newIndex = (CurrentIndex == WritingSystemCount - 1) ? CurrentIndex - 1 : CurrentIndex;
			CurrentDefinition.MarkedForDeletion = true;
			_deletedWritingSystemDefinitions.Add(CurrentDefinition);
			WritingSystemDefinitions.RemoveAt(CurrentIndex);
			CurrentIndex = newIndex;
			OnAddOrDelete();
		}