示例#1
0
        public void Execute(IActionContext context)
        {
            IResourceList resources         = context.SelectedResources;
            IResource     folder            = BookmarkService.GetBookmarksRoot();
            IResource     selected          = folder;
            string        url               = context.CurrentUrl;
            bool          isWeblinkSelected = false;

            if (resources.Count > 0)
            {
                selected = resources[0];
            }
            else
            {
                if (FavoritesPlugin._favoritesTreePane.SelectedNode != null)
                {
                    selected = FavoritesPlugin._favoritesTreePane.SelectedNode;
                }
            }
            if (selected.Type == "Folder")
            {
                folder = selected;
            }
            else if (selected.Type == "Weblink")
            {
                folder            = BookmarkService.GetParent(selected);
                isWeblinkSelected = url != null && selected.GetPropText(FavoritesPlugin._propURL) == url;
            }
            else
            {
                selected = selected.GetLinkProp("Source");
                if (selected != null && selected.Type == "Weblink")
                {
                    folder            = BookmarkService.GetParent(selected);
                    isWeblinkSelected = url != null && selected.GetPropText(FavoritesPlugin._propURL) == url;
                }
            }

            using (AddFavoriteForm frm = new AddFavoriteForm(folder))
            {
                if (!isWeblinkSelected || Core.TabManager.CurrentTabId != "Web")
                {
                    if (url != null)
                    {
                        frm.SetURL(url);
                    }
                    if (context.CurrentPageTitle != null)
                    {
                        frm._nameBox.Text = context.CurrentPageTitle;
                    }
                }
                frm.ShowDialog(Core.MainWindow);
            }
        }
示例#2
0
        public static void EditFavorite(IResource favorite)
        {
            AddFavoriteForm theForm = new AddFavoriteForm(null);

            using ( theForm )
            {
                if (favorite.Type != "Weblink")
                {
                    favorite = favorite.GetLinkProp("Source");
                    if (favorite == null)
                    {
                        return;
                    }
                }
                theForm._favorite     = favorite;
                theForm._URLBox.Text  = favorite.GetPropText(FavoritesPlugin._propURL);
                theForm._nameBox.Text = favorite.GetPropText(Core.Props.Name);
                int freq = favorite.GetIntProp(FavoritesPlugin._propUpdateFreq) / 3600;
                if (freq <= 0)
                {
                    theForm._fakeTextBox.Visible = true;
                }
                else
                {
                    if (freq % 24 == 0)
                    {
                        theForm._unitBox.SelectedIndex = 1;
                        freq /= 24;
                        if (freq % 7 == 0)
                        {
                            theForm._unitBox.SelectedIndex = 2;
                            freq /= 7;
                        }
                    }
                    theForm._hoursBox.Value         = freq;
                    theForm._updateCheckBox.Checked = true;
                }
                theForm._okButton.Enabled = true;
                theForm.Text = "Bookmark Properties";
                theForm._selectFolderPanel.Visible = false;
                theForm.Height = theForm.MinimumSize.Height;
                IBookmarkProfile profile  = _bookmarkService.GetOwnerProfile(favorite);
                string           error    = null;
                bool             readOnly = (profile != null && !profile.CanCreate(null, out error));
                if (theForm._URLBox.ReadOnly = theForm._nameBox.ReadOnly = readOnly)
                {
                    theForm._errorToolTip.SetToolTip(theForm._URLBox, error);
                    theForm._errorToolTip.SetToolTip(theForm._nameBox, error);
                    DisplayError(error);
                }
                theForm.ShowDialog(Core.MainWindow);
            }
        }