+ upd: GrepWin(NP3) Update

This commit is contained in:
Rainer Kottenhoff 2020-12-14 08:36:40 +01:00
parent c3b6e0f26e
commit e337298918
15 changed files with 382 additions and 80 deletions

View File

@ -214,8 +214,10 @@
<ClCompile Include="sktoolslib_mod\DropFiles.cpp" />
<ClCompile Include="sktoolslib_mod\EditDoubleClick.cpp" />
<ClCompile Include="sktoolslib_mod\FileDropTarget.cpp" />
<ClCompile Include="sktoolslib_mod\Hash.cpp" />
<ClCompile Include="sktoolslib_mod\hyperlink.cpp" />
<ClCompile Include="sktoolslib_mod\Language.cpp" />
<ClCompile Include="sktoolslib_mod\Monitor.cpp" />
<ClCompile Include="sktoolslib_mod\PathUtils.cpp" />
<ClCompile Include="sktoolslib_mod\PreserveChdir.cpp" />
<ClCompile Include="sktoolslib_mod\RegHistory.cpp" />
@ -223,6 +225,7 @@
<ClCompile Include="sktoolslib_mod\StringUtils.cpp" />
<ClCompile Include="sktoolslib_mod\SysImageList.cpp" />
<ClCompile Include="sktoolslib_mod\SysInfo.cpp" />
<ClCompile Include="sktoolslib_mod\TempFile.cpp" />
<ClCompile Include="sktoolslib_mod\TextFile.cpp" />
<ClCompile Include="sktoolslib_mod\UnicodeUtils.cpp" />
<ClCompile Include="src\AboutDlg.cpp" />
@ -259,10 +262,11 @@
<ClInclude Include="sktoolslib_mod\DropFiles.h" />
<ClInclude Include="sktoolslib_mod\EditDoubleClick.h" />
<ClInclude Include="sktoolslib_mod\FileDropTarget.h" />
<ClInclude Include="sktoolslib_mod\Hash.h" />
<ClInclude Include="sktoolslib_mod\hyperlink.h" />
<ClInclude Include="sktoolslib_mod\Language.h" />
<ClInclude Include="sktoolslib_mod\maxpath.h" />
<ClInclude Include="sktoolslib_mod\OnOutOfScope.h" />
<ClInclude Include="sktoolslib_mod\Monitor.h" />
<ClInclude Include="sktoolslib_mod\PathUtils.h" />
<ClInclude Include="sktoolslib_mod\PreserveChdir.h" />
<ClInclude Include="sktoolslib_mod\RegHistory.h" />

View File

@ -114,9 +114,6 @@
<ClCompile Include="sktoolslib_mod\FileDropTarget.cpp">
<Filter>sktoolslib_mod</Filter>
</ClCompile>
<ClCompile Include="sktoolslib_mod\hyperlink.cpp">
<Filter>sktoolslib_mod</Filter>
</ClCompile>
<ClCompile Include="sktoolslib_mod\Language.cpp">
<Filter>sktoolslib_mod</Filter>
</ClCompile>
@ -150,6 +147,18 @@
<ClCompile Include="sktoolslib_mod\PreserveChdir.cpp">
<Filter>sktoolslib_mod</Filter>
</ClCompile>
<ClCompile Include="sktoolslib_mod\Hash.cpp">
<Filter>sktoolslib_mod</Filter>
</ClCompile>
<ClCompile Include="sktoolslib_mod\Monitor.cpp">
<Filter>sktoolslib_mod</Filter>
</ClCompile>
<ClCompile Include="sktoolslib_mod\TempFile.cpp">
<Filter>sktoolslib_mod</Filter>
</ClCompile>
<ClCompile Include="sktoolslib_mod\hyperlink.cpp">
<Filter>sktoolslib_mod</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\AboutDlg.h">
@ -245,9 +254,6 @@
<ClInclude Include="sktoolslib_mod\FileDropTarget.h">
<Filter>sktoolslib_mod</Filter>
</ClInclude>
<ClInclude Include="sktoolslib_mod\hyperlink.h">
<Filter>sktoolslib_mod</Filter>
</ClInclude>
<ClInclude Include="sktoolslib_mod\Language.h">
<Filter>sktoolslib_mod</Filter>
</ClInclude>
@ -296,12 +302,18 @@
<ClInclude Include="src\COMPtrs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sktoolslib_mod\OnOutOfScope.h">
<Filter>sktoolslib_mod</Filter>
</ClInclude>
<ClInclude Include="src\last\version.h">
<Filter>Header Files\last</Filter>
</ClInclude>
<ClInclude Include="sktoolslib_mod\Hash.h">
<Filter>sktoolslib_mod</Filter>
</ClInclude>
<ClInclude Include="sktoolslib_mod\Monitor.h">
<Filter>sktoolslib_mod</Filter>
</ClInclude>
<ClInclude Include="sktoolslib_mod\hyperlink.h">
<Filter>sktoolslib_mod</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="default.build">

View File

@ -61,7 +61,7 @@ public:
}
/// Inherited via IUIAnimationTimerEventHandler
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void ** ppvObject) override
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override
{
if (ppvObject == nullptr)
return E_POINTER;
@ -94,7 +94,6 @@ public:
return ref;
}
virtual HRESULT STDMETHODCALLTYPE OnPreUpdate(void) override
{
return S_OK;
@ -113,7 +112,7 @@ public:
}
private:
std::map<IUIAnimationStoryboard *, std::function<void()>> callbacks;
std::map<IUIAnimationStoryboard*, std::function<void()>> callbacks;
unsigned long ref;
};
@ -135,7 +134,7 @@ public:
}
/// Sets the timer object event handler
void SetTimerObj(CTimerEventHandler * handler)
void SetTimerObj(CTimerEventHandler* handler)
{
if (timerEventHandler)
timerEventHandler->Release();
@ -145,7 +144,7 @@ public:
}
/// Inherited via IUIAnimationStoryboardEventHandler
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void ** ppvObject) override
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override
{
if (ppvObject == nullptr)
return E_POINTER;
@ -178,7 +177,6 @@ public:
return ref;
}
/// IUIAnimationStoryboardEventHandler Interface implementation
HRESULT STDMETHODCALLTYPE OnStoryboardStatusChanged(IUIAnimationStoryboard* storyboard,
UI_ANIMATION_STORYBOARD_STATUS newStatus,
@ -203,72 +201,104 @@ public:
return S_OK;
}
private:
CTimerEventHandler * timerEventHandler;
CTimerEventHandler* timerEventHandler;
unsigned long ref;
};
IUIAnimationVariablePtr Animator::CreateAnimationVariable(double start)
AnimationVariable Animator::CreateAnimationVariable(double start, double defValue)
{
AnimationVariable var;
var.m_defaultValue = defValue;
if (pAnimMgr)
{
IUIAnimationVariablePtr pAnimVar = nullptr;
if (SUCCEEDED(pAnimMgr->CreateAnimationVariable(start, &pAnimVar)))
return pAnimVar;
return nullptr;
{
var.m_animVar = pAnimVar;
}
}
return var;
}
INT32 Animator::GetIntegerValue(IUIAnimationVariablePtr var)
INT32 Animator::GetIntegerValue(AnimationVariable& var)
{
INT32 val;
var->GetIntegerValue(&val);
if (var.m_animVar)
{
INT32 val = 0;
if (SUCCEEDED(var.m_animVar->GetIntegerValue(&val)))
return val;
}
return (INT32)var.m_defaultValue;
}
double Animator::GetValue(IUIAnimationVariablePtr var)
double Animator::GetValue(AnimationVariable& var)
{
double val;
var->GetValue(&val);
if (var.m_animVar)
{
double val = 0.0;
if (SUCCEEDED(var.m_animVar->GetValue(&val)))
return val;
}
return var.m_defaultValue;
}
IUIAnimationTransitionPtr Animator::CreateAccelerateDecelerateTransition(UI_ANIMATION_SECONDS duration, double finalValue, double accelerationRatio, double decelerationRatio)
IUIAnimationTransitionPtr Animator::CreateAccelerateDecelerateTransition(AnimationVariable& var, UI_ANIMATION_SECONDS duration, double finalValue, double accelerationRatio, double decelerationRatio)
{
var.m_defaultValue = finalValue;
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateAccelerateDecelerateTransition(duration, finalValue, accelerationRatio, decelerationRatio, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateSmoothStopTransition(UI_ANIMATION_SECONDS duration, double finalValue)
IUIAnimationTransitionPtr Animator::CreateSmoothStopTransition(AnimationVariable& var, UI_ANIMATION_SECONDS duration, double finalValue)
{
var.m_defaultValue = finalValue;
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateSmoothStopTransition(duration, finalValue, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateParabolicTransitionFromAcceleration(double finalValue, double finalVelocity, double acceleration)
IUIAnimationTransitionPtr Animator::CreateParabolicTransitionFromAcceleration(AnimationVariable& var, double finalValue, double finalVelocity, double acceleration)
{
var.m_defaultValue = finalValue;
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateParabolicTransitionFromAcceleration(finalValue, finalVelocity, acceleration, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateCubicTransition(UI_ANIMATION_SECONDS maximumDuration, double finalValue, double finalVelocity)
IUIAnimationTransitionPtr Animator::CreateCubicTransition(AnimationVariable& var, UI_ANIMATION_SECONDS maximumDuration, double finalValue, double finalVelocity)
{
var.m_defaultValue = finalValue;
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateCubicTransition(maximumDuration, finalValue, finalVelocity, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateReversalTransition(UI_ANIMATION_SECONDS duration)
{
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateReversalTransition(duration, &trans)))
return trans;
}
return nullptr;
}
@ -278,65 +308,93 @@ IUIAnimationTransitionPtr Animator::CreateSinusoidalTransitionFromRange(UI_ANIMA
UI_ANIMATION_SECONDS period,
UI_ANIMATION_SLOPE slope)
{
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateSinusoidalTransitionFromRange(duration, minimumValue, maximumValue, period, slope, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateSinusoidalTransitionFromVelocity(UI_ANIMATION_SECONDS duration, UI_ANIMATION_SECONDS period)
{
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateSinusoidalTransitionFromVelocity(duration, period, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateLinearTransitionFromSpeed(double speed, double finalValue)
IUIAnimationTransitionPtr Animator::CreateLinearTransitionFromSpeed(AnimationVariable& var, double speed, double finalValue)
{
var.m_defaultValue = finalValue;
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateLinearTransitionFromSpeed(speed, finalValue, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateLinearTransition(UI_ANIMATION_SECONDS duration, double finalValue)
IUIAnimationTransitionPtr Animator::CreateLinearTransition(AnimationVariable& var, UI_ANIMATION_SECONDS duration, double finalValue)
{
var.m_defaultValue = finalValue;
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateLinearTransition(duration, finalValue, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateDiscreteTransition(UI_ANIMATION_SECONDS delay, double finalValue, UI_ANIMATION_SECONDS hold)
IUIAnimationTransitionPtr Animator::CreateDiscreteTransition(AnimationVariable& var, UI_ANIMATION_SECONDS delay, double finalValue, UI_ANIMATION_SECONDS hold)
{
var.m_defaultValue = finalValue;
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateDiscreteTransition(delay, finalValue, hold, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateConstantTransition(UI_ANIMATION_SECONDS duration)
{
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateConstantTransition(duration, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationTransitionPtr Animator::CreateInstantaneousTransition(double finalValue)
IUIAnimationTransitionPtr Animator::CreateInstantaneousTransition(AnimationVariable& var, double finalValue)
{
var.m_defaultValue = finalValue;
if (pTransLib)
{
IUIAnimationTransitionPtr trans;
if (SUCCEEDED(pTransLib->CreateInstantaneousTransition(finalValue, &trans)))
return trans;
}
return nullptr;
}
IUIAnimationStoryboardPtr Animator::CreateStoryBoard()
{
if (pAnimMgr)
{
IUIAnimationStoryboardPtr storyBoard;
if (SUCCEEDED(pAnimMgr->CreateStoryboard(&storyBoard)))
return storyBoard;
}
return nullptr;
}
@ -351,6 +409,8 @@ HRESULT Animator::RunStoryBoard(IUIAnimationStoryboardPtr storyBoard, std::funct
storyBoard->SetStoryboardEventHandler(notificationAnimEvHandler);
}
if (pAnimTmr)
{
// start the animation
UI_ANIMATION_SECONDS secs = 0;
pAnimTmr->GetTime(&secs);
@ -360,11 +420,15 @@ HRESULT Animator::RunStoryBoard(IUIAnimationStoryboardPtr storyBoard, std::funct
if (pAnimTmr->IsEnabled() != S_OK)
pAnimTmr->Enable();
return hr;
}
return E_FAIL;
}
HRESULT Animator::AbandonAllStoryBoards()
{
if (pAnimMgr)
return pAnimMgr->AbandonAllStoryboards();
return E_FAIL;
}
Animator::Animator()
@ -410,12 +474,14 @@ Animator::Animator()
Animator::~Animator()
{
// release the timer event handler object (CTimerEventHandler)
if (pAnimTmr)
pAnimTmr->SetTimerEventHandler(nullptr);
// shut down the animation manager: No methods can be called on any animation object after Shutdown
if (pAnimMgr)
pAnimMgr->Shutdown();
}
Animator & Animator::Instance()
Animator& Animator::Instance()
{
if (instance == nullptr)
instance.reset(new Animator());
@ -433,4 +499,3 @@ bool Animator::IsInstanceActive()
}
std::unique_ptr<Animator> Animator::instance = nullptr;

View File

@ -74,6 +74,14 @@ _COM_SMARTPTR_TYPEDEF(IUIAnimationTransition, __uuidof(IUIAnimationTransition));
class CTimerEventHandler;
class AnimationVariable
{
public:
IUIAnimationVariablePtr m_animVar;
double m_defaultValue;
};
class Animator
{
public:
@ -88,22 +96,22 @@ public:
Animator& operator=(const Animator&) = delete;
IUIAnimationVariablePtr CreateAnimationVariable(double start);
static INT32 GetIntegerValue(IUIAnimationVariablePtr var);
static double GetValue(IUIAnimationVariablePtr var);
AnimationVariable CreateAnimationVariable(double start, double defValue);
static INT32 GetIntegerValue(AnimationVariable& var);
static double GetValue(AnimationVariable& var);
IUIAnimationTransitionPtr CreateAccelerateDecelerateTransition(UI_ANIMATION_SECONDS duration, double finalValue, double accelerationRatio = 0.4, double decelerationRatio = 0.4);
IUIAnimationTransitionPtr CreateSmoothStopTransition(UI_ANIMATION_SECONDS duration, double finalValue);
IUIAnimationTransitionPtr CreateParabolicTransitionFromAcceleration(double finalValue, double finalVelocity, double acceleration);
IUIAnimationTransitionPtr CreateCubicTransition(UI_ANIMATION_SECONDS maximumDuration, double finalValue, double finalVelocity);
IUIAnimationTransitionPtr CreateAccelerateDecelerateTransition(AnimationVariable& var, UI_ANIMATION_SECONDS duration, double finalValue, double accelerationRatio = 0.4, double decelerationRatio = 0.4);
IUIAnimationTransitionPtr CreateSmoothStopTransition(AnimationVariable& var, UI_ANIMATION_SECONDS duration, double finalValue);
IUIAnimationTransitionPtr CreateParabolicTransitionFromAcceleration(AnimationVariable& var, double finalValue, double finalVelocity, double acceleration);
IUIAnimationTransitionPtr CreateCubicTransition(AnimationVariable& var, UI_ANIMATION_SECONDS maximumDuration, double finalValue, double finalVelocity);
IUIAnimationTransitionPtr CreateReversalTransition(UI_ANIMATION_SECONDS duration);
IUIAnimationTransitionPtr CreateSinusoidalTransitionFromRange(UI_ANIMATION_SECONDS duration, double minimumValue, double maximumValue, UI_ANIMATION_SECONDS period, UI_ANIMATION_SLOPE slope);
IUIAnimationTransitionPtr CreateSinusoidalTransitionFromVelocity(UI_ANIMATION_SECONDS duration, UI_ANIMATION_SECONDS period);
IUIAnimationTransitionPtr CreateLinearTransitionFromSpeed(double speed, double finalValue);
IUIAnimationTransitionPtr CreateLinearTransition(UI_ANIMATION_SECONDS duration, double finalValue);
IUIAnimationTransitionPtr CreateDiscreteTransition(UI_ANIMATION_SECONDS delay, double finalValue, UI_ANIMATION_SECONDS hold);
IUIAnimationTransitionPtr CreateLinearTransitionFromSpeed(AnimationVariable& var, double speed, double finalValue);
IUIAnimationTransitionPtr CreateLinearTransition(AnimationVariable& var, UI_ANIMATION_SECONDS duration, double finalValue);
IUIAnimationTransitionPtr CreateDiscreteTransition(AnimationVariable& var, UI_ANIMATION_SECONDS delay, double finalValue, UI_ANIMATION_SECONDS hold);
IUIAnimationTransitionPtr CreateConstantTransition(UI_ANIMATION_SECONDS duration);
IUIAnimationTransitionPtr CreateInstantaneousTransition(double finalValue);
IUIAnimationTransitionPtr CreateInstantaneousTransition(AnimationVariable& var, double finalValue);
IUIAnimationStoryboardPtr CreateStoryBoard();

View File

@ -0,0 +1,88 @@
// sktoolslib - common files for SK tools
// Copyright (C) 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#include "stdafx.h"
#include "Hash.h"
std::wstring GetHashText(const void* data, const size_t data_size, HashType hashType)
{
HCRYPTPROV hProv = NULL;
if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
{
return {};
}
BOOL hash_ok = FALSE;
HCRYPTPROV hHash = NULL;
switch (hashType)
{
case HashType::HashSha1:
hash_ok = CryptCreateHash(hProv, CALG_SHA1, 0, 0, &hHash);
break;
case HashType::HashMd5:
hash_ok = CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash);
break;
case HashType::HashSha256:
hash_ok = CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash);
break;
}
if (!hash_ok)
{
CryptReleaseContext(hProv, 0);
return {};
}
if (!CryptHashData(hHash, static_cast<const BYTE*>(data), static_cast<DWORD>(data_size), 0))
{
CryptDestroyHash(hHash);
CryptReleaseContext(hProv, 0);
return {};
}
DWORD cbHashSize = 0, dwCount = sizeof(DWORD);
if (!CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashSize, &dwCount, 0))
{
CryptDestroyHash(hHash);
CryptReleaseContext(hProv, 0);
return {};
}
std::vector<BYTE> buffer(cbHashSize);
if (!CryptGetHashParam(hHash, HP_HASHVAL, reinterpret_cast<BYTE*>(&buffer[0]), &cbHashSize, 0))
{
CryptDestroyHash(hHash);
CryptReleaseContext(hProv, 0);
return {};
}
std::wostringstream oss;
oss.fill('0');
oss.width(2);
for (const auto& b : buffer)
{
oss << std::hex << static_cast<const int>(b);
}
CryptDestroyHash(hHash);
CryptReleaseContext(hProv, 0);
return oss.str();
}

View File

@ -0,0 +1,33 @@
// sktoolslib - common files for SK tools
// Copyright (C) 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#pragma once
#include <Wincrypt.h>
#include <string>
#include <vector>
#include <sstream>
enum class HashType
{
HashSha1,
HashMd5,
HashSha256
};
std::wstring GetHashText(const void* data, const size_t data_size, HashType hashType);

View File

@ -0,0 +1,50 @@
// sktoolslib - common files for SK tools
// Copyright (C) 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#include "stdafx.h"
#include "Monitor.h"
static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC /*hdc*/, LPRECT lprcMonitor, LPARAM pData)
{
MONITORINFOEX miex{};
miex.cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(hMon, &miex);
if (miex.dwFlags == DISPLAY_DEVICE_MIRRORING_DRIVER)
{
return TRUE;
}
std::vector<RECT>* pMonRects = reinterpret_cast<std::vector<RECT>*>(pData);
pMonRects->push_back(*lprcMonitor);
return TRUE;
}
std::wstring GetMonitorSetupHash()
{
std::vector<RECT> monRects;
EnumDisplayMonitors(0, 0, MonitorEnum, (LPARAM)&monRects);
std::sort(monRects.begin(), monRects.end(),
[](const RECT& a, const RECT& b) -> bool {
if (a.left == b.left)
return a.top < b.top;
return a.left < b.left;
});
return GetHashText(monRects.data(), monRects.size() * sizeof(RECT), HashType::HashMd5);
}

View File

@ -0,0 +1,26 @@
// sktoolslib - common files for SK tools
// Copyright (C) 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#pragma once
#include "Hash.h"
#include <string>
#include <vector>
#include <algorithm>
std::wstring GetMonitorSetupHash();

View File

@ -19,7 +19,6 @@
#pragma once
#include <string>
#include <memory>
#include <tchar.h>
#include "shlwapi.h"
#include "FormatMessageWrapper.h"
@ -432,8 +431,7 @@ void CRegTypedBase<T, Base>::write()
HKEY hKey = nullptr;
DWORD disp = 0;
WCHAR empty[1] = {L'\0'};
if ((Base::LastError = RegCreateKeyEx(Base::m_base, Base::GetPlainString(Base::m_path), 0, empty, REG_OPTION_NON_VOLATILE, KEY_WRITE | Base::m_sam, nullptr, &hKey, &disp)) != ERROR_SUCCESS)
if ((Base::LastError = RegCreateKeyEx(Base::m_base, Base::GetPlainString(Base::m_path), 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE | Base::m_sam, nullptr, &hKey, &disp)) != ERROR_SUCCESS)
{
return;
}
@ -982,7 +980,7 @@ public:
~CKeyList()
{
for (typename TElements::iterator iter = elements.begin(), end = elements.end(); iter != end; ++iter)
for (auto iter = elements.begin(), end = elements.end(); iter != end; ++iter)
{
delete iter->second;
}
@ -1021,19 +1019,17 @@ public:
template <class T>
const typename T::ValueT& CKeyList<T>::GetDefault(int index) const
{
typename TDefaults::const_iterator iter = defaults.find(index);
auto iter = defaults.find(index);
return iter == defaults.end() ? defaultValue : iter->second;
}
template <class T>
T& CKeyList<T>::GetAt(int index) const
{
typename TElements::iterator iter = elements.find(index);
auto iter = elements.find(index);
if (iter == elements.end())
{
wchar_t buffer[10];
_itot_s(index, buffer, 10);
typename T::StringT indexKey = key + _T('\\') + buffer;
typename T::StringT indexKey = key + '\\' + std::to_wstring(index);
T* newElement = new T(indexKey, GetDefault(index), false, base);
iter = elements.insert(std::make_pair(index, newElement)).first;

View File

@ -101,14 +101,14 @@ bool CRichStatusBar::SetPart(int index, const CRichStatusBarItem& item, bool red
{
m_parts.push_back(std::move(CRichStatusBarItem()));
m_partwidths.push_back({});
m_AnimVars.push_back(Animator::Instance().CreateAnimationVariable(0.0));
m_AnimVars.push_back(Animator::Instance().CreateAnimationVariable(0.0, 0.0));
}
}
if (index < 0)
{
m_parts.push_back(item);
m_partwidths.push_back({});
m_AnimVars.push_back(Animator::Instance().CreateAnimationVariable(0.0));
m_AnimVars.push_back(Animator::Instance().CreateAnimationVariable(0.0, 0.0));
index = (int)m_parts.size() - 1;
}
else if (replace)
@ -119,7 +119,7 @@ bool CRichStatusBar::SetPart(int index, const CRichStatusBarItem& item, bool red
{
m_parts.insert(m_parts.begin() + index - 1, item);
m_partwidths.insert(m_partwidths.begin() + index - 1, {});
m_AnimVars.insert(m_AnimVars.begin() + index - 1, Animator::Instance().CreateAnimationVariable(0.0));
m_AnimVars.insert(m_AnimVars.begin() + index - 1, Animator::Instance().CreateAnimationVariable(0.0, 1.0));
}
CalcRequestedWidths(index);
if (redraw)
@ -365,22 +365,32 @@ LRESULT CRichStatusBar::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
{
if ((m_hoverPart >= 0) && m_parts[m_hoverPart].hoverActive)
{
auto transHot = Animator::Instance().CreateLinearTransition(0.3, 1.0);
auto transHot = Animator::Instance().CreateLinearTransition(m_AnimVars[m_hoverPart], 0.3, 1.0);
auto storyBoard = Animator::Instance().CreateStoryBoard();
storyBoard->AddTransition(m_AnimVars[m_hoverPart], transHot);
if (storyBoard && transHot)
{
storyBoard->AddTransition(m_AnimVars[m_hoverPart].m_animVar, transHot);
Animator::Instance().RunStoryBoard(storyBoard, [this]() {
InvalidateRect(*this, nullptr, false);
});
}
else
InvalidateRect(*this, nullptr, false);
}
if (oldHover >= 0)
{
auto transHot = Animator::Instance().CreateLinearTransition(0.3, 0.0);
auto transHot = Animator::Instance().CreateLinearTransition(m_AnimVars[oldHover], 0.3, 0.0);
auto storyBoard = Animator::Instance().CreateStoryBoard();
storyBoard->AddTransition(m_AnimVars[oldHover], transHot);
if (storyBoard && transHot)
{
storyBoard->AddTransition(m_AnimVars[oldHover].m_animVar, transHot);
Animator::Instance().RunStoryBoard(storyBoard, [this]() {
InvalidateRect(*this, nullptr, false);
});
}
else
InvalidateRect(*this, nullptr, false);
}
}
}
break;
@ -393,12 +403,17 @@ LRESULT CRichStatusBar::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
TrackMouseEvent(&tme);
if (m_hoverPart >= 0)
{
auto transHot = Animator::Instance().CreateLinearTransition(0.3, 0.0);
auto transHot = Animator::Instance().CreateLinearTransition(m_AnimVars[m_hoverPart], 0.3, 0.0);
auto storyBoard = Animator::Instance().CreateStoryBoard();
storyBoard->AddTransition(m_AnimVars[m_hoverPart], transHot);
if (storyBoard && transHot)
{
storyBoard->AddTransition(m_AnimVars[m_hoverPart].m_animVar, transHot);
Animator::Instance().RunStoryBoard(storyBoard, [this]() {
InvalidateRect(*this, nullptr, false);
});
}
else
InvalidateRect(*this, nullptr, false);
}
m_hoverPart = -1;
}

View File

@ -138,5 +138,5 @@ private:
int m_hoverPart;
int m_height;
bool m_drawGrip;
std::vector<IUIAnimationVariablePtr> m_AnimVars;
std::vector<AnimationVariable> m_AnimVars;
};

View File

@ -550,7 +550,7 @@ bool CTextFile::CalculateLines(volatile LONG *bCancelled)
long CTextFile::LineFromPosition(long pos) const
{
auto lb = std::lower_bound(linepositions.begin(), linepositions.end(), static_cast<size_t>(pos));
auto lb = std::lower_bound(linepositions.begin(), linepositions.end(), (size_t)pos);
auto lbLine = lb - linepositions.begin();
return long(lbLine + 1);
}

View File

@ -41,6 +41,7 @@
#include "Settings.h"
#include "SysInfo.h"
#include "Language.h"
#include "Monitor.h"
#include "SmartHandle.h"
#include "PathUtils.h"
#include "DebugOutput.h"
@ -53,6 +54,7 @@
#ifdef NP3_ALLOW_UPDATE
#include "TempFile.h"
#include "Monitor.h"
#include "version.h"
#endif
@ -535,9 +537,11 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
WINDOWPLACEMENT wpl = {0};
DWORD size = sizeof(wpl);
std::wstring winPosKey = L"windowpos_" + GetMonitorSetupHash();
if (bPortable)
{
std::wstring sPos = g_iniFile.GetValue(L"global", L"windowpos", L"");
std::wstring sPos = g_iniFile.GetValue(L"global", winPosKey.c_str(), L"");
if (!sPos.empty())
{
@ -558,7 +562,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
}
else
{
if (SHGetValue(HKEY_CURRENT_USER, L"Software\\grepWinNP3", L"windowpos", REG_NONE, &wpl, &size) == ERROR_SUCCESS)
if (SHGetValue(HKEY_CURRENT_USER, L"Software\\grepWinNP3", winPosKey.c_str(), REG_NONE, &wpl, &size) == ERROR_SUCCESS)
SetWindowPlacement(*this, &wpl);
else
ShowWindow(*this, SW_SHOW);
@ -1714,6 +1718,7 @@ void CSearchDlg::SaveWndPosition()
WINDOWPLACEMENT wpl = {0};
wpl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(*this, &wpl);
std::wstring winPosKey = L"windowpos_" + GetMonitorSetupHash();
if (bPortable)
{
auto sPos = CStringUtils::Format(L"%d;%d;%d;%d;%d;%d;%d;%d;%d;%d",
@ -1721,11 +1726,11 @@ void CSearchDlg::SaveWndPosition()
wpl.ptMinPosition.x, wpl.ptMinPosition.y,
wpl.ptMaxPosition.x, wpl.ptMaxPosition.y,
wpl.rcNormalPosition.left, wpl.rcNormalPosition.top, wpl.rcNormalPosition.right, wpl.rcNormalPosition.bottom);
g_iniFile.SetValue(L"global", L"windowpos", sPos.c_str());
g_iniFile.SetValue(L"global", winPosKey.c_str(), sPos.c_str());
}
else
{
SHSetValue(HKEY_CURRENT_USER, L"Software\\grepWinNP3", L"windowpos", REG_NONE, &wpl, sizeof(wpl));
SHSetValue(HKEY_CURRENT_USER, L"Software\\grepWinNP3", winPosKey.c_str(), REG_NONE, &wpl, sizeof(wpl));
}
}

View File

@ -1271,7 +1271,7 @@ void DrawRect(LPRECT prc, HDC hdcPaint, Gdiplus::DashStyle dashStyle, Gdiplus::C
std::unique_ptr<Gdiplus::Graphics> myGraphics(new Gdiplus::Graphics(hdcPaint));
myGraphics->DrawRectangle(myPen.get(), (INT)prc->left, (INT)prc->top,
(INT)(prc->right - 1 - prc->left), (INT)(prc->bottom - 1 - prc->top));
INT(prc->right - 1 - prc->left), INT(prc->bottom - 1 - prc->top));
}
void DrawFocusRect(LPRECT prcFocus, HDC hdcPaint)

View File

@ -6,13 +6,13 @@
//#pragma message(__LOC__"Run the NAnt script to get proper version info")
#define FILEVER 2, 1, 4, 31
#define PRODUCTVER 2, 1, 4, 31
#define STRFILEVER "2.1.4.31\0"
#define STRPRODUCTVER "2.1.4.31\0"
#define FILEVER 2, 1, 4, 32
#define PRODUCTVER 2, 1, 4, 32
#define STRFILEVER "2.1.4.32\0"
#define STRPRODUCTVER "2.1.4.32\0"
#define GREPWIN_VERMAJOR 2
#define GREPWIN_VERMINOR 1
#define GREPWIN_VERMICRO 4
#define GREPWIN_VERBUILD 31
#define GREPWIN_VERDATE "2020-11-16"
#define GREPWIN_VERBUILD 32
#define GREPWIN_VERDATE "2020-12-14"