Skip to content

Commit

Permalink
v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Apr 30, 2021
1 parent 661017f commit c78b74e
Show file tree
Hide file tree
Showing 19 changed files with 443 additions and 411 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

### 1.3 Beta

- Path is included in search
- Context menu uses dark theme
- Selected item is remembered
- Only files are found and displayed
- Context menu that shows the most recent searches
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@ https://github.com/stax76/Everything.NET/releases

### Usage

ESC key closes the app.

Up key restores the search text from the last session.
ESC key clears the search box, if empty the app exits.

Double-click shows the file in File Explorer.

Right-click opens the files native shell context menu.
Right-click and menu key opens the files native shell context menu.

F1 key shows the about dialog.
Right-click in the search box shows a context menu with the most recent searches.

Up/Down key navigates the main list.
F1 key shows the usage section of the readme page.

Shift+F10 or Menu key show the context menu.
Up/Down key navigates the main list.


### Syntax
Expand Down
21 changes: 21 additions & 0 deletions src/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@

using System.Windows;
using System.Windows.Threading;

namespace EverythingNET
{
public partial class App : Application
{
public App()
{
DispatcherUnhandledException += App_DispatcherUnhandledException;
}

void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.Exception.ToString());
}

static AppSettings _Settings;

public static AppSettings Settings {
get {
if (_Settings == null)
_Settings = SettingsManager.Load();

return _Settings;
}
}
}
}
20 changes: 20 additions & 0 deletions src/BindingProxy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

using System.Windows;

namespace EverythingNET
{
public class BindingProxy : Freezable
{
protected override Freezable CreateInstanceCore() => new BindingProxy();

public object Data {
get { return GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}

// Using a DependencyProperty as the backing store for Data.
// This enables animation, styling, binding, etc...
public static readonly DependencyProperty DataProperty =
DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
}
}
36 changes: 0 additions & 36 deletions src/DarkMode.cs

This file was deleted.

3 changes: 2 additions & 1 deletion src/Everything.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
<Description>Everything frontend with dark UI.</Description>
<AssemblyName>EverythingNET</AssemblyName>
<RootNamespace>EverythingNET</RootNamespace>
<Version>1.2.0</Version>
<Version>1.3.0</Version>
</PropertyGroup>

<ItemGroup>
<None Include="..\Changelog.md" Link="Changelog.md" />
<None Include="..\README.md" Link="README.md" />
</ItemGroup>

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

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;

using static EverythingNET.EverythingNative;

namespace EverythingNET
{
class Everything
{
public static List<EverythingItem> GetItems(string searchText)
{
List<EverythingItem> items = new List<EverythingItem>();

if (searchText.Length < 2)
return items;

Everything_SetSearch(searchText);

Everything_SetRequestFlags(
EVERYTHING_REQUEST_FILE_NAME |
EVERYTHING_REQUEST_PATH |
EVERYTHING_REQUEST_DATE_MODIFIED |
EVERYTHING_REQUEST_SIZE);

Everything_SetMatchPath(true);

if (!Everything_Query(true))
{
string[] errorCodes = {
"EVERYTHING_OK",
"EVERYTHING_ERROR_MEMORY",
"EVERYTHING_ERROR_IPC",
"EVERYTHING_ERROR_REGISTERCLASSEX",
"EVERYTHING_ERROR_CREATEWINDOW",
"EVERYTHING_ERROR_CREATETHREAD",
"EVERYTHING_ERROR_INVALIDINDEX",
"EVERYTHING_ERROR_INVALIDCALL"
};

uint lastError = Everything_GetLastError();

if (lastError > 0 && lastError < errorCodes.Length)
throw new Exception(errorCodes[lastError]);
else
throw new Exception("Unknown Error");
}

uint count = Everything_GetNumResults();

for (uint i = 0; i < count; i++)
{
Everything_GetResultSize(i, out var size);

if (size > -1)
items.Add(new EverythingItem() { Index = i, Size = size });
}

return items;
}

public static void InitItem(EverythingItem item)
{
StringBuilder sb = new StringBuilder(500);
Everything_GetResultFullPathName(item.Index, sb, (uint)sb.Capacity);
string path = sb.ToString();
Everything_GetResultDateModified(item.Index, out var fileTime);
item.Directory = Path.GetDirectoryName(path);
item.Name = Path.GetFileName(path);

if (fileTime != -1)
item.Date = DateTime.FromFileTime(fileTime);

item.WasInitialized = true;
}
}

class EverythingItem
{
public uint Index { get; set; }
public long Size { get; set; }
public bool WasInitialized { get; set; }

string _Name;

public string Name {
get {
if (!WasInitialized)
Everything.InitItem(this);
return _Name;
}
set => _Name = value;
}

string _Directory;

public string Directory {
get {
if (!WasInitialized)
Everything.InitItem(this);
return _Directory;
}
set => _Directory = value;
}

DateTime _Date;

public DateTime Date {
get {
if (!WasInitialized)
Everything.InitItem(this);
return _Date;
}
set => _Date = value;
}
}

class EverythingNative
{
public const int EVERYTHING_REQUEST_FILE_NAME = 0x00000001;
public const int EVERYTHING_REQUEST_PATH = 0x00000002;
public const int EVERYTHING_REQUEST_SIZE = 0x00000010;
public const int EVERYTHING_REQUEST_DATE_MODIFIED = 0x00000040;

[DllImport("Everything.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_SetSearch(string lpSearchString);

[DllImport("Everything.dll")]
public static extern void Everything_SetRequestFlags(uint dwRequestFlags);

[DllImport("Everything.dll")]
public static extern void Everything_SetSort(uint dwSortType);

[DllImport("Everything.dll")]
public static extern bool Everything_Query(bool bWait);

[DllImport("Everything.dll", CharSet = CharSet.Unicode)]
public static extern void Everything_GetResultFullPathName(uint nIndex, StringBuilder lpString, uint nMaxCount);

[DllImport("Everything.dll")]
public static extern bool Everything_GetResultDateModified(uint nIndex, out long lpFileTime);

[DllImport("Everything.dll")]
public static extern bool Everything_GetResultSize(uint nIndex, out long lpFileSize);

[DllImport("Everything.dll")]
public static extern uint Everything_GetNumResults();

[DllImport("Everything.dll")]
public static extern void Everything_SetMatchPath(bool bEnable);

[DllImport("Everything.dll")]
public static extern uint Everything_GetLastError();
}
}
46 changes: 0 additions & 46 deletions src/Item.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/License.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

MIT License

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

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and ssociated documentation
Expand Down
Loading

0 comments on commit c78b74e

Please sign in to comment.