/// <summary> /// iView.NET subroutine. Allows the user to edit the currently selected treeview favourite node. /// </summary> /// <returns></returns> private SResult SubEditFavourite() { TreeNode oNode = etvw_Directorys.SelectedNode; if (oNode == null) return SResult.Void; Favourite oFavourite = oNode.Tag as Favourite; if (oFavourite != null) { if (m_oFavourites != null) { string sName = oFavourite.Name; string sPath = oFavourite.Path; using (FavouriteDialog oForm = new FavouriteDialog(sName, sPath)) { if (oForm.ShowDialog(this) == DialogResult.OK) { // Remove the old favourite. m_oFavourites.Remove(oFavourite); // Add the new favourite to the list. m_oFavourites.Add(oForm.NewFavorite); // Update the related tree view node. oNode.Text = oForm.NewFavorite.Name; oNode.Name = oForm.NewFavorite.Path; oNode.ToolTipText = "Created: " + oForm.NewFavorite.Created + "\nLocation: " + oForm.NewFavorite.Path; // Assign the new favourite to the nodes tag property. oNode.Tag = oForm.NewFavorite; } } } else return SResult.NullFavouritesCollection; } return SResult.Completed; }
/// <summary> /// iView.NET subroutine. Adds a new favourite to the FavouritesCollection. /// </summary> /// <param name="bUseDialog">Specifies whether to use the dialog or to use the currently selected location.</param> /// <returns></returns> private SResult SubAddFavourite(bool bUseDialog) { if (m_oFavourites == null) return SResult.NullFavouritesCollection; string sName = null; string sCreated = null; string sPath = (m_oImageBrowser != null) ? m_oImageBrowser.SelectedDirectory : null; Favourite oFavourite = null; if (!bUseDialog) { if (!string.IsNullOrEmpty(sPath)) { oFavourite = new Favourite(); oFavourite.Name = new DirectoryInfo(sPath).Name; oFavourite.Path = sPath; oFavourite.Created = DateTime.Now.ToShortDateString(); } } else { // Open the favourite dialog. using (FavouriteDialog oForm = new FavouriteDialog(sName, sPath)) { if (oForm.ShowDialog(this) == DialogResult.OK) oFavourite = oForm.NewFavorite; } } if (oFavourite != null) { if ((etvw_Directorys.Nodes.Count > 0) && (etvw_Directorys.Nodes[0] != null)) { sName = oFavourite.Name; sCreated = oFavourite.Created; sPath = oFavourite.Path; // Add a new Favourite object to the FavouritesCollection. m_oFavourites.Add(oFavourite); // Create and add a new tree node to the explorer tree view control. TreeNode oNode = new TreeNode(); oNode.Name = sPath; oNode.Text = sName; oNode.Tag = oFavourite; oNode.ImageIndex = (int)NodeImageType.FolderClosed; oNode.SelectedImageIndex = (int)NodeImageType.FolderOpened; oNode.ToolTipText = "Created: " + sCreated + "\nLocation: " + sPath; // Add the new favourite node to the parent. etvw_Directorys.Nodes[0].Nodes.Add(oNode); // Expand the parent node. if (!etvw_Directorys.Nodes[0].IsExpanded) etvw_Directorys.Nodes[0].Expand(); return SResult.Completed; } } return SResult.Completed; }