mirror of
https://github.com/wagesj45/mdfinder.git
synced 2024-12-21 08:02:28 -06:00
Beginning Work
This is early stage development. Still getting the main components together and figureing out how the flow should work.
This commit is contained in:
parent
7e92f9ebef
commit
f5b2f9e0f6
19 changed files with 1317 additions and 29 deletions
|
@ -1,6 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<configSections>
|
||||
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="mdfinder.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="mssqllocaldb" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
|
||||
<userSettings>
|
||||
<mdfinder.Properties.Settings>
|
||||
<setting name="FilesFoundAlert" serializeAs="String">
|
||||
<value>25</value>
|
||||
</setting>
|
||||
</mdfinder.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
|
@ -4,6 +4,10 @@
|
|||
xmlns:local="clr-namespace:mdfinder"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Icons.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
|
59
mdfinder/BoolVisibilityConverter.cs
Normal file
59
mdfinder/BoolVisibilityConverter.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
/// <summary> A visibility converter. </summary>
|
||||
/// <remarks> This code is derived from code in the butterflow-ui project. https://github.com/wagesj45/butterflow-ui </remarks>
|
||||
[ValueConversion(typeof(bool), typeof(Visibility))]
|
||||
public class BoolVisibilityConverter : IValueConverter
|
||||
{
|
||||
/// <summary> Converts a value. </summary>
|
||||
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
|
||||
/// type. </exception>
|
||||
/// <param name="value"> The value produced by the binding source. </param>
|
||||
/// <param name="targetType"> The type of the binding target property. </param>
|
||||
/// <param name="parameter"> The converter parameter to use. </param>
|
||||
/// <param name="culture"> The culture to use in the converter. </param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns <see langword="null" />, the valid null value is
|
||||
/// used.
|
||||
/// </returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (targetType == typeof(Visibility))
|
||||
{
|
||||
return (bool)value ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
|
||||
throw new InvalidCastException(string.Format(Localization.Localization.BooleanInvalidCastExceptionFormat, targetType.Name));
|
||||
}
|
||||
|
||||
/// <summary> Converts a value. </summary>
|
||||
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
|
||||
/// type. </exception>
|
||||
/// <param name="value"> The value that is produced by the binding target. </param>
|
||||
/// <param name="targetType"> The type to convert to. </param>
|
||||
/// <param name="parameter"> The converter parameter to use. </param>
|
||||
/// <param name="culture"> The culture to use in the converter. </param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns <see langword="null" />, the valid null value is
|
||||
/// used.
|
||||
/// </returns>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (targetType == typeof(Visibility))
|
||||
{
|
||||
return ((Visibility)value == Visibility.Visible) ? true : false;
|
||||
}
|
||||
|
||||
throw new InvalidCastException(string.Format(Localization.Localization.BooleanInvalidCastExceptionFormat, targetType.Name));
|
||||
}
|
||||
}
|
||||
}
|
70
mdfinder/DBHelper.cs
Normal file
70
mdfinder/DBHelper.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using LiteDB;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
/// <summary> A database helper class. </summary>
|
||||
public class DBHelper
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> The default database file name. </summary>
|
||||
private const string DEFAULT_DB_FILE_NAME = "mdfinder.db";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets or sets the database. </summary>
|
||||
/// <value> The database. </value>
|
||||
private LiteDatabase Database { get; set; }
|
||||
|
||||
/// <summary> Gets the file records. </summary>
|
||||
/// <value> The file records. </value>
|
||||
public LiteCollection<FileRecord> FileRecords
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Database.GetCollection<FileRecord>("FileRecords");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary> Default constructor. </summary>
|
||||
public DBHelper()
|
||||
{
|
||||
this.Database = new LiteDatabase(DEFAULT_DB_FILE_NAME);
|
||||
}
|
||||
|
||||
/// <summary> Constructor. </summary>
|
||||
/// <param name="database"> The database. </param>
|
||||
public DBHelper(string database)
|
||||
{
|
||||
this.Database = new LiteDatabase(database);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary> Inserts a file record. </summary>
|
||||
/// <param name="path"> Full pathname of the file. </param>
|
||||
/// <param name="size"> The size. </param>
|
||||
/// <param name="hash"> The hash. </param>
|
||||
/// <param name="hashProvider"> The hash provider. </param>
|
||||
public void InsertFileRecord(string path, long size, string hash, string hashProvider)
|
||||
{
|
||||
this.FileRecords.Insert(new FileRecord() { Path = path, Size = size, Hash = hash, HashProvider = hashProvider });
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
31
mdfinder/Extensions.cs
Normal file
31
mdfinder/Extensions.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
/// <summary> Enumerates <paramref name="items"/> into bins of size <paramref name="binSize"/>. </summary>
|
||||
/// <typeparam name="T"> Generic type parameter. </typeparam>
|
||||
/// <param name="items"> The items to act on. </param>
|
||||
/// <param name="binSize"> Size of the bin. </param>
|
||||
/// <returns>
|
||||
/// An enumerator that allows foreach to be used to process bin in this collection.
|
||||
/// </returns>
|
||||
/// <remarks> Thanks to @juharr at Stack Overflow. https://stackoverflow.com/a/32970228/1210377 </remarks>
|
||||
public static IEnumerable<IEnumerable<T>> Bin<T>(this IEnumerable<T> items, int binSize)
|
||||
{
|
||||
if(binSize <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("binSize", Localization.Localization.BinSizeOutOfRangeExceptionMessage);
|
||||
}
|
||||
|
||||
return items.Select((x, i) => new { x, i })
|
||||
.GroupBy(a => a.i / binSize)
|
||||
.Select(grp => grp.Select(a => a.x));
|
||||
}
|
||||
}
|
||||
}
|
35
mdfinder/FileRecord.cs
Normal file
35
mdfinder/FileRecord.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
public class FileRecord
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets or sets the identifier. </summary>
|
||||
/// <value> The identifier. </value>
|
||||
public uint Id { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the full pathname of the file. </summary>
|
||||
/// <value> The full pathname of the file. </value>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the size. </summary>
|
||||
/// <value> The size. </value>
|
||||
public long Size { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the hash. </summary>
|
||||
/// <value> The hash. </value>
|
||||
public string Hash { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the hash provider. </summary>
|
||||
/// <value> The hash provider. </value>
|
||||
public string HashProvider { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
88
mdfinder/Icons.xaml
Normal file
88
mdfinder/Icons.xaml
Normal file
|
@ -0,0 +1,88 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:mdfinder">
|
||||
<ControlTemplate x:Key="OptionsIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M19 0h-14c-2.762 0-5 2.239-5 5v14c0 2.761 2.238 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-4 4h2v3h-2v-3zm-8 0h2v8h-2v-8zm4 13h-2v3h-2v-3h-2v-3h6v3zm8-5h-2v8h-2v-8h-2v-3h6v3z" FillRule="NonZero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="InfoIcon">
|
||||
<Viewbox>
|
||||
<Canvas Width="24" Height="24">
|
||||
<Ellipse Canvas.Left="1.4" Canvas.Top="1.4" Width="21.2" Height="21.2" Fill="#FF0F5777" StrokeThickness="4.02519703" StrokeMiterLimit="4" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Opacity="1"/>
|
||||
<Path Fill="#FFFFFFFF">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-.001 5.75c.69 0 1.251.56 1.251 1.25s-.561 1.25-1.251 1.25-1.249-.56-1.249-1.25.559-1.25 1.249-1.25zm2.001 12.25h-4v-1c.484-.179 1-.201 1-.735v-4.467c0-.534-.516-.618-1-.797v-1h3v6.265c0 .535.517.558 1 .735v.999z" FillRule="Nonzero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="LinkIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z" FillRule="NonZero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="QuestionIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm0 22c-5.514 0-10-4.486-10-10s4.486-10 10-10 10 4.486 10 10-4.486 10-10 10zm0-18.8c-4.853 0-8.8 3.947-8.8 8.8s3.947 8.8 8.8 8.8 8.8-3.947 8.8-8.8-3.947-8.8-8.8-8.8zm0 15.05c-.689 0-1.25-.56-1.25-1.25s.561-1.25 1.25-1.25c.691 0 1.25.56 1.25 1.25s-.559 1.25-1.25 1.25zm1.961-5.928c-.904.975-.947 1.514-.935 2.178h-2.005c-.007-1.475.02-2.125 1.432-3.468.572-.544 1.024-.975.962-1.821-.058-.805-.73-1.226-1.364-1.226-.709 0-1.538.527-1.538 2.013h-2.011c0-2.4 1.41-3.95 3.59-3.95 1.036 0 1.942.339 2.551.955.57.578.865 1.372.854 2.298-.018 1.383-.859 2.291-1.536 3.021z" FillRule="NonZero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="SaveIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M15.003 3h2.997v5h-2.997v-5zm8.997 1v20h-24v-24h20l4 4zm-19 5h14v-7h-14v7zm16 4h-18v9h18v-9z" FillRule="NonZero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="OpenIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M9 2h6v1h-6v-1zm6-1v-1h-6v1h6zm-5.146 21l-1.854 2h8l-1.854-2h-4.292zm10.146-14h-5v-4h-6v4h-5l8 8 8-8zm-2 11h-12v-6.172l-2-2v10.172h16v-10.172l-2 2v6.172z" FillRule="NonZero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="SaveAsIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M15.563 22.282l-3.563.718.72-3.562 2.843 2.844zm-2.137-3.552l2.845 2.845 7.729-7.73-2.845-2.845-7.729 7.73zm-3.062 2.27h-7.364v-7h12.327l6.673-6.688v-2.312l-4-4h-18v22h9.953l.411-2zm-5.364-18h12v7h-12v-7zm8.004 6h2.996v-5h-2.996v5z" FillRule="NonZero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="FolderIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M11 5c-1.629 0-2.305-1.058-4-3h-7v20h24v-17h-13z" FillRule="NonZero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="ScanIcon">
|
||||
<Viewbox>
|
||||
<Path Fill="#000000">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M19 2h-14l-5 14v6h24v-6l-5-14zm-10.844 5.323l1.296 1.352c-.761.988-.544 2.088.178 2.84 1.039 1.084 2.923 1.267 4.221.42 1.372-.895 1.486-2.547.45-3.627-.443-.463-1.099-.821-1.957-.969l-.202 1.487-2.464-2.572 3.091-2.025-.197 1.493c1.339.188 2.47.805 3.263 1.633 1.783 1.859 1.448 4.464-.731 5.886-2.151 1.402-5.31 1.095-7.037-.706-1.411-1.469-1.538-3.62.089-5.212zm13.844 12.677h-20v-3h20v3zm-3-1.5c0-.276.224-.5.5-.5s.5.224.5.5-.224.5-.5.5-.5-.224-.5-.5z" FillRule="NonZero"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Viewbox>
|
||||
</ControlTemplate>
|
||||
</ResourceDictionary>
|
58
mdfinder/InverseBoolConverter.cs
Normal file
58
mdfinder/InverseBoolConverter.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
/// <summary> An inverse boolean converter. </summary>
|
||||
/// <remarks> This code is derived from code in the butterflow-ui project. https://github.com/wagesj45/butterflow-ui </remarks>
|
||||
[ValueConversion(typeof(bool), typeof(bool))]
|
||||
public class InverseBoolConverter : IValueConverter
|
||||
{
|
||||
/// <summary> Converts a boolean to its inverse. </summary>
|
||||
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
|
||||
/// type. </exception>
|
||||
/// <param name="value"> The value produced by the binding source. </param>
|
||||
/// <param name="targetType"> The type of the binding target property. </param>
|
||||
/// <param name="parameter"> The converter parameter to use. </param>
|
||||
/// <param name="culture"> The culture to use in the converter. </param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns <see langword="null" />, the valid null value is
|
||||
/// used.
|
||||
/// </returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (targetType == typeof(bool))
|
||||
{
|
||||
return !(bool)value;
|
||||
}
|
||||
|
||||
throw new InvalidCastException(string.Format(Localization.Localization.BooleanInvalidCastExceptionFormat, targetType.Name));
|
||||
}
|
||||
|
||||
/// <summary> Converts an inverse boolean back to its original state. </summary>
|
||||
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
|
||||
/// type. </exception>
|
||||
/// <param name="value"> The value that is produced by the binding target. </param>
|
||||
/// <param name="targetType"> The type to convert to. </param>
|
||||
/// <param name="parameter"> The converter parameter to use. </param>
|
||||
/// <param name="culture"> The culture to use in the converter. </param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns <see langword="null" />, the valid null value is
|
||||
/// used.
|
||||
/// </returns>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (targetType == typeof(bool))
|
||||
{
|
||||
return !(bool)value;
|
||||
}
|
||||
|
||||
throw new InvalidCastException(string.Format(Localization.Localization.BooleanInvalidCastExceptionFormat, targetType.Name));
|
||||
}
|
||||
}
|
||||
}
|
59
mdfinder/InverseBoolVisibilityConverter.cs
Normal file
59
mdfinder/InverseBoolVisibilityConverter.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
/// <summary> An inverse bool visibility converter. </summary>
|
||||
/// <remarks> This code is derived from code in the butterflow-ui project. https://github.com/wagesj45/butterflow-ui </remarks>
|
||||
[ValueConversion(typeof(bool), typeof(Visibility))]
|
||||
public class InverseBoolVisibilityConverter : IValueConverter
|
||||
{
|
||||
/// <summary> Converts a value. </summary>
|
||||
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
|
||||
/// type. </exception>
|
||||
/// <param name="value"> The value produced by the binding source. </param>
|
||||
/// <param name="targetType"> The type of the binding target property. </param>
|
||||
/// <param name="parameter"> The converter parameter to use. </param>
|
||||
/// <param name="culture"> The culture to use in the converter. </param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns <see langword="null" />, the valid null value is
|
||||
/// used.
|
||||
/// </returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (targetType == typeof(Visibility))
|
||||
{
|
||||
return (bool)value ? Visibility.Hidden : Visibility.Visible;
|
||||
}
|
||||
|
||||
throw new InvalidCastException(string.Format(Localization.Localization.BooleanInvalidCastExceptionFormat, targetType.Name));
|
||||
}
|
||||
|
||||
/// <summary> Converts a value. </summary>
|
||||
/// <exception cref="InvalidCastException"> Thrown when an object cannot be cast to a required
|
||||
/// type. </exception>
|
||||
/// <param name="value"> The value that is produced by the binding target. </param>
|
||||
/// <param name="targetType"> The type to convert to. </param>
|
||||
/// <param name="parameter"> The converter parameter to use. </param>
|
||||
/// <param name="culture"> The culture to use in the converter. </param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns <see langword="null" />, the valid null value is
|
||||
/// used.
|
||||
/// </returns>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (targetType == typeof(Visibility))
|
||||
{
|
||||
return ((Visibility)value == Visibility.Visible) ? false : true;
|
||||
}
|
||||
|
||||
throw new InvalidCastException(string.Format(Localization.Localization.BooleanInvalidCastExceptionFormat, targetType.Name));
|
||||
}
|
||||
}
|
||||
}
|
216
mdfinder/Localization/Localization.Designer.cs
generated
Normal file
216
mdfinder/Localization/Localization.Designer.cs
generated
Normal file
|
@ -0,0 +1,216 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace mdfinder.Localization {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Localization {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Localization() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mdfinder.Localization.Localization", typeof(Localization).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Actions.
|
||||
/// </summary>
|
||||
public static string ActionBarLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("ActionBarLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Would you like to visit mdfinder to update to the latest version?.
|
||||
/// </summary>
|
||||
public static string BehindVersionQuestion {
|
||||
get {
|
||||
return ResourceManager.GetString("BehindVersionQuestion", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The current version is behind the github repository and should be updated..
|
||||
/// </summary>
|
||||
public static string BehindVersionStatusDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("BehindVersionStatusDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The bin size must be greater than or equal to 1 and less than [int max | todo: find out the actual value]..
|
||||
/// </summary>
|
||||
public static string BinSizeOutOfRangeExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("BinSizeOutOfRangeExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Cannot convert type to {0} from or to a boolean..
|
||||
/// </summary>
|
||||
public static string BooleanInvalidCastExceptionFormat {
|
||||
get {
|
||||
return ResourceManager.GetString("BooleanInvalidCastExceptionFormat", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The current version is up to date with the github repository..
|
||||
/// </summary>
|
||||
public static string CurrentVersionStatusDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("CurrentVersionStatusDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The current version is ahead of the github repository, or is a custom version of butterflow-ui that cannot be compared to the github repository..
|
||||
/// </summary>
|
||||
public static string CustomVersionStatusDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("CustomVersionStatusDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Edit.
|
||||
/// </summary>
|
||||
public static string EditMenu {
|
||||
get {
|
||||
return ResourceManager.GetString("EditMenu", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to File.
|
||||
/// </summary>
|
||||
public static string FileMenu {
|
||||
get {
|
||||
return ResourceManager.GetString("FileMenu", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Help.
|
||||
/// </summary>
|
||||
public static string HelpMenu {
|
||||
get {
|
||||
return ResourceManager.GetString("HelpMenu", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open File Database....
|
||||
/// </summary>
|
||||
public static string OpenMenuItem {
|
||||
get {
|
||||
return ResourceManager.GetString("OpenMenuItem", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save File Database....
|
||||
/// </summary>
|
||||
public static string SaveMenuItem {
|
||||
get {
|
||||
return ResourceManager.GetString("SaveMenuItem", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scan.
|
||||
/// </summary>
|
||||
public static string ScanLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("ScanLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Location to Scan.
|
||||
/// </summary>
|
||||
public static string ScanLocationLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("ScanLocationLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scan the selected path.
|
||||
/// </summary>
|
||||
public static string ScanTooltip {
|
||||
get {
|
||||
return ResourceManager.GetString("ScanTooltip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to mdfinder.
|
||||
/// </summary>
|
||||
public static string Title {
|
||||
get {
|
||||
return ResourceManager.GetString("Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Github failed to respond with the current version. This could be because of rate limits or a network failure..
|
||||
/// </summary>
|
||||
public static string UnknownVersionStatusDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("UnknownVersionStatusDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
171
mdfinder/Localization/Localization.resx
Normal file
171
mdfinder/Localization/Localization.resx
Normal file
|
@ -0,0 +1,171 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ActionBarLabel" xml:space="preserve">
|
||||
<value>Actions</value>
|
||||
</data>
|
||||
<data name="BehindVersionQuestion" xml:space="preserve">
|
||||
<value>Would you like to visit mdfinder to update to the latest version?</value>
|
||||
</data>
|
||||
<data name="BehindVersionStatusDescription" xml:space="preserve">
|
||||
<value>The current version is behind the github repository and should be updated.</value>
|
||||
</data>
|
||||
<data name="BinSizeOutOfRangeExceptionMessage" xml:space="preserve">
|
||||
<value>The bin size must be greater than or equal to 1 and less than [int max | todo: find out the actual value].</value>
|
||||
</data>
|
||||
<data name="BooleanInvalidCastExceptionFormat" xml:space="preserve">
|
||||
<value>Cannot convert type to {0} from or to a boolean.</value>
|
||||
</data>
|
||||
<data name="CurrentVersionStatusDescription" xml:space="preserve">
|
||||
<value>The current version is up to date with the github repository.</value>
|
||||
</data>
|
||||
<data name="CustomVersionStatusDescription" xml:space="preserve">
|
||||
<value>The current version is ahead of the github repository, or is a custom version of butterflow-ui that cannot be compared to the github repository.</value>
|
||||
</data>
|
||||
<data name="EditMenu" xml:space="preserve">
|
||||
<value>Edit</value>
|
||||
</data>
|
||||
<data name="FileMenu" xml:space="preserve">
|
||||
<value>File</value>
|
||||
</data>
|
||||
<data name="HelpMenu" xml:space="preserve">
|
||||
<value>Help</value>
|
||||
</data>
|
||||
<data name="OpenMenuItem" xml:space="preserve">
|
||||
<value>Open File Database...</value>
|
||||
</data>
|
||||
<data name="SaveMenuItem" xml:space="preserve">
|
||||
<value>Save File Database...</value>
|
||||
</data>
|
||||
<data name="ScanLabel" xml:space="preserve">
|
||||
<value>Scan</value>
|
||||
</data>
|
||||
<data name="ScanLocationLabel" xml:space="preserve">
|
||||
<value>Location to Scan</value>
|
||||
</data>
|
||||
<data name="ScanTooltip" xml:space="preserve">
|
||||
<value>Scan the selected path</value>
|
||||
</data>
|
||||
<data name="Title" xml:space="preserve">
|
||||
<value>mdfinder</value>
|
||||
</data>
|
||||
<data name="UnknownVersionStatusDescription" xml:space="preserve">
|
||||
<value>Github failed to respond with the current version. This could be because of rate limits or a network failure.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -3,10 +3,76 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:mdfinder"
|
||||
xmlns:mdfinder="clr-namespace:mdfinder"
|
||||
xmlns:loc="clr-namespace:mdfinder.Localization"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
Title="{x:Static loc:Localization.Title}" Height="450" Width="800">
|
||||
<Window.Resources>
|
||||
<mdfinder:InverseBoolConverter x:Key="InverseBoolConverter" />
|
||||
<mdfinder:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />
|
||||
<mdfinder:InverseBoolVisibilityConverter x:Key="InverseBoolVisibilityConverter" />
|
||||
</Window.Resources>
|
||||
<DockPanel>
|
||||
<Menu DockPanel.Dock="Top">
|
||||
<MenuItem Header="{x:Static loc:Localization.FileMenu}">
|
||||
<MenuItem Name="menuOpen" Header="{x:Static loc:Localization.OpenMenuItem}">
|
||||
<MenuItem.Icon>
|
||||
<ContentControl Template="{StaticResource OpenIcon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Name="menuSave" Header="{x:Static loc:Localization.SaveMenuItem}">
|
||||
<MenuItem.Icon>
|
||||
<ContentControl Template="{StaticResource SaveIcon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<Grid x:Name="MainWindowGrid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.5*" />
|
||||
<ColumnDefinition Width="0.5*"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Grid.ColumnSpan="3" Grid.Row="0" Header="{x:Static loc:Localization.ScanLocationLabel}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentControl Grid.Column="0" Template="{StaticResource FolderIcon}" Width="16" Margin="0,0,4,0" />
|
||||
<TextBox Name="txtScanLocation" Grid.Column="1" IsReadOnly="True" />
|
||||
<Button Grid.Column="2" MinWidth="25" Name="btnFilePicker">...</Button>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.ColumnSpan="3" Grid.Row="1" Header="{x:Static loc:Localization.ActionBarLabel}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="48" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Row="0" Name="btnProcess" ToolTip="{x:Static loc:Localization.ScanTooltip}" IsEnabled="{Binding Scanner.IsScanning, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mdfinder:MainWindow}}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource InverseBoolConverter}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentControl MaxWidth="16" HorizontalAlignment="Center" Template="{StaticResource ScanIcon}" />
|
||||
<Label Content="{x:Static loc:Localization.ScanLabel}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<DataGrid Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mdfinder:MainWindow}} }" />
|
||||
<StatusBar Grid.Row="3" Grid.ColumnSpan="4">
|
||||
<ProgressBar />
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
|
|
@ -20,9 +20,21 @@ namespace mdfinder
|
|||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public DBHelper Database { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary> Default constructor for the main window of the application. </summary>
|
||||
public MainWindow()
|
||||
{
|
||||
this.Database = new DBHelper();
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
145
mdfinder/OctokitWrapper.cs
Normal file
145
mdfinder/OctokitWrapper.cs
Normal file
|
@ -0,0 +1,145 @@
|
|||
using csmic;
|
||||
using Octokit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
/// <summary> An octokit wrapper. </summary>
|
||||
public static class OctokitWrapper
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> The RegEx string for matching . </summary>
|
||||
private const string REGEX_VERSION = @"(?<Major>\d+ ?)\.(?<Minor>\d+ ?)\.(?<Patch>\d+ ?)";
|
||||
|
||||
/// <summary> The version status of the current installation. </summary>
|
||||
private static VersionStatus versionStatus = VersionStatus.Unknown;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets the current version status of this installation. </summary>
|
||||
/// <value> The current version status of this installation. </value>
|
||||
public static VersionStatus CurrentVersionStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return versionStatus;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets information describing the current version status. </summary>
|
||||
/// <value> Information describing the current version status. </value>
|
||||
public static string CurrentVersionStatusDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (CurrentVersionStatus)
|
||||
{
|
||||
case VersionStatus.Current:
|
||||
return Localization.Localization.CurrentVersionStatusDescription;
|
||||
case VersionStatus.Behind:
|
||||
return Localization.Localization.BehindVersionStatusDescription;
|
||||
case VersionStatus.Custom:
|
||||
return Localization.Localization.CustomVersionStatusDescription;
|
||||
case VersionStatus.Unknown:
|
||||
default:
|
||||
return Localization.Localization.UnknownVersionStatusDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Static constructor. </summary>
|
||||
static OctokitWrapper()
|
||||
{
|
||||
versionStatus = GetVersionStatus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary> Gets version status from github. </summary>
|
||||
/// <returns> The current version status. </returns>
|
||||
private static VersionStatus GetVersionStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
var interpreter = new InputInterpreter();
|
||||
var client = new GitHubClient(new ProductHeaderValue("mdfinder"));
|
||||
var releases = client.Repository.Release.GetAll("wagesj45", "mdfinder").Result;
|
||||
|
||||
if (releases.Any())
|
||||
{
|
||||
var latest = releases.First();
|
||||
decimal latestMajor = 0, latestMinor = 0, latestPatch = 0, currentMajor = 0, currentMinor = 0, currentPatch = 0;
|
||||
|
||||
var regex = new Regex(REGEX_VERSION);
|
||||
foreach (Match match in regex.Matches(latest.TagName))
|
||||
{
|
||||
latestMajor = interpreter.ComputeExpression(match.Groups["Major"].Value);
|
||||
latestMinor = interpreter.ComputeExpression(match.Groups["Minor"].Value);
|
||||
latestPatch = interpreter.ComputeExpression(match.Groups["Patch"].Value);
|
||||
}
|
||||
|
||||
foreach (Match match in regex.Matches(Assembly.GetExecutingAssembly().GetName().Version.ToString()))
|
||||
{
|
||||
currentMajor = interpreter.ComputeExpression(match.Groups["Major"].Value);
|
||||
currentMinor = interpreter.ComputeExpression(match.Groups["Minor"].Value);
|
||||
currentPatch = interpreter.ComputeExpression(match.Groups["Patch"].Value);
|
||||
}
|
||||
|
||||
if (latestMajor == currentMajor && latestMinor == currentMinor && latestPatch == currentPatch)
|
||||
{
|
||||
return VersionStatus.Current;
|
||||
}
|
||||
|
||||
if (latestMajor >= currentMajor && latestMinor >= currentMinor && latestPatch >= currentPatch)
|
||||
{
|
||||
return VersionStatus.Behind;
|
||||
}
|
||||
|
||||
return VersionStatus.Custom;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//There was an issue connecting to Github. This could be caused by a missing network connection.
|
||||
//We can safely ignore an error in this process and proceed, falling through to the default connection
|
||||
//value of Unknown.
|
||||
}
|
||||
|
||||
return VersionStatus.Unknown;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Subclasses
|
||||
|
||||
/// <summary> Values that represent version status of the current installation of butterflow-ui. </summary>
|
||||
public enum VersionStatus
|
||||
{
|
||||
/// <summary> The current version is up to date with the github repository. </summary>
|
||||
Current,
|
||||
/// <summary> The current version is behind the github repository and should be updated. </summary>
|
||||
Behind,
|
||||
/// <summary> The current version is ahead of the github repository, or is a custom version of butterflow-ui that cannot be compared to the github repository. </summary>
|
||||
Custom,
|
||||
/// <summary> Github failed to respond with the current version. This could be because of rate limits or a network failure. </summary>
|
||||
Unknown
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
34
mdfinder/Properties/Settings.Designer.cs
generated
34
mdfinder/Properties/Settings.Designer.cs
generated
|
@ -8,23 +8,31 @@
|
|||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace mdfinder.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace mdfinder.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("25")]
|
||||
public int FilesFoundAlert {
|
||||
get {
|
||||
return ((int)(this["FilesFoundAlert"]));
|
||||
}
|
||||
set {
|
||||
this["FilesFoundAlert"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="mdfinder.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="FilesFoundAlert" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">25</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
186
mdfinder/Scanner.cs
Normal file
186
mdfinder/Scanner.cs
Normal file
|
@ -0,0 +1,186 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mdfinder
|
||||
{
|
||||
/// <summary> Scans directories, logging files and their attributes. </summary>
|
||||
public static class Scanner
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> Event queue for all listeners interested in FilesFound events. </summary>
|
||||
public static event EventHandler<FilesFoundEventArgs> FilesFound;
|
||||
|
||||
/// <summary> Event queue for all listeners interested in DirectoryFound events. </summary>
|
||||
public static event EventHandler<DirectoryFoundEventArgs> DirectoryFound;
|
||||
|
||||
/// <summary> Event queue for all listeners interested in ReportProgress events. </summary>
|
||||
public static event EventHandler<ProgressReportEventArgs> ReportProgress;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public static uint Processed { get; private set; }
|
||||
|
||||
public static uint Total { get; private set; }
|
||||
|
||||
public static bool IsScanning { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public static void Scan(string path)
|
||||
{
|
||||
Processed = 0;
|
||||
Total = 0;
|
||||
|
||||
var scanPath = new DirectoryInfo(path);
|
||||
if (scanPath.Exists)
|
||||
{
|
||||
Scan(scanPath);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Scan(DirectoryInfo directory)
|
||||
{
|
||||
var files = directory.GetFiles();
|
||||
var fileBatches = files.Bin(Properties.Settings.Default.FilesFoundAlert);
|
||||
var subdirectories = directory.GetDirectories();
|
||||
|
||||
Total += (uint)files.Count();
|
||||
|
||||
foreach (var subdirectory in subdirectories)
|
||||
{
|
||||
OnDirectoryFound(subdirectory);
|
||||
|
||||
Scan(subdirectory);
|
||||
}
|
||||
|
||||
foreach (var batch in fileBatches)
|
||||
{
|
||||
OnFilesFound(batch);
|
||||
|
||||
Processed += (uint)batch.Count();
|
||||
|
||||
OnReportProgress(Processed, Total);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Executes the files found action. </summary>
|
||||
/// <param name="files"> The files. </param>
|
||||
private static void OnFilesFound(IEnumerable<FileInfo> files)
|
||||
{
|
||||
FilesFound?.Invoke(null, new FilesFoundEventArgs(files));
|
||||
}
|
||||
|
||||
/// <summary> Executes the directory found action. </summary>
|
||||
/// <param name="directory"> Pathname of the directory. </param>
|
||||
private static void OnDirectoryFound(DirectoryInfo directory)
|
||||
{
|
||||
DirectoryFound?.Invoke(null, new DirectoryFoundEventArgs(directory));
|
||||
}
|
||||
|
||||
/// <summary> Executes the report progress action. </summary>
|
||||
/// <param name="processed"> The processed. </param>
|
||||
/// <param name="total"> Number of. </param>
|
||||
private static void OnReportProgress(uint processed, uint total)
|
||||
{
|
||||
ReportProgress?.Invoke(null, new ProgressReportEventArgs(processed, total));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Subclasses
|
||||
|
||||
/// <summary> Event arguments describing the state of the <see cref="Scanner"/> when it has found files. </summary>
|
||||
public class FilesFoundEventArgs : EventArgs
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets or sets the files. </summary>
|
||||
/// <value> The files. </value>
|
||||
public IEnumerable<FileInfo> Files { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary> Constructor. </summary>
|
||||
/// <param name="files"> The files. </param>
|
||||
public FilesFoundEventArgs(IEnumerable<FileInfo> files)
|
||||
{
|
||||
this.Files = files;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary> Event arguments describing the state of the <see cref="Scanner"/> when it has found a directory. </summary>
|
||||
public class DirectoryFoundEventArgs : EventArgs
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets or sets the pathname of the directory. </summary>
|
||||
/// <value> The pathname of the directory. </value>
|
||||
public DirectoryInfo Directory { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary> Constructor. </summary>
|
||||
/// <param name="directory"> The pathname of the directory. </param>
|
||||
public DirectoryFoundEventArgs(DirectoryInfo directory)
|
||||
{
|
||||
this.Directory = directory;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class ProgressReportEventArgs : EventArgs
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets or sets the progress as a percentage. </summary>
|
||||
/// <value> The percentage. </value>
|
||||
public double Percentage
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((double)this.Processed / (double)this.Total);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the number of processed items. </summary>
|
||||
/// <value> The processed. </value>
|
||||
public uint Processed { get; private set; }
|
||||
|
||||
/// <summary> Gets or sets the number of items discovered to process. </summary>
|
||||
/// <value> The total. </value>
|
||||
public uint Total { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary> Constructor. </summary>
|
||||
/// <param name="processed"> The processed item count. </param>
|
||||
/// <param name="total"> The total discovereditem count. </param>
|
||||
public ProgressReportEventArgs(uint processed, uint total)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -14,6 +14,8 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
@ -35,8 +37,23 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="csmic, Version=1.1.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\csmic.1.1.4\lib\net40\csmic.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="LiteDB, Version=4.1.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\LiteDB.4.1.4\lib\net40\LiteDB.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Octokit, Version=0.32.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Octokit.0.32.0\lib\net45\Octokit.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Standard.Licensing, Version=1.1.5.0, Culture=neutral, PublicKeyToken=9f81b18f6db6aea5, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Standard.Licensing.1.1.5\lib\net45\Standard.Licensing.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -55,6 +72,10 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Icons.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -63,12 +84,25 @@
|
|||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BoolVisibilityConverter.cs" />
|
||||
<Compile Include="DBHelper.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="FileRecord.cs" />
|
||||
<Compile Include="InverseBoolConverter.cs" />
|
||||
<Compile Include="InverseBoolVisibilityConverter.cs" />
|
||||
<Compile Include="Scanner.cs" />
|
||||
<Compile Include="Localization\Localization.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Localization.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="OctokitWrapper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
@ -82,10 +116,15 @@
|
|||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Localization\Localization.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Localization.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
@ -94,5 +133,11 @@
|
|||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Icon\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
7
mdfinder/packages.config
Normal file
7
mdfinder/packages.config
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="csmic" version="1.1.4" targetFramework="net461" />
|
||||
<package id="LiteDB" version="4.1.4" targetFramework="net461" />
|
||||
<package id="Octokit" version="0.32.0" targetFramework="net461" />
|
||||
<package id="Standard.Licensing" version="1.1.5" targetFramework="net461" />
|
||||
</packages>
|
Loading…
Reference in a new issue