Skip to content

Commit

Permalink
修复设置背景图解析bug;更新预览图
Browse files Browse the repository at this point in the history
  • Loading branch information
DearVa committed Sep 8, 2022
1 parent d5680fa commit 8a85044
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions ExplorerEx/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ public bool IsDarkMode {

public double BackgroundImageOpacity => this[CommonSettings.BackgroundImageOpacity].GetDouble();

private void BackgroundImage_OnChanged(object? o) {
if (o is string path && File.Exists(path)) {
private void BackgroundImage_OnChanged(SettingsItem si) {
var path = si.GetString().Trim(' ').Trim('"').Trim(' ');
if (File.Exists(path)) {
try {
BackgroundImage = new BitmapImage(new Uri(path));
} catch {
Expand Down Expand Up @@ -426,7 +427,7 @@ private void RegisterEvents() {
settings[CommonSettings.WindowBackdrop].Changed += _ => ThemeChanged?.Invoke();

settings[CommonSettings.BackgroundImage].Changed += BackgroundImage_OnChanged;
BackgroundImage_OnChanged(settings[CommonSettings.BackgroundImage].Value);
BackgroundImage_OnChanged(settings[CommonSettings.BackgroundImage]);

settings[CommonSettings.BackgroundImageOpacity].Changed += _ => OnPropertyChanged(nameof(BackgroundImageOpacity));
settings[CommonSettings.ColorMode].Changed += _ => ThemeChanged?.Invoke(); // 更改颜色
Expand Down
10 changes: 7 additions & 3 deletions ExplorerEx/View/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,14 @@ protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) {
}
}

/// <summary>
/// 是否打开了任何对话框?或者正在添加书签?
/// </summary>
private bool IsAnyDialogShown => RootPanel.Children.Count > 2 || IsAddToBookmarkShow;

protected override void OnKeyDown(KeyEventArgs e) {
var handled = true;
if (RootPanel.Children.Count == 2) { // 没有打开任何对话框
if (!IsAnyDialogShown) {
var mouseOverTab = FileTabControl.MouseOverTabControl?.SelectedTab;
if (mouseOverTab != null) {
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) {
Expand Down Expand Up @@ -889,8 +894,7 @@ protected override void OnKeyDown(KeyEventArgs e) {
}

protected override void OnPreviewTextInput(TextCompositionEventArgs e) {
if ((RootPanel.Children.Count == 2 || !IsAddToBookmarkShow) &&
!string.IsNullOrWhiteSpace(e.Text) && e.OriginalSource is not TextBox and not AddressBar) { // 没有打开任何对话框
if (!IsAnyDialogShown && !string.IsNullOrWhiteSpace(e.Text) && e.OriginalSource is not TextBox and not AddressBar) {
var mouseOverTabControl = FileTabControl.MouseOverTabControl;
if (mouseOverTabControl != null) {
var fileListView = mouseOverTabControl.SelectedTab.FileListView;
Expand Down
Binary file modified Images/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8a85044

Please sign in to comment.