mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-28 23:42:13 +12:00
Rename variables in HistoryItem class
This commit is contained in:
parent
2400d529c8
commit
6df8c70cb3
7 changed files with 43 additions and 43 deletions
|
@ -124,8 +124,8 @@ private void OutputStats(HistoryItem[] historyItems)
|
|||
rtbStats.SetFontRegular();
|
||||
|
||||
IEnumerable<string> fileExtensions = historyItems.
|
||||
Where(x => !string.IsNullOrEmpty(x.Filename) && !x.Filename.EndsWith(")")).
|
||||
Select(x => Helpers.GetFilenameExtension(x.Filename)).
|
||||
Where(x => !string.IsNullOrEmpty(x.FileName) && !x.FileName.EndsWith(")")).
|
||||
Select(x => Helpers.GetFilenameExtension(x.FileName)).
|
||||
GroupBy(x => x).
|
||||
OrderByDescending(x => x.Count()).
|
||||
Select(x => string.Format("{0} ({1})", x.Key, x.Count()));
|
||||
|
@ -211,7 +211,7 @@ private HistoryItem[] ApplyFilters(HistoryItem[] historyItems)
|
|||
{
|
||||
string pattern = Regex.Escape(filenameFilter).Replace("\\?", ".").Replace("\\*", ".*");
|
||||
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
result = result.Where(x => x.Filename != null && regex.IsMatch(x.Filename));
|
||||
result = result.Where(x => x.FileName != null && regex.IsMatch(x.FileName));
|
||||
}
|
||||
|
||||
string urlFilter = txtURLFilter.Text;
|
||||
|
@ -265,7 +265,7 @@ private void AddHistoryItems(HistoryItem[] historyItems)
|
|||
}
|
||||
|
||||
lvi.SubItems.Add(hi.DateTime.ToString()).Tag = hi.DateTime;
|
||||
lvi.SubItems.Add(hi.Filename);
|
||||
lvi.SubItems.Add(hi.FileName);
|
||||
lvi.SubItems.Add(hi.URL);
|
||||
lvi.Tag = hi;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ private void UpdatePictureBox()
|
|||
{
|
||||
if (him.IsImageFile)
|
||||
{
|
||||
pbThumbnail.LoadImageFromFileAsync(him.HistoryItem.Filepath);
|
||||
pbThumbnail.LoadImageFromFileAsync(him.HistoryItem.FilePath);
|
||||
}
|
||||
else if (him.IsImageURL)
|
||||
{
|
||||
|
@ -461,9 +461,9 @@ private void lvHistory_ItemDrag(object sender, ItemDragEventArgs e)
|
|||
foreach (ListViewItem item in lvHistory.SelectedItems)
|
||||
{
|
||||
HistoryItem hi = (HistoryItem)item.Tag;
|
||||
if (File.Exists(hi.Filepath))
|
||||
if (File.Exists(hi.FilePath))
|
||||
{
|
||||
selection.Add(hi.Filepath);
|
||||
selection.Add(hi.FilePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ private void RefreshHistoryItems()
|
|||
{
|
||||
UpdateSearchText();
|
||||
ilvImages.Items.Clear();
|
||||
ImageListViewItem[] ilvItems = GetHistoryItems().Select(hi => new ImageListViewItem(hi.Filepath) { Tag = hi }).ToArray();
|
||||
ImageListViewItem[] ilvItems = GetHistoryItems().Select(hi => new ImageListViewItem(hi.FilePath) { Tag = hi }).ToArray();
|
||||
ilvImages.Items.AddRange(ilvItems);
|
||||
}
|
||||
|
||||
|
@ -131,9 +131,9 @@ private IEnumerable<HistoryItem> GetHistoryItems()
|
|||
{
|
||||
HistoryItem hi = historyItems[i];
|
||||
|
||||
if (!string.IsNullOrEmpty(hi.Filepath) && Helpers.IsImageFile(hi.Filepath) &&
|
||||
(regex == null || regex.IsMatch(hi.Filename)) &&
|
||||
(!Settings.FilterMissingFiles || File.Exists(hi.Filepath)))
|
||||
if (!string.IsNullOrEmpty(hi.FilePath) && Helpers.IsImageFile(hi.FilePath) &&
|
||||
(regex == null || regex.IsMatch(hi.FileName)) &&
|
||||
(!Settings.FilterMissingFiles || File.Exists(hi.FilePath)))
|
||||
{
|
||||
filteredHistoryItems.Add(hi);
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace ShareX.HistoryLib
|
|||
{
|
||||
public class HistoryItem
|
||||
{
|
||||
public string Filename { get; set; }
|
||||
public string Filepath { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public DateTime DateTime { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Host { get; set; }
|
||||
|
|
|
@ -75,10 +75,10 @@ public bool RefreshInfo()
|
|||
IsDeletionURLExist = !string.IsNullOrEmpty(HistoryItem.DeletionURL);
|
||||
IsImageURL = IsURLExist && Helpers.IsImageFile(HistoryItem.URL);
|
||||
IsTextURL = IsURLExist && Helpers.IsTextFile(HistoryItem.URL);
|
||||
IsFilePathValid = !string.IsNullOrEmpty(HistoryItem.Filepath) && Path.HasExtension(HistoryItem.Filepath);
|
||||
IsFileExist = IsFilePathValid && File.Exists(HistoryItem.Filepath);
|
||||
IsImageFile = IsFileExist && Helpers.IsImageFile(HistoryItem.Filepath);
|
||||
IsTextFile = IsFileExist && Helpers.IsTextFile(HistoryItem.Filepath);
|
||||
IsFilePathValid = !string.IsNullOrEmpty(HistoryItem.FilePath) && Path.HasExtension(HistoryItem.FilePath);
|
||||
IsFileExist = IsFilePathValid && File.Exists(HistoryItem.FilePath);
|
||||
IsImageFile = IsFileExist && Helpers.IsImageFile(HistoryItem.FilePath);
|
||||
IsTextFile = IsFileExist && Helpers.IsTextFile(HistoryItem.FilePath);
|
||||
|
||||
UpdateButtons();
|
||||
return true;
|
||||
|
@ -135,12 +135,12 @@ public void OpenDeletionURL()
|
|||
|
||||
public void OpenFile()
|
||||
{
|
||||
if (HistoryItem != null && IsFileExist) Helpers.OpenFile(HistoryItem.Filepath);
|
||||
if (HistoryItem != null && IsFileExist) Helpers.OpenFile(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void OpenFolder()
|
||||
{
|
||||
if (HistoryItem != null && IsFileExist) Helpers.OpenFolderWithFile(HistoryItem.Filepath);
|
||||
if (HistoryItem != null && IsFileExist) Helpers.OpenFolderWithFile(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void TryOpen()
|
||||
|
@ -157,7 +157,7 @@ public void TryOpen()
|
|||
}
|
||||
else if (IsFileExist)
|
||||
{
|
||||
Helpers.OpenFile(HistoryItem.Filepath);
|
||||
Helpers.OpenFile(HistoryItem.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,17 +199,17 @@ public void CopyDeletionURL()
|
|||
|
||||
public void CopyFile()
|
||||
{
|
||||
if (HistoryItem != null && IsFileExist) ClipboardHelpers.CopyFile(HistoryItem.Filepath);
|
||||
if (HistoryItem != null && IsFileExist) ClipboardHelpers.CopyFile(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void CopyImage()
|
||||
{
|
||||
if (HistoryItem != null && IsImageFile) ClipboardHelpers.CopyImageFromFile(HistoryItem.Filepath);
|
||||
if (HistoryItem != null && IsImageFile) ClipboardHelpers.CopyImageFromFile(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void CopyText()
|
||||
{
|
||||
if (HistoryItem != null && IsTextFile) ClipboardHelpers.CopyTextFromFile(HistoryItem.Filepath);
|
||||
if (HistoryItem != null && IsTextFile) ClipboardHelpers.CopyTextFromFile(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void CopyHTMLLink()
|
||||
|
@ -265,42 +265,42 @@ public void CopyForumLinkedImage()
|
|||
|
||||
public void CopyMarkdownLink()
|
||||
{
|
||||
if (HistoryItem != null && IsURLExist) ClipboardHelpers.CopyText(string.Format("[{0}]({1})", HistoryItem.Filename, HistoryItem.URL));
|
||||
if (HistoryItem != null && IsURLExist) ClipboardHelpers.CopyText(string.Format("[{0}]({1})", HistoryItem.FileName, HistoryItem.URL));
|
||||
}
|
||||
|
||||
public void CopyMarkdownImage()
|
||||
{
|
||||
if (HistoryItem != null && IsImageURL) ClipboardHelpers.CopyText(string.Format("![{0}]({1})", HistoryItem.Filename, HistoryItem.URL));
|
||||
if (HistoryItem != null && IsImageURL) ClipboardHelpers.CopyText(string.Format("![{0}]({1})", HistoryItem.FileName, HistoryItem.URL));
|
||||
}
|
||||
|
||||
public void CopyMarkdownLinkedImage()
|
||||
{
|
||||
if (HistoryItem != null && IsImageURL) ClipboardHelpers.CopyText(string.Format("[![{0}]({1})]({2})", HistoryItem.Filename, HistoryItem.URL, HistoryItem.URL));
|
||||
if (HistoryItem != null && IsImageURL) ClipboardHelpers.CopyText(string.Format("[![{0}]({1})]({2})", HistoryItem.FileName, HistoryItem.URL, HistoryItem.URL));
|
||||
}
|
||||
|
||||
public void CopyFilePath()
|
||||
{
|
||||
if (HistoryItem != null && IsFilePathValid) ClipboardHelpers.CopyText(HistoryItem.Filepath);
|
||||
if (HistoryItem != null && IsFilePathValid) ClipboardHelpers.CopyText(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void CopyFileName()
|
||||
{
|
||||
if (HistoryItem != null && IsFilePathValid) ClipboardHelpers.CopyText(Path.GetFileNameWithoutExtension(HistoryItem.Filepath));
|
||||
if (HistoryItem != null && IsFilePathValid) ClipboardHelpers.CopyText(Path.GetFileNameWithoutExtension(HistoryItem.FilePath));
|
||||
}
|
||||
|
||||
public void CopyFileNameWithExtension()
|
||||
{
|
||||
if (HistoryItem != null && IsFilePathValid) ClipboardHelpers.CopyText(Path.GetFileName(HistoryItem.Filepath));
|
||||
if (HistoryItem != null && IsFilePathValid) ClipboardHelpers.CopyText(Path.GetFileName(HistoryItem.FilePath));
|
||||
}
|
||||
|
||||
public void CopyFolder()
|
||||
{
|
||||
if (HistoryItem != null && IsFilePathValid) ClipboardHelpers.CopyText(Path.GetDirectoryName(HistoryItem.Filepath));
|
||||
if (HistoryItem != null && IsFilePathValid) ClipboardHelpers.CopyText(Path.GetDirectoryName(HistoryItem.FilePath));
|
||||
}
|
||||
|
||||
public void ShowImagePreview()
|
||||
{
|
||||
if (HistoryItem != null && IsImageFile) ImageViewer.ShowImage(HistoryItem.Filepath);
|
||||
if (HistoryItem != null && IsImageFile) ImageViewer.ShowImage(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void ShowMoreInfo()
|
||||
|
@ -310,12 +310,12 @@ public void ShowMoreInfo()
|
|||
|
||||
public void UploadFile()
|
||||
{
|
||||
if (uploadFile != null && HistoryItem != null && IsFileExist) uploadFile(HistoryItem.Filepath);
|
||||
if (uploadFile != null && HistoryItem != null && IsFileExist) uploadFile(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void EditImage()
|
||||
{
|
||||
if (editImage != null && HistoryItem != null && IsImageFile) editImage(HistoryItem.Filepath);
|
||||
if (editImage != null && HistoryItem != null && IsImageFile) editImage(HistoryItem.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -80,8 +80,8 @@ public bool AppendHistoryItem(HistoryItem historyItem)
|
|||
|
||||
private bool IsValidHistoryItem(HistoryItem historyItem)
|
||||
{
|
||||
return historyItem != null && !string.IsNullOrEmpty(historyItem.Filename) && historyItem.DateTime != DateTime.MinValue &&
|
||||
(!string.IsNullOrEmpty(historyItem.URL) || !string.IsNullOrEmpty(historyItem.Filepath));
|
||||
return historyItem != null && !string.IsNullOrEmpty(historyItem.FileName) && historyItem.DateTime != DateTime.MinValue &&
|
||||
(!string.IsNullOrEmpty(historyItem.URL) || !string.IsNullOrEmpty(historyItem.FilePath));
|
||||
}
|
||||
|
||||
public List<HistoryItem> Load()
|
||||
|
@ -123,8 +123,8 @@ public void Test(string filePath, int itemCount)
|
|||
{
|
||||
HistoryItem historyItem = new HistoryItem()
|
||||
{
|
||||
Filename = "Example.png",
|
||||
Filepath = @"C:\ShareX\Screenshots\Example.png",
|
||||
FileName = "Example.png",
|
||||
FilePath = @"C:\ShareX\Screenshots\Example.png",
|
||||
DateTime = DateTime.Now,
|
||||
Type = "Image",
|
||||
Host = "Imgur",
|
||||
|
|
|
@ -95,10 +95,10 @@ private HistoryItem ParseHistoryItem(XElement element)
|
|||
switch (name)
|
||||
{
|
||||
case "Filename":
|
||||
hi.Filename = child.Value;
|
||||
hi.FileName = child.Value;
|
||||
break;
|
||||
case "Filepath":
|
||||
hi.Filepath = child.Value;
|
||||
hi.FilePath = child.Value;
|
||||
break;
|
||||
case "DateTimeUtc":
|
||||
DateTime dateTime;
|
||||
|
@ -148,8 +148,8 @@ public override bool Append(string filePath, params HistoryItem[] historyItems)
|
|||
foreach (HistoryItem historyItem in historyItems)
|
||||
{
|
||||
writer.WriteStartElement("HistoryItem");
|
||||
writer.WriteElementIfNotEmpty("Filename", historyItem.Filename);
|
||||
writer.WriteElementIfNotEmpty("Filepath", historyItem.Filepath);
|
||||
writer.WriteElementIfNotEmpty("Filename", historyItem.FileName);
|
||||
writer.WriteElementIfNotEmpty("Filepath", historyItem.FilePath);
|
||||
writer.WriteElementIfNotEmpty("DateTimeUtc", historyItem.DateTime.ToString("o"));
|
||||
writer.WriteElementIfNotEmpty("Type", historyItem.Type);
|
||||
writer.WriteElementIfNotEmpty("Host", historyItem.Host);
|
||||
|
|
|
@ -176,8 +176,8 @@ public HistoryItem GetHistoryItem()
|
|||
{
|
||||
return new HistoryItem
|
||||
{
|
||||
Filename = FileName,
|
||||
Filepath = FilePath,
|
||||
FileName = FileName,
|
||||
FilePath = FilePath,
|
||||
DateTime = TaskEndTime,
|
||||
Type = DataType.ToString(),
|
||||
Host = UploaderHost,
|
||||
|
|
Loading…
Reference in a new issue