Exemple #1
0
        private void treeView_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(DrapDropItem)))
            {
                TreeNode node = GetTreeNode(e.X, e.Y);
                if (node != null)
                {
                    DrapDropItem data = (DrapDropItem)e.Data.GetData(typeof(DrapDropItem));

                    Bookmarks.Folder folder = node.Tag as Bookmarks.Folder;
                    if (folder != null && data.Folder != folder)
                    {
                        foreach (Bookmarks.BookmarkBase bb in data.Items)
                        {
                            Bookmarks.Bookmark b = bb as Bookmarks.Bookmark;

                            if (b != null)
                            {
                                data.Folder.Items.Remove(b);
                                folder.Items.Add(b);
                            }
                            else
                            {
                                MessageBox.Show("フォルダはフォルダにドロップできません:" + bb.Name);
                            }
                        }

                        UpdateTreeView();
                        SelectNode(folder);
                    }
                }
            }
        }
Exemple #2
0
        public Bookmarks.Bookmark GetBookmark()
        {
            Bookmarks.Bookmark bookmark = new Bookmarks.Bookmark();

            bookmark.Name = textBoxTitle.Text;
            bookmark.URL  = textBoxURL.Text;

            return(bookmark);
        }
Exemple #3
0
        public void UpdateUI()
        {
            isUpdatingUI = true;

            try
            {
                bool nameEnabled = false;
                bool urlEnabled  = false;

                if (listView.SelectedItems.Count > 0)
                {
                    ListViewItem selectedItem = listView.SelectedItems[0];

                    Bookmarks.Folder childFolder = selectedItem.Tag as Bookmarks.Folder;

                    if (childFolder != null)
                    {
                        nameEnabled      = true;
                        textBoxName.Text = childFolder.Name;
                        textBoxURL.Text  = "";
                    }

                    Bookmarks.Bookmark bookmark = selectedItem.Tag as Bookmarks.Bookmark;

                    if (bookmark != null)
                    {
                        nameEnabled      = true;
                        textBoxName.Text = bookmark.Name;

                        urlEnabled      = true;
                        textBoxURL.Text = bookmark.URL;
                    }
                }

                labelName.Enabled   = nameEnabled;
                labelURL.Enabled    = urlEnabled;
                textBoxName.Enabled = nameEnabled;
                textBoxURL.Enabled  = urlEnabled;
            }
            finally
            {
                isUpdatingUI = false;
            }
        }
Exemple #4
0
        public void UpdateListView()
        {
            listView.Items.Clear();
            TreeNode selectedNode = treeView.SelectedNode;

            if (selectedNode != null)
            {
                Bookmarks.Folder folder = selectedNode.Tag as Bookmarks.Folder;
                if (folder != null)
                {
                    foreach (Bookmarks.BookmarkBase bb in folder.Items)
                    {
                        Bookmarks.Folder childFolder = bb as Bookmarks.Folder;

                        if (childFolder != null)
                        {
                            ListViewItem item = listView.Items.Add("");

                            item.SubItems.Add("");
                            item.Tag = childFolder;
                            UpdateListViewItem(item);
                        }

                        Bookmarks.Bookmark bookmark = bb as Bookmarks.Bookmark;

                        if (bookmark != null)
                        {
                            ListViewItem item = listView.Items.Add("");

                            item.Tag = bookmark;
                            item.SubItems.Add("");
                            item.SubItems.Add("");
                            UpdateListViewItem(item);
                        }
                    }
                }
            }
            UpdateUI();
        }
Exemple #5
0
        private void UpdateListViewItem(ListViewItem item)
        {
            Bookmarks.Folder childFolder = item.Tag as Bookmarks.Folder;

            if (childFolder != null)
            {
                item.SubItems[1].Text = childFolder.Name;
                item.ImageIndex       = 0;
                TreeNode node = FindNode(childFolder);
                if (node != null)
                {
                    node.Text = childFolder.Name;
                }
            }

            Bookmarks.Bookmark bookmark = item.Tag as Bookmarks.Bookmark;

            if (bookmark != null)
            {
                item.SubItems[1].Text = bookmark.Name;
                item.SubItems[2].Text = bookmark.URL;
            }
        }
Exemple #6
0
        private void UpdateBookmark()
        {
            if (listView.SelectedItems.Count > 0)
            {
                ListViewItem selectedItem = listView.SelectedItems[0];

                Bookmarks.Folder childFolder = selectedItem.Tag as Bookmarks.Folder;

                if (childFolder != null)
                {
                    childFolder.Name = textBoxName.Text;
                }

                Bookmarks.Bookmark bookmark = selectedItem.Tag as Bookmarks.Bookmark;

                if (bookmark != null)
                {
                    bookmark.Name = textBoxName.Text;
                    bookmark.URL  = textBoxURL.Text;
                }

                UpdateListViewItem(selectedItem);
            }
        }