mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-06 12:35:00 +03:00
Fix (#10530)
* Fix DataGridRowHeight * Fix disposable Co-authored-by: Eliot the Cougar <eliotfur@gmail.com> * Simplify code --------- Co-authored-by: Eliot the Cougar <eliotfur@gmail.com>
This commit is contained in:
@@ -31,6 +31,9 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
|||||||
CurrentFontSize = _config.UiItem.CurrentFontSize;
|
CurrentFontSize = _config.UiItem.CurrentFontSize;
|
||||||
CurrentLanguage = _config.UiItem.CurrentLanguage;
|
CurrentLanguage = _config.UiItem.CurrentLanguage;
|
||||||
|
|
||||||
|
// Set Default Value
|
||||||
|
ModifyFontSizeEx(12);
|
||||||
|
|
||||||
this.WhenAnyValue(x => x.CurrentTheme)
|
this.WhenAnyValue(x => x.CurrentTheme)
|
||||||
.Where(y => y.IsNotEmpty())
|
.Where(y => y.IsNotEmpty())
|
||||||
.SubscribeAsync(async _ =>
|
.SubscribeAsync(async _ =>
|
||||||
|
|||||||
@@ -125,12 +125,25 @@
|
|||||||
HorizontalAlignment="Stretch" />
|
HorizontalAlignment="Stretch" />
|
||||||
<DockPanel x:Name="tabDockPanel" Grid.Column="2">
|
<DockPanel x:Name="tabDockPanel" Grid.Column="2">
|
||||||
<TabStrip
|
<TabStrip
|
||||||
x:Name="tabStrip"
|
x:Name="tabStripH"
|
||||||
Margin="{StaticResource MarginLr8}"
|
Margin="{StaticResource MarginLr8}"
|
||||||
DockPanel.Dock="Top">
|
DockPanel.Dock="Top">
|
||||||
<TabStripItem Content="{x:Static resx:ResUI.MsgInformationTitle}" />
|
<TabStrip.ItemsPanel>
|
||||||
<TabStripItem Content="{x:Static resx:ResUI.TbProxies}" />
|
<ItemsPanelTemplate>
|
||||||
<TabStripItem Content="{x:Static resx:ResUI.TbConnections}" />
|
<WrapPanel Orientation="Horizontal" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</TabStrip.ItemsPanel>
|
||||||
|
</TabStrip>
|
||||||
|
<TabStrip
|
||||||
|
x:Name="tabStripV"
|
||||||
|
Margin="{StaticResource MarginLr8}"
|
||||||
|
DockPanel.Dock="Left"
|
||||||
|
IsVisible="False">
|
||||||
|
<TabStrip.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<WrapPanel Orientation="Vertical" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</TabStrip.ItemsPanel>
|
||||||
</TabStrip>
|
</TabStrip>
|
||||||
<ContentControl x:Name="tabContent" />
|
<ContentControl x:Name="tabContent" />
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Avalonia.Controls.Notifications;
|
using Avalonia.Controls.Notifications;
|
||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Controls.Templates;
|
|
||||||
using Avalonia.Layout;
|
using Avalonia.Layout;
|
||||||
using DialogHostAvalonia;
|
using DialogHostAvalonia;
|
||||||
using v2rayN.Desktop.Base;
|
using v2rayN.Desktop.Base;
|
||||||
@@ -88,11 +87,12 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
|
|
||||||
this.OneWayBind(ViewModel, vm => vm.StatusBarViewModel, v => v.contentStatusBarView.Content).DisposeWith(disposables);
|
this.OneWayBind(ViewModel, vm => vm.StatusBarViewModel, v => v.contentStatusBarView.Content).DisposeWith(disposables);
|
||||||
|
|
||||||
|
var layoutBindings = new SingleReplaceableDisposable().DisposeWith(disposables);
|
||||||
this.WhenAnyValue(v => v.ViewModel.MainGirdOrientation)
|
this.WhenAnyValue(v => v.ViewModel.MainGirdOrientation)
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(orientation =>
|
.Subscribe(orientation =>
|
||||||
{
|
{
|
||||||
UpdateLayout(orientation, disposables);
|
UpdateLayout(orientation, layoutBindings);
|
||||||
})
|
})
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
@@ -408,8 +408,10 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateLayout(EGirdOrientation orientation, MultipleDisposable disposable)
|
private void UpdateLayout(EGirdOrientation orientation, SingleReplaceableDisposable disposable)
|
||||||
{
|
{
|
||||||
|
var currentLayoutDisposables = new MultipleDisposable();
|
||||||
|
disposable.Create(currentLayoutDisposables);
|
||||||
gridMain.IsVisible = true;
|
gridMain.IsVisible = true;
|
||||||
_msgView ??= new MsgView
|
_msgView ??= new MsgView
|
||||||
{
|
{
|
||||||
@@ -440,32 +442,33 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
Grid.SetRow(tabProfiles, 0);
|
Grid.SetRow(tabProfiles, 0);
|
||||||
Grid.SetRow(gridSplitter, 0);
|
Grid.SetRow(gridSplitter, 0);
|
||||||
Grid.SetRow(tabDockPanel, 0);
|
Grid.SetRow(tabDockPanel, 0);
|
||||||
DockPanel.SetDock(tabStrip, Dock.Top);
|
tabStripH.IsVisible = true;
|
||||||
tabProfiles.Content = _profilesView;
|
tabStripV.IsVisible = false;
|
||||||
|
gridSplitter.IsVisible = true;
|
||||||
gridSplitter.HorizontalAlignment = HorizontalAlignment.Stretch;
|
gridSplitter.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||||
tabStrip.ItemsPanel = new FuncTemplate<Panel?>(() => new StackPanel
|
tabContent.Content = null;
|
||||||
{
|
tabProfiles.Content = _profilesView;
|
||||||
Orientation = Orientation.Horizontal,
|
|
||||||
});
|
|
||||||
this.WhenAnyValue(x => x.ViewModel!.ShowClashUI)
|
this.WhenAnyValue(x => x.ViewModel!.ShowClashUI)
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(show =>
|
.Subscribe(show =>
|
||||||
{
|
{
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
tabStrip.Items.Clear();
|
tabStripH.ItemsSource = new List<string>
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.MsgInformationTitle });
|
{
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.TbProxies });
|
ResUI.MsgInformationTitle,
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.TbConnections });
|
ResUI.TbProxies,
|
||||||
tabStrip.IsVisible = true;
|
ResUI.TbConnections,
|
||||||
|
};
|
||||||
|
tabStripH.IsVisible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tabStrip.IsVisible = false;
|
tabStripH.IsVisible = false;
|
||||||
tabStrip.Items.Clear();
|
tabStripH.ItemsSource = new List<string>();
|
||||||
}
|
}
|
||||||
}).DisposeWith(disposable);
|
}).DisposeWith(currentLayoutDisposables);
|
||||||
tabStrip.GetObservable(SelectingItemsControl.SelectedIndexProperty)
|
tabStripH.GetObservable(SelectingItemsControl.SelectedIndexProperty)
|
||||||
.Subscribe(index =>
|
.Subscribe(index =>
|
||||||
{
|
{
|
||||||
tabContent.Content = index switch
|
tabContent.Content = index switch
|
||||||
@@ -474,7 +477,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
2 => _clashConnectionsView,
|
2 => _clashConnectionsView,
|
||||||
_ => _msgView,
|
_ => _msgView,
|
||||||
};
|
};
|
||||||
}).DisposeWith(disposable);
|
}).DisposeWith(currentLayoutDisposables);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EGirdOrientation.Vertical:
|
case EGirdOrientation.Vertical:
|
||||||
@@ -486,32 +489,33 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
Grid.SetColumn(tabProfiles, 0);
|
Grid.SetColumn(tabProfiles, 0);
|
||||||
Grid.SetColumn(gridSplitter, 0);
|
Grid.SetColumn(gridSplitter, 0);
|
||||||
Grid.SetColumn(tabDockPanel, 0);
|
Grid.SetColumn(tabDockPanel, 0);
|
||||||
DockPanel.SetDock(tabStrip, Dock.Left);
|
tabStripV.IsVisible = true;
|
||||||
tabProfiles.Content = _profilesView;
|
tabStripH.IsVisible = false;
|
||||||
|
gridSplitter.IsVisible = true;
|
||||||
gridSplitter.VerticalAlignment = VerticalAlignment.Stretch;
|
gridSplitter.VerticalAlignment = VerticalAlignment.Stretch;
|
||||||
tabStrip.ItemsPanel = new FuncTemplate<Panel?>(() => new StackPanel
|
tabContent.Content = null;
|
||||||
{
|
tabProfiles.Content = _profilesView;
|
||||||
Orientation = Orientation.Vertical,
|
|
||||||
});
|
|
||||||
this.WhenAnyValue(x => x.ViewModel!.ShowClashUI)
|
this.WhenAnyValue(x => x.ViewModel!.ShowClashUI)
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(show =>
|
.Subscribe(show =>
|
||||||
{
|
{
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
tabStrip.Items.Clear();
|
tabStripV.ItemsSource = new List<string>
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.MsgInformationTitle });
|
{
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.TbProxies });
|
ResUI.MsgInformationTitle,
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.TbConnections });
|
ResUI.TbProxies,
|
||||||
tabStrip.IsVisible = true;
|
ResUI.TbConnections,
|
||||||
|
};
|
||||||
|
tabStripV.IsVisible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tabStrip.IsVisible = false;
|
tabStripV.IsVisible = false;
|
||||||
tabStrip.Items.Clear();
|
tabStripV.ItemsSource = new List<string>();
|
||||||
}
|
}
|
||||||
}).DisposeWith(disposable);
|
}).DisposeWith(currentLayoutDisposables);
|
||||||
tabStrip.GetObservable(SelectingItemsControl.SelectedIndexProperty)
|
tabStripV.GetObservable(SelectingItemsControl.SelectedIndexProperty)
|
||||||
.Subscribe(index =>
|
.Subscribe(index =>
|
||||||
{
|
{
|
||||||
tabContent.Content = index switch
|
tabContent.Content = index switch
|
||||||
@@ -520,7 +524,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
2 => _clashConnectionsView,
|
2 => _clashConnectionsView,
|
||||||
_ => _msgView,
|
_ => _msgView,
|
||||||
};
|
};
|
||||||
}).DisposeWith(disposable);
|
}).DisposeWith(currentLayoutDisposables);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EGirdOrientation.Tab:
|
case EGirdOrientation.Tab:
|
||||||
@@ -532,33 +536,33 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
Grid.SetRow(tabProfiles, 0);
|
Grid.SetRow(tabProfiles, 0);
|
||||||
Grid.SetRow(gridSplitter, 0);
|
Grid.SetRow(gridSplitter, 0);
|
||||||
Grid.SetRow(tabDockPanel, 0);
|
Grid.SetRow(tabDockPanel, 0);
|
||||||
DockPanel.SetDock(tabStrip, Dock.Left);
|
tabStripV.IsVisible = true;
|
||||||
|
tabStripH.IsVisible = false;
|
||||||
|
gridSplitter.IsVisible = false;
|
||||||
|
tabContent.Content = null;
|
||||||
tabProfiles.Content = null;
|
tabProfiles.Content = null;
|
||||||
gridSplitter.VerticalAlignment = VerticalAlignment.Stretch;
|
|
||||||
tabStrip.ItemsPanel = new FuncTemplate<Panel?>(() => new StackPanel
|
|
||||||
{
|
|
||||||
Orientation = Orientation.Vertical,
|
|
||||||
});
|
|
||||||
this.WhenAnyValue(x => x.ViewModel!.ShowClashUI)
|
this.WhenAnyValue(x => x.ViewModel!.ShowClashUI)
|
||||||
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
.ObserveOn(RxSchedulers.MainThreadScheduler)
|
||||||
.Subscribe(show =>
|
.Subscribe(show =>
|
||||||
{
|
{
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
tabStrip.Items.Clear();
|
tabStripV.ItemsSource = new List<string>
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.menuServers });
|
{
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.MsgInformationTitle });
|
ResUI.menuServers,
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.TbProxies });
|
ResUI.MsgInformationTitle,
|
||||||
tabStrip.Items.Add(new TabStripItem { Content = ResUI.TbConnections });
|
ResUI.TbProxies,
|
||||||
tabStrip.IsVisible = true;
|
ResUI.TbConnections,
|
||||||
|
};
|
||||||
|
tabStripV.IsVisible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tabStrip.IsVisible = false;
|
tabStripV.IsVisible = false;
|
||||||
tabStrip.Items.Clear();
|
tabStripV.ItemsSource = new List<string>();
|
||||||
}
|
}
|
||||||
}).DisposeWith(disposable);
|
}).DisposeWith(currentLayoutDisposables);
|
||||||
tabStrip.GetObservable(SelectingItemsControl.SelectedIndexProperty)
|
tabStripV.GetObservable(SelectingItemsControl.SelectedIndexProperty)
|
||||||
.Subscribe(index =>
|
.Subscribe(index =>
|
||||||
{
|
{
|
||||||
tabContent.Content = index switch
|
tabContent.Content = index switch
|
||||||
@@ -568,7 +572,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
3 => _clashConnectionsView,
|
3 => _clashConnectionsView,
|
||||||
_ => _profilesView,
|
_ => _profilesView,
|
||||||
};
|
};
|
||||||
}).DisposeWith(disposable);
|
}).DisposeWith(currentLayoutDisposables);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user