Esempio n. 1
0
        protected void OnCollectionChanged(NotifyCollectionChangedAction action, TreeViewItem2 b, int index)
        {
            NotifyCollectionChangedEventHandler

                handler = CollectionChanged;

            if (handler != null)
            {
                handler(this,

                        new NotifyCollectionChangedEventArgs(action,

                                                             b, index));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// TreeView Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void UserDirTree_ItemClick(object sender, ItemClickEventArgs e)
        {
            TreeViewItem2 item = (TreeViewItem2)e.ClickedItem;

            if (item.IsDir)
            {
                ReSet(item);
            }
            else
            {
                if (!File.Exists(item.FullPath))
                {
                    return;
                }
                StorageFile file = await AwaitGetStorageFile(item.FullPath);

                UserData udata = await UserXml.GetUserDataFromXml(file);

                SetEventTable(udata);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// TreeViewItemを元にディレクトリを再読み込み
        /// </summary>
        /// <param name="item"></param>
        private void ReSet(TreeViewItem2 item)
        {
            vm.DirTrees.Clear();
            vm.DirTrees.Add(new TreeViewItem2()
            {
                Name     = "..",
                IsDir    = false,
                Header   = "..",
                Icon     = FontAwesome.UWP.FontAwesomeIcon.File,
                FullPath = ""
            });

            if (item != null && item.IsDir)
            {
                vm.DirTrees.Clear();
                //                List<TreeViewItem2> tree = new List<TreeViewItem2>();

                DirectoryInfo dir = new DirectoryInfo(item.FullPath);
                foreach (var directory in dir.GetDirectories())
                {
                    vm.DirTrees.Add(new TreeViewItem2()
                    {
                        Name     = directory.Name,
                        IsDir    = true,
                        Header   = directory.Name,
                        Icon     = FontAwesome.UWP.FontAwesomeIcon.Folder,
                        FullPath = directory.FullName
                    });
                }

                foreach (var file in dir.GetFiles())
                {
                    // ファイル
                    string trimName = System.IO.Path.GetFileNameWithoutExtension(file.Name);
                    vm.DirTrees.Add(new TreeViewItem2()
                    {
                        Name     = file.Name,
                        IsDir    = false,
                        Header   = file.Name,
                        Icon     = FontAwesome.UWP.FontAwesomeIcon.File,
                        FullPath = file.FullName
                    });
                }

                if (DirTree.Count == 0)
                {
                    vm.DirTrees.Add(new TreeViewItem2()
                    {
                        Name     = "ファイルがありません",
                        IsDir    = false,
                        Header   = "ファイルがありません",
                        Icon     = FontAwesome.UWP.FontAwesomeIcon.File,
                        FullPath = dir.Parent.FullName,
                        NoFile   = true
                    });
                }

                //                dirVM.DirTree2 = tree;
            }
            else if (item != null && !item.IsDir)
            {
                //                UserData udata = UserXml.GetUserDataFromXml(item.FullPath);
            }

            PathCrumbParent.Text = item.Name;
            dataDir = new DirectoryInfo(item.FullPath);
        }