mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 02:09:24 +08:00
suit code style
This commit is contained in:
parent
004ddd0827
commit
85c8ca2a98
@ -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);
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
@ -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;
|
||||||
|
@ -79,6 +79,6 @@ Settings Settings::LoadFromFile()
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
</tkcontrols:SettingsCard>
|
</tkcontrols:SettingsCard>
|
||||||
|
|
||||||
<tkcontrols:SettingsCard x:Uid="MeasureTool_UnitsOfMeasure" HeaderIcon="{ui:FontIcon Glyph=}">
|
<tkcontrols:SettingsCard x:Uid="MeasureTool_UnitsOfMeasure" HeaderIcon="{ui:FontIcon Glyph=}">
|
||||||
<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" />
|
||||||
|
Loading…
Reference in New Issue
Block a user