Exemple #1
0
        /// <summary>
        /// BeforeExpand
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DirectoryTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            Trace.WriteLine("DirectoryTreeView::DirectoryTreeView_BeforeExpand(object, TreeViewCancelEventArgs)");
            DirectoryTreeNode expandNode = (DirectoryTreeNode)e.Node;

            Debug.WriteLine("Expand Node:" + expandNode.FullPath);
            string path = expandNode.FullPath;

            expandNode.Nodes.Clear();
            try
            {
                DirectoryInfo dirList = new DirectoryInfo(path);
                foreach (DirectoryInfo di in dirList.GetDirectories())
                {
                    DirectoryTreeNode child = new DirectoryTreeNode(di.FullName);
                    child.Nodes.Add(new DirectoryTreeNode());
                    expandNode.Nodes.Add(child);
                }
            }
            catch (IOException ex)
            {
                // TODO:例外
                Debug.WriteLine(ex.Message);
            }
            catch (UnauthorizedAccessException ex)
            {
                // TODO:例外
                Debug.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                // TODO:例外
                Debug.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        /// <summary>
        /// NodeMouseClick
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DirectoryTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            Trace.WriteLine("DirectoryTreeView::DirectoryTreeView_NodeMouseClick(object, TreeNodeMouseClickEventArgs)");
            DirectoryTreeNode mouseClick = (DirectoryTreeNode)e.Node;

            Debug.WriteLine("Mouse Click Node:" + mouseClick.FullPath);

            // イベント情報生成
            DirectoryTreeViewSelectedEventArgs _args = new DirectoryTreeViewSelectedEventArgs();

            _args.Info = mouseClick.Info;

            // 更新イベント
            this.OnSelected(_args);
        }
Exemple #3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="drive"></param>
        private void Update(string drive)
        {
            // 更新開始
            this.BeginUpdate();

            // 追加(ルートノード)
            DirectoryTreeNode node = new DirectoryTreeNode(drive);

            node.Nodes.Add(new DirectoryTreeNode());
            this.Nodes.Add(node);

            // 更新終了
            this.EndUpdate();

            // イベント情報生成
            DirectoryTreeViewUpdatedEventArgs _args = new DirectoryTreeViewUpdatedEventArgs();

            _args.Info = node.Info;

            // 更新イベント
            this.OnUpdated(_args);
        }
Exemple #4
0
        /// <summary>
        /// SetSelected
        /// </summary>
        /// <param name="path"></param>
        public void SetSelected(string path)
        {
            Trace.WriteLine("DirectoryTreeView::SetSelected(string)");
            Debug.WriteLine("path:" + path);


            // ノード検索
            DirectoryTreeNode findNode = this.FindNode(path);

            if (findNode == null)
            {
                return;
            }
            this.SelectedNode = findNode;

            // イベント情報生成
            DirectoryTreeViewSelectedEventArgs _args = new DirectoryTreeViewSelectedEventArgs();

            _args.Info = findNode.Info;

            // 更新イベント
            this.OnSelected(_args);
        }