Ejemplo n.º 1
0
        /// <summary>
        /// Создает новое окно свойств и заполняет его данными.
        /// </summary>
        /// <param name="pathFile">Путь файла</param>
        /// <param name="type">Тип файла</param>
        /// <returns></returns>
        private static WindowInformation CreateNewWindowInformation(string pathFile, TypeContentElement type)
        {
            WindowInformation window = new WindowInformation();

            if (type == TypeContentElement.folder)
            {
                DirectoryInfo directory     = new DirectoryInfo(pathFile);
                Stack <long>  infoDirectory = CalculateWeightOfFolder(pathFile);

                window.Icon.Source = new BitmapImage(new Uri("ControlElements/Images/FolderV3.png", UriKind.Relative));

                window.InfoName.Text = directory.Name;

                window.InfoTypeFile.Text = "Folder";

                window.InfoDescription.Text = "No description";

                window.InfoPath.Text = directory.FullName;

                window.InfoSize.Text = $"{FormatFileSize(infoDirectory.Pop())} ({infoDirectory.Pop()} files; {infoDirectory.Pop()} folders;)";

                window.InfoCreate.Text = directory.CreationTimeUtc.ToString();

                window.InfoChange.Text = directory.LastWriteTimeUtc.ToString();
            }
            if (type == TypeContentElement.file)
            {
                FileInfo file = new FileInfo(pathFile);

                window.Icon.Source = GetIconForFile(file.Extension, pathFile);

                window.InfoName.Text = file.Name;

                window.InfoTypeFile.Text = FormattingOfTypeFile(file.Extension);

                window.InfoDescription.Text = "No description";

                window.InfoPath.Text = file.FullName;

                window.InfoSize.Text = FormatFileSize(file.Length);

                window.InfoCreate.Text = file.CreationTimeUtc.ToString();

                window.InfoChange.Text = file.LastWriteTimeUtc.ToString();
            }

            return(window);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Выводит окно информации о файле или папке.
 /// </summary>
 /// <param name="pathFile">Путь файла или папки</param>
 /// <param name="type">Тип</param>
 public static void OpenWindowInformationOfFile(string pathFile, TypeContentElement type)
 {
     CreateNewWindowInformation(pathFile, type)?.Show();
 }