private void toolAddToFavorites_Click(object sender, EventArgs e)
        {
            IExplorerObject selected = catalogComboBox1.SelectedExplorerObject;

            if (selected == null)
            {
                return;
            }

            FormAddToFavorites dlg = new FormAddToFavorites(selected.FullName, false);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                MyFavorites favs = new MyFavorites();

                favs.AddFavorite(dlg.FavoriteName, selected.FullName, (selected.Icon != null) ? selected.Icon.Image : null);

                FavoriteMenuItem fItem = new FavoriteMenuItem(new MyFavorites.Favorite(dlg.FavoriteName, dlg.FavoritePath, (selected.Icon != null) ? selected.Icon.Image : null));
                fItem.Click += new EventHandler(fItem_Click);

                if (btnFavorites.DropDownItems.Count < 2)
                {
                    btnFavorites.DropDownItems.Add(new ToolStripSeparator());
                }

                btnFavorites.DropDownItems.Add(fItem);
            }
        }
        private void ExplorerDialogControl_Load(object sender, EventArgs e)
        {
            contentsList1.ItemSelected      += new ContentsList.ItemClickedEvent(contentsList1_ItemSelected);
            contentsList1.ItemDoubleClicked += new ContentsList.ItemDoubleClickedEvent(contentsList1_ItemDoubleClicked);
            contentsList1.SmallImageList     = ExplorerImageList.List.ImageList;
            catalogComboBox1.InitComboBox();

            LocalizedResources.GlobalizeMenuItem(btnFavorites);
            bool first = true;

            foreach (MyFavorites.Favorite fav in (new MyFavorites()).Favorites)
            {
                if (fav == null)
                {
                    continue;
                }
                FavoriteMenuItem fItem = new FavoriteMenuItem(fav);
                fItem.Click += new EventHandler(fItem_Click);

                if (first)
                {
                    first = false;
                    btnFavorites.DropDownItems.Add(new ToolStripSeparator());
                }
                btnFavorites.DropDownItems.Add(fItem);
            }
        }
Example #3
0
        async void fItem_Click(object sender, EventArgs e)
        {
            if (sender is FavoriteMenuItem)
            {
                FavoriteMenuItem item = (FavoriteMenuItem)sender;

                this.Cursor = Cursors.WaitCursor;

                await catalogComboBox1.InitComboBox();

                try
                {
                    StringBuilder fullPath = new StringBuilder();
                    foreach (string subPath in item.Favorite.Path.Split('\\'))
                    {
                        if (fullPath.Length > 0)
                        {
                            fullPath.Append(@"\");
                        }
                        fullPath.Append(subPath);

                        ListViewItem listItem = contentsList1.GetItemPerPath(fullPath.ToString());
                        if (item == null)
                        {
                            return;
                        }

                        contentsList1_ItemDoubleClicked(listItem);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                }
                this.Cursor = Cursors.Default;
            }
        }