Merge pull request #453 from Wox-launcher/master

Merge branch 'master' into 'dotnet45'
This commit is contained in:
bao-qian 2016-01-02 02:10:37 +00:00
commit 74fb470647
34 changed files with 41 additions and 2516 deletions

View File

@ -1,336 +0,0 @@
; *** Inno Setup version 5.5.3+ English messages ***
;
; To download user-contributed translations of this file, go to:
; http://www.jrsoftware.org/files/istrans/
;
; Note: When translating this text, do not add periods (.) to the end of
; messages that didn't have them already, because on those messages Inno
; Setup adds the periods automatically (appending a period would result in
; two periods being displayed).
[LangOptions]
; The following three entries are very important. Be sure to read and
; understand the '[LangOptions] section' topic in the help file.
LanguageName=English
LanguageID=$0409
LanguageCodePage=0
; If the language you are translating to requires special font faces or
; sizes, uncomment any of the following entries and change them accordingly.
;DialogFontName=
;DialogFontSize=8
;WelcomeFontName=Verdana
;WelcomeFontSize=12
;TitleFontName=Arial
;TitleFontSize=29
;CopyrightFontName=Arial
;CopyrightFontSize=8
[Messages]
; *** Application titles
SetupAppTitle=Setup
SetupWindowTitle=Setup - %1
UninstallAppTitle=Uninstall
UninstallAppFullTitle=%1 Uninstall
; *** Misc. common
InformationTitle=Information
ConfirmTitle=Confirm
ErrorTitle=Error
; *** SetupLdr messages
SetupLdrStartupMessage=This will install %1. Do you wish to continue?
LdrCannotCreateTemp=Unable to create a temporary file. Setup aborted
LdrCannotExecTemp=Unable to execute file in the temporary directory. Setup aborted
; *** Startup error messages
LastErrorMessage=%1.%n%nError %2: %3
SetupFileMissing=The file %1 is missing from the installation directory. Please correct the problem or obtain a new copy of the program.
SetupFileCorrupt=The setup files are corrupted. Please obtain a new copy of the program.
SetupFileCorruptOrWrongVer=The setup files are corrupted, or are incompatible with this version of Setup. Please correct the problem or obtain a new copy of the program.
InvalidParameter=An invalid parameter was passed on the command line:%n%n%1
SetupAlreadyRunning=Setup is already running.
WindowsVersionNotSupported=This program does not support the version of Windows your computer is running.
WindowsServicePackRequired=This program requires %1 Service Pack %2 or later.
NotOnThisPlatform=This program will not run on %1.
OnlyOnThisPlatform=This program must be run on %1.
OnlyOnTheseArchitectures=This program can only be installed on versions of Windows designed for the following processor architectures:%n%n%1
MissingWOW64APIs=The version of Windows you are running does not include functionality required by Setup to perform a 64-bit installation. To correct this problem, please install Service Pack %1.
WinVersionTooLowError=This program requires %1 version %2 or later.
WinVersionTooHighError=This program cannot be installed on %1 version %2 or later.
AdminPrivilegesRequired=You must be logged in as an administrator when installing this program.
PowerUserPrivilegesRequired=You must be logged in as an administrator or as a member of the Power Users group when installing this program.
SetupAppRunningError=Setup has detected that %1 is currently running.%n%nPlease close all instances of it now, then click OK to continue, or Cancel to exit.
UninstallAppRunningError=Uninstall has detected that %1 is currently running.%n%nPlease close all instances of it now, then click OK to continue, or Cancel to exit.
; *** Misc. errors
ErrorCreatingDir=Setup was unable to create the directory "%1"
ErrorTooManyFilesInDir=Unable to create a file in the directory "%1" because it contains too many files
; *** Setup common messages
ExitSetupTitle=Exit Setup
ExitSetupMessage=Setup is not complete. If you exit now, the program will not be installed.%n%nYou may run Setup again at another time to complete the installation.%n%nExit Setup?
AboutSetupMenuItem=&About Setup...
AboutSetupTitle=About Setup
AboutSetupMessage=%1 version %2%n%3%n%n%1 home page:%n%4
AboutSetupNote=
TranslatorNote=
; *** Buttons
ButtonBack=< &Back
ButtonNext=&Next >
ButtonInstall=&Install
ButtonOK=OK
ButtonCancel=Cancel
ButtonYes=&Yes
ButtonYesToAll=Yes to &All
ButtonNo=&No
ButtonNoToAll=N&o to All
ButtonFinish=&Finish
ButtonBrowse=&Browse...
ButtonWizardBrowse=B&rowse...
ButtonNewFolder=&Make New Folder
; *** "Select Language" dialog messages
SelectLanguageTitle=Select Setup Language
SelectLanguageLabel=Select the language to use during the installation:
; *** Common wizard text
ClickNext=Click Next to continue, or Cancel to exit Setup.
BeveledLabel=
BrowseDialogTitle=Browse For Folder
BrowseDialogLabel=Select a folder in the list below, then click OK.
NewFolderName=New Folder
; *** "Welcome" wizard page
WelcomeLabel1=Welcome to the [name] Setup Wizard
WelcomeLabel2=This will install [name/ver] on your computer.%n%nIt is recommended that you close all other applications before continuing.
; *** "Password" wizard page
WizardPassword=Password
PasswordLabel1=This installation is password protected.
PasswordLabel3=Please provide the password, then click Next to continue. Passwords are case-sensitive.
PasswordEditLabel=&Password:
IncorrectPassword=The password you entered is not correct. Please try again.
; *** "License Agreement" wizard page
WizardLicense=License Agreement
LicenseLabel=Please read the following important information before continuing.
LicenseLabel3=Please read the following License Agreement. You must accept the terms of this agreement before continuing with the installation.
LicenseAccepted=I &accept the agreement
LicenseNotAccepted=I &do not accept the agreement
; *** "Information" wizard pages
WizardInfoBefore=Information
InfoBeforeLabel=Please read the following important information before continuing.
InfoBeforeClickLabel=When you are ready to continue with Setup, click Next.
WizardInfoAfter=Information
InfoAfterLabel=Please read the following important information before continuing.
InfoAfterClickLabel=When you are ready to continue with Setup, click Next.
; *** "User Information" wizard page
WizardUserInfo=User Information
UserInfoDesc=Please enter your information.
UserInfoName=&User Name:
UserInfoOrg=&Organization:
UserInfoSerial=&Serial Number:
UserInfoNameRequired=You must enter a name.
; *** "Select Destination Location" wizard page
WizardSelectDir=Select Destination Location
SelectDirDesc=Where should [name] be installed?
SelectDirLabel3=Setup will install [name] into the following folder.
SelectDirBrowseLabel=To continue, click Next. If you would like to select a different folder, click Browse.
DiskSpaceMBLabel=At least [mb] MB of free disk space is required.
CannotInstallToNetworkDrive=Setup cannot install to a network drive.
CannotInstallToUNCPath=Setup cannot install to a UNC path.
InvalidPath=You must enter a full path with drive letter; for example:%n%nC:\APP%n%nor a UNC path in the form:%n%n\\server\share
InvalidDrive=The drive or UNC share you selected does not exist or is not accessible. Please select another.
DiskSpaceWarningTitle=Not Enough Disk Space
DiskSpaceWarning=Setup requires at least %1 KB of free space to install, but the selected drive only has %2 KB available.%n%nDo you want to continue anyway?
DirNameTooLong=The folder name or path is too long.
InvalidDirName=The folder name is not valid.
BadDirName32=Folder names cannot include any of the following characters:%n%n%1
DirExistsTitle=Folder Exists
DirExists=The folder:%n%n%1%n%nalready exists. Would you like to install to that folder anyway?
DirDoesntExistTitle=Folder Does Not Exist
DirDoesntExist=The folder:%n%n%1%n%ndoes not exist. Would you like the folder to be created?
; *** "Select Components" wizard page
WizardSelectComponents=Select Components
SelectComponentsDesc=Which components should be installed?
SelectComponentsLabel2=Select the components you want to install; clear the components you do not want to install. Click Next when you are ready to continue.
FullInstallation=Full installation
; if possible don't translate 'Compact' as 'Minimal' (I mean 'Minimal' in your language)
CompactInstallation=Compact installation
CustomInstallation=Custom installation
NoUninstallWarningTitle=Components Exist
NoUninstallWarning=Setup has detected that the following components are already installed on your computer:%n%n%1%n%nDeselecting these components will not uninstall them.%n%nWould you like to continue anyway?
ComponentSize1=%1 KB
ComponentSize2=%1 MB
ComponentsDiskSpaceMBLabel=Current selection requires at least [mb] MB of disk space.
; *** "Select Additional Tasks" wizard page
WizardSelectTasks=Select Additional Tasks
SelectTasksDesc=Which additional tasks should be performed?
SelectTasksLabel2=Select the additional tasks you would like Setup to perform while installing [name], then click Next.
; *** "Select Start Menu Folder" wizard page
WizardSelectProgramGroup=Select Start Menu Folder
SelectStartMenuFolderDesc=Where should Setup place the program's shortcuts?
SelectStartMenuFolderLabel3=Setup will create the program's shortcuts in the following Start Menu folder.
SelectStartMenuFolderBrowseLabel=To continue, click Next. If you would like to select a different folder, click Browse.
MustEnterGroupName=You must enter a folder name.
GroupNameTooLong=The folder name or path is too long.
InvalidGroupName=The folder name is not valid.
BadGroupName=The folder name cannot include any of the following characters:%n%n%1
NoProgramGroupCheck2=&Don't create a Start Menu folder
; *** "Ready to Install" wizard page
WizardReady=Ready to Install
ReadyLabel1=Setup is now ready to begin installing [name] on your computer.
ReadyLabel2a=Click Install to continue with the installation, or click Back if you want to review or change any settings.
ReadyLabel2b=Click Install to continue with the installation.
ReadyMemoUserInfo=User information:
ReadyMemoDir=Destination location:
ReadyMemoType=Setup type:
ReadyMemoComponents=Selected components:
ReadyMemoGroup=Start Menu folder:
ReadyMemoTasks=Additional tasks:
; *** "Preparing to Install" wizard page
WizardPreparing=Preparing to Install
PreparingDesc=Setup is preparing to install [name] on your computer.
PreviousInstallNotCompleted=The installation/removal of a previous program was not completed. You will need to restart your computer to complete that installation.%n%nAfter restarting your computer, run Setup again to complete the installation of [name].
CannotContinue=Setup cannot continue. Please click Cancel to exit.
ApplicationsFound=The following applications are using files that need to be updated by Setup. It is recommended that you allow Setup to automatically close these applications.
ApplicationsFound2=The following applications are using files that need to be updated by Setup. It is recommended that you allow Setup to automatically close these applications. After the installation has completed, Setup will attempt to restart the applications.
CloseApplications=&Automatically close the applications
DontCloseApplications=&Do not close the applications
ErrorCloseApplications=Setup was unable to automatically close all applications. It is recommended that you close all applications using files that need to be updated by Setup before continuing.
; *** "Installing" wizard page
WizardInstalling=Installing
InstallingLabel=Please wait while Setup installs [name] on your computer.
; *** "Setup Completed" wizard page
FinishedHeadingLabel=Completing the [name] Setup Wizard
FinishedLabelNoIcons=Setup has finished installing [name] on your computer.
FinishedLabel=Setup has finished installing [name] on your computer. The application may be launched by selecting the installed icons.
ClickFinish=Click Finish to exit Setup.
FinishedRestartLabel=To complete the installation of [name], Setup must restart your computer. Would you like to restart now?
FinishedRestartMessage=To complete the installation of [name], Setup must restart your computer.%n%nWould you like to restart now?
ShowReadmeCheck=Yes, I would like to view the README file
YesRadio=&Yes, restart the computer now
NoRadio=&No, I will restart the computer later
; used for example as 'Run MyProg.exe'
RunEntryExec=Run %1
; used for example as 'View Readme.txt'
RunEntryShellExec=View %1
; *** "Setup Needs the Next Disk" stuff
ChangeDiskTitle=Setup Needs the Next Disk
SelectDiskLabel2=Please insert Disk %1 and click OK.%n%nIf the files on this disk can be found in a folder other than the one displayed below, enter the correct path or click Browse.
PathLabel=&Path:
FileNotInDir2=The file "%1" could not be located in "%2". Please insert the correct disk or select another folder.
SelectDirectoryLabel=Please specify the location of the next disk.
; *** Installation phase messages
SetupAborted=Setup was not completed.%n%nPlease correct the problem and run Setup again.
EntryAbortRetryIgnore=Click Retry to try again, Ignore to proceed anyway, or Abort to cancel installation.
; *** Installation status messages
StatusClosingApplications=Closing applications...
StatusCreateDirs=Creating directories...
StatusExtractFiles=Extracting files...
StatusCreateIcons=Creating shortcuts...
StatusCreateIniEntries=Creating INI entries...
StatusCreateRegistryEntries=Creating registry entries...
StatusRegisterFiles=Registering files...
StatusSavingUninstall=Saving uninstall information...
StatusRunProgram=Finishing installation...
StatusRestartingApplications=Restarting applications...
StatusRollback=Rolling back changes...
; *** Misc. errors
ErrorInternal2=Internal error: %1
ErrorFunctionFailedNoCode=%1 failed
ErrorFunctionFailed=%1 failed; code %2
ErrorFunctionFailedWithMessage=%1 failed; code %2.%n%3
ErrorExecutingProgram=Unable to execute file:%n%1
; *** Registry errors
ErrorRegOpenKey=Error opening registry key:%n%1\%2
ErrorRegCreateKey=Error creating registry key:%n%1\%2
ErrorRegWriteKey=Error writing to registry key:%n%1\%2
; *** INI errors
ErrorIniEntry=Error creating INI entry in file "%1".
; *** File copying errors
FileAbortRetryIgnore=Click Retry to try again, Ignore to skip this file (not recommended), or Abort to cancel installation.
FileAbortRetryIgnore2=Click Retry to try again, Ignore to proceed anyway (not recommended), or Abort to cancel installation.
SourceIsCorrupted=The source file is corrupted
SourceDoesntExist=The source file "%1" does not exist
ExistingFileReadOnly=The existing file is marked as read-only.%n%nClick Retry to remove the read-only attribute and try again, Ignore to skip this file, or Abort to cancel installation.
ErrorReadingExistingDest=An error occurred while trying to read the existing file:
FileExists=The file already exists.%n%nWould you like Setup to overwrite it?
ExistingFileNewer=The existing file is newer than the one Setup is trying to install. It is recommended that you keep the existing file.%n%nDo you want to keep the existing file?
ErrorChangingAttr=An error occurred while trying to change the attributes of the existing file:
ErrorCreatingTemp=An error occurred while trying to create a file in the destination directory:
ErrorReadingSource=An error occurred while trying to read the source file:
ErrorCopying=An error occurred while trying to copy a file:
ErrorReplacingExistingFile=An error occurred while trying to replace the existing file:
ErrorRestartReplace=RestartReplace failed:
ErrorRenamingTemp=An error occurred while trying to rename a file in the destination directory:
ErrorRegisterServer=Unable to register the DLL/OCX: %1
ErrorRegSvr32Failed=RegSvr32 failed with exit code %1
ErrorRegisterTypeLib=Unable to register the type library: %1
; *** Post-installation errors
ErrorOpeningReadme=An error occurred while trying to open the README file.
ErrorRestartingComputer=Setup was unable to restart the computer. Please do this manually.
; *** Uninstaller messages
UninstallNotFound=File "%1" does not exist. Cannot uninstall.
UninstallOpenError=File "%1" could not be opened. Cannot uninstall
UninstallUnsupportedVer=The uninstall log file "%1" is in a format not recognized by this version of the uninstaller. Cannot uninstall
UninstallUnknownEntry=An unknown entry (%1) was encountered in the uninstall log
ConfirmUninstall=Are you sure you want to completely remove %1 and all of its components?
UninstallOnlyOnWin64=This installation can only be uninstalled on 64-bit Windows.
OnlyAdminCanUninstall=This installation can only be uninstalled by a user with administrative privileges.
UninstallStatusLabel=Please wait while %1 is removed from your computer.
UninstalledAll=%1 was successfully removed from your computer.
UninstalledMost=%1 uninstall complete.%n%nSome elements could not be removed. These can be removed manually.
UninstalledAndNeedsRestart=To complete the uninstallation of %1, your computer must be restarted.%n%nWould you like to restart now?
UninstallDataCorrupted="%1" file is corrupted. Cannot uninstall
; *** Uninstallation phase messages
ConfirmDeleteSharedFileTitle=Remove Shared File?
ConfirmDeleteSharedFile2=The system indicates that the following shared file is no longer in use by any programs. Would you like for Uninstall to remove this shared file?%n%nIf any programs are still using this file and it is removed, those programs may not function properly. If you are unsure, choose No. Leaving the file on your system will not cause any harm.
SharedFileNameLabel=File name:
SharedFileLocationLabel=Location:
WizardUninstalling=Uninstall Status
StatusUninstalling=Uninstalling %1...
; *** Shutdown block reasons
ShutdownBlockReasonInstallingApp=Installing %1.
ShutdownBlockReasonUninstallingApp=Uninstalling %1.
; The custom messages below aren't used by Setup itself, but if you make
; use of them in your scripts, you'll want to translate them.
[CustomMessages]
NameAndVersion=%1 version %2
AdditionalIcons=Additional icons:
CreateDesktopIcon=Create a &desktop icon
CreateQuickLaunchIcon=Create a &Quick Launch icon
ProgramOnTheWeb=%1 on the Web
UninstallProgram=Uninstall %1
LaunchProgram=Launch %1
AssocFileExtension=&Associate %1 with the %2 file extension
AssocingFileExtension=Associating %1 with the %2 file extension...
AutoStartProgramGroupDescription=Startup:
AutoStartProgram=Automatically start %1
AddonHostProgramNotFound=%1 could not be located in the folder you selected.%n%nDo you want to continue anyway?

Binary file not shown.

Binary file not shown.

View File

@ -1,345 +0,0 @@
; BEGIN ISPPBUILTINS.ISS
//
// Inno Setup Preprocessor 5
//
// Copyright (C) 2001-2004 Alex Yackimoff. All Rights Reserved.
// Portions by Martijn Laan.
// http://ispp.sourceforge.net
//
// Inno Setup (C) 1997-2009 Jordan Russell. All Rights Reserved.
// Portions by Martijn Laan.
//
// $Id: ISPPBuiltins.iss,v 1.3 2010/12/29 15:20:26 mlaan Exp $
//
#if defined(ISPP_INVOKED) && !defined(_BUILTINS_ISS_)
//
#if PREPROCVER < 0x01000000
# error Inno Setup Preprocessor version is outdated
#endif
//
#define _BUILTINS_ISS_
//
// ===========================================================================
//
// Default states for options.
//
//#pragma parseroption -b+ ; short circuit boolean evaluation: on
//#pragma parseroption -m- ; short circuit multiplication evaluation (0 * A will not eval A): off
//#pragma parseroption -p+ ; string literals without escape sequences: on
//#pragma parseroption -u- ; allow undeclared identifiers: off
//#pragma option -c+ ; pass script to the compiler: on
//#pragma option -e- ; emit empty lines to translation: off
//#pragma option -v- ; verbose mode: off
//
// ---------------------------------------------------------------------------
//
// Verbose levels:
// 0 - #include and #file acknowledgements
// 1 - information about any temp files created by #file
// 2 - #insert and #append acknowledgements
// 3 - reserved
// 4 - #dim, #define and #undef acknowledgements
// 5 - reserved
// 6 - conditional inclusion acknowledgements
// 7 - reserved
// 8 - show strings emitted with #emit directive
// 9 - macro and functions successfull call acknowledgements
//10 - Local macro array allocation acknowledgements
//
//#pragma verboselevel 0
//
#ifndef __POPT_P__
# define private CStrings
# pragma parseroption -p+
#endif
//
#pragma spansymbol "\"
//
#define True 1
#define False 0
#define Yes True
#define No False
//
#define MaxInt 0x7FFFFFFFL
#define MinInt 0x80000000L
//
#define NULL
#define void
//
// TypeOf constants
//
#define TYPE_ERROR 0
#define TYPE_NULL 1
#define TYPE_INTEGER 2
#define TYPE_STRING 3
#define TYPE_MACRO 4
#define TYPE_FUNC 5
#define TYPE_ARRAY 6
//
// Helper macro to find out the type of an array element or expression. TypeOf
// standard function only allows identifier as its parameter. Use this macro
// to convert an expression to identifier.
//
#define TypeOf2(any Expr) TypeOf(Expr)
//
// ReadReg constants
//
#define HKEY_CLASSES_ROOT 0x80000000UL
#define HKEY_CURRENT_USER 0x80000001UL
#define HKEY_LOCAL_MACHINE 0x80000002UL
#define HKEY_USERS 0x80000003UL
//
#define HKCR HKEY_CLASSES_ROOT
#define HKCU HKEY_CURRENT_USER
#define HKLM HKEY_LOCAL_MACHINE
#define HKU HKEY_USERS
//
// Exec constants
//
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_MAX 10
//
// Find constants
//
#define FIND_MATCH 0x00
#define FIND_BEGINS 0x01
#define FIND_ENDS 0x02
#define FIND_CONTAINS 0x03
#define FIND_CASESENSITIVE 0x04
#define FIND_SENSITIVE FIND_CASESENSITIVE
#define FIND_AND 0x00
#define FIND_OR 0x08
#define FIND_NOT 0x10
#define FIND_TRIM 0x20
//
// FindFirst constants
//
#define faReadOnly 0x00000001
#define faHidden 0x00000002
#define faSysFile 0x00000004
#define faVolumeID 0x00000008
#define faDirectory 0x00000010
#define faArchive 0x00000020
#define faSymLink 0x00000040
#define faAnyFile 0x0000003F
//
// GetStringFileInfo standard names
//
#define COMPANY_NAME "CompanyName"
#define FILE_DESCRIPTION "FileDescription"
#define FILE_VERSION "FileVersion"
#define INTERNAL_NAME "InternalName"
#define LEGAL_COPYRIGHT "LegalCopyright"
#define ORIGINAL_FILENAME "OriginalFilename"
#define PRODUCT_NAME "ProductName"
#define PRODUCT_VERSION "ProductVersion"
//
// GetStringFileInfo helpers
//
#define GetFileCompany(str FileName) GetStringFileInfo(FileName, COMPANY_NAME)
#define GetFileCopyright(str FileName) GetStringFileInfo(FileName, LEGAL_COPYRIGHT)
#define GetFileDescription(str FileName) GetStringFileInfo(FileName, FILE_DESCRIPTION)
#define GetFileProductVersion(str FileName) GetStringFileInfo(FileName, PRODUCT_VERSION)
#define GetFileVersionString(str FileName) GetStringFileInfo(FileName, FILE_VERSION)
//
// ParseVersion
//
// Macro internally calls GetFileVersion function and parses string returned
// by that function (in form "0.0.0.0"). All four version elements are stored
// in by-reference parameters Major, Minor, Rev, and Build. Macro returns
// string returned by GetFileVersion.
//
#define DeleteToFirstPeriod(str *S) \
Local[1] = Copy(S, 1, (Local[0] = Pos(".", S)) - 1), \
S = Copy(S, Local[0] + 1), \
Local[1]
//
#define ParseVersion(str FileName, *Major, *Minor, *Rev, *Build) \
Local[1] = Local[0] = GetFileVersion(FileName), \
Local[1] == "" ? "" : ( \
Major = Int(DeleteToFirstPeriod(Local[1])), \
Minor = Int(DeleteToFirstPeriod(Local[1])), \
Rev = Int(DeleteToFirstPeriod(Local[1])), \
Build = Int(Local[1]), \
Local[0])
//
// EncodeVer
//
// Encodes given four version elements to a 32 bit integer number (8 bits for
// each element, i.e. elements must be within 0...255 range).
//
#define EncodeVer(int Major, int Minor, int Revision = 0, int Build = -1) \
Major << 24 | (Minor & 0xFF) << 16 | (Revision & 0xFF) << 8 | (Build >= 0 ? Build & 0xFF : 0)
//
// DecodeVer
//
// Decodes given 32 bit integer encoded version to its string representation,
// Digits parameter indicates how many elements to show (if the fourth element
// is 0, it won't be shown anyway).
//
#define DecodeVer(int Ver, int Digits = 3) \
Str(Ver >> 0x18 & 0xFF) + (Digits > 1 ? "." : "") + \
(Digits > 1 ? \
Str(Ver >> 0x10 & 0xFF) + (Digits > 2 ? "." : "") : "") + \
(Digits > 2 ? \
Str(Ver >> 0x08 & 0xFF) + (Digits > 3 && (Local = Ver & 0xFF) ? "." : "") : "") + \
(Digits > 3 && Local ? \
Str(Ver & 0xFF) : "")
//
// FindSection
//
// Returns index of the line following the header of the section. This macro
// is intended to be used with #insert directive.
//
#define FindSection(str Section = "Files") \
Find(0, "[" + Section + "]", FIND_MATCH | FIND_TRIM) + 1
//
// FindSectionEnd
//
// Returns index of the line following last entry of the section. This macro
// is intended to be used with #insert directive.
//
#if VER >= 0x03000000
# define FindNextSection(int Line) \
Find(Line, "[", FIND_BEGINS | FIND_TRIM, "]", FIND_ENDS | FIND_AND)
# define FindSectionEnd(str Section = "Files") \
FindNextSection(FindSection(Section))
#else
# define FindSectionEnd(str Section = "Files") \
FindSection(Section) + EntryCount(Section)
#endif
//
// FindCode
//
// Returns index of the line (of translation) following either [Code] section
// header, or "program" keyword, if any.
//
#define FindCode() \
Local[1] = FindSection("Code"), \
Local[0] = Find(Local[1] - 1, "program", FIND_BEGINS, ";", FIND_ENDS | FIND_AND), \
(Local[0] < 0 ? Local[1] : Local[0] + 1)
//
// ExtractFilePath
//
// Returns directory portion of the given filename without backslash (unless
// it is a root directory). If PathName doesn't contain directory portion,
// the result is an empty string.
//
#define ExtractFilePath(str PathName) \
(Local[0] = \
!(Local[1] = RPos("\", PathName)) ? \
"" : \
Copy(PathName, 1, Local[1] - 1)), \
Local[0] + \
((Local[2] = Len(Local[0])) == 2 && Copy(Local[0], Local[2]) == ":" ? \
"\" : \
"")
#define ExtractFileDir(str PathName) \
RemoveBackslash(ExtractFilePath(PathName))
#define ExtractFileExt(str PathName) \
Local[0] = RPos(".", PathName), \
Copy(PathName, Local[0] + 1)
//
// ExtractFileName
//
// Returns name portion of the given filename. If PathName ends with
// a backslash, the result is an empty string.
//
#define ExtractFileName(str PathName) \
!(Local[0] = RPos("\", PathName)) ? \
PathName : \
Copy(PathName, Local[0] + 1)
//
// ChangeFileExt
//
// Changes extension in FileName with NewExt. NewExt must not contain
// period.
//
#define ChangeFileExt(str FileName, str NewExt) \
!(Local[0] = RPos(".", FileName)) ? \
FileName + "." + NewExt : \
Copy(FileName, 1, Local[0]) + NewExt
//
// AddBackslash
//
// Adds a backslash to the string, if it's not already there.
//
#define AddBackslash(str S) \
Copy(S, Len(S)) == "\" ? S : S + "\"
//
// RemoveBackslash
//
// Removes trailing backslash from the string unless the string points to
// a root directory.
//
#define RemoveBackslash(str S) \
Local[0] = Len(S), \
Local[0] > 0 ? \
Copy(S, Local[0]) == "\" ? \
(Local[0] == 3 && Copy(S, 2, 1) == ":" ? \
S : \
Copy(S, 1, Local[0] - 1)) : \
S : \
""
//
// Delete
//
// Deletes specified number of characters beginning with Index from S. S is
// passed by reference (therefore is modified). Acts like Delete function in
// Delphi (from System unit).
//
#define Delete(str *S, int Index, int Count = MaxInt) \
S = Copy(S, 1, Index - 1) + Copy(S, Index + Count)
//
// Insert
//
// Inserts specified Substr at Index'th character into S. S is passed by
// reference (therefore is modified).
//
#define Insert(str *S, int Index, str Substr) \
Index > Len(S) + 1 ? \
S : \
S = Copy(S, 1, Index - 1) + SubStr + Copy(S, Index)
//
// YesNo, IsDirSet
//
// Returns nonzero value if given string is "yes", "true" or "1". Intended to
// be used with SetupSetting function. This macro replaces YesNo function
// available in previous releases.
//
#define YesNo(str S) \
(S = LowerCase(S)) == "yes" || S == "true" || S == "1"
//
#define IsDirSet(str SetupDirective) \
YesNo(SetupSetting(SetupDirective))
//
//
#define Power(int X, int P = 2) \
!P ? 1 : X * Power(X, P - 1)
//
#define Min(int A, int B, int C = MaxInt) \
A < B ? A < C ? Int(A) : Int(C) : Int(B)
//
#define Max(int A, int B, int C = MinInt) \
A > B ? A > C ? Int(A) : Int(C) : Int(B)
//
#ifdef CStrings
# pragma parseroption -p-
#endif
#endif
; END ISPPBUILTINS.ISS

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,37 +0,0 @@
Inno Setup License
==================
Except where otherwise noted, all of the documentation and software included
in the Inno Setup package is copyrighted by Jordan Russell.
Copyright (C) 1997-2013 Jordan Russell. All rights reserved.
Portions Copyright (C) 2000-2013 Martijn Laan. All rights reserved.
This software is provided "as-is," without any express or implied warranty.
In no event shall the author be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter and redistribute it,
provided that the following conditions are met:
1. All redistributions of source code files must retain all copyright
notices that are currently in place, and this list of conditions without
modification.
2. All redistributions in binary form must retain all occurrences of the
above copyright notice and web site addresses that are currently in
place (for example, in the About boxes).
3. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software to
distribute a product, an acknowledgment in the product documentation
would be appreciated but is not required.
4. Modified versions in source or binary form must be plainly marked as
such, and must not be misrepresented as being the original software.
Jordan Russell
jr-2010 AT jrsoftware.org
http://www.jrsoftware.org/

View File

@ -1,55 +0,0 @@
#define MyAppName "Wox"
#define MyAppPublisher "qianlifeng"
#define MyAppURL "http://www.getwox.com"
#define MyAppExeName "Wox.exe"
#define MyAppPath SourcePath + "..\..\Output\Release"
#define OutputPath SourcePath + "..\..\Output"
#define MyAppVer = GetFileVersion(MyAppPath + "\Wox.exe")
[Setup]
AppId=05700E94-3DAD-4827-8AAA-9908178DE132-Wox
AppMutex=DBDE24E4-91F6-11DF-B495-C536DFD72085-Wox
AppName={#MyAppName}
AppVerName={#MyAppName} v{#MyAppVer}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=Wox-setup
OutputDir={#OutputPath}
Compression=lzma
SolidCompression=yes
DisableDirPage=auto
DisableProgramGroupPage=auto
[Languages]
Name: english; MessagesFile: compiler:Default.isl
[InstallDelete]
Type: files; Name: "{commonstartup}\{#MyAppName}.lnk"
[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons};
Name: startupfolder; Description: Startup with Windows;
[Files]
Source: {#MyAppPath}\*; Excludes: Plugins\*; DestDir: {app}; Flags: ignoreversion recursesubdirs
Source: {#MyAppPath}\Plugins\*; DestDir: {%USERPROFILE}\.Wox\Plugins; Flags: ignoreversion recursesubdirs
Source: {#MyAppPath}\Themes\Base.xaml; DestDir: {%USERPROFILE}\.Wox\Themes; Flags: ignoreversion recursesubdirs
[Icons]
Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}
Name: {userdesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon
Name: {userstartup}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: startupfolder
[Run]
Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent unchecked
[UninstallDelete]
Type: filesandordirs; Name: "{%USERPROFILE}\.Wox"
[UninstallRun]
Filename: {sys}\taskkill.exe; Parameters: "/f /im Wox.exe"; Flags: skipifdoesntexist runhidden

View File

@ -1,3 +0,0 @@
$root = (split-path -parent $MyInvocation.MyCommand.Definition) + '\..\..'
& $root\Deploy\Installer\InnoSetup\ISCC.exe $root\Deploy\Installer\Installer.iss

View File

@ -1,9 +0,0 @@
$path = $env:APPVEYOR_BUILD_FOLDER + "\Deploy\UpdateGenerator"
$current_path = Convert-Path .
Write-Host "Current path: " + $current_path
Write-Host "Target path: " + $path
Set-Location $path
& ".\Wox.UpdateFeedGenerator.exe"
Set-Location $current_path

View File

@ -1,10 +0,0 @@
{
"OutputDirectory": "..\\..\\Output\\Update",
"SourceDirectory": "..\\..\\Output\\Release",
"BaseURL": "http://127.0.0.1:8888",
"FeedXMLName": "update.xml",
"CheckVersion": false,
"CheckSize": false,
"CheckDate": false,
"CheckHash": true
}

9
Deploy/build-release.ps1 Normal file
View File

@ -0,0 +1,9 @@
$sourceDirectoryName = $env:APPVEYOR_BUILD_FOLDER + "\Output\Release"
$fileName = $env:APPVEYOR_BUILD_FOLDER + "\Wox-$env:APPVEYOR_BUILD_VERSION.zip"
$current_path = Convert-Path .
Write-Host "Current path: " + $current_path
Write-Host "Target path: " + $sourceDirectoryName
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourceDirectoryName, $fileName)

View File

@ -1,4 +1,4 @@
$path = $env:APPVEYOR_BUILD_FOLDER + "\Deploy\Nuget\wox.plugin.nuspec"
$path = $env:APPVEYOR_BUILD_FOLDER + "\Deploy\wox.plugin.nuspec"
$current_path = Convert-Path .
Write-Host "Current path: " + $current_path

View File

@ -4,13 +4,13 @@
<id>Wox.Plugin</id>
<version>$version$</version>
<authors>qianlifeng</authors>
<licenseUrl>https://github.com/qianlifeng/Wox/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/qianlifeng/wox</projectUrl>
<licenseUrl>https://github.com/Wox-launcher/Wox/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/Wox-launcher/Wox</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Reference this library if you want to develop a wox plugin</description>
<tags>wox</tags>
</metadata>
<files>
<file src="..\..\Output\Release\Wox.Plugin.dll" target="lib\net35" />
<file src="..\Output\Release\Wox.Plugin.dll" target="lib\net35" />
</files>
</package>

View File

@ -143,8 +143,12 @@ namespace Wox.Plugin.CMD
private void ExecuteCmd(string cmd, bool runAsAdministrator = false)
{
if (context.API.ShellRun(cmd, runAsAdministrator))
var fullCmd = CMDStorage.Instance.LeaveCmdOpen ? $"cmd /k \"{cmd}\" & pause & exit" : cmd;
var success = context.API.ShellRun(fullCmd, runAsAdministrator);
if (success)
{
CMDStorage.Instance.AddCmdHistory(cmd);
}
}
public void Init(PluginInitContext context)

View File

@ -1,12 +1,15 @@
Wox [![Build status](https://ci.appveyor.com/api/projects/status/bfktntbivg32e103)](https://ci.appveyor.com/project/qianlifeng/wox) [![Bountysource](https://www.bountysource.com/badge/team?team_id=39433&style=raised)](https://www.bountysource.com/teams/wox?utm_source=Wox&utm_medium=shield&utm_campaign=raised) [![Issue Stats](http://issuestats.com/github/Wox-launcher/Wox/badge/pr)](http://issuestats.com/github/Wox-launcher/Wox)
=========
[Wox](http://www.getwox.com/) is a launcher for Windows, an alternative to [Alfred](https://www.alfredapp.com/) or [Launchy](http://www.launchy.net/). You can launch everything with just a few keystrokes!
[![Build status](https://ci.appveyor.com/api/projects/status/bfktntbivg32e103)](https://ci.appveyor.com/project/qianlifeng/wox) [![Github All Releases](https://img.shields.io/github/downloads/Wox-launcher/Wox/total.svg)](https://github.com/Wox-launcher/Wox/releases)
[![Bountysource](https://www.bountysource.com/badge/team?team_id=39433&style=raised)](https://www.bountysource.com/teams/wox?utm_source=Wox&utm_medium=shield&utm_campaign=raised)
[![Issue Stats](http://issuestats.com/github/Wox-launcher/Wox/badge/pr)](http://issuestats.com/github/Wox-launcher/Wox)
Screenshot
=========
<a href="https://github.com/Wox-launcher/Wox/wiki/Screenshot">More screenshots</a>
<img src="http://ww3.sinaimg.cn/large/dce48faejw1eihx6ffo8eg20zk0m8hdt.gif" />
Wox is a launcher for Windows, an alternative to [Alfred](https://www.alfredapp.com/) and [Launchy](http://www.launchy.net/). You can launch everything with just a few keystrokes!
Demo
=========
![demo](http://i.imgur.com/DtxNBJi.gif)
Features
=========

View File

@ -895,6 +895,7 @@ namespace Wox
private void ShowContextMenu(Result result)
{
if (result == null) return;
List<Result> results = PluginManager.GetContextMenusForPlugin(result);
results.ForEach(o =>
{

View File

@ -425,7 +425,12 @@ namespace Wox
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
if (wallpaper != null && File.Exists(wallpaper))
{
var brush = new ImageBrush(new BitmapImage(new Uri(wallpaper)));
var memStream = new MemoryStream(File.ReadAllBytes(wallpaper));
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = memStream;
bitmap.EndInit();
var brush = new ImageBrush(bitmap);
brush.Stretch = Stretch.UniformToFill;
PreviewPanel.Background = brush;
}

View File

@ -1,850 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media.Animation;
using NHotkey;
using NHotkey.Wpf;
using Wox.Core.i18n;
using Wox.Core.Plugin;
using Wox.Core.Theme;
using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Wox.Plugin;
using Wox.Storage;
using ContextMenu = System.Windows.Forms.ContextMenu;
using DataFormats = System.Windows.DataFormats;
using DragEventArgs = System.Windows.DragEventArgs;
using IDataObject = System.Windows.IDataObject;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using MenuItem = System.Windows.Forms.MenuItem;
using MessageBox = System.Windows.MessageBox;
using ToolTip = System.Windows.Controls.ToolTip;
namespace Wox
{
public partial class MainWindow : IPublicAPI
{
#region Properties
private readonly Storyboard progressBarStoryboard = new Storyboard();
private NotifyIcon notifyIcon;
private bool queryHasReturn;
private string lastQuery;
private ToolTip toolTip = new ToolTip();
private bool ignoreTextChange = false;
#endregion
#region Public API
public void ChangeQuery(string query, bool requery = false)
{
Dispatcher.Invoke(new Action(() =>
{
tbQuery.Text = query;
tbQuery.CaretIndex = tbQuery.Text.Length;
if (requery)
{
TextBoxBase_OnTextChanged(null, null);
}
}));
}
public void CloseApp()
{
Dispatcher.Invoke(new Action(() =>
{
notifyIcon.Visible = false;
Close();
Environment.Exit(0);
}));
}
public void HideApp()
{
Dispatcher.Invoke(new Action(HideWox));
}
public void ShowApp()
{
Dispatcher.Invoke(new Action(() => ShowWox()));
}
public void ShowMsg(string title, string subTitle, string iconPath)
{
Dispatcher.Invoke(new Action(() =>
{
var m = new Msg { Owner = GetWindow(this) };
m.Show(title, subTitle, iconPath);
}));
}
public void OpenSettingDialog()
{
Dispatcher.Invoke(new Action(() => WindowOpener.Open<SettingWindow>(this)));
}
public void StartLoadingBar()
{
Dispatcher.Invoke(new Action(StartProgress));
}
public void StopLoadingBar()
{
Dispatcher.Invoke(new Action(StopProgress));
}
public void InstallPlugin(string path)
{
Dispatcher.Invoke(new Action(() => PluginManager.InstallPlugin(path)));
}
public void ReloadPlugins()
{
Dispatcher.Invoke(new Action(() => PluginManager.Init(this)));
}
public string GetTranslation(string key)
{
return InternationalizationManager.Instance.GetTranslation(key);
}
public List<PluginPair> GetAllPlugins()
{
return PluginManager.AllPlugins;
}
public event WoxKeyDownEventHandler BackKeyDownEvent;
public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
public event AfterWoxQueryEventHandler AfterWoxQueryEvent;
public event AfterWoxQueryEventHandler BeforeWoxQueryEvent;
public event ResultItemDropEventHandler ResultItemDropEvent;
public void PushResults(Query query, PluginMetadata plugin, List<Result> results)
{
results.ForEach(o =>
{
o.PluginDirectory = plugin.PluginDirectory;
o.PluginID = plugin.ID;
o.OriginQuery = query;
if (o.ContextMenu != null)
{
o.ContextMenu.ForEach(t =>
{
t.PluginDirectory = plugin.PluginDirectory;
t.PluginID = plugin.ID;
});
}
});
UpdateResultView(results);
}
public void ShowContextMenu(PluginMetadata plugin, List<Result> results)
{
if (results != null && results.Count > 0)
{
results.ForEach(o =>
{
o.PluginDirectory = plugin.PluginDirectory;
o.PluginID = plugin.ID;
o.ContextMenu = null;
});
pnlContextMenu.Clear();
pnlContextMenu.AddResults(results);
pnlContextMenu.Visibility = Visibility.Visible;
pnlResult.Visibility = Visibility.Collapsed;
}
}
#endregion
public MainWindow()
{
InitializeComponent();
ThreadPool.SetMaxThreads(30, 10);
ThreadPool.SetMinThreads(10, 5);
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
progressBar.ToolTip = toolTip;
InitialTray();
pnlResult.LeftMouseClickEvent += SelectResult;
pnlResult.ItemDropEvent += pnlResult_ItemDropEvent;
pnlContextMenu.LeftMouseClickEvent += SelectResult;
pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent;
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
InternationalizationManager.Instance.ChangeLanguage(UserSettingStorage.Instance.Language);
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
SetCustomPluginHotkey();
Closing += MainWindow_Closing;
//since MainWIndow implement IPublicAPI, so we need to finish ctor MainWindow object before
//PublicAPI invoke in plugin init methods. E.g FolderPlugin
ThreadPool.QueueUserWorkItem(o =>
{
Thread.Sleep(50);
PluginManager.Init(this);
});
ThreadPool.QueueUserWorkItem(o =>
{
Thread.Sleep(50);
PreLoadImages();
});
}
void pnlResult_ItemDropEvent(Result result, IDataObject dropDataObject, DragEventArgs args)
{
PluginPair pluginPair = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID);
if (ResultItemDropEvent != null && pluginPair != null)
{
foreach (var delegateHandler in ResultItemDropEvent.GetInvocationList())
{
if (delegateHandler.Target == pluginPair.Plugin)
{
delegateHandler.DynamicInvoke(result, dropDataObject, args);
}
}
}
}
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
{
if (GlobalKeyboardEvent != null)
{
return GlobalKeyboardEvent((int)keyevent, vkcode, state);
}
return true;
}
private void PreLoadImages()
{
ImageLoader.ImageLoader.PreloadImages();
}
void pnlResult_RightMouseClickEvent(Result result)
{
ShowContextMenuFromResult(result);
}
void MainWindow_Closing(object sender, CancelEventArgs e)
{
UserSettingStorage.Instance.WindowLeft = Left;
UserSettingStorage.Instance.WindowTop = Top;
UserSettingStorage.Instance.Save();
this.HideWox();
e.Cancel = true;
}
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
if (UserSettingStorage.Instance.WindowLeft == 0
&& UserSettingStorage.Instance.WindowTop == 0)
{
Left = UserSettingStorage.Instance.WindowLeft
= (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
Top = UserSettingStorage.Instance.WindowTop
= (SystemParameters.PrimaryScreenHeight - ActualHeight) / 5;
}
else
{
Left = UserSettingStorage.Instance.WindowLeft;
Top = UserSettingStorage.Instance.WindowTop;
}
InitProgressbarAnimation();
WindowIntelopHelper.DisableControlBox(this);
CheckUpdate();
}
private void CheckUpdate()
{
UpdaterManager.Instance.PrepareUpdateReady += OnPrepareUpdateReady;
UpdaterManager.Instance.UpdateError += OnUpdateError;
UpdaterManager.Instance.CheckUpdate();
}
void OnUpdateError(object sender, EventArgs e)
{
string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
MessageBox.Show(updateError);
}
private void OnPrepareUpdateReady(object sender, EventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
new WoxUpdate().ShowDialog();
}));
}
public void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
{
var hotkey = new HotkeyModel(hotkeyStr);
try
{
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
}
catch (Exception)
{
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
MessageBox.Show(errorMsg);
}
}
public void RemoveHotkey(string hotkeyStr)
{
if (!string.IsNullOrEmpty(hotkeyStr))
{
HotkeyManager.Current.Remove(hotkeyStr);
}
}
private void SetCustomPluginHotkey()
{
if (UserSettingStorage.Instance.CustomPluginHotkeys == null) return;
foreach (CustomPluginHotkey hotkey in UserSettingStorage.Instance.CustomPluginHotkeys)
{
CustomPluginHotkey hotkey1 = hotkey;
SetHotkey(hotkey.Hotkey, delegate
{
ShowApp();
ChangeQuery(hotkey1.ActionKeyword, true);
});
}
}
private void OnHotkey(object sender, HotkeyEventArgs e)
{
ToggleWox();
e.Handled = true;
}
public void ToggleWox()
{
if (!IsVisible)
{
ShowWox();
}
else
{
HideWox();
}
}
private void InitProgressbarAnimation()
{
var da = new DoubleAnimation(progressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
var da1 = new DoubleAnimation(progressBar.X1, ActualWidth, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
progressBarStoryboard.Children.Add(da);
progressBarStoryboard.Children.Add(da1);
progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever;
progressBar.Visibility = Visibility.Hidden;
progressBar.BeginStoryboard(progressBarStoryboard);
}
private void InitialTray()
{
notifyIcon = new NotifyIcon { Text = "Wox", Icon = Properties.Resources.app, Visible = true };
notifyIcon.Click += (o, e) => ShowWox();
var open = new MenuItem("Open");
open.Click += (o, e) => ShowWox();
var setting = new MenuItem("Settings");
setting.Click += (o, e) => OpenSettingDialog();
var exit = new MenuItem("Exit");
exit.Click += (o, e) => CloseApp();
MenuItem[] childen = { open, setting, exit };
notifyIcon.ContextMenu = new ContextMenu(childen);
}
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
if (ignoreTextChange) { ignoreTextChange = false; return; }
lastQuery = tbQuery.Text;
toolTip.IsOpen = false;
pnlResult.Dirty = true;
int searchDelay = GetSearchDelay(lastQuery);
Dispatcher.DelayInvoke("UpdateSearch",
o =>
{
Dispatcher.DelayInvoke("ClearResults", i =>
{
// first try to use clear method inside pnlResult, which is more closer to the add new results
// and this will not bring splash issues.After waiting 100ms, if there still no results added, we
// must clear the result. otherwise, it will be confused why the query changed, but the results
// didn't.
if (pnlResult.Dirty) pnlResult.Clear();
}, TimeSpan.FromMilliseconds(100), null);
queryHasReturn = false;
Query query = new Query(lastQuery);
query.IsIntantQuery = searchDelay == 0;
FireBeforeWoxQueryEvent(query);
Query(query);
Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
{
if (!queryHasReturn && originQuery == tbQuery.Text && !string.IsNullOrEmpty(lastQuery))
{
StartProgress();
}
}, TimeSpan.FromMilliseconds(150), tbQuery.Text);
FireAfterWoxQueryEvent(query);
}, TimeSpan.FromMilliseconds(searchDelay));
}
private int GetSearchDelay(string query)
{
if (!string.IsNullOrEmpty(query) && PluginManager.IsInstantQuery(query))
{
DebugHelper.WriteLine("execute query without delay");
return 0;
}
DebugHelper.WriteLine("execute query with 200ms delay");
return 200;
}
private void FireAfterWoxQueryEvent(Query q)
{
if (AfterWoxQueryEvent != null)
{
//We shouldn't let those events slow down real query
//so I put it in the new thread
ThreadPool.QueueUserWorkItem(o =>
{
AfterWoxQueryEvent(new WoxQueryEventArgs()
{
Query = q
});
});
}
}
private void FireBeforeWoxQueryEvent(Query q)
{
if (BeforeWoxQueryEvent != null)
{
//We shouldn't let those events slow down real query
//so I put it in the new thread
ThreadPool.QueueUserWorkItem(o =>
{
BeforeWoxQueryEvent(new WoxQueryEventArgs()
{
Query = q
});
});
}
}
private void Query(Query q)
{
PluginManager.Query(q);
StopProgress();
BackToResultMode();
}
private void BackToResultMode()
{
pnlResult.Visibility = Visibility.Visible;
pnlContextMenu.Visibility = Visibility.Collapsed;
}
private void Border_OnMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left) DragMove();
}
private void StartProgress()
{
progressBar.Visibility = Visibility.Visible;
}
private void StopProgress()
{
progressBar.Visibility = Visibility.Hidden;
}
private void HideWox()
{
Hide();
}
private void ShowWox(bool selectAll = true)
{
UserSettingStorage.Instance.IncreaseActivateTimes();
if (!double.IsNaN(Left) && !double.IsNaN(Top))
{
var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight));
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var coordX = (Left - origScreen.WorkingArea.Left) / (origScreen.WorkingArea.Width - ActualWidth);
var coordY = (Top - origScreen.WorkingArea.Top) / (origScreen.WorkingArea.Height - ActualHeight);
Left = (screen.WorkingArea.Width - ActualWidth) * coordX + screen.WorkingArea.Left;
Top = (screen.WorkingArea.Height - ActualHeight) * coordY + screen.WorkingArea.Top;
}
Show();
Activate();
Focus();
tbQuery.Focus();
if (selectAll) tbQuery.SelectAll();
}
private void MainWindow_OnDeactivated(object sender, EventArgs e)
{
if (UserSettingStorage.Instance.HideWhenDeactive)
{
HideWox();
}
}
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e)
{
//when alt is pressed, the real key should be e.SystemKey
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
switch (key)
{
case Key.Escape:
if (IsInContextMenuMode)
{
BackToResultMode();
}
else
{
HideWox();
}
e.Handled = true;
break;
case Key.Tab:
if (GlobalHotkey.Instance.CheckModifiers().ShiftPressed)
{
SelectPrevItem();
}
else
{
SelectNextItem();
}
e.Handled = true;
break;
case Key.N:
case Key.J:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
SelectNextItem();
}
break;
case Key.P:
case Key.K:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
SelectPrevItem();
}
break;
case Key.O:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
if (IsInContextMenuMode)
{
BackToResultMode();
}
else
{
ShowContextMenuFromResult(GetActiveResult());
}
}
break;
case Key.Down:
SelectNextItem();
e.Handled = true;
break;
case Key.Up:
SelectPrevItem();
e.Handled = true;
break;
case Key.D:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
pnlResult.SelectNextPage();
}
break;
case Key.PageDown:
pnlResult.SelectNextPage();
e.Handled = true;
break;
case Key.U:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
pnlResult.SelectPrevPage();
}
break;
case Key.PageUp:
pnlResult.SelectPrevPage();
e.Handled = true;
break;
case Key.Back:
if (BackKeyDownEvent != null)
{
BackKeyDownEvent(new WoxKeyDownEventArgs()
{
Query = tbQuery.Text,
keyEventArgs = e
});
}
break;
case Key.F1:
Process.Start("http://doc.getwox.com");
break;
case Key.Enter:
Result activeResult = GetActiveResult();
if (GlobalHotkey.Instance.CheckModifiers().ShiftPressed)
{
ShowContextMenuFromResult(activeResult);
}
else
{
SelectResult(activeResult);
}
e.Handled = true;
break;
case Key.D1:
SelectItem(1);
break;
case Key.D2:
SelectItem(2);
break;
case Key.D3:
SelectItem(3);
break;
case Key.D4:
SelectItem(4);
break;
case Key.D5:
SelectItem(5);
break;
case Key.D6:
SelectItem(6);
break;
}
}
private void SelectItem(int index)
{
int zeroBasedIndex = index - 1;
SpecialKeyState keyState = GlobalHotkey.Instance.CheckModifiers();
if (keyState.AltPressed || keyState.CtrlPressed)
{
List<Result> visibleResults = pnlResult.GetVisibleResults();
if (zeroBasedIndex < visibleResults.Count)
{
SelectResult(visibleResults[zeroBasedIndex]);
}
}
}
private bool IsInContextMenuMode
{
get { return pnlContextMenu.Visibility == Visibility.Visible; }
}
private Result GetActiveResult()
{
if (IsInContextMenuMode)
{
return pnlContextMenu.GetActiveResult();
}
else
{
return pnlResult.GetActiveResult();
}
}
private void SelectPrevItem()
{
if (IsInContextMenuMode)
{
pnlContextMenu.SelectPrev();
}
else
{
pnlResult.SelectPrev();
}
toolTip.IsOpen = false;
}
private void SelectNextItem()
{
if (IsInContextMenuMode)
{
pnlContextMenu.SelectNext();
}
else
{
pnlResult.SelectNext();
}
toolTip.IsOpen = false;
}
private void SelectResult(Result result)
{
if (result != null)
{
if (result.Action != null)
{
bool hideWindow = result.Action(new ActionContext()
{
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
});
if (hideWindow)
{
HideWox();
}
UserSelectedRecordStorage.Instance.Add(result);
}
}
}
private void UpdateResultView(List<Result> list)
{
queryHasReturn = true;
progressBar.Dispatcher.Invoke(new Action(StopProgress));
if (list == null || list.Count == 0) return;
if (list.Count > 0)
{
list.ForEach(o =>
{
o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o) * 5;
if (o.ContextMenu == null)
{
o.ContextMenu = new List<Result>();
}
HanleTopMost(o);
});
List<Result> l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
Dispatcher.Invoke(new Action(() =>
{
pnlResult.AddResults(l);
}));
}
}
private void HanleTopMost(Result result)
{
if (TopMostRecordStorage.Instance.IsTopMost(result))
{
result.ContextMenu.Add(new Result("Remove top most in this query", "Images\\down.png")
{
PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Action = _ =>
{
TopMostRecordStorage.Instance.Remove(result);
ShowMsg("Succeed", "", "");
return false;
}
});
}
else
{
result.ContextMenu.Add(new Result("Set as top most in this query", "Images\\up.png")
{
PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Action = _ =>
{
TopMostRecordStorage.Instance.Add(result);
ShowMsg("Succeed", "", "");
return false;
}
});
}
}
private void ShowContextMenuFromResult(Result result)
{
if (result.ContextMenu != null && result.ContextMenu.Count > 0)
{
pnlContextMenu.Clear();
pnlContextMenu.AddResults(result.ContextMenu);
pnlContextMenu.Visibility = Visibility.Visible;
pnlResult.Visibility = Visibility.Collapsed;
}
}
public bool ShellRun(string cmd, bool runAsAdministrator = false)
{
try
{
if (string.IsNullOrEmpty(cmd))
throw new ArgumentNullException();
WindowsShellRun.Start(cmd, runAsAdministrator);
return true;
}
catch (Exception ex)
{
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("couldnotStartCmd"), cmd);
ShowMsg(errorMsg, ex.Message, null);
}
return false;
}
private void MainWindow_OnDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
// Note that you can have more than one file.
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files[0].ToLower().EndsWith(".wox"))
{
PluginManager.InstallPlugin(files[0]);
}
else
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidWoxPluginFileFormat"));
}
}
}
private void TbQuery_OnPreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = true;
}
}
}

View File

@ -1,850 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media.Animation;
using NHotkey;
using NHotkey.Wpf;
using Wox.Core.i18n;
using Wox.Core.Plugin;
using Wox.Core.Theme;
using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Wox.Plugin;
using Wox.Storage;
using ContextMenu = System.Windows.Forms.ContextMenu;
using DataFormats = System.Windows.DataFormats;
using DragEventArgs = System.Windows.DragEventArgs;
using IDataObject = System.Windows.IDataObject;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using MenuItem = System.Windows.Forms.MenuItem;
using MessageBox = System.Windows.MessageBox;
using ToolTip = System.Windows.Controls.ToolTip;
namespace Wox
{
public partial class MainWindow : IPublicAPI
{
#region Properties
private readonly Storyboard progressBarStoryboard = new Storyboard();
private NotifyIcon notifyIcon;
private bool queryHasReturn;
private string lastQuery;
private ToolTip toolTip = new ToolTip();
private bool ignoreTextChange = false;
#endregion
#region Public API
public void ChangeQuery(string query, bool requery = false)
{
Dispatcher.Invoke(new Action(() =>
{
tbQuery.Text = query;
tbQuery.CaretIndex = tbQuery.Text.Length;
if (requery)
{
TextBoxBase_OnTextChanged(null, null);
}
}));
}
public void CloseApp()
{
Dispatcher.Invoke(new Action(() =>
{
notifyIcon.Visible = false;
Close();
Environment.Exit(0);
}));
}
public void HideApp()
{
Dispatcher.Invoke(new Action(HideWox));
}
public void ShowApp()
{
Dispatcher.Invoke(new Action(() => ShowWox()));
}
public void ShowMsg(string title, string subTitle, string iconPath)
{
Dispatcher.Invoke(new Action(() =>
{
var m = new Msg { Owner = GetWindow(this) };
m.Show(title, subTitle, iconPath);
}));
}
public void OpenSettingDialog()
{
Dispatcher.Invoke(new Action(() => WindowOpener.Open<SettingWindow>(this)));
}
public void StartLoadingBar()
{
Dispatcher.Invoke(new Action(StartProgress));
}
public void StopLoadingBar()
{
Dispatcher.Invoke(new Action(StopProgress));
}
public void InstallPlugin(string path)
{
Dispatcher.Invoke(new Action(() => PluginManager.InstallPlugin(path)));
}
public void ReloadPlugins()
{
Dispatcher.Invoke(new Action(() => PluginManager.Init(this)));
}
public string GetTranslation(string key)
{
return InternationalizationManager.Instance.GetTranslation(key);
}
public List<PluginPair> GetAllPlugins()
{
return PluginManager.AllPlugins;
}
public event WoxKeyDownEventHandler BackKeyDownEvent;
public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
public event AfterWoxQueryEventHandler AfterWoxQueryEvent;
public event AfterWoxQueryEventHandler BeforeWoxQueryEvent;
public event ResultItemDropEventHandler ResultItemDropEvent;
public void PushResults(Query query, PluginMetadata plugin, List<Result> results)
{
results.ForEach(o =>
{
o.PluginDirectory = plugin.PluginDirectory;
o.PluginID = plugin.ID;
o.OriginQuery = query;
if (o.ContextMenu != null)
{
o.ContextMenu.ForEach(t =>
{
t.PluginDirectory = plugin.PluginDirectory;
t.PluginID = plugin.ID;
});
}
});
UpdateResultView(results);
}
public void ShowContextMenu(PluginMetadata plugin, List<Result> results)
{
if (results != null && results.Count > 0)
{
results.ForEach(o =>
{
o.PluginDirectory = plugin.PluginDirectory;
o.PluginID = plugin.ID;
o.ContextMenu = null;
});
pnlContextMenu.Clear();
pnlContextMenu.AddResults(results);
pnlContextMenu.Visibility = Visibility.Visible;
pnlResult.Visibility = Visibility.Collapsed;
}
}
#endregion
public MainWindow()
{
InitializeComponent();
ThreadPool.SetMaxThreads(30, 10);
ThreadPool.SetMinThreads(10, 5);
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
progressBar.ToolTip = toolTip;
InitialTray();
pnlResult.LeftMouseClickEvent += SelectResult;
pnlResult.ItemDropEvent += pnlResult_ItemDropEvent;
pnlContextMenu.LeftMouseClickEvent += SelectResult;
pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent;
ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
InternationalizationManager.Instance.ChangeLanguage(UserSettingStorage.Instance.Language);
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
SetCustomPluginHotkey();
Closing += MainWindow_Closing;
//since MainWIndow implement IPublicAPI, so we need to finish ctor MainWindow object before
//PublicAPI invoke in plugin init methods. E.g FolderPlugin
ThreadPool.QueueUserWorkItem(o =>
{
Thread.Sleep(50);
PluginManager.Init(this);
});
ThreadPool.QueueUserWorkItem(o =>
{
Thread.Sleep(50);
PreLoadImages();
});
}
void pnlResult_ItemDropEvent(Result result, IDataObject dropDataObject, DragEventArgs args)
{
PluginPair pluginPair = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID);
if (ResultItemDropEvent != null && pluginPair != null)
{
foreach (var delegateHandler in ResultItemDropEvent.GetInvocationList())
{
if (delegateHandler.Target == pluginPair.Plugin)
{
delegateHandler.DynamicInvoke(result, dropDataObject, args);
}
}
}
}
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
{
if (GlobalKeyboardEvent != null)
{
return GlobalKeyboardEvent((int)keyevent, vkcode, state);
}
return true;
}
private void PreLoadImages()
{
ImageLoader.ImageLoader.PreloadImages();
}
void pnlResult_RightMouseClickEvent(Result result)
{
ShowContextMenuFromResult(result);
}
void MainWindow_Closing(object sender, CancelEventArgs e)
{
UserSettingStorage.Instance.WindowLeft = Left;
UserSettingStorage.Instance.WindowTop = Top;
UserSettingStorage.Instance.Save();
this.HideWox();
e.Cancel = true;
}
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
if (UserSettingStorage.Instance.WindowLeft == 0
&& UserSettingStorage.Instance.WindowTop == 0)
{
Left = UserSettingStorage.Instance.WindowLeft
= (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
Top = UserSettingStorage.Instance.WindowTop
= (SystemParameters.PrimaryScreenHeight - ActualHeight) / 5;
}
else
{
Left = UserSettingStorage.Instance.WindowLeft;
Top = UserSettingStorage.Instance.WindowTop;
}
InitProgressbarAnimation();
WindowIntelopHelper.DisableControlBox(this);
CheckUpdate();
}
private void CheckUpdate()
{
UpdaterManager.Instance.PrepareUpdateReady += OnPrepareUpdateReady;
UpdaterManager.Instance.UpdateError += OnUpdateError;
UpdaterManager.Instance.CheckUpdate();
}
void OnUpdateError(object sender, EventArgs e)
{
string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
MessageBox.Show(updateError);
}
private void OnPrepareUpdateReady(object sender, EventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
new WoxUpdate().ShowDialog();
}));
}
public void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
{
var hotkey = new HotkeyModel(hotkeyStr);
try
{
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
}
catch (Exception)
{
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
MessageBox.Show(errorMsg);
}
}
public void RemoveHotkey(string hotkeyStr)
{
if (!string.IsNullOrEmpty(hotkeyStr))
{
HotkeyManager.Current.Remove(hotkeyStr);
}
}
private void SetCustomPluginHotkey()
{
if (UserSettingStorage.Instance.CustomPluginHotkeys == null) return;
foreach (CustomPluginHotkey hotkey in UserSettingStorage.Instance.CustomPluginHotkeys)
{
CustomPluginHotkey hotkey1 = hotkey;
SetHotkey(hotkey.Hotkey, delegate
{
ShowApp();
ChangeQuery(hotkey1.ActionKeyword, true);
});
}
}
private void OnHotkey(object sender, HotkeyEventArgs e)
{
ToggleWox();
e.Handled = true;
}
public void ToggleWox()
{
if (!IsVisible)
{
ShowWox();
}
else
{
HideWox();
}
}
private void InitProgressbarAnimation()
{
var da = new DoubleAnimation(progressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
var da1 = new DoubleAnimation(progressBar.X1, ActualWidth, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
progressBarStoryboard.Children.Add(da);
progressBarStoryboard.Children.Add(da1);
progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever;
progressBar.Visibility = Visibility.Hidden;
progressBar.BeginStoryboard(progressBarStoryboard);
}
private void InitialTray()
{
notifyIcon = new NotifyIcon { Text = "Wox", Icon = Properties.Resources.app, Visible = true };
notifyIcon.Click += (o, e) => ShowWox();
var open = new MenuItem("Open");
open.Click += (o, e) => ShowWox();
var setting = new MenuItem("Settings");
setting.Click += (o, e) => OpenSettingDialog();
var exit = new MenuItem("Exit");
exit.Click += (o, e) => CloseApp();
MenuItem[] childen = { open, setting, exit };
notifyIcon.ContextMenu = new ContextMenu(childen);
}
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
if (ignoreTextChange) { ignoreTextChange = false; return; }
lastQuery = tbQuery.Text;
toolTip.IsOpen = false;
pnlResult.Dirty = true;
int searchDelay = GetSearchDelay(lastQuery);
Dispatcher.DelayInvoke("UpdateSearch",
o =>
{
Dispatcher.DelayInvoke("ClearResults", i =>
{
// first try to use clear method inside pnlResult, which is more closer to the add new results
// and this will not bring splash issues.After waiting 100ms, if there still no results added, we
// must clear the result. otherwise, it will be confused why the query changed, but the results
// didn't.
if (pnlResult.Dirty) pnlResult.Clear();
}, TimeSpan.FromMilliseconds(100), null);
queryHasReturn = false;
Query query = new Query(lastQuery);
query.IsIntantQuery = searchDelay == 0;
FireBeforeWoxQueryEvent(query);
Query(query);
Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
{
if (!queryHasReturn && originQuery == tbQuery.Text && !string.IsNullOrEmpty(lastQuery))
{
StartProgress();
}
}, TimeSpan.FromMilliseconds(150), tbQuery.Text);
FireAfterWoxQueryEvent(query);
}, TimeSpan.FromMilliseconds(searchDelay));
}
private int GetSearchDelay(string query)
{
if (!string.IsNullOrEmpty(query) && PluginManager.IsInstantQuery(query))
{
DebugHelper.WriteLine("execute query without delay");
return 0;
}
DebugHelper.WriteLine("execute query with 200ms delay");
return 200;
}
private void FireAfterWoxQueryEvent(Query q)
{
if (AfterWoxQueryEvent != null)
{
//We shouldn't let those events slow down real query
//so I put it in the new thread
ThreadPool.QueueUserWorkItem(o =>
{
AfterWoxQueryEvent(new WoxQueryEventArgs()
{
Query = q
});
});
}
}
private void FireBeforeWoxQueryEvent(Query q)
{
if (BeforeWoxQueryEvent != null)
{
//We shouldn't let those events slow down real query
//so I put it in the new thread
ThreadPool.QueueUserWorkItem(o =>
{
BeforeWoxQueryEvent(new WoxQueryEventArgs()
{
Query = q
});
});
}
}
private void Query(Query q)
{
PluginManager.Query(q);
StopProgress();
BackToResultMode();
}
private void BackToResultMode()
{
pnlResult.Visibility = Visibility.Visible;
pnlContextMenu.Visibility = Visibility.Collapsed;
}
private void Border_OnMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left) DragMove();
}
private void StartProgress()
{
progressBar.Visibility = Visibility.Visible;
}
private void StopProgress()
{
progressBar.Visibility = Visibility.Hidden;
}
private void HideWox()
{
Hide();
}
private void ShowWox(bool selectAll = true)
{
UserSettingStorage.Instance.IncreaseActivateTimes();
if (!double.IsNaN(Left) && !double.IsNaN(Top))
{
var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight));
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var coordX = (Left - origScreen.WorkingArea.Left) / (origScreen.WorkingArea.Width - ActualWidth);
var coordY = (Top - origScreen.WorkingArea.Top) / (origScreen.WorkingArea.Height - ActualHeight);
Left = (screen.WorkingArea.Width - ActualWidth) * coordX + screen.WorkingArea.Left;
Top = (screen.WorkingArea.Height - ActualHeight) * coordY + screen.WorkingArea.Top;
}
Show();
Activate();
Focus();
tbQuery.Focus();
if (selectAll) tbQuery.SelectAll();
}
private void MainWindow_OnDeactivated(object sender, EventArgs e)
{
if (UserSettingStorage.Instance.HideWhenDeactive)
{
HideWox();
}
}
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e)
{
//when alt is pressed, the real key should be e.SystemKey
Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
switch (key)
{
case Key.Escape:
if (IsInContextMenuMode)
{
BackToResultMode();
}
else
{
HideWox();
}
e.Handled = true;
break;
case Key.Tab:
if (GlobalHotkey.Instance.CheckModifiers().ShiftPressed)
{
SelectPrevItem();
}
else
{
SelectNextItem();
}
e.Handled = true;
break;
case Key.N:
case Key.J:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
SelectNextItem();
}
break;
case Key.P:
case Key.K:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
SelectPrevItem();
}
break;
case Key.O:
if (GlobalHotkey.Instance.CheckModifiers().CtrlPressed)
{
if (IsInContextMenuMode)
{
BackToResultMode();
}
else
{
ShowContextMenuFromResult(GetActiveResult());
}
}
break;
case Key.Down:
SelectNextItem();
e.Handled = true;
break;
case Key.Up:
SelectPrevItem();
e.Handled = true;
break;
case Key.D:
if (GlobalHotkey.Instance.CheckModifiers().AltPressed)
{
pnlResult.SelectNextPage();
}
break;
case Key.PageDown:
pnlResult.SelectNextPage();
e.Handled = true;
break;
case Key.U:
if (GlobalHotkey.Instance.CheckModifiers().AltPressed)
{
pnlResult.SelectPrevPage();
}
break;
case Key.PageUp:
pnlResult.SelectPrevPage();
e.Handled = true;
break;
case Key.Back:
if (BackKeyDownEvent != null)
{
BackKeyDownEvent(new WoxKeyDownEventArgs()
{
Query = tbQuery.Text,
keyEventArgs = e
});
}
break;
case Key.F1:
Process.Start("http://doc.getwox.com");
break;
case Key.Enter:
Result activeResult = GetActiveResult();
if (GlobalHotkey.Instance.CheckModifiers().ShiftPressed)
{
ShowContextMenuFromResult(activeResult);
}
else
{
SelectResult(activeResult);
}
e.Handled = true;
break;
case Key.D1:
SelectItem(1);
break;
case Key.D2:
SelectItem(2);
break;
case Key.D3:
SelectItem(3);
break;
case Key.D4:
SelectItem(4);
break;
case Key.D5:
SelectItem(5);
break;
case Key.D6:
SelectItem(6);
break;
}
}
private void SelectItem(int index)
{
int zeroBasedIndex = index - 1;
SpecialKeyState keyState = GlobalHotkey.Instance.CheckModifiers();
if (keyState.AltPressed || keyState.CtrlPressed)
{
List<Result> visibleResults = pnlResult.GetVisibleResults();
if (zeroBasedIndex < visibleResults.Count)
{
SelectResult(visibleResults[zeroBasedIndex]);
}
}
}
private bool IsInContextMenuMode
{
get { return pnlContextMenu.Visibility == Visibility.Visible; }
}
private Result GetActiveResult()
{
if (IsInContextMenuMode)
{
return pnlContextMenu.GetActiveResult();
}
else
{
return pnlResult.GetActiveResult();
}
}
private void SelectPrevItem()
{
if (IsInContextMenuMode)
{
pnlContextMenu.SelectPrev();
}
else
{
pnlResult.SelectPrev();
}
toolTip.IsOpen = false;
}
private void SelectNextItem()
{
if (IsInContextMenuMode)
{
pnlContextMenu.SelectNext();
}
else
{
pnlResult.SelectNext();
}
toolTip.IsOpen = false;
}
private void SelectResult(Result result)
{
if (result != null)
{
if (result.Action != null)
{
bool hideWindow = result.Action(new ActionContext()
{
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
});
if (hideWindow)
{
HideWox();
}
UserSelectedRecordStorage.Instance.Add(result);
}
}
}
private void UpdateResultView(List<Result> list)
{
queryHasReturn = true;
progressBar.Dispatcher.Invoke(new Action(StopProgress));
if (list == null || list.Count == 0) return;
if (list.Count > 0)
{
list.ForEach(o =>
{
o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o) * 5;
if (o.ContextMenu == null)
{
o.ContextMenu = new List<Result>();
}
HanleTopMost(o);
});
List<Result> l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
Dispatcher.Invoke(new Action(() =>
{
pnlResult.AddResults(l);
}));
}
}
private void HanleTopMost(Result result)
{
if (TopMostRecordStorage.Instance.IsTopMost(result))
{
result.ContextMenu.Add(new Result("Remove top most in this query", "Images\\down.png")
{
PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Action = _ =>
{
TopMostRecordStorage.Instance.Remove(result);
ShowMsg("Succeed", "", "");
return false;
}
});
}
else
{
result.ContextMenu.Add(new Result("Set as top most in this query", "Images\\up.png")
{
PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Action = _ =>
{
TopMostRecordStorage.Instance.Add(result);
ShowMsg("Succeed", "", "");
return false;
}
});
}
}
private void ShowContextMenuFromResult(Result result)
{
if (result.ContextMenu != null && result.ContextMenu.Count > 0)
{
pnlContextMenu.Clear();
pnlContextMenu.AddResults(result.ContextMenu);
pnlContextMenu.Visibility = Visibility.Visible;
pnlResult.Visibility = Visibility.Collapsed;
}
}
public bool ShellRun(string cmd, bool runAsAdministrator = false)
{
try
{
if (string.IsNullOrEmpty(cmd))
throw new ArgumentNullException();
WindowsShellRun.Start(cmd, runAsAdministrator);
return true;
}
catch (Exception ex)
{
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("couldnotStartCmd"), cmd);
ShowMsg(errorMsg, ex.Message, null);
}
return false;
}
private void MainWindow_OnDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
// Note that you can have more than one file.
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files[0].ToLower().EndsWith(".wox"))
{
PluginManager.InstallPlugin(files[0]);
}
else
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidWoxPluginFileFormat"));
}
}
}
private void TbQuery_OnPreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = true;
}
}
}

View File

@ -14,20 +14,18 @@ build:
project: Wox.sln
after_test:
- ps: >-
.\Deploy\UpdateGenerator\build.ps1
.\Deploy\Nuget\pack.ps1
.\Deploy\nuget.ps1
.\Deploy\build-release.ps1
artifacts:
- path: Output\Release
name: release-binary
- path: 'Wox-*.zip'
name: release_binary
- path: '*.nupkg'
name: nugetpackage
- path: Output\Update
name: update-binary
name: nuget_package
deploy:
- provider: NuGet
api_key:
secure: yybUOFgBuGVpbmOVZxsurC8OpkClzt9dR+/54WpMWcq6b6oyMatciaelRPnXsjRn
artifact: nugetpackage
artifact: nuget_package
on:
branch: api