Пример #1
0
        public AddFavoriteForm(IResource parent)
        {
            _parent          = parent;
            _bookmarkService = (IBookmarkService)Core.PluginLoader.GetPluginService(typeof(IBookmarkService));
            InitializeComponent();
            this.Icon = Core.UIManager.ApplicationIcon;

            if ((_nameBox.Visible) && (_nameBox.Enabled))
            {
                _nameBox.Focus();
            }
            _createInCombo.AddResourceHierarchy(_bookmarkService.BookmarksRoot,
                                                "Folder", FavoritesPlugin._propParent, new AcceptResourceDelegate(AcceptFolder));
            foreach (IBookmarkProfile profile in _bookmarkService.Profiles)
            {
                IResource root = _bookmarkService.GetProfileRoot(profile);
                string    error;
                if (!_createInCombo.Items.Contains(root) && profile.CanCreate(root, out error))
                {
                    _createInCombo.AddResourceHierarchy(root, "Folder", FavoritesPlugin._propParent, 1);
                }
            }
            _createInCombo.SelectedItem = parent;
            _unitBox.SelectedIndex      = 0;
            RestoreSettings();
            string      defaultUrl = null;
            IDataObject dataObj    = Clipboard.GetDataObject();

            if (dataObj != null)
            {
                defaultUrl = (string)dataObj.GetData(typeof(string));
                if (defaultUrl != null && defaultUrl.Length > 0)
                {
                    try
                    {
                        new Uri(defaultUrl);
                    }
                    catch
                    {
                        defaultUrl = "http://";
                    }
                }
            }
            _URLBox.Text           = (defaultUrl == null || defaultUrl.Length == 0) ? string.Empty : defaultUrl;
            _URLBox.SelectionStart = _URLBox.Text.Length;
            Height = MaximumSize.Height;
        }