-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b41d28
commit 033753f
Showing
9 changed files
with
140 additions
and
36 deletions.
There are no files selected for viewing
18 changes: 9 additions & 9 deletions
18
Natsurainko.FluentLauncher (Package)/BundleArtifacts/Upload/x64.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
MainPackage=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0_x64.msix | ||
SymbolPackage=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0\Natsurainko.FluentLauncher (Package)_2.1.3.0_x64.appxsym | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0_language-ru.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0_language-zh-hans.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0_language-zh-hant.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0_scale-100.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0_scale-125.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0_scale-150.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.3.0_scale-400.msix | ||
MainPackage=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0_x64.msix | ||
SymbolPackage=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0\Natsurainko.FluentLauncher (Package)_2.1.4.0_x64.appxsym | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0_language-ru.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0_language-zh-hans.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0_language-zh-hant.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0_scale-100.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0_scale-125.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0_scale-150.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Upload\Natsurainko.FluentLauncher (Package)_2.1.4.0_scale-400.msix |
18 changes: 9 additions & 9 deletions
18
Natsurainko.FluentLauncher (Package)/BundleArtifacts/x64.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
MainPackage=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.3.0_x64.msix | ||
SymbolPackage=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\obj\x64\Release\Symbols\Natsurainko.FluentLauncher (Package)_2.1.3.0_x64.appxsym | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.3.0_language-ru.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.3.0_language-zh-hans.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.3.0_language-zh-hant.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.3.0_scale-100.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.3.0_scale-125.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.3.0_scale-150.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.3.0_scale-400.msix | ||
MainPackage=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.4.0_x64.msix | ||
SymbolPackage=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\obj\x64\Release\Symbols\Natsurainko.FluentLauncher (Package)_2.1.4.0_x64.appxsym | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.4.0_language-ru.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.4.0_language-zh-hans.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.4.0_language-zh-hant.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.4.0_scale-100.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.4.0_scale-125.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.4.0_scale-150.msix | ||
ResourcePack=D:\Git\fluentlauncher-preview-edition\Natsurainko.FluentLauncher (Package)\bin\x64\Release\Natsurainko.FluentLauncher (Package)_2.1.4.0_scale-400.msix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
Natsurainko.FluentLauncher/Behaviors/SetComboBoxWidthFromItemsBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Threading; | ||
using Microsoft.UI.Dispatching; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Automation.Peers; | ||
using Microsoft.UI.Xaml.Automation.Provider; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.Xaml.Interactivity; | ||
using Windows.Foundation.Collections; | ||
|
||
namespace Natsurainko.FluentLauncher.Behaviors; | ||
|
||
class SetComboBoxWidthFromItemsBehavior : Behavior<ComboBox> | ||
{ | ||
public static readonly DependencyProperty SetComboBoxWidthFromItemsProperty = | ||
DependencyProperty.RegisterAttached | ||
( | ||
"SetComboBoxWidthFromItems", | ||
typeof(bool), | ||
typeof(SetComboBoxWidthFromItemsBehavior), | ||
new PropertyMetadata(false, OnSetComboBoxWidthFromItemsPropertyChanged) | ||
); | ||
|
||
public bool SetComboBoxWidthFromItems | ||
{ | ||
get => (bool)GetValue(SetComboBoxWidthFromItemsProperty); | ||
set => SetValue(SetComboBoxWidthFromItemsProperty, value); | ||
} | ||
|
||
protected override void OnAttached() | ||
{ | ||
AssociatedObject.Loaded += OnComboBoxLoaded; | ||
AssociatedObject.Items.VectorChanged += Items_VectorChanged; | ||
} | ||
|
||
public void Items_VectorChanged(IObservableVector<object> sender, IVectorChangedEventArgs e) | ||
{ | ||
SetComboBoxWidth(AssociatedObject); | ||
} | ||
|
||
private static void OnComboBoxLoaded(object sender, RoutedEventArgs e) | ||
{ | ||
SetComboBoxWidth((ComboBox)sender); | ||
} | ||
|
||
private static void OnSetComboBoxWidthFromItemsPropertyChanged( | ||
DependencyObject dpo, | ||
DependencyPropertyChangedEventArgs e) | ||
{ | ||
SetComboBoxWidthFromItemsBehavior behavior = (SetComboBoxWidthFromItemsBehavior)dpo; | ||
ComboBox comboBox = behavior.AssociatedObject; | ||
|
||
bool newValue = (bool)e.NewValue; | ||
bool oldValue = (bool)e.OldValue; | ||
|
||
if (comboBox != null && newValue != oldValue) | ||
{ | ||
if (newValue == true) | ||
{ | ||
comboBox.Loaded += OnComboBoxLoaded; | ||
comboBox.Items.VectorChanged += behavior.Items_VectorChanged; | ||
|
||
} | ||
else | ||
{ | ||
comboBox.Loaded -= OnComboBoxLoaded; | ||
comboBox.Items.VectorChanged -= behavior.Items_VectorChanged; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Set the width of a ComboBox to the longest item in its drop down menu | ||
/// </summary> | ||
/// <param name="comboBox">Target</param> | ||
private static void SetComboBoxWidth(ComboBox comboBox) | ||
{ | ||
// Open ComboBox drop down and prepare ItemContainerGenerator | ||
comboBox.IsDropDownOpen = true; | ||
comboBox.ItemContainerGenerator.StartAt(new GeneratorPosition(0, 0), GeneratorDirection.Forward, true); | ||
|
||
double maxWidth = 0; | ||
ComboBoxItem? item; | ||
while ((item = comboBox.ItemContainerGenerator.GenerateNext(out _) as ComboBoxItem) != null) | ||
{ | ||
item.Measure(new Windows.Foundation.Size(double.PositiveInfinity, double.PositiveInfinity)); | ||
var size = item.DesiredSize; | ||
if (size.Width > maxWidth) | ||
{ | ||
maxWidth = size.Width; | ||
} | ||
} | ||
|
||
maxWidth += 20; // This constant adds more space to include the drop down button and paddings | ||
comboBox.Width = maxWidth > 70 ? maxWidth : 70; // Ensures a MinWidth of 70 when there is no content; Less width will result in issues with appearance | ||
comboBox.ItemContainerGenerator.Stop(); | ||
comboBox.IsDropDownOpen = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters