コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_OK_Click(object sender, EventArgs e)
        {
            m_oFavourite = new Favourite();
            m_oFavourite.Name = txtb_Name.Text;
            m_oFavourite.Created = DateTime.Now.ToShortDateString();
            m_oFavourite.Path = txtb_Location.Text;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            m_oFavourite = null;

            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
コード例 #3
0
 /// <summary>
 /// Determines whether the specified object is in the collection.
 /// </summary>
 /// <param name="oFavourite">Specifies the object to search for.</param>
 /// <returns></returns>
 public bool Contains(Favourite oFavourite)
 {
     return m_oFavourites.Contains(oFavourite);
 }
コード例 #4
0
 /// <summary>
 /// Creates a new instance of the FavouritesCollection class that contains 
 /// elements copied from the specified favourite collection.
 /// </summary>
 /// <param name="oFavourites">Specifies an array of Favourite objects to add to the collection.</param>
 public FavouritesCollection(Favourite[] oFavourites)
 {
     m_oFavourites = new List<Favourite>(oFavourites);
 }
コード例 #5
0
 /// <summary>
 /// Removes the first occurrence of the specified object from the collection.
 /// </summary>
 /// <param name="oFavourite">Specifies a Favourite object to add to the end of the collection.</param>
 public void Remove(Favourite oFavourite)
 {
     m_oFavourites.Remove(oFavourite);
 }
コード例 #6
0
 /// <summary>
 /// Searches for the specified object and returns the zero based index value of the first occurence found in the collection.
 /// </summary>
 /// <param name="oFavourite">Specifies the object to search for.</param>
 /// <returns></returns>
 public int IndexOf(Favourite oFavourite)
 {
     return m_oFavourites.IndexOf(oFavourite);
 }
コード例 #7
0
 /// <summary>
 /// Inserts an element into the collection at the specified index.
 /// </summary>
 /// <param name="nIndex">Specifies the index at which to insert the element.</param>
 /// <param name="oFavourite">Specifies the object to insert.</param>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public void Insert(int nIndex, Favourite oFavourite)
 {
     try
     {
         m_oFavourites.Insert(nIndex, oFavourite);
     }
     catch (ArgumentOutOfRangeException e)
     {
         throw new ArgumentOutOfRangeException(e.Message, e);
     }
 }
コード例 #8
0
 /// <summary>
 /// Adds a Favourite object to the end of the collection.
 /// </summary>
 /// <param name="oFavourite">Specifies a Favourite object to add to the end of the collection.</param>
 public void Add(Favourite oFavourite)
 {
     m_oFavourites.Add(oFavourite);
 }
コード例 #9
0
        /// <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;
        }