示例#1
0
        /// <summary>
        /// Starts creating new item.
        /// </summary>
        /// <param name="proxy">The new item proxy.</param>
        /// <param name="argument">The argument passed to the proxy for the item creation. In most cases it is null.</param>
        /// <param name="created">The event called when the item is crated by the user. The argument is the new item.</param>
        public void NewItem(ContentProxy proxy, object argument = null, Action <ContentItem> created = null)
        {
            Assert.IsNull(_newElement);
            if (proxy == null)
            {
                throw new ArgumentNullException(nameof(proxy));
            }

            string        proxyName        = proxy.Name;
            ContentFolder parentFolder     = CurrentViewFolder;
            string        parentFolderPath = parentFolder.Path;

            // Create asset name
            string path;
            string extension = '.' + proxy.FileExtension;
            int    i         = 0;

            do
            {
                path = StringUtils.CombinePaths(parentFolderPath, string.Format("{0} {1}", proxyName, i++) + extension);
            } while (parentFolder.FindChild(path) != null);

            // Create new asset proxy, add to view and rename it
            _newElement = new NewItem(path, proxy, argument);
            _newElement.ParentFolder = parentFolder;
            _newElement.Tag          = created;
            RefreshView();
            Rename(_newElement);
        }
示例#2
0
        /// <summary>
        /// Starts creating new item.
        /// </summary>
        /// <param name="proxy">The new item proxy.</param>
        private void NewItem(ContentProxy proxy)
        {
            Assert.IsNull(_newElement);

            string        proxyName        = proxy.Name;
            ContentFolder parentFolder     = CurrentViewFolder;
            string        parentFolderPath = parentFolder.Path;

            // Create asset name
            string path;
            string extension = '.' + proxy.FileExtension;
            int    i         = 0;

            do
            {
                path = StringUtils.CombinePaths(parentFolderPath, string.Format("{0} {1}", proxyName, i++) + extension);
            } while (parentFolder.FindChild(path) != null);

            // Create new asset proxy, add to view and rename it
            _newElement = new NewItem(path, proxy);
            _newElement.ParentFolder = parentFolder;
            RefreshView();
            Rename(_newElement);
        }