コード例 #1
0
        private void FileInfoView_SortColumn(object sender, ColumnClickEventArgs e)
        {
            // Determine whether the column is the same as the last column clicked.
            if (e.Column != sortColumn)
            {
                // Set the sort column to the new column.
                sortColumn = e.Column;
                // Set the sort order to ascending by default.
                FileInfoView.Sorting = SortOrder.Ascending;
            }
            else
            {
                // Determine what the last sort order was and change it.
                if (FileInfoView.Sorting == SortOrder.Ascending)
                {
                    FileInfoView.Sorting = SortOrder.Descending;
                }
                else
                {
                    FileInfoView.Sorting = SortOrder.Ascending;
                }
            }

            // Call the sort method to manually sort.
            FileInfoView.Sort();
            // Set the ListViewItemSorter property to a new ListViewItemComparer
            // object.
            FileInfoView.ListViewItemSorter = new ListViewItemComparer(e.Column, FileInfoView.Sorting);
        }
コード例 #2
0
ファイル: ResourceManager.cs プロジェクト: piandmash/PI.Cms
        ///// <markdown>
        ///// ### public async Task[FileInfoView] Save(HttpContent content, string relativePath = "")
        ///// </markdown>
        ///// <summary>
        ///// Saves a file to the path specified
        ///// </summary>
        ///// <param name="content">The HttpContent that contains the upload form data</param>
        ///// <param name="relativePath">The relative path to save the file to</param>
        ///// <returns>The new FileInfoView</returns>
        //public async Task<FileInfoView> Save(HttpContent content, string relativePath = "")
        //{
        //    //rebuild reltative path
        //    relativePath = RebuildRelativePath(relativePath);
        //    string fullPath = FullRoot + relativePath + @"\";
        //    string path = Root + relativePath;
        //    //throw directory doesn't exist method
        //    if (!Directory.Exists(fullPath)) throw new DirectoryNotFoundException("Directory '" + path + "' does not exist");

        //    MultipartFormDataStreamProvider provider = new MultipartFormDataStreamProvider(fullPath);
        //    var result = await content.ReadAsMultipartAsync(provider);
        //    var originalFileName = GetDeserializedFileName(result.FileData.First());
        //    var uploadedFileInfo = new FileInfo(result.FileData.First().LocalFileName);
        //    //remove old file
        //    if (File.Exists(fullPath + originalFileName)) File.Delete(fullPath + originalFileName);
        //    //add new file
        //    File.Move(fullPath + uploadedFileInfo.Name, fullPath + originalFileName);
        //    //get file info on new file
        //    FileInfo file = new FileInfo(fullPath + originalFileName);
        //    FileInfoView resource = new FileInfoView();
        //    //map to resource model
        //    Mapper.Map(file, resource);
        //    //return model
        //    return CleanFileView(resource);
        //}

        /// <markdown>
        /// ### public FileInfoView GetFileInfoView(string path = "")
        /// </markdown>
        /// <summary>
        /// Saves a file to the path specified
        /// </summary>
        /// <param name="path">The relative path to the file</param>
        /// <returns>The new FileInfoView</returns>
        public FileInfoView GetFileInfoView(string path = "")
        {
            //get file info on new file
            FileInfo     file     = new FileInfo(path);
            FileInfoView resource = CreateFileInfoView(file);

            //return model
            return(CleanFileView(resource));
        }
コード例 #3
0
        void ItemCopy_Executed(object sender, EventArgs e)
        {
            FileInfoView selected = null;

            if ((selected = _status.FileGridView.SelectedItem as FileInfoView) != null)
            {
                _status.CopyFileFullPath = selected.FullName;
                _status.CopyFileName     = selected.Name;
            }
        }
コード例 #4
0
ファイル: ItemPaste.cs プロジェクト: TinSyner/github_spider
        void ItemPaste_Executed(object sender, EventArgs e)
        {
            FileInfoView selected = null;

            if ((selected = _status.FileGridView.SelectedItem as FileInfoView) != null)
            {
                var sourceFullName = _status.CopyFileFullPath;
                var targetDir      = _status.CurrentDirPath;
                var targetFullName = targetDir + _status.PathSeparator + _status.CopyFileName;
                if (targetFullName != sourceFullName)
                {
                    _status.FileManager.CopyFileOrDir(sourceFullName, targetFullName);
                    //clear
                    _status.CopyFileFullPath = string.Empty;
                    _status.CopyFileName     = string.Empty;
                }
            }
        }
コード例 #5
0
        public dynamic Search([FromBody] SearchModel model)
        {
            string q = model.q;

            q = q.ToLower();
            List <FileInfoView>   items        = new List <FileInfoView>();
            List <IndexedFileDoc> docs         = searchService.Query(q, config.MaxSearchResult);
            HashSet <string>      importedDirs = new HashSet <string>();

            foreach (IndexedFileDoc doc in docs)
            {
                if (importedDirs.Contains(doc.DirectoryName) == false)
                {
                    importedDirs.Add(doc.DirectoryName);
                    FileInfoView fiv = mainService.GetFileInfoView(new DirectoryInfo(doc.DirectoryName));
                    items.Add(fiv);
                }
            }
            foreach (IndexedFileDoc doc in docs)
            {
                string fileType = Helper.GetFileDocType(Path.GetExtension(doc.Name));
                string efid     = fimgr.GetIdByFilePath(doc.FullName);

                string relPath;
                PathUtility.TryGetRelPath(doc.FullName, out relPath);
                items.Add(new FileInfoView
                {
                    Id     = efid,
                    Size   = Helper.GetReadableByteSize(doc.Length, 2),
                    GetUrl = "/get" + relPath,
                    Title  = doc.Name,
                    Modify = doc.LastWriteTime.ToString(),
                    Type   = fileType
                });
            }
            return(new
            {
                message = "找到 " + items.Count + " 筆.",
                items
            });
        }
コード例 #6
0
		void ItemCreateDir_Executed(object sender, EventArgs e)
		{
			string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
			var newItem = new FileInfoView("NewFolder", "NewFolder", true, time, "0", "0777");
			newItem.IsCreateing = true;

			if (!Platform.Instance.IsWinForms)
			{
				var items = _status.FileGridView.DataStore as DataStoreCollection<FileInfoView>;
				items.Add(newItem);

				var row = items.IndexOf(newItem);
				_status.FileGridView.BeginEdit(row, 1);
			}
			else
			{
				var oldText = "NewFolder";
				var dir = new Dialogs.CreateDir(oldText);
				string result = dir.ShowModal(_status.FileGridView);

				if (!string.IsNullOrEmpty(result))
				{
					var newText = result;
					if (newText == oldText)
					{
						return;
					}
					if (GetOldFiles().FirstOrDefault(r => r == newText) != null)
					{
						MessageBox.Show("This name already exists, please rename");
						return;
					}
					//创建文件夹
					var currentDir = _status.CurrentDirPath;
					string dirName = newText;
					string dirFullPath = currentDir + _status.PathSeparator + dirName;
					_status.FileManager.CreateDir(dirFullPath);
				}
			}
		}
コード例 #7
0
ファイル: ResourceManager.cs プロジェクト: piandmash/PI.Cms
 /// <markdown>
 /// ### public FileInfoView CleanFileView(FileInfoView file)
 /// </markdown>
 /// <summary>
 /// Cleans a file removing full paths and leaving it with relative paths only
 /// </summary>
 /// <param name="file">The file to clean</param>
 /// <returns>The cleaned file</returns>
 public FileInfoView CleanFileView(FileInfoView file)
 {
     file.DirectoryName = file.DirectoryName.Replace(FullRoot, "");
     file.FullName      = file.FullName.Replace(FullRoot, "");
     return(file);
 }