| | |
| | | private readonly IDesktopRuntime _runtime; |
| | | private readonly IDiagnosticsService _diagnostics; |
| | | private readonly ILocalApiStatus _apiStatus; |
| | | private readonly IPluginManager _plugins; |
| | | private readonly DesktopPaths _paths; |
| | | private readonly DispatcherTimer _timer; |
| | | private AppRuntimeState? _state; |
| | |
| | | IDesktopRuntime runtime, |
| | | IDiagnosticsService diagnostics, |
| | | ILocalApiStatus apiStatus, |
| | | IPluginManager plugins, |
| | | DesktopPaths paths) |
| | | { |
| | | _runtime = runtime; |
| | | _diagnostics = diagnostics; |
| | | _apiStatus = apiStatus; |
| | | _plugins = plugins; |
| | | _paths = paths; |
| | | InitializeComponent(); |
| | | DisplayLayerSelector.ItemsSource = Enum.GetValues<DisplayLayer>(); |
| | |
| | | } |
| | | } |
| | | |
| | | await _runtime.CancelPluginRequestsAsync(new PluginId(widget.PluginId)); |
| | | await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { DisplayLayer = layer }); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { IsLocked = !widget.IsLocked }); |
| | | } |
| | | |
| | | private async void ToggleWidgetClickThrough_Click(object sender, RoutedEventArgs e) |
| | | { |
| | | if (SelectedWidget() is not { } widget) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { ClickThrough = !widget.ClickThrough }); |
| | | } |
| | | |
| | | private async void ResetLayout_Click(object sender, RoutedEventArgs e) |
| | |
| | | |
| | | foreach (var widget in _state.Widgets) |
| | | { |
| | | var clickThrough = true; |
| | | var displayLayer = DisplayLayer.Desktop; |
| | | try |
| | | { |
| | | var plugin = await _plugins.GetAsync(widget.PluginId); |
| | | if (plugin is not null) |
| | | { |
| | | clickThrough = plugin.Manifest.DefaultLayout.ClickThrough; |
| | | displayLayer = plugin.Manifest.DefaultLayout.DisplayLayer; |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | } |
| | | |
| | | await _runtime.UpdateWidgetLayoutAsync( |
| | | widget.InstanceId, |
| | | new WidgetLayoutPatch |
| | |
| | | IsVisible = true, |
| | | IsLocked = false, |
| | | Opacity = 1, |
| | | ClickThrough = true, |
| | | DisplayLayer = DisplayLayer.Desktop |
| | | ClickThrough = clickThrough, |
| | | DisplayLayer = displayLayer |
| | | }); |
| | | } |
| | | |
| | |
| | | { |
| | | DisplayLayerSelector.SelectedItem = DisplayLayer.Desktop; |
| | | _selectedWidgetForDisplayLayer = null; |
| | | ClickThroughButton.Content = "点击穿透"; |
| | | return; |
| | | } |
| | | |
| | | ClickThroughButton.Content = widget.ClickThrough ? "关闭穿透" : "开启穿透"; |
| | | |
| | | if (!force) |
| | | { |
| | | return; |