/// <summary>
        /// Helper function called by a child of this collection to handle renaming of this child.
        /// </summary>
        /// <param name="newName">The new name of the child.</param>
        /// <param name="child">The child's instance.</param>
        /// <param name="setName">Action to set the name to the provided value. This function should only do set the name, but not raise any evens etc.</param>
        /// <param name="raiseOnNameChanged">Action to raise the NameChanged event on the child.</param>
        /// <exception cref="ArgumentNullException">newName - New name is null</exception>
        /// <exception cref="ApplicationException"></exception>
        public void RenameChild(INameOwner child, string newName, Action <string> setName, Action <string> raiseOnNameChanged)
        {
            var oldName = child.Name;

            if (null == newName)
            {
                throw new ArgumentNullException(nameof(newName), string.Format("New name of {0} is null (the old name was: {1})", child?.GetType(), oldName));
            }

            if (newName == oldName)
            {
                return; // nothing changed
            }
            var parentAs     = (IParentOfINameOwnerChildNodes)this;
            var canBeRenamed = parentAs.EhChild_CanBeRenamed(child, newName);

            if (canBeRenamed)
            {
                setName(newName);

                parentAs.EhChild_HasBeenRenamed(child, oldName);

                raiseOnNameChanged(oldName);
            }
            else
            {
                throw new ApplicationException(string.Format("Renaming of {0} {1} into {2} not possible, because name exists already", child.GetType().Name, oldName, newName));
            }
        }
Beispiel #2
0
		private void EhTableNameChanged_Unsynchronized(INameOwner sender, string oldName)
		{
			var view = ViewObject as IWorksheetView;
			if (view != null)
				view.TableViewTitle = _table.Name;

			this.TitleName = _table.Name;
		}
Beispiel #3
0
		private void EhGraphDocumentNameChanged_Unsynchronized(INameOwner sender, string oldName)
		{
			if (null != _view)
				_view.GraphViewTitle = Doc.Name;

			this.TitleName = Doc.Name;
		}