Example #1
0
 /// <summary>
 /// 更新イベント
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnUpdated(FileListViewUpdatedEventArgs e)
 {
     // イベントハンドラ呼出し
     if (this.Updated != null)
     {
         // 呼出し
         this.Updated(this, e);
     }
 }
Example #2
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="path"></param>
        /// <param name="mask"></param>
        public void Update(string path, string mask)
        {
            Trace.WriteLine("FileListView::Update(string, string)");
            Debug.WriteLine("path:" + path);
            Debug.WriteLine("mask:" + mask);

            // 設定
            this.m_Path = path;
            this.m_Mask = mask;

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

            _args.Path = this.m_Path;
            _args.Mask = this.m_Mask;

            // 更新開始
            this.BeginUpdate();

            // クリア
            this.Items.Clear();

            // ディレクトリ存在判定
            if (Directory.Exists(path))
            {
                // TODO:追加(カレントディレクトリ)

                // TODO:追加(親ディレクトリ)

                // 追加用リスト
                List <FileListViewItem> list = new List <FileListViewItem>();

                try
                {
                    // 配下のディレクトリを取得
                    foreach (string directory in Directory.GetDirectories(this.m_Path))
                    {
                        // ファイルListViewItemオブジェクト生成
                        FileListViewItem _item = new FileListViewItem(directory);

                        // 追加
                        list.Add(_item);
                    }

                    // 配下のファイルを取得
                    foreach (string file in Directory.EnumerateFiles(this.m_Path, this.m_Mask, SearchOption.TopDirectoryOnly))
                    {
                        // ファイルListViewItemオブジェクト生成
                        FileListViewItem _item = new FileListViewItem(file);

                        // 追加
                        list.Add(_item);
                    }
                }
                catch (UnauthorizedAccessException ex)
                {
                    Debug.WriteLine(ex.Message);
                }

                // 仮想モード設定
                this.VirtualListSize = list.Count;
                this.m_Items         = list.ToArray();
            }
            else
            {
                // TODO:ディレクトリ存在なし
            }

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

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