mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
feat: 添加 BoolToNegativeVisibilityConverter
This commit is contained in:
parent
131438ea98
commit
f4fa5092d7
15 changed files with 82 additions and 20 deletions
|
|
@ -1,3 +1,5 @@
|
|||
#include "BoolNegationConverter.idl"
|
||||
#include "BoolToNegativeVisibilityConverter.idl"
|
||||
#include "LoggerHelper.idl"
|
||||
#include "TextBlockHelper.idl"
|
||||
#include "CandidateWindowItem.idl"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<local:BoolNegationConverter x:Key="NegationConverter" />
|
||||
<local:BoolToNegativeVisibilityConverter x:Key="NegativeVisibilityConverter" />
|
||||
|
||||
<Style x:Key="ToggleSwitchWithoutText"
|
||||
BasedOn="{StaticResource DefaultToggleSwitchStyle}"
|
||||
|
|
|
|||
|
|
@ -5,13 +5,17 @@
|
|||
#endif
|
||||
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Windows::UI::Xaml::Interop;
|
||||
|
||||
|
||||
namespace winrt::Magpie::UI::implementation {
|
||||
|
||||
IInspectable BoolNegationConverter::Convert(IInspectable const& value, Interop::TypeName const&, IInspectable const&, hstring const&) {
|
||||
IInspectable BoolNegationConverter::Convert(IInspectable const& value, TypeName const&, IInspectable const&, hstring const&) {
|
||||
return box_value(!unbox_value<bool>(value));
|
||||
}
|
||||
|
||||
IInspectable BoolNegationConverter::ConvertBack(IInspectable const& value, Interop::TypeName const&, IInspectable const&, hstring const&) {
|
||||
IInspectable BoolNegationConverter::ConvertBack(IInspectable const& value, TypeName const&, IInspectable const&, hstring const&) {
|
||||
return box_value(!unbox_value<bool>(value));
|
||||
}
|
||||
|
||||
|
|
|
|||
22
src/Magpie.UI/BoolToNegativeVisibilityConverter.cpp
Normal file
22
src/Magpie.UI/BoolToNegativeVisibilityConverter.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "pch.h"
|
||||
#include "BoolToNegativeVisibilityConverter.h"
|
||||
#if __has_include("BoolToNegativeVisibilityConverter.g.cpp")
|
||||
#include "BoolToNegativeVisibilityConverter.g.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Windows::UI::Xaml::Interop;
|
||||
|
||||
|
||||
namespace winrt::Magpie::UI::implementation {
|
||||
|
||||
IInspectable BoolToNegativeVisibilityConverter::Convert(IInspectable const& value, TypeName const&, IInspectable const&, hstring const&) {
|
||||
return box_value(unbox_value<bool>(value) ? Visibility::Collapsed : Visibility::Visible);
|
||||
}
|
||||
|
||||
IInspectable BoolToNegativeVisibilityConverter::ConvertBack(IInspectable const& value, TypeName const&, IInspectable const&, hstring const&) {
|
||||
return box_value(unbox_value<Visibility>(value) == Visibility::Collapsed);
|
||||
}
|
||||
|
||||
}
|
||||
21
src/Magpie.UI/BoolToNegativeVisibilityConverter.h
Normal file
21
src/Magpie.UI/BoolToNegativeVisibilityConverter.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
#include "BoolToNegativeVisibilityConverter.g.h"
|
||||
|
||||
|
||||
namespace winrt::Magpie::UI::implementation {
|
||||
|
||||
struct BoolToNegativeVisibilityConverter : BoolToNegativeVisibilityConverterT<BoolToNegativeVisibilityConverter> {
|
||||
BoolToNegativeVisibilityConverter() = default;
|
||||
|
||||
IInspectable Convert(IInspectable const& value, Interop::TypeName const&, IInspectable const&, hstring const&);
|
||||
IInspectable ConvertBack(IInspectable const& value, Interop::TypeName const&, IInspectable const&, hstring const&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace winrt::Magpie::UI::factory_implementation {
|
||||
|
||||
struct BoolToNegativeVisibilityConverter : BoolToNegativeVisibilityConverterT<BoolToNegativeVisibilityConverter, implementation::BoolToNegativeVisibilityConverter> {
|
||||
};
|
||||
|
||||
}
|
||||
9
src/Magpie.UI/BoolToNegativeVisibilityConverter.idl
Normal file
9
src/Magpie.UI/BoolToNegativeVisibilityConverter.idl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
namespace Magpie.UI
|
||||
{
|
||||
// true -> Visibility::Collapsed
|
||||
// false -> Visibility::Visible
|
||||
runtimeclass BoolToNegativeVisibilityConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
||||
{
|
||||
BoolToNegativeVisibilityConverter();
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
<local:SettingItem Title="记忆缩放窗口"
|
||||
Margin="0,0,0,-2"
|
||||
Description="当该窗口回到前台时将自动缩放"
|
||||
Visibility="{x:Bind ViewModel.IsNoWndToRestore, Mode=OneWay}">
|
||||
Visibility="{x:Bind ViewModel.IsWndToRestore, Mode=OneWay, Converter={StaticResource NegativeVisibilityConverter}}">
|
||||
<local:SettingItem.Icon>
|
||||
<FontIcon Glyph="" />
|
||||
</local:SettingItem.Icon>
|
||||
|
|
|
|||
|
|
@ -156,7 +156,6 @@ void HomeViewModel::_MagService_IsRunningChanged(bool) {
|
|||
|
||||
void HomeViewModel::_MagService_WndToRestoreChanged(HWND) {
|
||||
_propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsWndToRestore"));
|
||||
_propertyChangedEvent(*this, PropertyChangedEventArgs(L"IsNoWndToRestore"));
|
||||
_propertyChangedEvent(*this, PropertyChangedEventArgs(L"RestoreWndDesc"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,6 @@ struct HomeViewModel : HomeViewModelT<HomeViewModel> {
|
|||
|
||||
bool IsWndToRestore() const noexcept;
|
||||
|
||||
bool IsNoWndToRestore() const noexcept {
|
||||
return !IsWndToRestore();
|
||||
}
|
||||
|
||||
void ActivateRestore() const noexcept;
|
||||
|
||||
void ClearRestore() const;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ namespace Magpie.UI
|
|||
|
||||
Boolean IsAutoRestore;
|
||||
Boolean IsWndToRestore { get; };
|
||||
Boolean IsNoWndToRestore { get; };
|
||||
String RestoreWndDesc { get; };
|
||||
|
||||
void ActivateRestore();
|
||||
|
|
|
|||
|
|
@ -113,6 +113,10 @@
|
|||
<DependentUpon>BoolNegationConverter.idl</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BoolToNegativeVisibilityConverter.h">
|
||||
<DependentUpon>BoolToNegativeVisibilityConverter.idl</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CandidateWindowItem.h">
|
||||
<DependentUpon>CandidateWindowItem.idl</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
|
@ -240,6 +244,10 @@
|
|||
<DependentUpon>BoolNegationConverter.idl</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BoolToNegativeVisibilityConverter.cpp">
|
||||
<DependentUpon>BoolToNegativeVisibilityConverter.idl</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CandidateWindowItem.cpp">
|
||||
<DependentUpon>CandidateWindowItem.idl</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
|
@ -382,9 +390,9 @@
|
|||
<None Include="LoggerHelper.idl">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<Midl Include="BoolNegationConverter.idl">
|
||||
<None Include="BoolNegationConverter.idl">
|
||||
<SubType>Designer</SubType>
|
||||
</Midl>
|
||||
</None>
|
||||
<None Include="ScalingProfilePage.idl">
|
||||
<DependentUpon>ScalingProfilePage.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
|
@ -398,6 +406,9 @@
|
|||
<None Include="NewProfileViewModel.idl">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="BoolToNegativeVisibilityConverter.idl">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<Midl Include="PageFrame.idl">
|
||||
<DependentUpon>PageFrame.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="App.idl" />
|
||||
<Midl Include="BoolNegationConverter.idl">
|
||||
<Filter>Converters</Filter>
|
||||
</Midl>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
|
|
@ -177,6 +174,12 @@
|
|||
<None Include="ScalingModeEffectItem.idl">
|
||||
<Filter>ViewModels</Filter>
|
||||
</None>
|
||||
<None Include="BoolToNegativeVisibilityConverter.idl">
|
||||
<Filter>Converters</Filter>
|
||||
</None>
|
||||
<None Include="BoolNegationConverter.idl">
|
||||
<Filter>Converters</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="MainPage.xaml" />
|
||||
|
|
|
|||
|
|
@ -74,10 +74,6 @@ struct ScalingModeItem : ScalingModeItemT<ScalingModeItem> {
|
|||
return _linkedProfiles.Size() > 0;
|
||||
}
|
||||
|
||||
bool NotShowLinkedProfiles() const noexcept {
|
||||
return !ShowLinkedProfiles();
|
||||
}
|
||||
|
||||
private:
|
||||
void _Index(uint32_t value) noexcept;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ namespace Magpie.UI
|
|||
void Remove();
|
||||
IVector<IInspectable> LinkedProfiles { get; };
|
||||
Boolean ShowLinkedProfiles { get; };
|
||||
Boolean NotShowLinkedProfiles { get; };
|
||||
|
||||
Boolean CanReorderEffects { get; };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@
|
|||
Visibility="{x:Bind ShowLinkedProfiles, Mode=OneTime}" />
|
||||
<TextBlock Margin="0,0,0,15"
|
||||
Text="确定删除此缩放模式?"
|
||||
Visibility="{x:Bind NotShowLinkedProfiles, Mode=OneTime}" />
|
||||
Visibility="{x:Bind ShowLinkedProfiles, Mode=OneTime, Converter={StaticResource NegativeVisibilityConverter}}" />
|
||||
<StackPanel Margin="0,0,0,10"
|
||||
Orientation="Vertical"
|
||||
Spacing="8"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue