Skip to content

Commit

Permalink
Merge pull request #56 from FaithfulDev/develop
Browse files Browse the repository at this point in the history
Release v1.2.0
  • Loading branch information
FaithfulDev authored Feb 20, 2024
2 parents fa686ba + 932eb54 commit eb8bd9a
Show file tree
Hide file tree
Showing 21 changed files with 697 additions and 357 deletions.
4 changes: 2 additions & 2 deletions CVS History Viewer.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CVS History Viewer", "CVS History Viewer\CVS History Viewer.csproj", "{8F95ECA1-9EB2-4D79-B596-5EEBE5F1A1A2}"
EndProject
Expand Down
11 changes: 11 additions & 0 deletions CVS History Viewer/CVS History Viewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<Compile Include="Resources\Classes\CVSCalls.cs" />
<Compile Include="Resources\Classes\CVSFile.cs" />
<Compile Include="Resources\Classes\Database.cs" />
<Compile Include="Resources\Classes\DatabaseMigration.cs" />
<Compile Include="Resources\Classes\DiffBlock.cs" />
<Compile Include="Resources\Classes\GlobalFunctions.cs" />
<Compile Include="Resources\Classes\JSONParser.cs" />
Expand All @@ -92,6 +93,9 @@
<Compile Include="Resources\Windows\CrashReport.xaml.cs">
<DependentUpon>CrashReport.xaml</DependentUpon>
</Compile>
<Compile Include="Resources\Windows\SettingsUI.xaml.cs">
<DependentUpon>SettingsUI.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -112,6 +116,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resources\Windows\SettingsUI.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand All @@ -131,6 +139,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="..\.editorconfig">
<Link>.editorconfig</Link>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
10 changes: 10 additions & 0 deletions CVS History Viewer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
xmlns:local="clr-namespace:CVS_History_Viewer"
mc:Ignorable="d"
Title="CVS History Viewer" Name="MWindow" Height="800" Width="1280" Loaded="Window_Loaded" ContentRendered="Window_ContentRendered" Style="{StaticResource CustomChrome}" WindowStartupLocation="CenterScreen" Icon="Resources/Images/icon.ico">

<Window.Resources>
<ContextMenu x:Key="RevisionContextMenu" x:Shared ="false">
<MenuItem Header="Open current Revision" Click="MenuItem_OpenCurrentRevisionClick"/>
<MenuItem Header="Open selected Revision" Click="MenuItem_OpenSelectedRevisionClick"/>
<MenuItem Header="Show in Explorer" Click="MenuItem_ShowInExplorerClick"/>
</ContextMenu>
</Window.Resources>

<Grid SnapsToDevicePixels="True">

<Grid.RowDefinitions>
Expand All @@ -21,6 +30,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Name="uiShowAbout" Content="?" FontWeight="Bold" Click="ShowAbout_Click" Height="20" Width="20" WindowChrome.IsHitTestVisibleInChrome="True" Style="{StaticResource Button}"/>
<Button Name="uiMinimize" Content="&#xf2d1;" FontFamily="{StaticResource FontAwesomeRegular}" Click="Minimize_Click" WindowChrome.IsHitTestVisibleInChrome="True" Height="20" Width="20" Style="{StaticResource Button}"/>
<Button Name="uiOpenSettings" Content="&#xf013;" FontFamily="{StaticResource FontAwesomeSolid}" Click="uiOpenSettings_Click" WindowChrome.IsHitTestVisibleInChrome="True" Height="20" Width="20" Style="{StaticResource Button}"/>
<Button Name="uiMaximize" Content="&#xf2d0;" FontFamily="{StaticResource FontAwesomeRegular}" Click="Maximize_Click" WindowChrome.IsHitTestVisibleInChrome="True" Height="20" Width="20">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource Button}">
Expand Down
106 changes: 71 additions & 35 deletions CVS History Viewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.WindowsAPICodePack.Dialogs;
using System.Windows.Media;
using System.Windows.Threading;
using System.Text;

namespace CVS_History_Viewer
{
Expand All @@ -19,25 +20,26 @@ namespace CVS_History_Viewer
/// </summary>
public partial class MainWindow : Window
{
private string sAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\CVS History Viewer";
private string sSyntaxPath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\Resources\\Syntax";
private readonly string sAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\CVS History Viewer";
private readonly string sSyntaxPath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\Resources\\Syntax";

private Database oDatabase;
private Settings oSettings;
private BackgroundStuff oBackgroundStuff;
private SyntaxHighlighting oSyntaxHighlighting;
private readonly Database oDatabase;
private readonly Settings oSettings;
private readonly BackgroundStuff oBackgroundStuff;
private readonly SyntaxHighlighting oSyntaxHighlighting;

private BackgroundWorker oUpdateCommitsWorker;
private readonly BackgroundWorker oUpdateCommitsWorker;

private readonly Dictionary<string, int> PreviousRevisionSelection = new Dictionary<string, int>();

private readonly DispatcherTimer oDiffFetchDelay = new DispatcherTimer();

private List<CVSFile> cFiles = new List<CVSFile>();
private List<Tag> cTags = new List<Tag>();
private List<CommitTag> cCommitTags = new List<CommitTag>();
private List<Commit> cCommits = new List<Commit>();
private List<Commit> cDummy = new List<Commit>();

private Dictionary<string, int> PreviousRevisionSelection = new Dictionary<string, int>();

private DispatcherTimer oDiffFetchDelay = new DispatcherTimer();
private readonly char sPathSeparator = Path.DirectorySeparatorChar;

private bool bIssueOnLoad = true;

Expand Down Expand Up @@ -69,7 +71,7 @@ public MainWindow()

private void Close_Click(object sender, RoutedEventArgs e)
{
this.Close();
Application.Current.Shutdown();
}

private void Minimize_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -177,7 +179,7 @@ private void UpdateCommits_BackgroundWorker_DoWork(object sender, DoWorkEventArg
bool bFound = false;
for(int i = cTempFileList.Count - 1; i >= 0; i--)
{
if (cTempFileList[i].sName == oFileInfo.Name && cTempFileList[i].sPath == oFileInfo.DirectoryName)
if (cTempFileList[i].sName.ToLower() == oFileInfo.Name.ToLower() && cTempFileList[i].sPath.ToLower() == oFileInfo.DirectoryName.ToLower())
{
bFound = true;

Expand Down Expand Up @@ -212,19 +214,16 @@ private void UpdateCommits_BackgroundWorker_DoWork(object sender, DoWorkEventArg
//Look for newly deleted files (files known to the DB, not already marked as deleted, but not findable in the directory)
foreach (CVSFile oFile in cTempFileList)
{
if (!oFile.bDeleted)
if (IsNewlyDeletedFile(oFile))
{
if (!File.Exists(oFile.sPath + "\\" + oFile.sName))
{
//For future checks the file will be marked as deleted...
oFile.bDeleted = true;
//...but it does get one last check.
cOutDatedFiles.Add(oFile);
oProgress.iTotal = cOutDatedFiles.Count;
oUpdateCommitsWorker.ReportProgress(0, oProgress);
}
//For future checks the file will be marked as deleted...
oFile.bDeleted = true;
//...but it does get one last check.
cOutDatedFiles.Add(oFile);
oProgress.iTotal = cOutDatedFiles.Count;
oUpdateCommitsWorker.ReportProgress(0, oProgress);
}
}
}

oProgress.iTotal = cOutDatedFiles.Count;

Expand All @@ -242,6 +241,11 @@ private void UpdateCommits_BackgroundWorker_DoWork(object sender, DoWorkEventArg
}
}

private bool IsNewlyDeletedFile(CVSFile oFile)
{
return !oFile.bDeleted && !File.Exists(oFile.sPath + sPathSeparator + oFile.sName);
}

private void UpdateCommits_BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
UpdateProgress oProgress = (UpdateProgress)e.UserState;
Expand Down Expand Up @@ -380,24 +384,25 @@ private void Search(string sText, bool bFolowUpSearch = false)
cPairs.Add(new KeyValuePair<string, object>("description", "%" + sText.Trim(' ') + "%"));
}

string sWhere = "";
string sWhere;
string sLimit = "";
StringBuilder oWhereBuilder = new StringBuilder();

foreach (KeyValuePair<string, object> oPair in cPairs)
{
switch (oPair.Key)
{
case "date":
sWhere += $" AND strftime('%Y-%m-%d', date) = '{((DateTime)oPair.Value).ToString("yyyy-MM-dd")}'";
oWhereBuilder.Append($" AND strftime('%Y-%m-%d', date) = '{(DateTime)oPair.Value:yyyy-MM-dd}'");
break;
case "from":
sWhere += $" AND strftime('%Y-%m-%d', date) >= '{((DateTime)oPair.Value).ToString("yyyy-MM-dd")}'";
oWhereBuilder.Append($" AND strftime('%Y-%m-%d', date) >= '{(DateTime)oPair.Value:yyyy-MM-dd}'");
break;
case "to":
sWhere += $" AND strftime('%Y-%m-%d', date) <= '{((DateTime)oPair.Value).ToString("yyyy-MM-dd")}'";
oWhereBuilder.Append($" AND strftime('%Y-%m-%d', date) <= '{(DateTime)oPair.Value:yyyy-MM-dd}'");
break;
case "description":
sWhere += $" AND {oPair.Key} LIKE '{oPair.Value.ToString().Replace("'", @"''")}'";
oWhereBuilder.Append($" AND {oPair.Key} LIKE '{oPair.Value.ToString().Replace("'", @"''")}'");
break;
case "limit":
sLimit = " LIMIT " + oPair.Value;
Expand Down Expand Up @@ -436,9 +441,10 @@ private void Search(string sText, bool bFolowUpSearch = false)
{
if (oSubWhere.Value != "")
{
sWhere += " AND (" + oSubWhere.Value + ")";
oWhereBuilder.Append(" AND (" + oSubWhere.Value + ")");
}
}
sWhere = oWhereBuilder.ToString();

if (sLimit != "")
{
Expand Down Expand Up @@ -486,7 +492,7 @@ private void Commits_SelectionChanged(object sender, SelectionChangedEventArgs e

this.uiCommitHASH.Text = oCommit.sHASH + $" [{oCommit.sShortHASH}]";
this.uiCommitAuthor.Text = oCommit.sAuthor;
this.uiCommitDate.Text = oCommit.dDate.ToLongDateString() + " " + oCommit.dDate.ToLongTimeString();
this.uiCommitDate.Text = oCommit.dLocalDate.ToLongDateString() + " " + oCommit.dLocalDate.ToLongTimeString();
this.uiCommitDescription.Text = oCommit.sDescription;

this.uiCommitRevisions.Items.Clear();
Expand All @@ -511,7 +517,9 @@ private void Commits_SelectionChanged(object sender, SelectionChangedEventArgs e
oItem.Content = $" {oRevision.oFile.sName } {oRevision.sRevision}";
oItem.Tag = oRevision;
oItem.ToolTip = oRevision.oFile.sPath + "\\" + oRevision.oFile.sName;

oItem.ContextMenu = (ContextMenu)FindResource("RevisionContextMenu");
oItem.ContextMenu.Tag = oRevision;

this.uiCommitRevisions.Items.Add(oItem);
}

Expand All @@ -537,9 +545,9 @@ private void CommitRevisions_MouseDoubleClick(object sender, MouseButtonEventArg
if (this.uiCommitRevisions.SelectedItem != null && e.OriginalSource.GetType() == typeof(TextBlock))
{
CVSFile oFile = ((Revision)((ListBoxItem)this.uiCommitRevisions.SelectedItem).Tag).oFile;
if(System.IO.File.Exists(oFile.sPath + "\\" + oFile.sName))
if(System.IO.File.Exists(oFile.sPath + sPathSeparator + oFile.sName))
{
System.Diagnostics.Process.Start(oFile.sPath + "\\" + oFile.sName);
System.Diagnostics.Process.Start(oFile.sPath + sPathSeparator + oFile.sName);
}
}
}
Expand Down Expand Up @@ -612,7 +620,6 @@ private void CommitRevisions_SelectionChanged(object sender, SelectionChangedEve
return;
}

Revision oRevision = (Revision)((ListBoxItem)this.uiCommitRevisions.SelectedItem).Tag;
Commit oCommit = (Commit)this.uiCommits.SelectedItem;

if (this.PreviousRevisionSelection.ContainsKey(oCommit.sHASH))
Expand Down Expand Up @@ -742,6 +749,35 @@ private void LoadDiffView(Revision oRevision)

this.uiDiffLoading.Visibility = Visibility.Collapsed;
}

private void MenuItem_ShowInExplorerClick(object sender, RoutedEventArgs e)
{
CVSFile oFile = ((Revision)((ContextMenu)((MenuItem)sender).Parent).Tag).oFile;
if (System.IO.File.Exists(oFile.sPath + sPathSeparator + oFile.sName))
{
System.Diagnostics.Process.Start("explorer.exe", $"/select, \"{oFile.sPath}\\{oFile.sName}\"");
}
}

private void MenuItem_OpenCurrentRevisionClick(object sender, RoutedEventArgs e)
{
CVSFile oFile = ((Revision)((ContextMenu)((MenuItem)sender).Parent).Tag).oFile;
if (System.IO.File.Exists(oFile.sPath + sPathSeparator + oFile.sName))
{
System.Diagnostics.Process.Start(oFile.sPath + sPathSeparator + oFile.sName);
}
}

private void MenuItem_OpenSelectedRevisionClick(object sender, RoutedEventArgs e)
{
string newFile = CVSCalls.OutputRevisionToFile((Revision)((ContextMenu)((MenuItem)sender).Parent).Tag);
System.Diagnostics.Process.Start(newFile);
}

private void uiOpenSettings_Click(object sender, RoutedEventArgs e)
{
new SettingsUI(oSettings).ShowDialog();
}
}

class UpdateProgress
Expand Down
2 changes: 1 addition & 1 deletion CVS History Viewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
7 changes: 2 additions & 5 deletions CVS History Viewer/Resources/Classes/BackgroundStuff.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CVS_History_Viewer.Resources.Classes
{
class BackgroundStuff
{
private Database oDatabase;
private List<BackgroundWorker> cDiffWorkers = new List<BackgroundWorker>();
private readonly Database oDatabase;
private readonly List<BackgroundWorker> cDiffWorkers = new List<BackgroundWorker>();

public delegate void DiffCompleted(object sender, DiffCompletedEventArgs e);
public event DiffCompleted OnDiffCompleted;
Expand Down
Loading

0 comments on commit eb8bd9a

Please sign in to comment.