示例#1
0
        private void UpdateLableTreeView()
        {
            PDFFileModel model = Global.Model;

            List <TreeNode> treeNodes = new List <TreeNode>();

            treeViewLable.BeginUpdate();
            treeViewLable.Nodes.Clear();

            int i = 0;

            foreach (Lable l in model.Lables)
            {
                TreeNode node = new TreeNode(l.name);
                node.Tag = i++;
                treeNodes.Add(node);
            }

            for (i = 0; i < model.Lables.Count; i++)
            {
                Lable l = model.Lables[i];
                if (l.parent == -1)
                {
                    treeViewLable.Nodes.Add(treeNodes[i]);
                }
                else
                {
                    treeNodes[l.parent].Nodes.Add(treeNodes[i]);
                }
            }

            treeViewLable.EndUpdate();
            treeViewLable.ExpandAll();
        }
示例#2
0
        private void treeViewLable_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            int   index = (int)e.Node.Tag;
            Lable l     = Global.Model.Lables[index];

            l.name = e.Label;
        }
 private void RemapFiles(Dictionary <int, int> oldToNewIndex)
 {
     for (int i = 0; i < Global.Model.Lables.Count; i++)
     {
         Lable l = Global.Model.Lables[i];
         for (int j = 0; j < l.files.Count; j++)
         {
             l.files[j] = oldToNewIndex[l.files[j]];
         }
     }
 }
示例#4
0
        private void treeViewLable_DragDrop(object sender, DragEventArgs e)
        {
            Console.WriteLine("treeViewLable_DragDrop");
            Point    point  = treeViewLable.PointToClient(new Point(e.X, e.Y));
            TreeNode dragTo = treeViewLable.GetNodeAt(point);

            TreeNode dragFrom = (TreeNode)e.Data.GetData(typeof(TreeNode));

            // 拖拽的是树节点
            if (dragFrom != null)
            {
                if (dragFrom.Equals(dragTo))
                {
                    return;
                }

                if (HasChildNode(dragFrom, dragTo))
                {
                    MessageBox.Show("错误的操作");
                    return;
                }

                dragFrom.Remove();
                if (dragTo == null)
                {
                    treeViewLable.Nodes.Add(dragFrom);
                }
                else
                {
                    dragTo.Nodes.Add(dragFrom);
                    dragTo.Expand();
                }

                BuildLableData();
            }

            ListView.SelectedListViewItemCollection items = (ListView.SelectedListViewItemCollection)e.Data.GetData(typeof(ListView.SelectedListViewItemCollection));
            if (items != null && dragTo != null)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    ListViewItem listItem   = items[i];
                    int          lableIndex = (int)dragTo.Tag;
                    Lable        l          = Global.Model.Lables[lableIndex];
                    int          index      = (int)listItem.Tag;
                    if (!l.files.Contains(index))
                    {
                        l.files.Add(index);
                    }
                }
            }
        }
        public void DeleteFile(int fileIndex)
        {
            for (int i = 0; i < Global.Model.Directories.Count; i++)
            {
                FileDirectory dir = Global.Model.Directories[i];
                dir.files.Remove(fileIndex);
            }

            for (int i = 0; i < Global.Model.Lables.Count; i++)
            {
                Lable l = Global.Model.Lables[i];
                l.files.Remove(fileIndex);
            }
        }
示例#6
0
        private void RebuildLableList_r(List <Lable> list, TreeNode node, int parent)
        {
            int   origIndex = (int)node.Tag;
            Lable l         = Global.Model.Lables[origIndex];

            l.parent = parent;

            int index = list.Count;

            list.Add(l);
            node.Tag = index;
            for (int i = 0; i < node.Nodes.Count; i++)
            {
                RebuildLableList_r(list, node.Nodes[i], index);
            }
        }
示例#7
0
        private void AddLableMenuItem_Click(object sender, EventArgs e)
        {
            Lable l = new Lable();

            l.name = "new lable";
            if (m_ClickNode == null)
            {
                l.parent = -1;
            }
            else
            {
                int nodeIndex = (int)m_ClickNode.Tag;
                l.parent = nodeIndex;
            }
            Global.Model.Lables.Add(l);

            UpdateLableTreeView();
        }
示例#8
0
        private void PropertyPanelLables_Clicked(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn == null)
            {
                MessageBox.Show("删除文件的标签出错");
                return;
            }

            RemoveLableInfo info = (RemoveLableInfo)btn.Tag;
            Lable           l    = Global.Model.Lables[info.lable];

            l.files.RemoveAt(info.removeAt);

            flowLayoutPanelLable.Controls.Remove(btn);
            listViewFile.Items.Remove((ListViewItem)info.obj);
        }
示例#9
0
        private void PropertyPanelShowLables(int fileIndex, object o)
        {
            for (int i = 0; i < Global.Model.Lables.Count; i++)
            {
                Lable l = Global.Model.Lables[i];
                for (int j = 0; j < l.files.Count; j++)
                {
                    if (l.files[j] != fileIndex)
                    {
                        continue;
                    }

                    Button btn = new Button();
                    btn.Text      = l.name;
                    btn.Tag       = new RemoveLableInfo(i, j, o);
                    btn.FlatStyle = FlatStyle.Flat;
                    btn.Click    += new EventHandler(this.PropertyPanelLables_Clicked);
                    flowLayoutPanelLable.Controls.Add(btn);
                }
            }
        }
示例#10
0
        private void treeViewLable_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag == null)
            {
                return;
            }

            int nodeIndex = (int)e.Node.Tag;

            listViewFile.Items.Clear();
            treeViewDir.SelectedNode = null;

            Lable l = Global.Model.Lables[nodeIndex];

            foreach (int i in l.files)
            {
                FileData     f    = Global.Model.Files[i];
                ListViewItem item = new ListViewItem();
                item.Text = f.name;
                item.Tag  = i;
                listViewFile.Items.Add(item);
            }
        }