suit code style

This commit is contained in:
Sophanatprime 2024-11-12 14:47:28 +08:00
parent 004ddd0827
commit 85c8ca2a98
7 changed files with 25 additions and 23 deletions

View File

@ -69,7 +69,8 @@ MonitorInfo MonitorInfo::GetFromPoint(int32_t x, int32_t y)
return MonitorInfo::MonitorInfo(monitor); return MonitorInfo::MonitorInfo(monitor);
} }
MonitorInfo::Size MonitorInfo::GetSize(const MONITORINFOEX& monitorInfoEx) { MonitorInfo::Size MonitorInfo::GetSize(const MONITORINFOEX& monitorInfoEx)
{
Size size = {}; Size size = {};
auto device_name = PCTSTR(monitorInfoEx.szDevice); auto device_name = PCTSTR(monitorInfoEx.szDevice);

View File

@ -19,17 +19,17 @@ namespace
{ {
switch (mode) switch (mode)
{ {
case MeasureToolState::Mode::Cross: case MeasureToolState::Mode::Cross:
return { true, true }; return { true, true };
case MeasureToolState::Mode::Vertical: case MeasureToolState::Mode::Vertical:
return { false, true }; return { false, true };
case MeasureToolState::Mode::Horizontal: case MeasureToolState::Mode::Horizontal:
return { true, false }; return { true, false };
default: default:
throw std::runtime_error("Unknown MeasureToolState Mode"); throw std::runtime_error("Unknown MeasureToolState Mode");
} }
} }
@ -77,7 +77,7 @@ namespace
CopyToClipboard(window, *toolState); CopyToClipboard(window, *toolState);
auto& perScreen = toolState->perScreen[window]; auto& perScreen = toolState->perScreen[window];
const bool shiftPress = GetKeyState(VK_SHIFT) & 0x8000; const bool shiftPress = GetKeyState(VK_SHIFT) & 0x8000;
if (shiftPress && perScreen.measuredEdges) if (shiftPress && perScreen.measuredEdges)
{ {

View File

@ -95,8 +95,7 @@ Measurement::PrintResult Measurement::Print(wchar_t* buf,
auto print = [=, &result](Measurement::Unit unit, const bool paren) { auto print = [=, &result](Measurement::Unit unit, const bool paren) {
if (paren) if (paren)
{ {
result.strLen += swprintf_s(buf + result.strLen, bufSize - result.strLen, result.strLen += swprintf_s(buf + result.strLen, bufSize - result.strLen, printWidth && printHeight ? L"\n(" : L" (");
printWidth && printHeight ? L"\n(" : L" (");
} }
if (printWidth) if (printWidth)
{ {
@ -150,8 +149,10 @@ Measurement::PrintResult Measurement::Print(wchar_t* buf,
int count = 0; int count = 0;
const Measurement::Unit allUnits[] = { const Measurement::Unit allUnits[] = {
Measurement::Unit::Pixel, Measurement::Unit::Millimetre, Measurement::Unit::Pixel,
Measurement::Unit::Inch, Measurement::Unit::Centimetre, Measurement::Unit::Millimetre,
Measurement::Unit::Inch,
Measurement::Unit::Centimetre,
}; };
// We only use two units at most, it would be to long otherwise. // We only use two units at most, it would be to long otherwise.
for each (Measurement::Unit unit in allUnits) for each (Measurement::Unit unit in allUnits)
@ -159,7 +160,8 @@ Measurement::PrintResult Measurement::Print(wchar_t* buf,
if ((unit & units) == unit) if ((unit & units) == unit)
{ {
count += 1; count += 1;
if (count > 2) break; if (count > 2)
break;
print(unit, count != 1); print(unit, count != 1);
} }
} }
@ -205,4 +207,3 @@ void Measurement::PrintToStream(std::wostream& stream,
break; break;
} }
} }

View File

@ -42,8 +42,8 @@ struct Measurement
const int units) const; const int units) const;
void PrintToStream(std::wostream& stream, void PrintToStream(std::wostream& stream,
const bool prependNewLine, const bool prependNewLine,
const bool printWidth, const bool printWidth,
const bool printHeight, const bool printHeight,
const Unit units) const; const Unit units) const;
}; };

View File

@ -45,7 +45,7 @@ namespace winrt::PowerToys::MeasureToolCore::implementation
wil::shared_event _stopMouseCaptureThreadSignal; wil::shared_event _stopMouseCaptureThreadSignal;
std::thread _mouseCaptureThread; std::thread _mouseCaptureThread;
std::vector<std::thread> _screenCaptureThreads; std::vector<std::thread> _screenCaptureThreads;
std::vector<std::unique_ptr<OverlayUIState>> _overlayUIStates; std::vector<std::unique_ptr<OverlayUIState>> _overlayUIStates;
Serialized<MeasureToolState> _measureToolState; Serialized<MeasureToolState> _measureToolState;
BoundsToolState _boundsToolState; BoundsToolState _boundsToolState;

View File

@ -79,6 +79,6 @@ Settings Settings::LoadFromFile()
catch (...) catch (...)
{ {
} }
return result; return result;
} }

View File

@ -65,7 +65,7 @@
</tkcontrols:SettingsCard> </tkcontrols:SettingsCard>
<tkcontrols:SettingsCard x:Uid="MeasureTool_UnitsOfMeasure" HeaderIcon="{ui:FontIcon Glyph=&#xECC6;}"> <tkcontrols:SettingsCard x:Uid="MeasureTool_UnitsOfMeasure" HeaderIcon="{ui:FontIcon Glyph=&#xECC6;}">
<ComboBox SelectedIndex="{x:Bind Path=ViewModel.UnitsOfMeasure, Mode=TwoWay}" MinWidth="{StaticResource SettingActionControlMinWidth}"> <ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Path=ViewModel.UnitsOfMeasure, Mode=TwoWay}">
<ComboBoxItem x:Uid="MeasureTool_UnitsOfMeasure_Pixels" /> <ComboBoxItem x:Uid="MeasureTool_UnitsOfMeasure_Pixels" />
<ComboBoxItem x:Uid="MeasureTool_UnitsOfMeasure_Inches" /> <ComboBoxItem x:Uid="MeasureTool_UnitsOfMeasure_Inches" />
<ComboBoxItem x:Uid="MeasureTool_UnitsOfMeasure_Centimeters" /> <ComboBoxItem x:Uid="MeasureTool_UnitsOfMeasure_Centimeters" />