Exemplo n.º 1
0
        /// <summary>
        /// Show details/info for a WebFile
        /// </summary>
        /// <param name="File">WebFile object</param>
        /// <param name="createNewInstance">Whether to create a new instance</param>
        public void ShowFileDetails(WebFile File, DataGridView parentDataGrid, bool isLocal = false, bool createNewInstance = true)
        {
            Program.log.Info("Showing file details dialog : " + File.URL);

            if (createNewInstance)
            {
                FrmFileDetails = new FileDetailsWindow();
            }

            FrmFileDetails.IsLocalFile    = isLocal;
            FrmFileDetails.ParentDataGrid = parentDataGrid;
            FrmFileDetails.CurrentFile    = File;

            FrmFileDetails.LabelFileName.Text      = File.Name;
            FrmFileDetails.LabelValueName.Text     = File.Name;
            FrmFileDetails.LabelValueRefferer.Text = File.Host;
            FrmFileDetails.LabelValueType.Text     = File.Type;
            FrmFileDetails.InfoFileURL.Text        = Uri.UnescapeDataString(File.URL);

            // Builds parts of the URL into a better presented string, simply replaces '/' with '>' and no filename
            var url         = new Uri(File.URL);
            var directories = new StringBuilder();

            if (!File.URL.StartsWith(@"C:\"))
            {
                directories.Append(File.Host);
            }
            else
            {
                FrmFileDetails.LabelValueRefferer.Text = "Local";
            }                                                                                                                               // Appends the Host at the start if not Local, else it will be named 'Local'
            foreach (string path in url.LocalPath.Split('/', '\\'))
            {
                if (!Path.HasExtension(path))
                {
                    directories.Append(path + "> ");
                }
            }
            FrmFileDetails.LabelValueDirectory.Text = directories.ToString();

            FrmFileDetails.LabelValueSize.Text = StringExtensions.BytesToPrefix(File.Size);
            FrmFileDetails.LabelValueAge.Text  = StringExtensions.TimeSpanAge(File.DateUploaded);

            if (!createNewInstance)
            {
                FrmFileDetails.CheckFileEvents();
            }
            else
            {
                FrmFileDetails.ShowDialog(this);
            }

            Program.log.Info("Successfully loaded file details dialog");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Show details/info for a WebFile
        /// </summary>
        /// <param name="File">WebFile object</param>
        /// <param name="parentDataGrid">Parent data grid to scroll</param>
        /// <param name="createNewInstance">Whether to create a new instance</param>
        public void ShowFileDetails(FtpFile File, DataGridView parentDataGrid, bool createNewInstance = true)
        {
            Program.Log.Info("Loading file details : " + File.URL);

            if (createNewInstance)
            {
                FormFileDetails = new FileDetailsWindow();
            }

            FormFileDetails.FileExtension  = Path.GetExtension(File.URL).Replace(".", "").ToUpper();
            FormFileDetails.ParentDataGrid = parentDataGrid;
            FormFileDetails.CurrentFile    = File;

            FormFileDetails.LabelFileName.Text      = File.Name;
            FormFileDetails.LabelValueName.Text     = File.Name;
            FormFileDetails.LabelValueSize.Text     = StringExtensions.BytesToPrefix(File.Size);
            FormFileDetails.LabelValueRefferer.Text = new Uri(File.URL).Host;

            // Builds parts of the URL into a better presented string, simply replaces '/' with '>' and no filename
            var url         = new Uri(File.URL);
            var directories = new StringBuilder();

            directories.Append(new Uri(File.URL).Host);
            foreach (var path in url.LocalPath.Split('/', '\\'))
            {
                if (!Path.HasExtension(path))
                {
                    directories.Append(path + "> ");
                }
            }
            FormFileDetails.LabelValueDirectory.Text = directories.ToString();

            FormFileDetails.LabelValueExtension.Text = Path.GetExtension(File.URL).Replace(".", "").ToUpper();
            FormFileDetails.LabelValueAge.Text       = StringExtensions.TimeSpanAge(File.DateModified);
            FormFileDetails.InfoFileURL.Text         = Uri.UnescapeDataString(File.URL);

            if (!createNewInstance)
            {
                FormFileDetails.CheckFileEvents();
            }
            else
            {
                FormFileDetails.ShowDialog(this);
            }

            FormFileDetails.Text = File.Name + " - File Details";
            Program.Log.Info("Completed file details");
        }