Beispiel #1
0
        /// <summary>
        /// 读取完成,转存到fileList中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GetFilesCompleted(object sender, GetFilesCompletedEventArgs e)
        {
            List <List <string> > files = e.Result;
            List <string>         tmp_file;     // 临时变量

            m_FileList.Clear();

            foreach (var file in files)
            {
                tmp_file = new List <string>();

                // 排序按windows资源管理器来
                tmp_file.Add(file[2]);                  // 名称
                tmp_file.Add(file[5]);                  // 创建日期
                tmp_file.Add(file[4]);                  // 类型
                // 文件大小,转成KB
                tmp_file.Add(ConvertToKB(Convert.ToInt64(file[3])));

                m_FileList.Add(tmp_file);
            }

            onLoadFileFinish(null, null);
        }
        /// <summary>
        /// Helper that performs our asynchronous GetFiles.
        /// </summary>
        private void DoGetFilesAsync(object asyncState)
        {
            FileOperationState state = asyncState as FileOperationState;
            Exception error = null;
            string[] result = null;

            // perform the GetFiles operation
            try
            {
                result = GetFiles(state.Container, state.Pattern);
            }
            catch (Exception e)
            {
                error = e;
            }

            // construct our event arguments
            GetFilesCompletedEventArgs args = new GetFilesCompletedEventArgs(error, result, state.UserState);

            // fire our completion event
            GetFilesCompleted(this, args);

            // recycle our state object
            ReturnFileOperationState(state);

            // decrement our pending operation count
            PendingOperationsDecrement();
        }
Beispiel #3
0
        void client_GetFilesCompleted(object sender, GetFilesCompletedEventArgs e)
        {
            showHideProgressBar(true);

            if (e.Cancelled)
            {
                showHideProgressBar(true);
                return;
            }

            if (e.Error != null || e.Files == null)
            {
                showHideProgressBar(true);
                return;
            }

            ObservableCollection <FileDescriptor> items = e.Files;

            foreach (FileDescriptor item in items)
            {
                item.DisplayName = makeFileNameUserFriendly(item.FileName);
            }

            if (CurrentFolderDepth > 0)
            {
                UpNavigationItem upItem = new UpNavigationItem()
                {
                    FileName     = Strings.Up,
                    DisplayName  = Strings.Up,
                    RelativePath = "..",
                };
                if (items.Count > 0)
                {
                    items.Insert(0, upItem);
                }
                else
                {
                    items.Add(upItem);
                }
            }
            else
            {
                RelativeUrl = null;
            }

            showHideProgressBar(true);
            if (items.Count > 0)
            {
                foreach (var item in items)
                {
                    Files.Items.Add(item);
                }
                NoFilesLabel.Visibility = Visibility.Collapsed;
                Files.Visibility        = System.Windows.Visibility.Visible;
                Dispatcher.BeginInvoke(() =>
                {
                    FilesScrollViewer.ScrollToTop();
                });
            }
            else
            {
                NoFilesLabel.Visibility = Visibility.Visible;
                Files.Visibility        = System.Windows.Visibility.Collapsed;
            }
        }