Skip to content

Commit

Permalink
chore: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Oct 5, 2024
1 parent 07fc9a5 commit 7fdef45
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 80 deletions.
122 changes: 60 additions & 62 deletions src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.Uno.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,75 @@
using System.Text;
using Microsoft.UI.Xaml;

namespace Uno.UI.Xaml.Controls
namespace Uno.UI.Xaml.Controls;

/// <summary>
/// Defines how a <see cref="Microsoft.UI.Xaml.Controls.ComboBox"/> tries to place it drop down.
/// </summary>
public enum DropDownPlacement
{
/// <summary>
/// Defines how a <see cref="Microsoft.UI.Xaml.Controls.ComboBox"/> tries to place it drop down.
/// When opening the "drop down" the ComboBox tries to keep the selected item over the closed combo box.
/// That means that if the selected is the last one of the list, the "drop down" will appear above.
/// If there isn't any selected item, the "drop down" will appear centered over the combo box.
/// </summary>
public enum DropDownPlacement
{
/// <summary>
/// When opening the "drop down" the ComboBox tries to keep the selected item over the closed combo box.
/// That means that if the selected is the last one of the list, the "drop down" will appear above.
/// If there isn't any selected item, the "drop down" will appear centered over the combo box.
/// </summary>
Auto,

/// <summary>
/// Always try to render the drop down above the combo
/// </summary>
Above,
Auto,

/// <summary>
/// Always try to render the drop down below the combo
/// </summary>
Below,
/// <summary>
/// Always try to render the drop down above the combo
/// </summary>
Above,

/// <summary>
/// Always try to render the drop down center over the combo
/// </summary>
Centered,
}
/// <summary>
/// Always try to render the drop down below the combo
/// </summary>
Below,

/// <summary>
/// The configurations of the <see cref="Microsoft.UI.Xaml.Controls.ComboBox"/> specific to the Uno platform.
/// Always try to render the drop down center over the combo
/// </summary>
public static class ComboBox
{
/// <summary>
/// Backing property for the <see cref="DropDownPlacement"/> of a ComboBox. (cf. Remarks.)
/// </summary>
/// <remarks>
/// This is only the preferred placement, the combo will still ensure to keep its drop down in the visual bounds of the window
/// (When content cannot be rendered out of the current window ...)
/// </remarks>
public static DependencyProperty DropDownPreferredPlacementProperty { get; } = DependencyProperty.RegisterAttached(
"DropDownPreferredPlacement",
typeof(DropDownPlacement),
typeof(Microsoft.UI.Xaml.Controls.ComboBox),
new FrameworkPropertyMetadata(FeatureConfiguration.ComboBox.DefaultDropDownPreferredPlacement));
Centered,
}

/// <summary>
/// Sets the preferred <see cref="DropDownPlacement"/> of a ComboBox. (cf. Remarks)
/// </summary>
/// <remarks>
/// This is only the preferred placement, the combo will still ensure to keep its drop down in the visual bounds of the window
/// (When content cannot be rendered out of the current window ...)
/// </remarks>
/// <param name="combo">The target ComboBox to configure</param>
/// <param name="mode">The updates mode to set</param>
public static void SetDropDownPreferredPlacement(Microsoft.UI.Xaml.Controls.ComboBox combo, DropDownPlacement mode)
=> combo.SetValue(DropDownPreferredPlacementProperty, mode);
/// <summary>
/// The configurations of the <see cref="Microsoft.UI.Xaml.Controls.ComboBox"/> specific to the Uno platform.
/// </summary>
public static class ComboBox
{
/// <summary>
/// Backing property for the <see cref="DropDownPlacement"/> of a ComboBox. (cf. Remarks.)
/// </summary>
/// <remarks>
/// This is only the preferred placement, the combo will still ensure to keep its drop down in the visual bounds of the window
/// (When content cannot be rendered out of the current window ...)
/// </remarks>
public static DependencyProperty DropDownPreferredPlacementProperty { get; } = DependencyProperty.RegisterAttached(
"DropDownPreferredPlacement",
typeof(DropDownPlacement),
typeof(Microsoft.UI.Xaml.Controls.ComboBox),
new FrameworkPropertyMetadata(FeatureConfiguration.ComboBox.DefaultDropDownPreferredPlacement));

/// <summary>
/// Gets the <see cref="DropDownPlacement"/> of a ComboBox. (cf. Remarks)
/// </summary>
/// <remarks>
/// This is only the preferred placement, the combo will still ensure to keep its drop down in the visual bounds of the window
/// (When content cannot be rendered out of the current window ...)
/// </remarks>
/// <param name="combo">The target ComboBox</param>
/// <returns>The updates mode of the <paramref name="combo"/>.</returns>
public static DropDownPlacement GetDropDownPreferredPlacement(Microsoft.UI.Xaml.Controls.ComboBox combo)
=> (DropDownPlacement)combo.GetValue(DropDownPreferredPlacementProperty);
}
/// <summary>
/// Sets the preferred <see cref="DropDownPlacement"/> of a ComboBox. (cf. Remarks)
/// </summary>
/// <remarks>
/// This is only the preferred placement, the combo will still ensure to keep its drop down in the visual bounds of the window
/// (When content cannot be rendered out of the current window ...)
/// </remarks>
/// <param name="combo">The target ComboBox to configure</param>
/// <param name="mode">The updates mode to set</param>
public static void SetDropDownPreferredPlacement(Microsoft.UI.Xaml.Controls.ComboBox combo, DropDownPlacement mode)
=> combo.SetValue(DropDownPreferredPlacementProperty, mode);

/// <summary>
/// Gets the <see cref="DropDownPlacement"/> of a ComboBox. (cf. Remarks)
/// </summary>
/// <remarks>
/// This is only the preferred placement, the combo will still ensure to keep its drop down in the visual bounds of the window
/// (When content cannot be rendered out of the current window ...)
/// </remarks>
/// <param name="combo">The target ComboBox</param>
/// <returns>The updates mode of the <paramref name="combo"/>.</returns>
public static DropDownPlacement GetDropDownPreferredPlacement(Microsoft.UI.Xaml.Controls.ComboBox combo)
=> (DropDownPlacement)combo.GetValue(DropDownPreferredPlacementProperty);
}
5 changes: 4 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.custom.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#nullable enable
// This contains Uno-specific logic for ComboBox. Ideally, it will be possible to remove when we port further portions
// of the control from WinUI

#nullable enable

using System;
using DirectUI;
Expand Down
14 changes: 0 additions & 14 deletions src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.legacy.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
using System;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference src\dxaml\xcp\dxaml\lib\ComboBox_Partial.h, tag winui3/release/1.6.1, commit f31293f

// The file is not ported completely, some methods are still missing!

using System;
using DirectUI;
using Microsoft.UI.Xaml.Media.Animation;
using Uno.Disposables;
Expand All @@ -11,7 +17,6 @@ partial class ComboBox
{
private const char VK_ESCAPE = (char)0x1B;

// TODO MZ: These disablings should not be required
#pragma warning disable CS0067 // Unused
#pragma warning disable CS0649 // Unused
#pragma warning disable CS0169 // Unused
Expand Down
8 changes: 7 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/ComboBox/ComboBox.partial.mux.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#nullable enable
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference src\dxaml\xcp\dxaml\lib\ComboBox_Partial.cpp, tag winui3/release/1.6.1, commit f31293f

// The file is not ported completely, some methods are still missing!

#nullable enable

using System;
using System.Collections.Generic;
Expand Down

0 comments on commit 7fdef45

Please sign in to comment.