コード例 #1
0
 /// <summary>
 /// Инициализирует и выводит дерево
 /// </summary>
 /// <param name="treeView">Принемает указанный объект в работу</param>
 /// <returns>результат инициализации</returns>
 public TreeView InitTreeView(TreeView treeView)
 {
     treeView.Nodes.Clear();
     VitIcons.FormCompanents formCompanents = new VitIcons.FormCompanents();
     treeView.ImageList = formCompanents.imageListColor;
     TreeViewFolder(treeView);
     TreeViewFile(treeView);
     treeView.Nodes[0].Expand();
     globalNode = (TreeNode)objectTreeView.Nodes[0].Clone();
     formTree.treeView1.Nodes.Clear();
     formTree.treeView1.Nodes.Insert(0, globalNode);
     return(objectTreeView);
 }
コード例 #2
0
ファイル: ClassUsers.cs プロジェクト: htoto2007/DocManager
        private void Init()
        {
            formUsers.listBoxAccessGroup.Items.Clear();
            ClassAccessGroup.AccessGroup[] accessGroups = classAccessGroup.getInfo();
            foreach (ClassAccessGroup.AccessGroup accessGroup in accessGroups)
            {
                formUsers.listBoxAccessGroup.Items.Add(accessGroup.name);
            }
            VitIcons.FormCompanents formCompanents = new VitIcons.FormCompanents();
            formUsers.listView1.LargeImageList = formCompanents.imageListColor;
            formUsers.listView1.SmallImageList = formCompanents.imageListColor;
            formUsers.listView1.BeginUpdate();
            formUsers.listView1.View          = View.Details;
            formUsers.listView1.FullRowSelect = true;
            formUsers.listView1.MultiSelect   = false;
            formUsers.listView1.Columns.Clear();
            formUsers.listView1.Columns.Add("");
            formUsers.listView1.Columns.Add("id");
            formUsers.listView1.Columns.Add("Имя");
            formUsers.listView1.Columns.Add("Тип доступа");
            formUsers.listView1.Columns.Add("Пароль");
            ClassUsers classUsers = new ClassUsers();

            UserColection[] userColections = classUsers.GetAllUsers();
            foreach (ClassUsers.UserColection userColection in userColections)
            {
                string accessGroupName = classAccessGroup.getNameById(userColection.idAccessGroup);

                ListViewItem listViewItem = new ListViewItem();

                if (accessGroupName == "Админ")
                {
                    listViewItem.ImageKey = "icons8-crown-50.png";
                }
                else
                {
                    listViewItem.ImageKey = "icons8-user-avatar-48.png";
                }

                listViewItem.SubItems.Add(userColection.id.ToString()).Name = "id";
                listViewItem.SubItems.Add(userColection.name).Name          = "name";
                listViewItem.SubItems.Add(accessGroupName).Name             = "idAccessGroup";
                listViewItem.SubItems.Add(userColection.password).Name      = "password";
                formUsers.listView1.Items.Add(listViewItem);
            }
            formUsers.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            formUsers.listView1.EndUpdate();
            formUsers.listView1.Update();
        }
コード例 #3
0
ファイル: ClassLisView.cs プロジェクト: htoto2007/DocManager
        public void listViewFromTreeVuew(TreeView treeView, ListView listView)
        {
            listView.Columns.Clear();
            listView.Items.Clear();
            VitIcons.FormCompanents formCompanents = new VitIcons.FormCompanents();
            listView.LargeImageList = formCompanents.imageListColor;
            listView.SmallImageList = formCompanents.imageListColor;
            listView.StateImageList = formCompanents.imageListColor;
            listView.View           = View.Details;
            listView.MultiSelect    = true;
            listView.FullRowSelect  = true;
            listView.BeginUpdate();
            listView.Columns.Add("");
            listView.Columns.Add("Имя");
            listView.Columns.Add("тип");
            listView.Columns.Add("Дата создания");

            TreeNode           treeNode = treeView.SelectedNode;
            TreeNodeCollection treeNodeCollection;

            try
            {
                treeNodeCollection = treeNode.Nodes;
            }
            catch (System.NullReferenceException)
            {
                Console.WriteLine("treeNode.Nodes is null");
                return;
            }

            Console.WriteLine("treeNode.Nodes out to listView");
            foreach (TreeNode tn in treeNodeCollection)
            {
                Console.WriteLine(tn.Name);
                ListViewItem listViewItem = new ListViewItem();
                string       type         = tn.Name.Split('_')[0];
                if (ClassTree.TypeNodeCollection.FILE == type)
                {
                    Console.WriteLine(ClassTree.TypeNodeCollection.FILE + " = " + type);
                    listViewItem.ImageKey = "icons8-document-48.png";
                }
                else if (ClassTree.TypeNodeCollection.FOLDER == type)
                {
                    Console.WriteLine(ClassTree.TypeNodeCollection.FILE + " = " + type);
                    listViewItem.ImageKey = "icons8-folder-48.png";
                }
                else
                {
                    Console.WriteLine(ClassTree.TypeNodeCollection.FILE + " = " + type + " (undefined)");
                    listViewItem.ImageKey = "icons8-question-mark-48.png";
                }

                string name = tn.Text;
                listViewItem.SubItems.Add(name);
                listViewItem.SubItems.Add(type);
                listView.Items.Add(listViewItem);
                //int id = Convert.ToInt32(tn.Name.Split('_')[1]);
                //classFiles.GetFileById(id).
            }
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView.EndUpdate();
            listView.Update();
            Console.WriteLine("\n");
        }