/// <summary>
        /// Called when user finishes editing tree label.
        /// Updates edited element title.
        /// </summary>
        /// <param name="sender">Event sender (treeview)</param>
        /// <param name="e">Event arguments</param>
        private void OnGroupsAfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            // Check that label is changed and valid
            if (e.Label == null || e.Label.Length == 0 || e.Label.Equals(e.Node.Text))
            {
                e.CancelEdit = true;
                return;
            }

            // Update edited element with new title
            GroupElement element = e.Node.Tag as GroupElement;
            NodeType     nt      = (NodeType)e.Node.ImageIndex;

            // Select appropriate updater and method
            if (nt == NodeType.Group)
            {
                GroupUpdater updater = new GroupUpdater();
                updater.Title = e.Label;
                element       = _client.UpdateGroup(element.Id, updater);
            }
            else
            {
                // It could be either collection or gallery here
                PhotoSetUpdater updater = new PhotoSetUpdater();
                updater.Title = e.Label;
                element       = _client.UpdatePhotoSet(element.Id, updater);
            }

            // Store updated snapshot
            e.Node.Tag = element;
        }
        /// <summary>
        /// Called when user presses "Make New Group" button.
        /// Creates new Group under selected Group.
        /// </summary>
        /// <param name="sender">Event sender (button)</param>
        /// <param name="e">Event arguments</param>
        private void OnNewGroup(object sender, EventArgs e)
        {
            // Extract current context
            TreeNode     currentNode = _tvGroups.SelectedNode;
            Group        parent      = (Group)currentNode.Tag;
            GroupUpdater updater     = new GroupUpdater();

            updater.Title = "New Group";

            // Create Group
            Group newGroup = _client.CreateGroup(parent.Id, updater);

            // Attach new Group to the tree and start edit
            TreeNode newNode = CreateGroupNode(newGroup);

            currentNode.Nodes.Add(newNode);
            currentNode.Expand();
            newNode.BeginEdit();
        }