Beispiel #1
0
 void updateFileList(object path)
 {
     try
     {
         Path_Lab.Text = "当前路径:" + path.ToString().Replace("apps", "我的应用数据");
         var jobj = JObject.Parse(WebTool.GetHtml($"https://pcs.baidu.com/rest/2.0/pcs/file?method=list&access_token={Program.config.Access_Token}&path=" + Uri.EscapeDataString($"{path.ToString()}")));
         FilelistView.BeginUpdate();
         FilelistView.Items.Clear();
         Fileinfo.Clear();
         foreach (JObject job in jobj["list"])
         {
             DiskFileInfo fileinfo = JsonConvert.DeserializeObject <DiskFileInfo>(job.ToString());
             FilelistView.Items.Add(fileinfo.getName());
             this.Fileinfo.Add(fileinfo.getName(), fileinfo);
             if (fileinfo.isdir == 1)
             {
                 setEndItemImageKey("Dir.png");
             }
             else
             {
                 setEndItemImageKey(getIconImage(fileinfo.getSuffix()));
             }
         }
         FilelistView.EndUpdate();
     }
     catch (Exception ex)
     {
         MessageBox.Show("更新文件列表时遇到意外的错误: " + ex.ToString());
     }
     Info_Lab.Text = "等待中...";
 }
Beispiel #2
0
        /// <summary>
        ///     ref : https://msdn.microsoft.com/en-us/library/ms996467.aspx
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilelistViewColumnClick(object sender, ColumnClickEventArgs e)
        {
            if (e.Column != _sortColumn)
            {
                // Set the sort column to the new column.
                _sortColumn = e.Column;
                // Set the sort order to ascending by default.
                FilelistView.Sorting = SortOrder.Ascending;
            }
            else
            {
                FilelistView.Sorting = FilelistView.Sorting == SortOrder.Ascending
                    ? SortOrder.Descending
                    : SortOrder.Ascending;
            }

            FilelistView.Sort();
            FilelistView.ListViewItemSorter = new ListViewItemComparer(e.Column,
                                                                       FilelistView.Sorting);
        }
Beispiel #3
0
        private void FilelistViewMouseDown(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo HI = FilelistView.HitTest(e.Location);

            if (e.Button == MouseButtons.Right)
            {
                if (HI.Location != ListViewHitTestLocations.None)//(FilelistView.FocusedItem.Bounds.Contains(e.Location))
                {
                    contextMenuStripFileList.Items[1].Visible = true;
                    contextMenuStripFileList.Items[2].Visible = true;
                    contextMenuStripFileList.Items[3].Visible = true;
                    contextMenuStripFileList.Items[4].Visible = true;
                }
                else
                {
                    contextMenuStripFileList.Items[1].Visible = false;
                    contextMenuStripFileList.Items[2].Visible = false;
                    contextMenuStripFileList.Items[3].Visible = false;
                    contextMenuStripFileList.Items[4].Visible = false;
                }
                contextMenuStripFileList.Show(Cursor.Position);
            }
        }
Beispiel #4
0
        private void UpdateListView(IReadOnlyCollection <NlFile> list)
        {
            if (list == null)
            {
                tsbLock.Enabled = false;
                toolStripFileCountLabel.Text = FilelistView.Items.Count.ToString();
                return;
            }
            if (list.Count <= 0)
            {
                tsbLock.Enabled = false;
                FilelistView.Items.Clear();
                toolStripFileCountLabel.Text = FilelistView.Items.Count.ToString();
                return;
            }
            FilelistView.BeginUpdate();

            try
            {
                FilelistView.Items.Clear();

                //TODO: add image icon to file list
                foreach (var key in list)
                {
                    var    item       = new ListViewItem(Path.GetFileName(key.FileName));
                    var    type       = " B";
                    double original   = key.OriginalSize;
                    double compressed = key.CompressedSize;
                    if (key.OriginalSize > 1024)
                    {
                        original   = key.OriginalSize / 1024.0;
                        compressed = key.CompressedSize / 1024.0;
                        type       = "KiB";
                    }

                    if (key.OriginalSize > 1024 * 1024)
                    {
                        original   = original / 1024;
                        compressed = compressed / 1024;
                        type       = "MiB";
                    }

                    if (key.OriginalSize > 1024 * 1024 * 1024)
                    {
                        original   = original / 1024;
                        compressed = compressed / 1024;
                        type       = "GiB";
                    }

                    item.SubItems.Add(string.Format("{0:N2} {1}", original, type));
                    item.SubItems.Add(string.Format("{0:N2} {1}", compressed, type));

                    item.SubItems.Add(key.FilePath != null ? key.FilePath + "\\" : "\\");
                    FilelistView.Items.Add(item);

                    tsbLock.Enabled = FilelistView.Items.Count > 0;
                }
            }
            finally
            {
                FilelistView.EndUpdate();
                toolStripFileCountLabel.Text = FilelistView.Items.Count.ToString();
            }
        }
Beispiel #5
0
 private void FileListViewResize()
 {
     FilelistView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     FilelistView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }