Use direct property to allow calling onPropertyChanged

Remove default value initialization
This commit is contained in:
Kevin Zhang 2021-06-21 13:39:54 +08:00
parent a0011db9d3
commit 77f8a8e27b
3 changed files with 12 additions and 18 deletions

View file

@ -97,7 +97,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public bool RememberLastLaunchLocation { get; set; }
public bool IgnoreHotkeysOnFullscreen { get; set; }
public bool AutoHideScrollBar { get; set; } = false;
public bool AutoHideScrollBar { get; set; }
public HttpProxy Proxy { get; set; } = new HttpProxy();

View file

@ -36,7 +36,7 @@
<TabControl Height="auto" SelectedIndex="0">
<TabItem Header="{DynamicResource general}">
<ScrollViewer ui:ScrollViewerHelper.AutoHideScrollBars="{Binding Settings.AutoHideScrollBar}" Margin="60,30,0,30">
<ScrollViewer ui:ScrollViewerHelper.AutoHideScrollBars="{Binding AutoHideScrollBar, Mode=OneWay}" Margin="60,30,0,30">
<StackPanel Orientation="Vertical">
<ui:ToggleSwitch Margin="10" IsOn="{Binding PortableMode}">
<TextBlock Text="{DynamicResource portableMode}" />
@ -67,7 +67,7 @@
ToolTip="{DynamicResource ShouldUsePinyinToolTip}">
<TextBlock Text="{DynamicResource ShouldUsePinyin}" />
</CheckBox>
<ui:ToggleSwitch Margin="10" IsOn="{Binding AutoHideScrollBar}"
<ui:ToggleSwitch Margin="10" IsOn="{Binding AutoHideScrollBar, Mode=TwoWay}"
ToolTip="{DynamicResource autoHideScrollBarToolTip}">
<TextBlock Text="{DynamicResource autoHideScrollBar}" />
</ui:ToggleSwitch>
@ -117,7 +117,7 @@
</TextBlock>
<ListBox SelectedIndex="0" SelectedItem="{Binding SelectedPlugin}"
ItemsSource="{Binding PluginViewModels}"
Margin="10, 0, 10, 10" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ui:ScrollViewerHelper.AutoHideScrollBars="{Binding Settings.AutoHideScrollBar}">
Margin="10, 0, 10, 10" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ui:ScrollViewerHelper.AutoHideScrollBars="{Binding AutoHideScrollBar, Mode=OneWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="3">

View file

@ -63,14 +63,8 @@ namespace Flow.Launcher.ViewModel
public bool AutoHideScrollBar
{
get
{
return Settings.AutoHideScrollBar;
}
set
{
Settings.AutoHideScrollBar = value;
}
get => Settings.AutoHideScrollBar;
set => Settings.AutoHideScrollBar = value;
}
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
@ -150,11 +144,11 @@ namespace Flow.Launcher.ViewModel
public bool ShouldUsePinyin
{
get
get
{
return Settings.ShouldUsePinyin;
return Settings.ShouldUsePinyin;
}
set
set
{
Settings.ShouldUsePinyin = value;
}
@ -193,7 +187,7 @@ namespace Flow.Launcher.ViewModel
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_updater.GitHubRepository);
if (string.IsNullOrEmpty(proxyUserName) || string.IsNullOrEmpty(Settings.Proxy.Password))
{
request.Proxy = new WebProxy(proxyServer, Settings.Proxy.Port);
@ -237,7 +231,7 @@ namespace Flow.Launcher.ViewModel
var metadatas = PluginManager.AllPlugins
.OrderBy(x => x.Metadata.Disabled)
.ThenBy(y => y.Metadata.Name)
.Select(p => new PluginViewModel { PluginPair = p})
.Select(p => new PluginViewModel { PluginPair = p })
.ToList();
return metadatas;
}
@ -465,7 +459,7 @@ namespace Flow.Launcher.ViewModel
#region about
public string Website => Constant.Website;
public string ReleaseNotes => _updater.GitHubRepository + @"/releases/latest";
public string ReleaseNotes => _updater.GitHubRepository + @"/releases/latest";
public string Documentation => Constant.Documentation;
public static string Version => Constant.Version;
public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);