Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Dec 26, 2020
1 parent 98435f6 commit eebd302
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 12 deletions.
24 changes: 24 additions & 0 deletions License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

MIT License

Copyright (C) 2017-2020 Frank Skare (stax76)

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and ssociated documentation
files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ Voidtools Everything frontend with dark mode.
### Requirements

- [Voidtools Everything installation](https://www.voidtools.com/downloads)
- [.NET 5 Desktop Runtime](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-5.0.0-windows-x64-installer)
- [.NET 5 Desktop Runtime installation](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-5.0.0-windows-x64-installer)

### Usage

ESC key closes the app.

Up key restores the search text from the last session.

Double-click shows the file in File Explorer.

Right-click opens the files native shell context menu.

F1 key shows the about dialog.

### Theme

Expand Down
1 change: 1 addition & 0 deletions src/Everything.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<Description>Everything frontend with dark UI.</Description>
<AssemblyName>EverythingNET</AssemblyName>
<RootNamespace>EverythingNET</RootNamespace>
<Version>1.1.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions src/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

MIT License

Copyright (C) 2017-2020 Frank Skare (stax76)

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and ssociated documentation
files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64 changes: 64 additions & 0 deletions src/RegistryHelp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

using System;
using Microsoft.Win32;
using System.Windows.Forms;

public class RegistryHelp
{
public static string ApplicationKey { get; } = @"HKCU\Software\" + Application.ProductName;

public static void SetValue(string path, string name, object value)
{
using (RegistryKey regKey = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
regKey.SetValue(name, value);
}

public static string GetString(string path, string name, string defaultValue = "")
{
object value = GetValue(path, name, defaultValue);
return !(value is string) ? defaultValue : value.ToString();
}

public static int GetInt(string path, string name, int defaultValue = 0)
{
object value = GetValue(path, name, defaultValue);
return !(value is int) ? defaultValue : (int)value;
}

public static object GetValue(string path, string name, object defaultValue = null)
{
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5)))
return regKey == null ? null : regKey.GetValue(name, defaultValue);
}

public static void RemoveKey(string path)
{
try
{
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
}
catch { }
}

public static void RemoveValue(string path, string name)
{
try
{
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5), true))
if (regKey != null)
regKey.DeleteValue(name, false);
}
catch { }
}

static RegistryKey GetRootKey(string path)
{
switch (path.Substring(0, 4))
{
case "HKLM": return Registry.LocalMachine;
case "HKCU": return Registry.CurrentUser;
case "HKCR": return Registry.ClassesRoot;
default: throw new Exception();
}
}
}
11 changes: 7 additions & 4 deletions src/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
Title="Everything.NET"
Height="450"
Width="800"
WindowStartupLocation="CenterScreen">
WindowStartupLocation="CenterScreen"
Activated="Window_Activated"
SizeChanged="Window_SizeChanged">

<Window.Resources>
<local:SizeConverter x:Key="SizeConverter" />
Expand All @@ -29,7 +31,8 @@
Margin="20"
Padding="2"
FontSize="14"
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" >
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
PreviewKeyDown="SearchTextBox_PreviewKeyDown" >
</TextBox>

<DataGrid AutoGenerateColumns="False"
Expand All @@ -42,8 +45,8 @@
MouseRightButtonUp="DataGrid_MouseRightButtonUp">

<DataGrid.Columns>
<DataGridTextColumn Header="Name" Width="250" Binding="{Binding Name}" />
<DataGridTextColumn Header="Directory" Width="300" Binding="{Binding Directory}" />
<DataGridTextColumn x:Name="NameColumn" Header="Name" Width="250" Binding="{Binding Name}" />
<DataGridTextColumn x:Name="DirectoryColumn" Header="Directory" Width="300" Binding="{Binding Directory}" />
<DataGridTextColumn Header="Size" Binding="{Binding Size, Converter={StaticResource SizeConverter}}" />
<DataGridTextColumn Header="Modified Date" Binding="{Binding Date, StringFormat=\{0:g\}, ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}" />
</DataGrid.Columns>
Expand Down
80 changes: 76 additions & 4 deletions src/View.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@

using Shell;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;

using Shell;

namespace EverythingNET
{
public partial class View : Window
{
ViewModel ViewModel;

public View()
{
InitializeComponent();
DataContext = new ViewModel();
ViewModel = new ViewModel();
DataContext = ViewModel;
}

void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
Expand All @@ -42,7 +50,7 @@ void DataGrid_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
row.IsSelected = true;
}

private void DataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
void DataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
DataGrid grid = sender as DataGrid;

Expand All @@ -55,12 +63,76 @@ private void DataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
ShellContextMenu menu = new ShellContextMenu();
FileInfo[] files = { new FileInfo(file) };
IntPtr handle = new System.Windows.Interop.WindowInteropHelper(this).Handle;
IntPtr handle = new WindowInteropHelper(this).Handle;
Point screenPos = PointToScreen(Mouse.GetPosition(this));
System.Drawing.Point screenPos2 = new System.Drawing.Point((int)screenPos.X, (int)screenPos.Y);
menu.ShowContextMenu(handle, files, screenPos2);
Task.Run(() => {
Thread.Sleep(2000);
ViewModel.Update();
});
}
}
}

protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);

if (e.Key == Key.Escape)
Close();

if (e.Key == Key.F1)
{
using (var proc = Process.GetCurrentProcess())
{
string txt = "Everything.NET\n\nCopyright (C) 2020 Frank Skare (stax76)\n\nVersion " +
FileVersionInfo.GetVersionInfo(proc.MainModule.FileName).FileVersion.ToString() +
"\n\n" + "MIT License";

MessageBox.Show(txt);
}
}
}

protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);

if (!string.IsNullOrEmpty(ViewModel.SearchText))
RegistryHelp.SetValue(RegistryHelp.ApplicationKey, "LastText", ViewModel.SearchText);
}

protected override void OnStateChanged(EventArgs e)
{
base.OnStateChanged(e);

}

void SearchTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Up)
{
string last = RegistryHelp.GetString(RegistryHelp.ApplicationKey, "LastText");

if (!string.IsNullOrEmpty(last))
{
SearchTextBox.Text = last;
SearchTextBox.CaretIndex = 1000;
}
}
}

void Window_Activated(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(ViewModel.SearchText))
ViewModel.Update();
}

void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
NameColumn.Width = ActualWidth * 0.25;
DirectoryColumn.Width = ActualWidth * 0.5;
}
}
}
9 changes: 6 additions & 3 deletions src/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ public string SearchText {
}
}

void TypeAssistant_Idled(string text) => Update(text);
void TypeAssistant_Idled(string text)
{
Update();
}

void Update(string text)
public void Update()
{
List<Item> items = Model.GetItems(text);
List<Item> items = Model.GetItems(SearchText);
Application.Current.Dispatcher.Invoke(() => Items = items);
}
}
Expand Down

0 comments on commit eebd302

Please sign in to comment.