SIL.FieldWorks.FdoUi.CmObjectUi.DeleteUnderlyingObject C# (CSharp) Method

DeleteUnderlyingObject() public method

Delete the object, after showing a confirmation dialog. Return true if deleted, false, if cancelled.
public DeleteUnderlyingObject ( ) : bool
return bool
		public bool DeleteUnderlyingObject()
		{
			CheckDisposed();

			ICmObject cmo = GetCurrentCmObject();
			if (cmo != null && m_obj != null && cmo.Hvo == m_obj.Hvo)
			{
				object command = this;
				if (m_command != null)
					command = m_command;
				m_mediator.SendMessage("DeleteRecord", command);
			}
			else
			{
				var mainWindow = (Form) m_mediator.PropertyTable.GetValue("window");
				using (new WaitCursor(mainWindow))
				{
					using (var dlg = new ConfirmDeleteObjectDlg(m_mediator.HelpTopicProvider))
					{
						string cannotDeleteMsg;
						if (CanDelete(out cannotDeleteMsg))
						dlg.SetDlgInfo(this, m_cache, Mediator);
						else
							dlg.SetDlgInfo(this, m_cache, Mediator, m_cache.TsStrFactory.MakeString(cannotDeleteMsg, m_cache.DefaultUserWs));
						if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
						{
							ReallyDeleteUnderlyingObject();
							return true; // deleted it
						}
					}
				}
			}
			return false; // didn't delete it.
		}